diff options
Diffstat (limited to 'Source/WebCore/page/scrolling/ScrollingStateTree.h')
-rw-r--r-- | Source/WebCore/page/scrolling/ScrollingStateTree.h | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/Source/WebCore/page/scrolling/ScrollingStateTree.h b/Source/WebCore/page/scrolling/ScrollingStateTree.h index 59659e534..3b256151a 100644 --- a/Source/WebCore/page/scrolling/ScrollingStateTree.h +++ b/Source/WebCore/page/scrolling/ScrollingStateTree.h @@ -23,14 +23,11 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ScrollingStateTree_h -#define ScrollingStateTree_h +#pragma once #if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) -#include "ScrollingStateScrollingNode.h" -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> +#include "ScrollingStateFrameScrollingNode.h" #include <wtf/RefPtr.h> namespace WebCore { @@ -43,29 +40,30 @@ class AsyncScrollingCoordinator; // the scrolling thread, avoiding locking. class ScrollingStateTree { + WTF_MAKE_FAST_ALLOCATED; friend class ScrollingStateNode; public: - - static PassOwnPtr<ScrollingStateTree> create(AsyncScrollingCoordinator* = 0); - ~ScrollingStateTree(); + WEBCORE_EXPORT ScrollingStateTree(AsyncScrollingCoordinator* = nullptr); + WEBCORE_EXPORT ~ScrollingStateTree(); - ScrollingStateScrollingNode* rootStateNode() const { return m_rootStateNode.get(); } - ScrollingStateNode* stateNodeForID(ScrollingNodeID); + ScrollingStateFrameScrollingNode* rootStateNode() const { return m_rootStateNode.get(); } + WEBCORE_EXPORT ScrollingStateNode* stateNodeForID(ScrollingNodeID) const; - ScrollingNodeID attachNode(ScrollingNodeType, ScrollingNodeID, ScrollingNodeID parentID); + WEBCORE_EXPORT ScrollingNodeID attachNode(ScrollingNodeType, ScrollingNodeID, ScrollingNodeID parentID); void detachNode(ScrollingNodeID); void clear(); - const Vector<ScrollingNodeID>& removedNodes() const { return m_nodesRemovedSinceLastCommit; } - void setRemovedNodes(Vector<ScrollingNodeID>); + const HashSet<ScrollingNodeID>& removedNodes() const { return m_nodesRemovedSinceLastCommit; } + WEBCORE_EXPORT void setRemovedNodes(HashSet<ScrollingNodeID>); // Copies the current tree state and clears the changed properties mask in the original. - PassOwnPtr<ScrollingStateTree> commit(LayerRepresentation::Type preferredLayerRepresentation); + WEBCORE_EXPORT std::unique_ptr<ScrollingStateTree> commit(LayerRepresentation::Type preferredLayerRepresentation); - void setHasChangedProperties(bool = true); + WEBCORE_EXPORT void setHasChangedProperties(bool = true); bool hasChangedProperties() const { return m_hasChangedProperties; } bool hasNewRootStateNode() const { return m_hasNewRootStateNode; } + void setHasNewRootStateNode(bool hasNewRoot) { m_hasNewRootStateNode = hasNewRoot; } int nodeCount() const { return m_stateNodeMap.size(); } @@ -76,17 +74,24 @@ public: void setPreferredLayerRepresentation(LayerRepresentation::Type representation) { m_preferredLayerRepresentation = representation; } private: - ScrollingStateTree(AsyncScrollingCoordinator*); - - void setRootStateNode(PassOwnPtr<ScrollingStateScrollingNode> rootStateNode) { m_rootStateNode = rootStateNode; } + void setRootStateNode(Ref<ScrollingStateFrameScrollingNode>&& rootStateNode) { m_rootStateNode = WTFMove(rootStateNode); } void addNode(ScrollingStateNode*); - void removeNode(ScrollingStateNode*); - void didRemoveNode(ScrollingNodeID); + + Ref<ScrollingStateNode> createNode(ScrollingNodeType, ScrollingNodeID); + + bool nodeTypeAndParentMatch(ScrollingStateNode&, ScrollingNodeType, ScrollingNodeID parentID) const; + + enum class SubframeNodeRemoval { Delete, Orphan }; + void removeNodeAndAllDescendants(ScrollingStateNode*, SubframeNodeRemoval = SubframeNodeRemoval::Delete); + + void recursiveNodeWillBeRemoved(ScrollingStateNode* currNode, SubframeNodeRemoval); + void willRemoveNode(ScrollingStateNode*); AsyncScrollingCoordinator* m_scrollingCoordinator; StateNodeMap m_stateNodeMap; - OwnPtr<ScrollingStateScrollingNode> m_rootStateNode; - Vector<ScrollingNodeID> m_nodesRemovedSinceLastCommit; + RefPtr<ScrollingStateFrameScrollingNode> m_rootStateNode; + HashSet<ScrollingNodeID> m_nodesRemovedSinceLastCommit; + HashMap<ScrollingNodeID, RefPtr<ScrollingStateNode>> m_orphanedSubframeNodes; bool m_hasChangedProperties; bool m_hasNewRootStateNode; LayerRepresentation::Type m_preferredLayerRepresentation; @@ -94,6 +99,9 @@ private: } // namespace WebCore -#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) +#ifndef NDEBUG +void showScrollingStateTree(const WebCore::ScrollingStateTree*); +void showScrollingStateTree(const WebCore::ScrollingStateNode*); +#endif -#endif // ScrollingStateTree_h +#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) |