Add scrolling node types to distinguish main frames and subframes.
authorfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Feb 2018 10:01:43 +0000 (10:01 +0000)
committerfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Feb 2018 10:01:43 +0000 (10:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182533

Patch by Frederic Wang <fwang@igalia.com> on 2018-02-08
Reviewed by Simon Fraser.

Source/WebCore:

This patch splits FrameScrollingNode type into two types: MainFrameScrollingNode and
SubframeScrollingNode. This is needed because new places in the code are likely to
distinguish them e.g. in ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll
or when iOS frame scrolling is introduced (see bug 173833).

No new tests, behavior unchanged.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::ensureRootStateNodeForFrameView): This is only called
for main frames, so pass MainFrameScrollingNode.
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::operator<<): Distinguish subframe and main frame when dumping.
* page/scrolling/ScrollingCoordinator.h: Split FrameScrollingNode into two cases.
* page/scrolling/ScrollingStateFrameScrollingNode.cpp: Add node type to constructor and
ASSERT it remains of type FrameScrollingNode.
(WebCore::ScrollingStateFrameScrollingNode::create):
(WebCore::ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode):
* page/scrolling/ScrollingStateFrameScrollingNode.h: Add node type to constructor.
* page/scrolling/ScrollingStateNode.h:
(WebCore::ScrollingStateNode::isFrameScrollingNode const): Includes the two cases.
* page/scrolling/ScrollingStateTree.cpp:
(WebCore::ScrollingStateTree::createNode): Split FrameScrollingNode into two cases and pass
the node type.
(WebCore::ScrollingStateTree::attachNode): The first case only happens for main frames while
the second case only happens with subframes. Use the appriate node type.
* page/scrolling/ScrollingTreeFrameScrollingNode.cpp: Add node type to constructor and
ASSERT it remains of type FrameScrollingNode.
(WebCore::ScrollingTreeFrameScrollingNode::ScrollingTreeFrameScrollingNode):
* page/scrolling/ScrollingTreeFrameScrollingNode.h: Add node type to constructor.
* page/scrolling/ScrollingTreeNode.h: Includes the two cases.
(WebCore::ScrollingTreeNode::isFrameScrollingNode const):
* page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.h: Add node type to constructor.
* page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm: Ditto.
(WebCore::ScrollingTreeFrameScrollingNodeIOS::create):
(WebCore::ScrollingTreeFrameScrollingNodeIOS::ScrollingTreeFrameScrollingNodeIOS):
* page/scrolling/ios/ScrollingTreeIOS.cpp: Split FrameScrollingNode into two cases.
(WebCore::ScrollingTreeIOS::createScrollingTreeNode):
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: Add node type to constructor.
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: Ditto.
(WebCore::ScrollingTreeFrameScrollingNodeMac::create):
(WebCore::ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac):
* page/scrolling/mac/ScrollingTreeMac.cpp: Split FrameScrollingNode into two cases.
(ScrollingTreeMac::createScrollingTreeNode):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::reattachSubframeScrollLayers): Distinguish the cases of
main frames and subframes.
(WebCore::scrollCoordinationRoleForNodeType): Split FrameScrollingNode into two cases.
(WebCore::RenderLayerCompositor::updateScrollCoordinationForThisFrame): Distinguish the cases
of main frames and subframes.
(WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): Split FrameScrollingNode into
two cases.

Source/WebKit:

* Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp: Replace the case of
FrameScrollingNode with MainFrameScrollingNode and SubframeScrollingNode.
(WebKit::encodeNodeAndDescendants):
(WebKit::RemoteScrollingCoordinatorTransaction::decode):
(WebKit::dump):
* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp: Ditto.
(WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
* UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp: Ditto and pass the node type to the
constructor of the frame scrolling node.
(WebKit::RemoteScrollingTree::createScrollingTreeNode):
* UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm: Replace the case of
FrameScrollingNode with MainFrameScrollingNode and SubframeScrollingNode.
(WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
* UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm: In order to
determine whether the node is a main frame or subframe, use the node type instead of checking
whether the node as a parent.
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228264 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h
Source/WebCore/page/scrolling/ScrollingStateNode.h
Source/WebCore/page/scrolling/ScrollingStateTree.cpp
Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h
Source/WebCore/page/scrolling/ScrollingTreeNode.h
Source/WebCore/page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.h
Source/WebCore/page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm
Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.cpp
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeMac.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm

index 52d0f7e..de05dea 100644 (file)
@@ -1,3 +1,62 @@
+2018-02-08  Frederic Wang  <fwang@igalia.com>
+
+        Add scrolling node types to distinguish main frames and subframes.
+        https://bugs.webkit.org/show_bug.cgi?id=182533
+
+        Reviewed by Simon Fraser.
+
+        This patch splits FrameScrollingNode type into two types: MainFrameScrollingNode and
+        SubframeScrollingNode. This is needed because new places in the code are likely to
+        distinguish them e.g. in ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll
+        or when iOS frame scrolling is introduced (see bug 173833).
+
+        No new tests, behavior unchanged.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::ensureRootStateNodeForFrameView): This is only called
+        for main frames, so pass MainFrameScrollingNode.
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::operator<<): Distinguish subframe and main frame when dumping.
+        * page/scrolling/ScrollingCoordinator.h: Split FrameScrollingNode into two cases.
+        * page/scrolling/ScrollingStateFrameScrollingNode.cpp: Add node type to constructor and
+        ASSERT it remains of type FrameScrollingNode.
+        (WebCore::ScrollingStateFrameScrollingNode::create):
+        (WebCore::ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode):
+        * page/scrolling/ScrollingStateFrameScrollingNode.h: Add node type to constructor.
+        * page/scrolling/ScrollingStateNode.h:
+        (WebCore::ScrollingStateNode::isFrameScrollingNode const): Includes the two cases.
+        * page/scrolling/ScrollingStateTree.cpp:
+        (WebCore::ScrollingStateTree::createNode): Split FrameScrollingNode into two cases and pass
+        the node type.
+        (WebCore::ScrollingStateTree::attachNode): The first case only happens for main frames while
+        the second case only happens with subframes. Use the appriate node type.
+        * page/scrolling/ScrollingTreeFrameScrollingNode.cpp: Add node type to constructor and
+        ASSERT it remains of type FrameScrollingNode.
+        (WebCore::ScrollingTreeFrameScrollingNode::ScrollingTreeFrameScrollingNode):
+        * page/scrolling/ScrollingTreeFrameScrollingNode.h: Add node type to constructor.
+        * page/scrolling/ScrollingTreeNode.h: Includes the two cases.
+        (WebCore::ScrollingTreeNode::isFrameScrollingNode const):
+        * page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.h: Add node type to constructor.
+        * page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm: Ditto.
+        (WebCore::ScrollingTreeFrameScrollingNodeIOS::create):
+        (WebCore::ScrollingTreeFrameScrollingNodeIOS::ScrollingTreeFrameScrollingNodeIOS):
+        * page/scrolling/ios/ScrollingTreeIOS.cpp: Split FrameScrollingNode into two cases.
+        (WebCore::ScrollingTreeIOS::createScrollingTreeNode):
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: Add node type to constructor.
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: Ditto.
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::create):
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac):
+        * page/scrolling/mac/ScrollingTreeMac.cpp: Split FrameScrollingNode into two cases.
+        (ScrollingTreeMac::createScrollingTreeNode):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::reattachSubframeScrollLayers): Distinguish the cases of
+        main frames and subframes.
+        (WebCore::scrollCoordinationRoleForNodeType): Split FrameScrollingNode into two cases.
+        (WebCore::RenderLayerCompositor::updateScrollCoordinationForThisFrame): Distinguish the cases
+        of main frames and subframes.
+        (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): Split FrameScrollingNode into
+        two cases.
+
 2018-02-07  Darin Adler  <darin@apple.com>
 
         Try to fix ErrorEvent tests seen failing on buildbot after fix for bug 179591.
index f84b525..c5e5c0a 100644 (file)
@@ -505,7 +505,7 @@ void AsyncScrollingCoordinator::ensureRootStateNodeForFrameView(FrameView& frame
     // For non-main frames, it is only possible to arrive in this function from
     // RenderLayerCompositor::updateBacking where the node has already been created.
     ASSERT(frameView.frame().isMainFrame());
-    attachToStateTree(FrameScrollingNode, frameView.scrollLayerID(), 0);
+    attachToStateTree(MainFrameScrollingNode, frameView.scrollLayerID(), 0);
 }
 
 void AsyncScrollingCoordinator::updateFrameScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* layer, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer, GraphicsLayer* insetClipLayer, const ScrollingGeometry* scrollingGeometry)
index ce8f0ec..1dd35c1 100644 (file)
@@ -425,8 +425,11 @@ TextStream& operator<<(TextStream& ts, ScrollableAreaParameters scrollableAreaPa
 TextStream& operator<<(TextStream& ts, ScrollingNodeType nodeType)
 {
     switch (nodeType) {
-    case FrameScrollingNode:
-        ts << "frame-scrolling";
+    case MainFrameScrollingNode:
+        ts << "main-frame-scrolling";
+        break;
+    case SubframeScrollingNode:
+        ts << "subframe-scrolling";
         break;
     case OverflowScrollingNode:
         ts << "overflow-scrolling";
index 1d658a8..4deb2e8 100644 (file)
@@ -54,7 +54,7 @@ namespace WebCore {
 typedef unsigned SynchronousScrollingReasons;
 typedef uint64_t ScrollingNodeID;
 
-enum ScrollingNodeType { FrameScrollingNode, OverflowScrollingNode, FixedNode, StickyNode };
+enum ScrollingNodeType { MainFrameScrollingNode, SubframeScrollingNode, OverflowScrollingNode, FixedNode, StickyNode };
 
 enum ScrollingStateTreeAsTextBehaviorFlags {
     ScrollingStateTreeAsTextBehaviorNormal                  = 0,
index d4f0af0..01c36d6 100644 (file)
 
 namespace WebCore {
 
-Ref<ScrollingStateFrameScrollingNode> ScrollingStateFrameScrollingNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
+Ref<ScrollingStateFrameScrollingNode> ScrollingStateFrameScrollingNode::create(ScrollingStateTree& stateTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
 {
-    return adoptRef(*new ScrollingStateFrameScrollingNode(stateTree, nodeID));
+    return adoptRef(*new ScrollingStateFrameScrollingNode(stateTree, nodeType, nodeID));
 }
 
-ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
-    : ScrollingStateScrollingNode(stateTree, FrameScrollingNode, nodeID)
+ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode(ScrollingStateTree& stateTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
+    : ScrollingStateScrollingNode(stateTree, nodeType, nodeID)
 {
+    ASSERT(isFrameScrollingNode());
 }
 
 ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode(const ScrollingStateFrameScrollingNode& stateNode, ScrollingStateTree& adoptiveTree)
index 52a3ddc..0fbc4ff 100644 (file)
@@ -39,7 +39,7 @@ class Scrollbar;
 
 class ScrollingStateFrameScrollingNode final : public ScrollingStateScrollingNode {
 public:
-    static Ref<ScrollingStateFrameScrollingNode> create(ScrollingStateTree&, ScrollingNodeID);
+    static Ref<ScrollingStateFrameScrollingNode> create(ScrollingStateTree&, ScrollingNodeType, ScrollingNodeID);
 
     Ref<ScrollingStateNode> clone(ScrollingStateTree&) override;
 
@@ -134,7 +134,7 @@ public:
     void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override;
 
 private:
-    ScrollingStateFrameScrollingNode(ScrollingStateTree&, ScrollingNodeID);
+    ScrollingStateFrameScrollingNode(ScrollingStateTree&, ScrollingNodeType, ScrollingNodeID);
     ScrollingStateFrameScrollingNode(const ScrollingStateFrameScrollingNode&, ScrollingStateTree&);
 
     LayerRepresentation m_counterScrollingLayer;
index 5da79f6..6fbe638 100644 (file)
@@ -197,7 +197,7 @@ public:
     bool isFixedNode() const { return m_nodeType == FixedNode; }
     bool isStickyNode() const { return m_nodeType == StickyNode; }
     bool isScrollingNode() const { return isFrameScrollingNode() || isOverflowScrollingNode(); }
-    bool isFrameScrollingNode() const { return m_nodeType == FrameScrollingNode; }
+    bool isFrameScrollingNode() const { return m_nodeType == MainFrameScrollingNode || m_nodeType == SubframeScrollingNode; }
     bool isOverflowScrollingNode() const { return m_nodeType == OverflowScrollingNode; }
 
     virtual Ref<ScrollingStateNode> clone(ScrollingStateTree& adoptiveTree) = 0;
index 2bba2ca..b33aa0c 100644 (file)
@@ -72,8 +72,9 @@ Ref<ScrollingStateNode> ScrollingStateTree::createNode(ScrollingNodeType nodeTyp
         return ScrollingStateFixedNode::create(*this, nodeID);
     case StickyNode:
         return ScrollingStateStickyNode::create(*this, nodeID);
-    case FrameScrollingNode:
-        return ScrollingStateFrameScrollingNode::create(*this, nodeID);
+    case MainFrameScrollingNode:
+    case SubframeScrollingNode:
+        return ScrollingStateFrameScrollingNode::create(*this, nodeType, nodeID);
     case OverflowScrollingNode:
         return ScrollingStateOverflowScrollingNode::create(*this, nodeID);
     }
@@ -116,7 +117,7 @@ ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, Scrol
         // If we're resetting the root node, we should clear the HashMap and destroy the current children.
         clear();
 
-        setRootStateNode(ScrollingStateFrameScrollingNode::create(*this, newNodeID));
+        setRootStateNode(ScrollingStateFrameScrollingNode::create(*this, MainFrameScrollingNode, newNodeID));
         newNode = rootStateNode();
         m_hasNewRootStateNode = true;
     } else {
@@ -124,7 +125,7 @@ ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, Scrol
         if (!parent)
             return 0;
 
-        if (nodeType == FrameScrollingNode && parentID) {
+        if (nodeType == SubframeScrollingNode && parentID) {
             if (auto orphanedNode = m_orphanedSubframeNodes.take(newNodeID)) {
                 newNode = orphanedNode.get();
                 parent->appendChild(orphanedNode.releaseNonNull());
index bfcbff9..de5214a 100644 (file)
 
 namespace WebCore {
 
-ScrollingTreeFrameScrollingNode::ScrollingTreeFrameScrollingNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
-    : ScrollingTreeScrollingNode(scrollingTree, FrameScrollingNode, nodeID)
+ScrollingTreeFrameScrollingNode::ScrollingTreeFrameScrollingNode(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
+    : ScrollingTreeScrollingNode(scrollingTree, nodeType, nodeID)
 {
+    ASSERT(isFrameScrollingNode());
 }
 
 ScrollingTreeFrameScrollingNode::~ScrollingTreeFrameScrollingNode() = default;
index cbc8d63..95395b2 100644 (file)
@@ -61,7 +61,7 @@ public:
     FloatRect fixedPositionRect() { return FloatRect(lastCommittedScrollPosition(), scrollableAreaSize()); };
 
 protected:
-    ScrollingTreeFrameScrollingNode(ScrollingTree&, ScrollingNodeID);
+    ScrollingTreeFrameScrollingNode(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
 
     void scrollBy(const FloatSize&);
     void scrollByWithoutContentEdgeConstraints(const FloatSize&);
index fd8c50c..7951dad 100644 (file)
@@ -50,7 +50,7 @@ public:
     bool isFixedNode() const { return nodeType() == FixedNode; }
     bool isStickyNode() const { return nodeType() == StickyNode; }
     bool isScrollingNode() const { return isFrameScrollingNode() || isOverflowScrollingNode(); }
-    bool isFrameScrollingNode() const { return nodeType() == FrameScrollingNode; }
+    bool isFrameScrollingNode() const { return nodeType() == MainFrameScrollingNode || nodeType() == SubframeScrollingNode; }
     bool isOverflowScrollingNode() const { return nodeType() == OverflowScrollingNode; }
 
     virtual void commitStateBeforeChildren(const ScrollingStateNode&) = 0;
index 22394e4..bfaa0f1 100644 (file)
@@ -36,11 +36,11 @@ namespace WebCore {
 
 class ScrollingTreeFrameScrollingNodeIOS : public ScrollingTreeFrameScrollingNode {
 public:
-    WEBCORE_EXPORT static Ref<ScrollingTreeFrameScrollingNodeIOS> create(ScrollingTree&, ScrollingNodeID);
+    WEBCORE_EXPORT static Ref<ScrollingTreeFrameScrollingNodeIOS> create(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
     virtual ~ScrollingTreeFrameScrollingNodeIOS();
 
 protected:
-    ScrollingTreeFrameScrollingNodeIOS(ScrollingTree&, ScrollingNodeID);
+    ScrollingTreeFrameScrollingNodeIOS(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
 
     // ScrollingTreeNode member functions.
     void commitStateBeforeChildren(const ScrollingStateNode&) override;
index 7603260..1095f0b 100644 (file)
 
 namespace WebCore {
 
-Ref<ScrollingTreeFrameScrollingNodeIOS> ScrollingTreeFrameScrollingNodeIOS::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
+Ref<ScrollingTreeFrameScrollingNodeIOS> ScrollingTreeFrameScrollingNodeIOS::create(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
 {
-    return adoptRef(*new ScrollingTreeFrameScrollingNodeIOS(scrollingTree, nodeID));
+    return adoptRef(*new ScrollingTreeFrameScrollingNodeIOS(scrollingTree, nodeType, nodeID));
 }
 
-ScrollingTreeFrameScrollingNodeIOS::ScrollingTreeFrameScrollingNodeIOS(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
-    : ScrollingTreeFrameScrollingNode(scrollingTree, nodeID)
+ScrollingTreeFrameScrollingNodeIOS::ScrollingTreeFrameScrollingNodeIOS(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
+    : ScrollingTreeFrameScrollingNode(scrollingTree, nodeType, nodeID)
 {
 }
 
index 5375ce1..f7af41b 100644 (file)
@@ -86,8 +86,9 @@ void ScrollingTreeIOS::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const
 Ref<ScrollingTreeNode> ScrollingTreeIOS::createScrollingTreeNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
 {
     switch (nodeType) {
-    case FrameScrollingNode:
-        return ScrollingTreeFrameScrollingNodeIOS::create(*this, nodeID);
+    case MainFrameScrollingNode:
+    case SubframeScrollingNode:
+        return ScrollingTreeFrameScrollingNodeIOS::create(*this, nodeType, nodeID);
     case OverflowScrollingNode:
         ASSERT_NOT_REACHED();
         break;
index d67c618..a894233 100644 (file)
@@ -38,11 +38,11 @@ namespace WebCore {
 
 class ScrollingTreeFrameScrollingNodeMac : public ScrollingTreeFrameScrollingNode, private ScrollControllerClient {
 public:
-    WEBCORE_EXPORT static Ref<ScrollingTreeFrameScrollingNode> create(ScrollingTree&, ScrollingNodeID);
+    WEBCORE_EXPORT static Ref<ScrollingTreeFrameScrollingNode> create(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
     virtual ~ScrollingTreeFrameScrollingNodeMac();
 
 private:
-    ScrollingTreeFrameScrollingNodeMac(ScrollingTree&, ScrollingNodeID);
+    ScrollingTreeFrameScrollingNodeMac(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
 
     void releaseReferencesToScrollerImpsOnTheMainThread();
 
index 8c0b154..0a1c72c 100644 (file)
 
 namespace WebCore {
 
-Ref<ScrollingTreeFrameScrollingNode> ScrollingTreeFrameScrollingNodeMac::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
+Ref<ScrollingTreeFrameScrollingNode> ScrollingTreeFrameScrollingNodeMac::create(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
 {
-    return adoptRef(*new ScrollingTreeFrameScrollingNodeMac(scrollingTree, nodeID));
+    return adoptRef(*new ScrollingTreeFrameScrollingNodeMac(scrollingTree, nodeType, nodeID));
 }
 
-ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
-    : ScrollingTreeFrameScrollingNode(scrollingTree, nodeID)
+ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
+    : ScrollingTreeFrameScrollingNode(scrollingTree, nodeType, nodeID)
     , m_scrollController(*this)
     , m_verticalScrollerImp(nullptr)
     , m_horizontalScrollerImp(nullptr)
index 899f1e9..649be4f 100644 (file)
@@ -47,8 +47,9 @@ ScrollingTreeMac::ScrollingTreeMac(AsyncScrollingCoordinator& scrollingCoordinat
 Ref<ScrollingTreeNode> ScrollingTreeMac::createScrollingTreeNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
 {
     switch (nodeType) {
-    case FrameScrollingNode:
-        return ScrollingTreeFrameScrollingNodeMac::create(*this, nodeID);
+    case MainFrameScrollingNode:
+    case SubframeScrollingNode:
+        return ScrollingTreeFrameScrollingNodeMac::create(*this, nodeType, nodeID);
     case OverflowScrollingNode:
         ASSERT_NOT_REACHED();
         break;
index 940f290..c10dc85 100644 (file)
@@ -3675,14 +3675,15 @@ void RenderLayerCompositor::reattachSubframeScrollLayers()
         if (!parentNodeID)
             continue;
 
-        scrollingCoordinator->attachToStateTree(FrameScrollingNode, frameScrollingNodeID, parentNodeID);
+        scrollingCoordinator->attachToStateTree(child->isMainFrame() ? MainFrameScrollingNode : SubframeScrollingNode, frameScrollingNodeID, parentNodeID);
     }
 }
 
 static inline LayerScrollCoordinationRole scrollCoordinationRoleForNodeType(ScrollingNodeType nodeType)
 {
     switch (nodeType) {
-    case FrameScrollingNode:
+    case MainFrameScrollingNode:
+    case SubframeScrollingNode:
     case OverflowScrollingNode:
         return Scrolling;
     case FixedNode:
@@ -3741,7 +3742,7 @@ void RenderLayerCompositor::updateScrollCoordinationForThisFrame(ScrollingNodeID
     auto* scrollingCoordinator = this->scrollingCoordinator();
     ASSERT(scrollingCoordinator->coordinatesScrollingForFrameView(m_renderView.frameView()));
 
-    ScrollingNodeID nodeID = attachScrollingNode(*m_renderView.layer(), FrameScrollingNode, parentNodeID);
+    ScrollingNodeID nodeID = attachScrollingNode(*m_renderView.layer(), m_renderView.frame().isMainFrame() ? MainFrameScrollingNode : SubframeScrollingNode, parentNodeID);
     scrollingCoordinator->updateFrameScrollingNode(nodeID, m_scrollLayer.get(), m_rootContentLayer.get(), fixedRootBackgroundLayer(), clipLayer());
 }
 
@@ -3775,7 +3776,7 @@ void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, Lay
     // Always call this even if the backing is already attached because the parent may have changed.
     // If a node plays both roles, fixed/sticky is always the ancestor node of scrolling.
     if (reasons & ViewportConstrained) {
-        ScrollingNodeType nodeType = FrameScrollingNode;
+        ScrollingNodeType nodeType = MainFrameScrollingNode;
         if (layer.renderer().isFixedPositioned())
             nodeType = FixedNode;
         else if (layer.renderer().style().position() == StickyPosition)
@@ -3800,7 +3801,8 @@ void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, Lay
             case StickyNode:
                 scrollingCoordinator->updateNodeViewportConstraints(nodeID, computeStickyViewportConstraints(layer));
                 break;
-            case FrameScrollingNode:
+            case MainFrameScrollingNode:
+            case SubframeScrollingNode:
             case OverflowScrollingNode:
                 break;
             }
index b9387cf..595376e 100644 (file)
@@ -1,3 +1,28 @@
+2018-02-08  Frederic Wang  <fwang@igalia.com>
+
+        Add scrolling node types to distinguish main frames and subframes.
+        https://bugs.webkit.org/show_bug.cgi?id=182533
+
+        Reviewed by Simon Fraser.
+
+        * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp: Replace the case of
+        FrameScrollingNode with MainFrameScrollingNode and SubframeScrollingNode.
+        (WebKit::encodeNodeAndDescendants):
+        (WebKit::RemoteScrollingCoordinatorTransaction::decode):
+        (WebKit::dump):
+        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp: Ditto.
+        (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
+        * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp: Ditto and pass the node type to the
+        constructor of the frame scrolling node.
+        (WebKit::RemoteScrollingTree::createScrollingTreeNode):
+        * UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm: Replace the case of
+        FrameScrollingNode with MainFrameScrollingNode and SubframeScrollingNode.
+        (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm: In order to
+        determine whether the node is a main frame or subframe, use the node type instead of checking
+        whether the node as a parent.
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll):
+
 2018-02-05  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         WebDriver: addCookie command should prepend a dot to domain if missing
index 2ce1f89..8d2d18c 100644 (file)
@@ -334,7 +334,8 @@ static void encodeNodeAndDescendants(IPC::Encoder& encoder, const ScrollingState
     ++encodedNodeCount;
 
     switch (stateNode.nodeType()) {
-    case FrameScrollingNode:
+    case MainFrameScrollingNode:
+    case SubframeScrollingNode:
         encoder << downcast<ScrollingStateFrameScrollingNode>(stateNode);
         break;
     case OverflowScrollingNode:
@@ -418,7 +419,8 @@ bool RemoteScrollingCoordinatorTransaction::decode(IPC::Decoder& decoder)
         ASSERT(!parentNodeID || newNode->parent());
         
         switch (nodeType) {
-        case FrameScrollingNode:
+        case MainFrameScrollingNode:
+        case SubframeScrollingNode:
             if (!decoder.decode(downcast<ScrollingStateFrameScrollingNode>(*newNode)))
                 return false;
             break;
@@ -561,7 +563,8 @@ static void dump(TextStream& ts, const ScrollingStateNode& node, bool changedPro
         ts.dumpProperty("layer", static_cast<GraphicsLayer::PlatformLayerID>(node.layer()));
     
     switch (node.nodeType()) {
-    case FrameScrollingNode:
+    case MainFrameScrollingNode:
+    case SubframeScrollingNode:
         dump(ts, downcast<ScrollingStateFrameScrollingNode>(node), changedPropertiesOnly);
         break;
     case OverflowScrollingNode:
index e5d1eb7..96c58ed 100644 (file)
@@ -103,7 +103,8 @@ void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree&
             currNode->setLayer(layerTreeHost.getLayer(currNode->layer()));
 
         switch (currNode->nodeType()) {
-        case FrameScrollingNode: {
+        case MainFrameScrollingNode:
+        case SubframeScrollingNode: {
             ScrollingStateFrameScrollingNode& scrollingStateNode = downcast<ScrollingStateFrameScrollingNode>(*currNode);
             
             if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer))
index 25ebb4b..b9d55f8 100644 (file)
@@ -113,11 +113,12 @@ void RemoteScrollingTree::scrollingTreeNodeRequestsScroll(ScrollingNodeID nodeID
 Ref<ScrollingTreeNode> RemoteScrollingTree::createScrollingTreeNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
 {
     switch (nodeType) {
-    case FrameScrollingNode:
+    case MainFrameScrollingNode:
+    case SubframeScrollingNode:
 #if PLATFORM(IOS)
-        return ScrollingTreeFrameScrollingNodeIOS::create(*this, nodeID);
+        return ScrollingTreeFrameScrollingNodeIOS::create(*this, nodeType, nodeID);
 #else
-        return ScrollingTreeFrameScrollingNodeMac::create(*this, nodeID);
+        return ScrollingTreeFrameScrollingNodeMac::create(*this, nodeType, nodeID);
 #endif
     case OverflowScrollingNode:
 #if PLATFORM(IOS)
index 28d3959..e2b8141 100644 (file)
@@ -67,7 +67,8 @@ void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree&
                 scrollingStateNode.setScrolledContentsLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode.scrolledContentsLayer())));
             break;
         };
-        case FrameScrollingNode: {
+        case MainFrameScrollingNode:
+        case SubframeScrollingNode: {
             ScrollingStateFrameScrollingNode& scrollingStateNode = downcast<ScrollingStateFrameScrollingNode>(*currNode);
             
             if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::ScrollLayer))
index 1353960..4a2e29b 100644 (file)
@@ -247,7 +247,7 @@ void ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll(const Fl
 
     FloatRect fixedPositionRect;
     auto* frameNode = scrollingNode().enclosingFrameNodeIncludingSelf();
-    if (frameNode && frameNode->parent())
+    if (frameNode && frameNode->nodeType() == SubframeScrollingNode)
         fixedPositionRect = frameNode->fixedPositionRect();
     else
         fixedPositionRect = scrollingTree().fixedPositionRect();