Changeset 238947 in webkit
- Timestamp:
- Dec 6, 2018 5:47:04 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r238946 r238947 1 2018-12-06 Frederic Wang <fwang@igalia.com> 2 3 Allow control over child order when adding nodes to the scrolling tree 4 https://bugs.webkit.org/show_bug.cgi?id=176914 5 6 Reviewed by Simon Fraser. 7 8 Based on an earlier patch by Simon Fraser. 9 10 Previously ScrollingCoordinator just allowed nodes to be "attached" with a given parent, 11 but with no control over sibling order. To allow for correct hit-testing overflow and 12 frame scrolling nodes, we have to build the scrolling tree in z-order. 13 14 This patch adds a 'childIndex' parameter to attachNode() which gives control over 15 sibling order. For now, RenderLayerCompositor always uses the default 'notFound' value 16 for childIndex so the current behavior (appending new nodes at the end of child list) is 17 preserved. 18 19 No new tests, behavior unchanged and already covered by existing tests. 20 21 * page/scrolling/AsyncScrollingCoordinator.cpp: 22 (WebCore::AsyncScrollingCoordinator::attachToStateTree): 23 (WebCore::AsyncScrollingCoordinator::ensureRootStateNodeForFrameView): 24 * page/scrolling/AsyncScrollingCoordinator.h: 25 * page/scrolling/ScrollingCoordinator.h: 26 (WebCore::ScrollingCoordinator::attachToStateTree): 27 * page/scrolling/ScrollingStateNode.cpp: 28 (WebCore::ScrollingStateNode::insertChild): 29 (WebCore::ScrollingStateNode::indexOfChild const): 30 * page/scrolling/ScrollingStateNode.h: 31 * page/scrolling/ScrollingStateTree.cpp: 32 (WebCore::ScrollingStateTree::nodeTypeAndParentMatch const): 33 (WebCore::ScrollingStateTree::attachNode): 34 * page/scrolling/ScrollingStateTree.h: 35 1 36 2018-12-06 Yongjun Zhang <yongjun_zhang@apple.com> 2 37 -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
r238885 r238947 475 475 } 476 476 477 ScrollingNodeID AsyncScrollingCoordinator::attachToStateTree(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID )478 { 479 return m_scrollingStateTree->attachNode(nodeType, newNodeID, parentID );477 ScrollingNodeID AsyncScrollingCoordinator::attachToStateTree(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex) 478 { 479 return m_scrollingStateTree->attachNode(nodeType, newNodeID, parentID, childIndex); 480 480 } 481 481 … … 510 510 // RenderLayerCompositor::updateBacking where the node has already been created. 511 511 ASSERT(frameView.frame().isMainFrame()); 512 attachToStateTree(MainFrameScrollingNode, frameView.scrollLayerID(), 0 );512 attachToStateTree(MainFrameScrollingNode, frameView.scrollLayerID(), 0, 0); 513 513 } 514 514 -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
r238885 r238947 98 98 WEBCORE_EXPORT bool requestScrollPositionUpdate(FrameView&, const IntPoint&) override; 99 99 100 WEBCORE_EXPORT ScrollingNodeID attachToStateTree(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID ) override;100 WEBCORE_EXPORT ScrollingNodeID attachToStateTree(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex) override; 101 101 WEBCORE_EXPORT void detachFromStateTree(ScrollingNodeID) override; 102 102 WEBCORE_EXPORT void clearStateTree() override; -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h
r238898 r238947 165 165 virtual bool requestScrollPositionUpdate(FrameView&, const IntPoint&) { return false; } 166 166 virtual bool handleWheelEvent(FrameView&, const PlatformWheelEvent&) { return true; } 167 virtual ScrollingNodeID attachToStateTree(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID /*parentID*/) { return newNodeID; } 167 virtual ScrollingNodeID attachToStateTree(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID /*parentID*/, size_t /*childIndex*/ = notFound) { return newNodeID; } 168 168 169 virtual void detachFromStateTree(ScrollingNodeID) { } 169 170 virtual void clearStateTree() { } -
trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp
r238898 r238947 98 98 } 99 99 100 void ScrollingStateNode::insertChild(Ref<ScrollingStateNode>&& childNode, size_t index) 101 { 102 childNode->setParent(this); 103 104 if (!m_children) { 105 ASSERT(!index); 106 m_children = std::make_unique<Vector<RefPtr<ScrollingStateNode>>>(); 107 } 108 109 m_children->insert(index, WTFMove(childNode)); 110 } 111 112 size_t ScrollingStateNode::indexOfChild(ScrollingStateNode& childNode) const 113 { 114 if (!m_children) 115 return notFound; 116 117 return m_children->find(&childNode); 118 } 119 100 120 void ScrollingStateNode::reconcileLayerPositionForViewportRect(const LayoutRect& viewportRect, ScrollingLayerPositionAction action) 101 121 { -
trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h
r238898 r238947 237 237 238 238 void appendChild(Ref<ScrollingStateNode>&&); 239 void insertChild(Ref<ScrollingStateNode>&&, size_t index); 240 241 size_t indexOfChild(ScrollingStateNode&) const; 239 242 240 243 String scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const; -
trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp
r238898 r238947 83 83 } 84 84 85 bool ScrollingStateTree::nodeTypeAndParentMatch(ScrollingStateNode& node, ScrollingNodeType nodeType, Scrolling NodeID parentID) const85 bool ScrollingStateTree::nodeTypeAndParentMatch(ScrollingStateNode& node, ScrollingNodeType nodeType, ScrollingStateNode* parentNode) const 86 86 { 87 87 if (node.nodeType() != nodeType) 88 88 return false; 89 89 90 auto* parent = stateNodeForID(parentID); 91 if (!parent) 92 return true; 93 94 return node.parent() == parent; 95 } 96 97 ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID) 90 return node.parent() == parentNode; 91 } 92 93 ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex) 98 94 { 99 95 ASSERT(newNodeID); 100 96 101 97 if (auto* node = stateNodeForID(newNodeID)) { 102 if (nodeTypeAndParentMatch(*node, nodeType, parentID)) 98 auto* parent = stateNodeForID(parentID); 99 if (nodeTypeAndParentMatch(*node, nodeType, parent)) { 100 if (!parentID) 101 return newNodeID; 102 103 size_t currentIndex = parent->indexOfChild(*node); 104 if (currentIndex == childIndex) 105 return newNodeID; 106 107 ASSERT(currentIndex != notFound); 108 Ref<ScrollingStateNode> protectedNode(*node); 109 parent->children()->remove(currentIndex); 110 111 if (childIndex == notFound) 112 parent->appendChild(WTFMove(protectedNode)); 113 else 114 parent->insertChild(WTFMove(protectedNode), childIndex); 115 103 116 return newNodeID; 117 } 104 118 105 119 #if ENABLE(ASYNC_SCROLLING) … … 115 129 ScrollingStateNode* newNode = nullptr; 116 130 if (!parentID) { 131 ASSERT(!childIndex || childIndex == notFound); 117 132 // If we're resetting the root node, we should clear the HashMap and destroy the current children. 118 133 clear(); … … 123 138 } else { 124 139 auto* parent = stateNodeForID(parentID); 125 if (!parent) 140 if (!parent) { 141 ASSERT_NOT_REACHED(); 126 142 return 0; 143 } 127 144 128 145 if (nodeType == SubframeScrollingNode && parentID) { 129 146 if (auto orphanedNode = m_orphanedSubframeNodes.take(newNodeID)) { 130 147 newNode = orphanedNode.get(); 131 parent->appendChild(orphanedNode.releaseNonNull()); 148 if (childIndex == notFound) 149 parent->appendChild(orphanedNode.releaseNonNull()); 150 else 151 parent->insertChild(orphanedNode.releaseNonNull(), childIndex); 132 152 } 133 153 } … … 136 156 auto stateNode = createNode(nodeType, newNodeID); 137 157 newNode = stateNode.ptr(); 138 parent->appendChild(WTFMove(stateNode)); 139 } 140 } 141 142 m_stateNodeMap.set(newNodeID, newNode); 158 if (childIndex == notFound) 159 parent->appendChild(WTFMove(stateNode)); 160 else 161 parent->insertChild(WTFMove(stateNode), childIndex); 162 } 163 } 164 165 addNode(*newNode); 143 166 m_nodesRemovedSinceLastCommit.remove(newNodeID); 144 167 return newNodeID; -
trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h
r238898 r238947 52 52 WEBCORE_EXPORT ScrollingStateNode* stateNodeForID(ScrollingNodeID) const; 53 53 54 WEBCORE_EXPORT ScrollingNodeID attachNode(ScrollingNodeType, ScrollingNodeID, ScrollingNodeID parentID );54 WEBCORE_EXPORT ScrollingNodeID attachNode(ScrollingNodeType, ScrollingNodeID, ScrollingNodeID parentID, size_t childIndex); 55 55 void detachNode(ScrollingNodeID); 56 56 void clear(); … … 82 82 Ref<ScrollingStateNode> createNode(ScrollingNodeType, ScrollingNodeID); 83 83 84 bool nodeTypeAndParentMatch(ScrollingStateNode&, ScrollingNodeType, Scrolling NodeID parentID) const;84 bool nodeTypeAndParentMatch(ScrollingStateNode&, ScrollingNodeType, ScrollingStateNode* parentNode) const; 85 85 86 86 enum class SubframeNodeRemoval { Delete, Orphan }; -
trunk/Source/WebKit/ChangeLog
r238946 r238947 1 2018-12-06 Frederic Wang <fwang@igalia.com> 2 3 Allow control over child order when adding nodes to the scrolling tree 4 https://bugs.webkit.org/show_bug.cgi?id=176914 5 6 Reviewed by Simon Fraser. 7 8 Based on an earlier patch by Simon Fraser. 9 10 * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp: 11 (WebKit::RemoteScrollingCoordinatorTransaction::decode): Make explicit that we want to append 12 the new node at the end of child list. 13 1 14 2018-12-06 Yongjun Zhang <yongjun_zhang@apple.com> 2 15 -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp
r228264 r238947 414 414 return false; 415 415 416 m_scrollingStateTree->attachNode(nodeType, nodeID, parentNodeID );416 m_scrollingStateTree->attachNode(nodeType, nodeID, parentNodeID, notFound); // Append new node. 417 417 ScrollingStateNode* newNode = m_scrollingStateTree->stateNodeForID(nodeID); 418 418 ASSERT(newNode);
Note: See TracChangeset
for help on using the changeset viewer.