diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/page/scrolling/ScrollingStateNode.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/page/scrolling/ScrollingStateNode.h')
-rw-r--r-- | Source/WebCore/page/scrolling/ScrollingStateNode.h | 107 |
1 files changed, 77 insertions, 30 deletions
diff --git a/Source/WebCore/page/scrolling/ScrollingStateNode.h b/Source/WebCore/page/scrolling/ScrollingStateNode.h index ca705f3e2..087d61829 100644 --- a/Source/WebCore/page/scrolling/ScrollingStateNode.h +++ b/Source/WebCore/page/scrolling/ScrollingStateNode.h @@ -23,27 +23,31 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ScrollingStateNode_h -#define ScrollingStateNode_h +#pragma once #if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) #include "GraphicsLayer.h" #include "ScrollingCoordinator.h" -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/TypeCasts.h> #include <wtf/Vector.h> -#if PLATFORM(MAC) -#include <wtf/RetainPtr.h> -#endif - namespace WebCore { class GraphicsLayer; class ScrollingStateTree; class TextStream; +enum ScrollingStateTreeAsTextBehaviorFlags { + ScrollingStateTreeAsTextBehaviorNormal = 0, + ScrollingStateTreeAsTextBehaviorIncludeLayerIDs = 1 << 0, + ScrollingStateTreeAsTextBehaviorIncludeNodeIDs = 1 << 1, + ScrollingStateTreeAsTextBehaviorIncludeLayerPositions = 1 << 2, + ScrollingStateTreeAsTextBehaviorDebug = ScrollingStateTreeAsTextBehaviorIncludeLayerIDs | ScrollingStateTreeAsTextBehaviorIncludeNodeIDs | ScrollingStateTreeAsTextBehaviorIncludeLayerPositions +}; +typedef unsigned ScrollingStateTreeAsTextBehavior; + // Used to allow ScrollingStateNodes to refer to layers in various contexts: // a) Async scrolling, main thread: ScrollingStateNode holds onto a GraphicsLayer, and uses m_layerID // to detect whether that GraphicsLayer's underlying PlatformLayer changed. @@ -75,14 +79,32 @@ public: : m_platformLayer(platformLayer) , m_layerID(0) , m_representation(PlatformLayerRepresentation) - { } + { + retainPlatformLayer(platformLayer); + } LayerRepresentation(GraphicsLayer::PlatformLayerID layerID) : m_graphicsLayer(nullptr) , m_layerID(layerID) , m_representation(PlatformLayerIDRepresentation) - { } - + { + } + + LayerRepresentation(const LayerRepresentation& other) + : m_platformLayer(other.m_platformLayer) + , m_layerID(other.m_layerID) + , m_representation(other.m_representation) + { + if (m_representation == PlatformLayerRepresentation) + retainPlatformLayer(m_platformLayer); + } + + ~LayerRepresentation() + { + if (m_representation == PlatformLayerRepresentation) + releasePlatformLayer(m_platformLayer); + } + operator GraphicsLayer*() const { ASSERT(m_representation == GraphicsLayerRepresentation); @@ -94,14 +116,31 @@ public: ASSERT(m_representation == PlatformLayerRepresentation); return m_platformLayer; } + + GraphicsLayer::PlatformLayerID layerID() const + { + return m_layerID; + } operator GraphicsLayer::PlatformLayerID() const { ASSERT(m_representation != PlatformLayerRepresentation); return m_layerID; } - - bool operator ==(const LayerRepresentation& other) const + + LayerRepresentation& operator=(const LayerRepresentation& other) + { + m_platformLayer = other.m_platformLayer; + m_layerID = other.m_layerID; + m_representation = other.m_representation; + + if (m_representation == PlatformLayerRepresentation) + retainPlatformLayer(m_platformLayer); + + return *this; + } + + bool operator==(const LayerRepresentation& other) const { if (m_representation != other.m_representation) return false; @@ -140,6 +179,9 @@ public: bool representsPlatformLayerID() const { return m_representation == PlatformLayerIDRepresentation; } private: + WEBCORE_EXPORT void retainPlatformLayer(PlatformLayer*); + WEBCORE_EXPORT void releasePlatformLayer(PlatformLayer*); + union { GraphicsLayer* m_graphicsLayer; PlatformLayer *m_platformLayer; @@ -149,15 +191,22 @@ private: Type m_representation; }; -class ScrollingStateNode { +class ScrollingStateNode : public RefCounted<ScrollingStateNode> { + WTF_MAKE_FAST_ALLOCATED; public: ScrollingStateNode(ScrollingNodeType, ScrollingStateTree&, ScrollingNodeID); virtual ~ScrollingStateNode(); ScrollingNodeType nodeType() const { return m_nodeType; } - virtual PassOwnPtr<ScrollingStateNode> clone(ScrollingStateTree& adoptiveTree) = 0; - PassOwnPtr<ScrollingStateNode> cloneAndReset(ScrollingStateTree& adoptiveTree); + bool isFixedNode() const { return m_nodeType == FixedNode; } + bool isStickyNode() const { return m_nodeType == StickyNode; } + bool isScrollingNode() const { return m_nodeType == FrameScrollingNode || m_nodeType == OverflowScrollingNode; } + bool isFrameScrollingNode() const { return m_nodeType == FrameScrollingNode; } + bool isOverflowScrollingNode() const { return m_nodeType == OverflowScrollingNode; } + + virtual Ref<ScrollingStateNode> clone(ScrollingStateTree& adoptiveTree) = 0; + Ref<ScrollingStateNode> cloneAndReset(ScrollingStateTree& adoptiveTree); void cloneAndResetChildren(ScrollingStateNode&, ScrollingStateTree& adoptiveTree); enum { @@ -174,10 +223,10 @@ public: ChangedProperties changedProperties() const { return m_changedProperties; } void setChangedProperties(ChangedProperties changedProperties) { m_changedProperties = changedProperties; } - virtual void syncLayerPositionForViewportRect(const LayoutRect& /*viewportRect*/) { } + virtual void reconcileLayerPositionForViewportRect(const LayoutRect& /*viewportRect*/, ScrollingLayerPositionAction) { } const LayerRepresentation& layer() const { return m_layer; } - void setLayer(const LayerRepresentation&); + WEBCORE_EXPORT void setLayer(const LayerRepresentation&); ScrollingStateTree& scrollingStateTree() const { return m_scrollingStateTree; } @@ -187,10 +236,9 @@ public: void setParent(ScrollingStateNode* parent) { m_parent = parent; } ScrollingNodeID parentNodeID() const { return m_parent ? m_parent->scrollingNodeID() : 0; } - Vector<OwnPtr<ScrollingStateNode>>* children() const { return m_children.get(); } + Vector<RefPtr<ScrollingStateNode>>* children() const { return m_children.get(); } - void appendChild(PassOwnPtr<ScrollingStateNode>); - void removeChild(ScrollingStateNode*); + void appendChild(Ref<ScrollingStateNode>&&); String scrollingStateTreeAsText() const; @@ -198,10 +246,9 @@ protected: ScrollingStateNode(const ScrollingStateNode&, ScrollingStateTree&); private: - void dump(TextStream&, int indent) const; + void dump(TextStream&, int indent, ScrollingStateTreeAsTextBehavior) const; - virtual void dumpProperties(TextStream&, int indent) const = 0; - void willBeRemovedFromStateTree(); + virtual void dumpProperties(TextStream&, int indent, ScrollingStateTreeAsTextBehavior) const = 0; const ScrollingNodeType m_nodeType; ScrollingNodeID m_nodeID; @@ -210,16 +257,16 @@ private: ScrollingStateTree& m_scrollingStateTree; ScrollingStateNode* m_parent; - OwnPtr<Vector<OwnPtr<ScrollingStateNode>>> m_children; + std::unique_ptr<Vector<RefPtr<ScrollingStateNode>>> m_children; LayerRepresentation m_layer; }; -#define SCROLLING_STATE_NODE_TYPE_CASTS(ToValueTypeName, predicate) \ - TYPE_CASTS_BASE(ToValueTypeName, ScrollingStateNode, value, value->predicate, value.predicate) - } // namespace WebCore -#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) +#define SPECIALIZE_TYPE_TRAITS_SCROLLING_STATE_NODE(ToValueTypeName, predicate) \ +SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \ + static bool isType(const WebCore::ScrollingStateNode& node) { return node.predicate; } \ +SPECIALIZE_TYPE_TRAITS_END() -#endif // ScrollingStateNode_h +#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) |