| Differences between
and this patch
- a/Source/WebCore/ChangeLog +30 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2018-12-04  Simon Fraser  <simon.fraser@apple.com>
2
3
        Allow control over child order when adding nodes to the scrolling tree
4
        https://bugs.webkit.org/show_bug.cgi?id=192395
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Previously ScrollingCoordinator just allowed nodes to be "attached" with a given parent,
9
        but with no control over sibling order. To allow for correct hit-testing overflow and
10
        frame scrolling nodes, we have to build the scrolling tree in z-order.
11
12
        This patch adds a 'childIndex' parameter to attachNode() which gives control over
13
        sibling order, but doesn't use it yet.
14
15
        * page/scrolling/AsyncScrollingCoordinator.cpp:
16
        (WebCore::AsyncScrollingCoordinator::attachToStateTree):
17
        (WebCore::AsyncScrollingCoordinator::ensureRootStateNodeForFrameView):
18
        * page/scrolling/AsyncScrollingCoordinator.h:
19
        * page/scrolling/ScrollingCoordinator.h:
20
        (WebCore::ScrollingCoordinator::attachToStateTree):
21
        * page/scrolling/ScrollingStateNode.cpp:
22
        (WebCore::ScrollingStateNode::insertChild):
23
        (WebCore::ScrollingStateNode::indexOfChild const):
24
        * page/scrolling/ScrollingStateNode.h:
25
        (WebCore::ScrollingStateNode::scrollingNodeID const):
26
        * page/scrolling/ScrollingStateTree.cpp:
27
        (WebCore::ScrollingStateTree::nodeTypeAndParentMatch const):
28
        (WebCore::ScrollingStateTree::attachNode):
29
        * page/scrolling/ScrollingStateTree.h:
30
1
2018-12-05  Frederic Wang  <fwang@igalia.com>
31
2018-12-05  Frederic Wang  <fwang@igalia.com>
2
32
3
        Minor refactoring of the scrolling code
33
        Minor refactoring of the scrolling code
- a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp -3 / +3 lines
Lines 474-482 void AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(Scrollable a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp_sec1
474
        scrollableArea.horizontalScrollbarLayerDidChange();
474
        scrollableArea.horizontalScrollbarLayerDidChange();
475
}
475
}
476
476
477
ScrollingNodeID AsyncScrollingCoordinator::attachToStateTree(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID)
477
ScrollingNodeID AsyncScrollingCoordinator::attachToStateTree(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex)
478
{
478
{
479
    return m_scrollingStateTree->attachNode(nodeType, newNodeID, parentID);
479
    return m_scrollingStateTree->attachNode(nodeType, newNodeID, parentID, childIndex);
480
}
480
}
481
481
482
void AsyncScrollingCoordinator::detachFromStateTree(ScrollingNodeID nodeID)
482
void AsyncScrollingCoordinator::detachFromStateTree(ScrollingNodeID nodeID)
Lines 509-515 void AsyncScrollingCoordinator::ensureRootStateNodeForFrameView(FrameView& frame a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp_sec2
509
    // For non-main frames, it is only possible to arrive in this function from
509
    // For non-main frames, it is only possible to arrive in this function from
510
    // RenderLayerCompositor::updateBacking where the node has already been created.
510
    // RenderLayerCompositor::updateBacking where the node has already been created.
511
    ASSERT(frameView.frame().isMainFrame());
511
    ASSERT(frameView.frame().isMainFrame());
512
    attachToStateTree(MainFrameScrollingNode, frameView.scrollLayerID(), 0);
512
    attachToStateTree(MainFrameScrollingNode, frameView.scrollLayerID(), 0, 0);
513
}
513
}
514
514
515
void AsyncScrollingCoordinator::updateFrameScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* layer, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer, GraphicsLayer* insetClipLayer, const ScrollingGeometry& scrollingGeometry)
515
void AsyncScrollingCoordinator::updateFrameScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* layer, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer, GraphicsLayer* insetClipLayer, const ScrollingGeometry& scrollingGeometry)
- a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h -1 / +1 lines
Lines 97-103 private: a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h_sec1
97
97
98
    WEBCORE_EXPORT bool requestScrollPositionUpdate(FrameView&, const IntPoint&) override;
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
    WEBCORE_EXPORT void detachFromStateTree(ScrollingNodeID) override;
101
    WEBCORE_EXPORT void detachFromStateTree(ScrollingNodeID) override;
102
    WEBCORE_EXPORT void clearStateTree() override;
102
    WEBCORE_EXPORT void clearStateTree() override;
103
    
103
    
- a/Source/WebCore/page/scrolling/ScrollingCoordinator.h -1 / +2 lines
Lines 164-170 public: a/Source/WebCore/page/scrolling/ScrollingCoordinator.h_sec1
164
    virtual void commitTreeStateIfNeeded() { }
164
    virtual void commitTreeStateIfNeeded() { }
165
    virtual bool requestScrollPositionUpdate(FrameView&, const IntPoint&) { return false; }
165
    virtual bool requestScrollPositionUpdate(FrameView&, const IntPoint&) { return false; }
166
    virtual bool handleWheelEvent(FrameView&, const PlatformWheelEvent&) { return true; }
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
    virtual void detachFromStateTree(ScrollingNodeID) { }
169
    virtual void detachFromStateTree(ScrollingNodeID) { }
169
    virtual void clearStateTree() { }
170
    virtual void clearStateTree() { }
170
171
- a/Source/WebCore/page/scrolling/ScrollingStateNode.cpp +20 lines
Lines 97-102 void ScrollingStateNode::appendChild(Ref<ScrollingStateNode>&& childNode) a/Source/WebCore/page/scrolling/ScrollingStateNode.cpp_sec1
97
    m_children->append(WTFMove(childNode));
97
    m_children->append(WTFMove(childNode));
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
void ScrollingStateNode::reconcileLayerPositionForViewportRect(const LayoutRect& viewportRect, ScrollingLayerPositionAction action)
120
void ScrollingStateNode::reconcileLayerPositionForViewportRect(const LayoutRect& viewportRect, ScrollingLayerPositionAction action)
101
{
121
{
102
    if (!m_children)
122
    if (!m_children)
- a/Source/WebCore/page/scrolling/ScrollingStateNode.h -2 / +4 lines
Lines 195-200 public: a/Source/WebCore/page/scrolling/ScrollingStateNode.h_sec1
195
    virtual ~ScrollingStateNode();
195
    virtual ~ScrollingStateNode();
196
    
196
    
197
    ScrollingNodeType nodeType() const { return m_nodeType; }
197
    ScrollingNodeType nodeType() const { return m_nodeType; }
198
    ScrollingNodeID scrollingNodeID() const { return m_nodeID; }
198
199
199
    bool isFixedNode() const { return m_nodeType == FixedNode; }
200
    bool isFixedNode() const { return m_nodeType == FixedNode; }
200
    bool isStickyNode() const { return m_nodeType == StickyNode; }
201
    bool isStickyNode() const { return m_nodeType == StickyNode; }
Lines 227-234 public: a/Source/WebCore/page/scrolling/ScrollingStateNode.h_sec2
227
228
228
    ScrollingStateTree& scrollingStateTree() const { return m_scrollingStateTree; }
229
    ScrollingStateTree& scrollingStateTree() const { return m_scrollingStateTree; }
229
230
230
    ScrollingNodeID scrollingNodeID() const { return m_nodeID; }
231
232
    ScrollingStateNode* parent() const { return m_parent; }
231
    ScrollingStateNode* parent() const { return m_parent; }
233
    void setParent(ScrollingStateNode* parent) { m_parent = parent; }
232
    void setParent(ScrollingStateNode* parent) { m_parent = parent; }
234
    ScrollingNodeID parentNodeID() const { return m_parent ? m_parent->scrollingNodeID() : 0; }
233
    ScrollingNodeID parentNodeID() const { return m_parent ? m_parent->scrollingNodeID() : 0; }
Lines 236-241 public: a/Source/WebCore/page/scrolling/ScrollingStateNode.h_sec3
236
    Vector<RefPtr<ScrollingStateNode>>* children() const { return m_children.get(); }
235
    Vector<RefPtr<ScrollingStateNode>>* children() const { return m_children.get(); }
237
236
238
    void appendChild(Ref<ScrollingStateNode>&&);
237
    void appendChild(Ref<ScrollingStateNode>&&);
238
    void insertChild(Ref<ScrollingStateNode>&&, size_t index);
239
240
    size_t indexOfChild(ScrollingStateNode&) const;
239
241
240
    String scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const;
242
    String scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const;
241
243
- a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp -11 / +33 lines
Lines 82-106 Ref<ScrollingStateNode> ScrollingStateTree::createNode(ScrollingNodeType nodeTyp a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp_sec1
82
    return ScrollingStateFixedNode::create(*this, nodeID);
82
    return ScrollingStateFixedNode::create(*this, nodeID);
83
}
83
}
84
84
85
bool ScrollingStateTree::nodeTypeAndParentMatch(ScrollingStateNode& node, ScrollingNodeType nodeType, ScrollingNodeID parentID) const
85
bool ScrollingStateTree::nodeTypeAndParentMatch(ScrollingStateNode& node, ScrollingNodeType nodeType, ScrollingStateNode* parentNode) const
86
{
86
{
87
    if (node.nodeType() != nodeType)
87
    if (node.nodeType() != nodeType)
88
        return false;
88
        return false;
89
89
90
    auto* parent = stateNodeForID(parentID);
90
    return node.parent() == parentNode;
91
    if (!parent)
92
        return true;
93
94
    return node.parent() == parent;
95
}
91
}
96
92
97
ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID)
93
ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex)
98
{
94
{
99
    ASSERT(newNodeID);
95
    ASSERT(newNodeID);
100
96
101
    if (auto* node = stateNodeForID(newNodeID)) {
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
            return newNodeID;
116
            return newNodeID;
117
        }
104
118
105
#if ENABLE(ASYNC_SCROLLING)
119
#if ENABLE(ASYNC_SCROLLING)
106
        // If the type has changed, we need to destroy and recreate the node with a new ID.
120
        // If the type has changed, we need to destroy and recreate the node with a new ID.
Lines 114-119 ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, Scrol a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp_sec2
114
128
115
    ScrollingStateNode* newNode = nullptr;
129
    ScrollingStateNode* newNode = nullptr;
116
    if (!parentID) {
130
    if (!parentID) {
131
        ASSERT(!childIndex || childIndex == notFound);
117
        // If we're resetting the root node, we should clear the HashMap and destroy the current children.
132
        // If we're resetting the root node, we should clear the HashMap and destroy the current children.
118
        clear();
133
        clear();
119
134
Lines 122-133 ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, Scrol a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp_sec3
122
        m_hasNewRootStateNode = true;
137
        m_hasNewRootStateNode = true;
123
    } else {
138
    } else {
124
        auto* parent = stateNodeForID(parentID);
139
        auto* parent = stateNodeForID(parentID);
125
        if (!parent)
140
        if (!parent) {
141
            ASSERT_NOT_REACHED();
126
            return 0;
142
            return 0;
143
        }
127
144
128
        if (nodeType == SubframeScrollingNode && parentID) {
145
        if (nodeType == SubframeScrollingNode && parentID) {
129
            if (auto orphanedNode = m_orphanedSubframeNodes.take(newNodeID)) {
146
            if (auto orphanedNode = m_orphanedSubframeNodes.take(newNodeID)) {
130
                newNode = orphanedNode.get();
147
                newNode = orphanedNode.get();
148
                // FIXME: use childIndex
131
                parent->appendChild(orphanedNode.releaseNonNull());
149
                parent->appendChild(orphanedNode.releaseNonNull());
132
            }
150
            }
133
        }
151
        }
Lines 135-145 ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, Scrol a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp_sec4
135
        if (!newNode) {
153
        if (!newNode) {
136
            auto stateNode = createNode(nodeType, newNodeID);
154
            auto stateNode = createNode(nodeType, newNodeID);
137
            newNode = stateNode.ptr();
155
            newNode = stateNode.ptr();
138
            parent->appendChild(WTFMove(stateNode));
156
157
            if (childIndex == notFound)
158
                parent->appendChild(WTFMove(stateNode));
159
            else
160
                parent->insertChild(WTFMove(stateNode), childIndex);
139
        }
161
        }
140
    }
162
    }
141
163
142
    m_stateNodeMap.set(newNodeID, newNode);
164
    addNode(*newNode);
143
    m_nodesRemovedSinceLastCommit.remove(newNodeID);
165
    m_nodesRemovedSinceLastCommit.remove(newNodeID);
144
    return newNodeID;
166
    return newNodeID;
145
}
167
}
- a/Source/WebCore/page/scrolling/ScrollingStateTree.h -2 / +2 lines
Lines 51-57 public: a/Source/WebCore/page/scrolling/ScrollingStateTree.h_sec1
51
    ScrollingStateFrameScrollingNode* rootStateNode() const { return m_rootStateNode.get(); }
51
    ScrollingStateFrameScrollingNode* rootStateNode() const { return m_rootStateNode.get(); }
52
    WEBCORE_EXPORT ScrollingStateNode* stateNodeForID(ScrollingNodeID) const;
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
    void detachNode(ScrollingNodeID);
55
    void detachNode(ScrollingNodeID);
56
    void clear();
56
    void clear();
57
    
57
    
Lines 81-87 private: a/Source/WebCore/page/scrolling/ScrollingStateTree.h_sec2
81
81
82
    Ref<ScrollingStateNode> createNode(ScrollingNodeType, ScrollingNodeID);
82
    Ref<ScrollingStateNode> createNode(ScrollingNodeType, ScrollingNodeID);
83
83
84
    bool nodeTypeAndParentMatch(ScrollingStateNode&, ScrollingNodeType, ScrollingNodeID parentID) const;
84
    bool nodeTypeAndParentMatch(ScrollingStateNode&, ScrollingNodeType, ScrollingStateNode* parentNode) const;
85
85
86
    enum class SubframeNodeRemoval { Delete, Orphan };
86
    enum class SubframeNodeRemoval { Delete, Orphan };
87
    void removeNodeAndAllDescendants(ScrollingStateNode*, SubframeNodeRemoval = SubframeNodeRemoval::Delete);
87
    void removeNodeAndAllDescendants(ScrollingStateNode*, SubframeNodeRemoval = SubframeNodeRemoval::Delete);
- a/Source/WebKit/ChangeLog +10 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2018-12-04  Simon Fraser  <simon.fraser@apple.com>
2
3
        Allow control over child order when adding nodes to the scrolling tree
4
        https://bugs.webkit.org/show_bug.cgi?id=192395
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
9
        (WebKit::RemoteScrollingCoordinatorTransaction::decode):
10
1
2018-12-05  Rob Buis  <rbuis@igalia.com>
11
2018-12-05  Rob Buis  <rbuis@igalia.com>
2
12
3
        [Mac] HEAD requests changed to GET after 301, 302, and 303 redirections (http/tests/xmlhttprequest/head-redirection.html)
13
        [Mac] HEAD requests changed to GET after 301, 302, and 303 redirections (http/tests/xmlhttprequest/head-redirection.html)
- a/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp -2 / +1 lines
Lines 413-419 bool RemoteScrollingCoordinatorTransaction::decode(IPC::Decoder& decoder) a/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp_sec1
413
        if (!decoder.decode(parentNodeID))
413
        if (!decoder.decode(parentNodeID))
414
            return false;
414
            return false;
415
415
416
        m_scrollingStateTree->attachNode(nodeType, nodeID, parentNodeID);
416
        m_scrollingStateTree->attachNode(nodeType, nodeID, parentNodeID, i);
417
        ScrollingStateNode* newNode = m_scrollingStateTree->stateNodeForID(nodeID);
417
        ScrollingStateNode* newNode = m_scrollingStateTree->stateNodeForID(nodeID);
418
        ASSERT(newNode);
418
        ASSERT(newNode);
419
        ASSERT(!parentNodeID || newNode->parent());
419
        ASSERT(!parentNodeID || newNode->parent());
420
- 

Return to Bug 192395