Introduce ScrollingTreeScrollingNodeDelegateIOS to share code between overflow and...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Sep 2017 12:42:46 +0000 (12:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Sep 2017 12:42:46 +0000 (12:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174097

Patch by Frédéric Wang <fwang@igalia.com> on 2017-09-06
Reviewed by Darin Adler.

Source/WebCore:

No new tests, behavior unchanged.

* WebCore.xcodeproj/project.pbxproj: Add ScrollingTreeScrollingNodeDelegate.
* page/scrolling/ScrollingTreeScrollingNode.h: Make ScrollingTreeScrollingNodeDelegate a
friend so that it can access private members.
* page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp: Added. New delegate class for a
scrolling node, which is used by the UI process.
(WebCore::ScrollingTreeScrollingNodeDelegate::ScrollingTreeScrollingNodeDelegate):
Constructor, taking the scrolling node as a parameter.
(WebCore::ScrollingTreeScrollingNodeDelegate::~ScrollingTreeScrollingNodeDelegate):
(WebCore::ScrollingTreeScrollingNodeDelegate::scrollingTree const): Expose the scrolling
tree containing the scrolling node.
(WebCore::ScrollingTreeScrollingNodeDelegate::lastCommittedScrollPosition const): Expose
the last committed scroll position of the scrolling node.
* page/scrolling/ScrollingTreeScrollingNodeDelegate.h: Added.
(WebCore::ScrollingTreeScrollingNodeDelegate::scrollingNode): Expose the scrolling node.
(WebCore::ScrollingTreeScrollingNodeDelegate::scrollingNode const): Ditto.

Source/WebKit:

This patch introduces a new ScrollingTreeScrollingNodeDelegateIOS that can be used by
WKOverflowScrollViewDelegate to communicate to the scrolling tree and nodes. It can also be
used as a helper class by ScrollingTreeOverflowScrollingNodeIOS. For now, only the non-
overriden member functions of ScrollingTreeOverflowScrollingNodeIOS are moved to that new
class. In follow-up commits, WKOverflowScrollViewDelegate can become a generic
ScrollViewDelegate and more code can be moved into the ScrollingTreeScrollingNodeDelegateIOS
file. Frame scrolling nodes will then be able to share the same UI code as overflow:auto when
iOS frame scrolling is implemented (bug 149264).

* UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.h: Move non-overriden member
functions and m_updatingFromStateNode into the delegate class. Also define a member to store
that delegate.
* UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm: Use the node delegate to
communicate to the scrolling tree and node.
(-[WKOverflowScrollViewDelegate initWithScrollingTreeNodeDelegate:]): Init with a delegate.
(-[WKOverflowScrollViewDelegate scrollViewDidScroll:]): Call the delegate function.
(-[WKOverflowScrollViewDelegate scrollViewWillBeginDragging:]): Ditto.
(-[WKOverflowScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
Use the delegate functions or pass by ScrollingTreeScrollingNodeDelegateIOS::scrollingNode().
(-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]): Use the delegate
functions.
(-[WKOverflowScrollViewDelegate scrollViewDidEndDecelerating:]): Ditto.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::ScrollingTreeOverflowScrollingNodeIOS):
Init the delegate for this class.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::commitStateAfterChildren): Use the delegate.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::setScrollLayerPosition): Use the delegate
function.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterDelegatedScroll): Ditto.
(-[WKOverflowScrollViewDelegate initWithScrollingTreeNode:]): Deleted. This is renamed
initWithScrollingTreeNodeDelegate and accepts a delegate.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateChildNodesAfterScroll): Deleted. Moved
to ScrollingTreeScrollingNodeDelegateIOS.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollWillStart): Ditto.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollDidEnd): Ditto.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewWillStartPanGesture): Ditto.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::scrollViewDidScroll): Ditto.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::currentSnapPointIndicesDidChange): Ditto.
* UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h: Added. New delegate class
for ScrollingTreeOverflowScrollingNodeIOS. The members used by WKOverflowScrollViewDelegate
are public and the others are private. ScrollingTreeOverflowScrollingNodeIOS is a friend of
ScrollingTreeScrollingNodeDelegateIOS so that it can access private members e.g.
updateChildNodesAfterScroll() or  m_updatingFromStateNode.
* UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm: Added.
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::ScrollingTreeScrollingNodeDelegateIOS):
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::~ScrollingTreeScrollingNodeDelegateIOS):
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll): Code extracted
from ScrollingTreeOverflowScrollingNodeIOS.
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollWillStart): Ditto.
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollDidEnd): Ditto.
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollViewWillStartPanGesture): Ditto.
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidScroll): Ditto.
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::currentSnapPointIndicesDidChange): Ditto.
* WebKit.xcodeproj/project.pbxproj: Add ScrollingTreeScrollingNodeDelegateIOS files to the
build system.

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp [new file with mode: 0644]
Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.h
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h [new file with mode: 0644]
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm [new file with mode: 0644]
Source/WebKit/WebKit.xcodeproj/project.pbxproj

index b022ed9..cea6536 100644 (file)
@@ -1,3 +1,28 @@
+2017-09-06  Frédéric Wang  <fwang@igalia.com>
+
+        Introduce ScrollingTreeScrollingNodeDelegateIOS to share code between overflow and frame scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=174097
+
+        Reviewed by Darin Adler.
+
+        No new tests, behavior unchanged.
+
+        * WebCore.xcodeproj/project.pbxproj: Add ScrollingTreeScrollingNodeDelegate.
+        * page/scrolling/ScrollingTreeScrollingNode.h: Make ScrollingTreeScrollingNodeDelegate a
+        friend so that it can access private members.
+        * page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp: Added. New delegate class for a
+        scrolling node, which is used by the UI process.
+        (WebCore::ScrollingTreeScrollingNodeDelegate::ScrollingTreeScrollingNodeDelegate):
+        Constructor, taking the scrolling node as a parameter.
+        (WebCore::ScrollingTreeScrollingNodeDelegate::~ScrollingTreeScrollingNodeDelegate):
+        (WebCore::ScrollingTreeScrollingNodeDelegate::scrollingTree const): Expose the scrolling
+        tree containing the scrolling node.
+        (WebCore::ScrollingTreeScrollingNodeDelegate::lastCommittedScrollPosition const): Expose
+        the last committed scroll position of the scrolling node.
+        * page/scrolling/ScrollingTreeScrollingNodeDelegate.h: Added.
+        (WebCore::ScrollingTreeScrollingNodeDelegate::scrollingNode): Expose the scrolling node.
+        (WebCore::ScrollingTreeScrollingNodeDelegate::scrollingNode const): Ditto.
+
 2017-09-06  Manuel Rego Casasnovas  <rego@igalia.com>
 
         [css-grid] grid shorthand should not reset the gutter properties
index 80abc9a..982f2b2 100644 (file)
                9391A991162746CB00297330 /* ScrollingCoordinatorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 9391A990162746CB00297330 /* ScrollingCoordinatorMac.h */; };
                9391A99C1629D70000297330 /* ScrollingTreeScrollingNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9391A99A1629D6FF00297330 /* ScrollingTreeScrollingNode.cpp */; };
                9391A99D1629D70000297330 /* ScrollingTreeScrollingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 9391A99B1629D70000297330 /* ScrollingTreeScrollingNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A6D5A99C1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A6D5A99A1629D6FF00297330 /* ScrollingTreeScrollingNodeDelegate.cpp */; };
+               A6D5A99D1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A6D5A99B1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9392146918A6D791000EE688 /* TextIteratorBehavior.h in Headers */ = {isa = PBXBuildFile; fileRef = 9392146818A6D791000EE688 /* TextIteratorBehavior.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9392262F10321084006E7D5D /* JSCSSRuleListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9392262E10321084006E7D5D /* JSCSSRuleListCustom.cpp */; };
                9392F1420AD185F400691BD4 /* RenderCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9392F1410AD185F400691BD4 /* RenderCounter.h */; };
                9391A990162746CB00297330 /* ScrollingCoordinatorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingCoordinatorMac.h; sourceTree = "<group>"; };
                9391A99A1629D6FF00297330 /* ScrollingTreeScrollingNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeScrollingNode.cpp; sourceTree = "<group>"; };
                9391A99B1629D70000297330 /* ScrollingTreeScrollingNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeScrollingNode.h; sourceTree = "<group>"; };
+               A6D5A99A1629D6FF00297330 /* ScrollingTreeScrollingNodeDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeScrollingNodeDelegate.cpp; sourceTree = "<group>"; };
+               A6D5A99B1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeScrollingNodeDelegate.h; sourceTree = "<group>"; };
                9392146818A6D791000EE688 /* TextIteratorBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextIteratorBehavior.h; sourceTree = "<group>"; };
                9392262E10321084006E7D5D /* JSCSSRuleListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSRuleListCustom.cpp; sourceTree = "<group>"; };
                9392F1410AD185F400691BD4 /* RenderCounter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderCounter.h; sourceTree = "<group>"; };
                                0FC4E40C187F82E10045882C /* ScrollingTreeFrameScrollingNodeIOS.mm */,
                                0FC4E409187F82E10045882C /* ScrollingTreeIOS.cpp */,
                                0FC4E40A187F82E10045882C /* ScrollingTreeIOS.h */,
+                               1B94E409187F82E10045882C /* ScrollingTreeScrollingNodeDelegate.cpp */,
+                               1B94E40A187F82E10045882C /* ScrollingTreeScrollingNodeDelegate.h */,
                        );
                        path = ios;
                        sourceTree = "<group>";
                                0FEA3E7E191B3169000F1B55 /* ScrollingTreeOverflowScrollingNode.h */,
                                9391A99A1629D6FF00297330 /* ScrollingTreeScrollingNode.cpp */,
                                9391A99B1629D70000297330 /* ScrollingTreeScrollingNode.h */,
+                               A6D5A99A1629D6FF00297330 /* ScrollingTreeScrollingNodeDelegate.cpp */,
+                               A6D5A99B1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h */,
                                7AAFE8CD19CB8672000F56D8 /* ScrollLatchingState.cpp */,
                                7AAFE8CE19CB8672000F56D8 /* ScrollLatchingState.h */,
                                F46729251E0DE5AB00ACC3D8 /* ScrollSnapOffsetsInfo.h */,
                                1AAADDE414DC8C8F00AF64B3 /* ScrollingTreeNode.h in Headers */,
                                0FEA3E80191B3169000F1B55 /* ScrollingTreeOverflowScrollingNode.h in Headers */,
                                9391A99D1629D70000297330 /* ScrollingTreeScrollingNode.h in Headers */,
+                               A6D5A99D1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h in Headers */,
                                0FB8890A167D2FA10010CDA5 /* ScrollingTreeStickyNode.h in Headers */,
                                7AAFE8D019CB8672000F56D8 /* ScrollLatchingState.h in Headers */,
                                F478755419983AFF0024A287 /* ScrollSnapAnimatorState.h in Headers */,
                                1AAADDE314DC8C8F00AF64B3 /* ScrollingTreeNode.cpp in Sources */,
                                0FEA3E7F191B3169000F1B55 /* ScrollingTreeOverflowScrollingNode.cpp in Sources */,
                                9391A99C1629D70000297330 /* ScrollingTreeScrollingNode.cpp in Sources */,
+                               A6D5A99C1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.cpp in Sources */,
                                0FB8890B167D2FA10010CDA5 /* ScrollingTreeStickyNode.mm in Sources */,
                                7AAFE8CF19CB8672000F56D8 /* ScrollLatchingState.cpp in Sources */,
                                F478755519983AFF0024A287 /* ScrollSnapAnimatorState.mm in Sources */,
index 5a3de87..da03432 100644 (file)
 #include "ScrollingCoordinator.h"
 #include "ScrollingTreeNode.h"
 
+#if PLATFORM(IOS)
+class ScrollingTreeScrollingNodeDelegate;
+#endif
+
 namespace WebCore {
 
 class ScrollingTree;
 class ScrollingStateScrollingNode;
 
 class ScrollingTreeScrollingNode : public ScrollingTreeNode {
+#if PLATFORM(IOS)
+    friend class ScrollingTreeScrollingNodeDelegate;
+#endif
+
 public:
     virtual ~ScrollingTreeScrollingNode();
 
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp
new file mode 100644 (file)
index 0000000..9daac77
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "ScrollingTreeScrollingNodeDelegate.h"
+
+#if PLATFORM(IOS) && ENABLE(ASYNC_SCROLLING)
+
+#import "ScrollingTreeScrollingNode.h"
+
+namespace WebCore {
+
+ScrollingTreeScrollingNodeDelegate::ScrollingTreeScrollingNodeDelegate(ScrollingTreeScrollingNode& scrollingNode)
+    : m_scrollingNode(scrollingNode)
+{
+}
+
+ScrollingTreeScrollingNodeDelegate::~ScrollingTreeScrollingNodeDelegate()
+{
+}
+
+ScrollingTree& ScrollingTreeScrollingNodeDelegate::scrollingTree() const
+{
+    return m_scrollingNode.scrollingTree();
+}
+
+FloatPoint ScrollingTreeScrollingNodeDelegate::lastCommittedScrollPosition() const
+{
+    return m_scrollingNode.lastCommittedScrollPosition();
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS) && ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h
new file mode 100644 (file)
index 0000000..e88d7c7
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2017 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(IOS) && ENABLE(ASYNC_SCROLLING)
+
+namespace WebCore {
+
+class FloatPoint;
+class ScrollingTreeScrollingNode;
+class ScrollingTree;
+
+class ScrollingTreeScrollingNodeDelegate {
+public:
+    WEBCORE_EXPORT explicit ScrollingTreeScrollingNodeDelegate(ScrollingTreeScrollingNode&);
+    WEBCORE_EXPORT virtual ~ScrollingTreeScrollingNodeDelegate();
+    ScrollingTreeScrollingNode& scrollingNode() { return m_scrollingNode; }
+    const ScrollingTreeScrollingNode& scrollingNode() const { return m_scrollingNode; }
+
+protected:
+    WEBCORE_EXPORT ScrollingTree& scrollingTree() const;
+    WEBCORE_EXPORT FloatPoint lastCommittedScrollPosition() const;
+
+private:
+    ScrollingTreeScrollingNode& m_scrollingNode;
+};
+
+} // namespace WebCore
+
+#endif // PLATFORM(IOS) && ENABLE(ASYNC_SCROLLING)
index a29e359..8e7b9cb 100644 (file)
@@ -1,3 +1,65 @@
+2017-09-06  Frédéric Wang  <fwang@igalia.com>
+
+        Introduce ScrollingTreeScrollingNodeDelegateIOS to share code between overflow and frame scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=174097
+
+        Reviewed by Darin Adler.
+
+        This patch introduces a new ScrollingTreeScrollingNodeDelegateIOS that can be used by
+        WKOverflowScrollViewDelegate to communicate to the scrolling tree and nodes. It can also be
+        used as a helper class by ScrollingTreeOverflowScrollingNodeIOS. For now, only the non-
+        overriden member functions of ScrollingTreeOverflowScrollingNodeIOS are moved to that new
+        class. In follow-up commits, WKOverflowScrollViewDelegate can become a generic
+        ScrollViewDelegate and more code can be moved into the ScrollingTreeScrollingNodeDelegateIOS
+        file. Frame scrolling nodes will then be able to share the same UI code as overflow:auto when
+        iOS frame scrolling is implemented (bug 149264).
+
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.h: Move non-overriden member
+        functions and m_updatingFromStateNode into the delegate class. Also define a member to store
+        that delegate.
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm: Use the node delegate to
+        communicate to the scrolling tree and node.
+        (-[WKOverflowScrollViewDelegate initWithScrollingTreeNodeDelegate:]): Init with a delegate.
+        (-[WKOverflowScrollViewDelegate scrollViewDidScroll:]): Call the delegate function.
+        (-[WKOverflowScrollViewDelegate scrollViewWillBeginDragging:]): Ditto.
+        (-[WKOverflowScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
+        Use the delegate functions or pass by ScrollingTreeScrollingNodeDelegateIOS::scrollingNode().
+        (-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]): Use the delegate
+        functions.
+        (-[WKOverflowScrollViewDelegate scrollViewDidEndDecelerating:]): Ditto.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::ScrollingTreeOverflowScrollingNodeIOS):
+        Init the delegate for this class.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::commitStateAfterChildren): Use the delegate.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::setScrollLayerPosition): Use the delegate
+        function.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterDelegatedScroll): Ditto.
+        (-[WKOverflowScrollViewDelegate initWithScrollingTreeNode:]): Deleted. This is renamed
+        initWithScrollingTreeNodeDelegate and accepts a delegate.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateChildNodesAfterScroll): Deleted. Moved
+        to ScrollingTreeScrollingNodeDelegateIOS.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollWillStart): Ditto.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollDidEnd): Ditto.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewWillStartPanGesture): Ditto.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::scrollViewDidScroll): Ditto.
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::currentSnapPointIndicesDidChange): Ditto.
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h: Added. New delegate class
+        for ScrollingTreeOverflowScrollingNodeIOS. The members used by WKOverflowScrollViewDelegate
+        are public and the others are private. ScrollingTreeOverflowScrollingNodeIOS is a friend of
+        ScrollingTreeScrollingNodeDelegateIOS so that it can access private members e.g.
+        updateChildNodesAfterScroll() or  m_updatingFromStateNode.
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm: Added.
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::ScrollingTreeScrollingNodeDelegateIOS):
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::~ScrollingTreeScrollingNodeDelegateIOS):
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll): Code extracted
+        from ScrollingTreeOverflowScrollingNodeIOS.
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollWillStart): Ditto.
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollDidEnd): Ditto.
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollViewWillStartPanGesture): Ditto.
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidScroll): Ditto.
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::currentSnapPointIndicesDidChange): Ditto.
+        * WebKit.xcodeproj/project.pbxproj: Add ScrollingTreeScrollingNodeDelegateIOS files to the
+        build system.
+
 2017-09-05  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS WK2] Add plumbing for WKContentView to ask the web process for additional drag items
index 81b1c7c..f4dfe44 100644 (file)
@@ -35,17 +35,13 @@ OBJC_CLASS WKOverflowScrollViewDelegate;
 
 namespace WebKit {
 
+class ScrollingTreeScrollingNodeDelegateIOS;
+
 class ScrollingTreeOverflowScrollingNodeIOS : public WebCore::ScrollingTreeOverflowScrollingNode {
 public:
     static Ref<ScrollingTreeOverflowScrollingNodeIOS> create(WebCore::ScrollingTree&, WebCore::ScrollingNodeID);
     virtual ~ScrollingTreeOverflowScrollingNodeIOS();
 
-    void overflowScrollWillStart();
-    void overflowScrollDidEnd();
-    void overflowScrollViewWillStartPanGesture();
-    void scrollViewDidScroll(const WebCore::FloatPoint&, bool inUserInteraction);
-    void currentSnapPointIndicesDidChange(unsigned horizontal, unsigned vertical);
-
     CALayer *scrollLayer() const { return m_scrollLayer.get(); }
 
 private:
@@ -65,13 +61,11 @@ private:
 
     void handleWheelEvent(const WebCore::PlatformWheelEvent&) override { }
 
-    void updateChildNodesAfterScroll(const WebCore::FloatPoint&);
-    
     RetainPtr<CALayer> m_scrollLayer;
     RetainPtr<CALayer> m_scrolledContentsLayer;
 
     RetainPtr<WKOverflowScrollViewDelegate> m_scrollViewDelegate;
-    bool m_updatingFromStateNode;
+    std::unique_ptr<ScrollingTreeScrollingNodeDelegateIOS> m_scrollingNodeDelegate;
 };
 
 } // namespace WebKit
index ac1cce4..1e9aaee 100644 (file)
@@ -34,7 +34,6 @@
 #import <UIKit/UIScrollView.h>
 #import <WebCore/ScrollingStateOverflowScrollingNode.h>
 #import <WebCore/ScrollingTree.h>
-#import <WebCore/ScrollingTreeFrameScrollingNode.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/SetForScope.h>
 
 #import <WebCore/ScrollSnapOffsetsInfo.h>
 #endif
 
+#import "ScrollingTreeScrollingNodeDelegateIOS.h"
+
 using namespace WebCore;
 
 @interface WKOverflowScrollViewDelegate : NSObject <UIScrollViewDelegate> {
-    WebKit::ScrollingTreeOverflowScrollingNodeIOS* _scrollingTreeNode;
+    WebKit::ScrollingTreeScrollingNodeDelegateIOS* _scrollingTreeNodeDelegate;
 }
 
 @property (nonatomic, getter=_isInUserInteraction) BOOL inUserInteraction;
 
-- (instancetype)initWithScrollingTreeNode:(WebKit::ScrollingTreeOverflowScrollingNodeIOS*)node;
+- (instancetype)initWithScrollingTreeNodeDelegate:(WebKit::ScrollingTreeScrollingNodeDelegateIOS*)delegate;
 
 @end
 
 @implementation WKOverflowScrollViewDelegate
 
-- (instancetype)initWithScrollingTreeNode:(WebKit::ScrollingTreeOverflowScrollingNodeIOS*)node
+- (instancetype)initWithScrollingTreeNodeDelegate:(WebKit::ScrollingTreeScrollingNodeDelegateIOS*)delegate
 {
     if ((self = [super init]))
-        _scrollingTreeNode = node;
+        _scrollingTreeNodeDelegate = delegate;
 
     return self;
 }
 
 - (void)scrollViewDidScroll:(UIScrollView *)scrollView
 {
-    _scrollingTreeNode->scrollViewDidScroll(scrollView.contentOffset, _inUserInteraction);
+    _scrollingTreeNodeDelegate->scrollViewDidScroll(scrollView.contentOffset, _inUserInteraction);
 }
 
 - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
@@ -75,8 +76,8 @@ using namespace WebCore;
     _inUserInteraction = YES;
 
     if (scrollView.panGestureRecognizer.state == UIGestureRecognizerStateBegan)
-        _scrollingTreeNode->overflowScrollViewWillStartPanGesture();
-    _scrollingTreeNode->overflowScrollWillStart();
+        _scrollingTreeNodeDelegate->scrollViewWillStartPanGesture();
+    _scrollingTreeNodeDelegate->scrollWillStart();
 }
 
 #if ENABLE(CSS_SCROLL_SNAP)
@@ -85,28 +86,28 @@ using namespace WebCore;
     CGFloat horizontalTarget = targetContentOffset->x;
     CGFloat verticalTarget = targetContentOffset->y;
 
-    unsigned originalHorizontalSnapPosition = _scrollingTreeNode->currentHorizontalSnapPointIndex();
-    unsigned originalVerticalSnapPosition = _scrollingTreeNode->currentVerticalSnapPointIndex();
+    unsigned originalHorizontalSnapPosition = _scrollingTreeNodeDelegate->scrollingNode().currentHorizontalSnapPointIndex();
+    unsigned originalVerticalSnapPosition = _scrollingTreeNodeDelegate->scrollingNode().currentVerticalSnapPointIndex();
 
-    if (!_scrollingTreeNode->horizontalSnapOffsets().isEmpty()) {
+    if (!_scrollingTreeNodeDelegate->scrollingNode().horizontalSnapOffsets().isEmpty()) {
         unsigned index;
-        float potentialSnapPosition = closestSnapOffset(_scrollingTreeNode->horizontalSnapOffsets(), _scrollingTreeNode->horizontalSnapOffsetRanges(), horizontalTarget, velocity.x, index);
-        _scrollingTreeNode->setCurrentHorizontalSnapPointIndex(index);
+        float potentialSnapPosition = closestSnapOffset(_scrollingTreeNodeDelegate->scrollingNode().horizontalSnapOffsets(), _scrollingTreeNodeDelegate->scrollingNode().horizontalSnapOffsetRanges(), horizontalTarget, velocity.x, index);
+        _scrollingTreeNodeDelegate->scrollingNode().setCurrentHorizontalSnapPointIndex(index);
         if (horizontalTarget >= 0 && horizontalTarget <= scrollView.contentSize.width)
             targetContentOffset->x = potentialSnapPosition;
     }
 
-    if (!_scrollingTreeNode->verticalSnapOffsets().isEmpty()) {
+    if (!_scrollingTreeNodeDelegate->scrollingNode().verticalSnapOffsets().isEmpty()) {
         unsigned index;
-        float potentialSnapPosition = closestSnapOffset(_scrollingTreeNode->verticalSnapOffsets(), _scrollingTreeNode->verticalSnapOffsetRanges(), verticalTarget, velocity.y, index);
-        _scrollingTreeNode->setCurrentVerticalSnapPointIndex(index);
+        float potentialSnapPosition = closestSnapOffset(_scrollingTreeNodeDelegate->scrollingNode().verticalSnapOffsets(), _scrollingTreeNodeDelegate->scrollingNode().verticalSnapOffsetRanges(), verticalTarget, velocity.y, index);
+        _scrollingTreeNodeDelegate->scrollingNode().setCurrentVerticalSnapPointIndex(index);
         if (verticalTarget >= 0 && verticalTarget <= scrollView.contentSize.height)
             targetContentOffset->y = potentialSnapPosition;
     }
 
-    if (originalHorizontalSnapPosition != _scrollingTreeNode->currentHorizontalSnapPointIndex()
-        || originalVerticalSnapPosition != _scrollingTreeNode->currentVerticalSnapPointIndex()) {
-        _scrollingTreeNode->currentSnapPointIndicesDidChange(_scrollingTreeNode->currentHorizontalSnapPointIndex(), _scrollingTreeNode->currentVerticalSnapPointIndex());
+    if (originalHorizontalSnapPosition != _scrollingTreeNodeDelegate->scrollingNode().currentHorizontalSnapPointIndex()
+        || originalVerticalSnapPosition != _scrollingTreeNodeDelegate->scrollingNode().currentVerticalSnapPointIndex()) {
+        _scrollingTreeNodeDelegate->currentSnapPointIndicesDidChange(_scrollingTreeNodeDelegate->scrollingNode().currentHorizontalSnapPointIndex(), _scrollingTreeNodeDelegate->scrollingNode().currentVerticalSnapPointIndex());
     }
 }
 #endif
@@ -115,8 +116,8 @@ using namespace WebCore;
 {
     if (_inUserInteraction && !willDecelerate) {
         _inUserInteraction = NO;
-        _scrollingTreeNode->scrollViewDidScroll(scrollView.contentOffset, _inUserInteraction);
-        _scrollingTreeNode->overflowScrollDidEnd();
+        _scrollingTreeNodeDelegate->scrollViewDidScroll(scrollView.contentOffset, _inUserInteraction);
+        _scrollingTreeNodeDelegate->scrollDidEnd();
     }
 }
 
@@ -124,8 +125,8 @@ using namespace WebCore;
 {
     if (_inUserInteraction) {
         _inUserInteraction = NO;
-        _scrollingTreeNode->scrollViewDidScroll(scrollView.contentOffset, _inUserInteraction);
-        _scrollingTreeNode->overflowScrollDidEnd();
+        _scrollingTreeNodeDelegate->scrollViewDidScroll(scrollView.contentOffset, _inUserInteraction);
+        _scrollingTreeNodeDelegate->scrollDidEnd();
     }
 }
 
@@ -140,7 +141,7 @@ Ref<ScrollingTreeOverflowScrollingNodeIOS> ScrollingTreeOverflowScrollingNodeIOS
 
 ScrollingTreeOverflowScrollingNodeIOS::ScrollingTreeOverflowScrollingNodeIOS(WebCore::ScrollingTree& scrollingTree, WebCore::ScrollingNodeID nodeID)
     : ScrollingTreeOverflowScrollingNode(scrollingTree, nodeID)
-    , m_updatingFromStateNode(false)
+    , m_scrollingNodeDelegate(std::make_unique<ScrollingTreeScrollingNodeDelegateIOS>(*this))
 {
 }
 
@@ -154,6 +155,10 @@ ScrollingTreeOverflowScrollingNodeIOS::~ScrollingTreeOverflowScrollingNodeIOS()
             scrollView.delegate = nil;
     }
     END_BLOCK_OBJC_EXCEPTIONS
+
+    // WKOverflowScrollViewDelegate holds a pointer to ScrollingTreeScrollingNodeDelegateIOS, so we ensure it is destroyed first.
+    m_scrollViewDelegate.clear();
+    m_scrollingNodeDelegate.reset();
 }
 
 void ScrollingTreeOverflowScrollingNodeIOS::commitStateBeforeChildren(const WebCore::ScrollingStateNode& stateNode)
@@ -181,7 +186,7 @@ void ScrollingTreeOverflowScrollingNodeIOS::commitStateAfterChildren(const Scrol
 {
     ScrollingTreeOverflowScrollingNode::commitStateAfterChildren(stateNode);
 
-    SetForScope<bool> updatingChange(m_updatingFromStateNode, true);
+    SetForScope<bool> updatingChange(m_scrollingNodeDelegate->m_updatingFromStateNode, true);
 
     const auto& scrollingStateNode = downcast<ScrollingStateOverflowScrollingNode>(stateNode);
 
@@ -196,7 +201,7 @@ void ScrollingTreeOverflowScrollingNodeIOS::commitStateAfterChildren(const Scrol
 
         if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollLayer)) {
             if (!m_scrollViewDelegate)
-                m_scrollViewDelegate = adoptNS([[WKOverflowScrollViewDelegate alloc] initWithScrollingTreeNode:this]);
+                m_scrollViewDelegate = adoptNS([[WKOverflowScrollViewDelegate alloc] initWithScrollingTreeNodeDelegate:m_scrollingNodeDelegate.get()]);
 
             scrollView.scrollsToTop = NO;
             scrollView.delegate = m_scrollViewDelegate.get();
@@ -260,60 +265,12 @@ void ScrollingTreeOverflowScrollingNodeIOS::setScrollLayerPosition(const FloatPo
 {
     [m_scrollLayer setPosition:CGPointMake(-scrollPosition.x() + scrollOrigin().x(), -scrollPosition.y() + scrollOrigin().y())];
 
-    updateChildNodesAfterScroll(scrollPosition);
+    m_scrollingNodeDelegate->updateChildNodesAfterScroll(scrollPosition);
 }
 
 void ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterDelegatedScroll(const FloatPoint& scrollPosition)
 {
-    updateChildNodesAfterScroll(scrollPosition);
-}
-
-void ScrollingTreeOverflowScrollingNodeIOS::updateChildNodesAfterScroll(const FloatPoint& scrollPosition)
-{
-    if (!m_children)
-        return;
-
-    FloatRect fixedPositionRect;
-    ScrollingTreeFrameScrollingNode* frameNode = enclosingFrameNode();
-    if (frameNode && frameNode->parent())
-        fixedPositionRect = frameNode->fixedPositionRect();
-    else
-        fixedPositionRect = scrollingTree().fixedPositionRect();
-    FloatSize scrollDelta = lastCommittedScrollPosition() - scrollPosition;
-
-    for (auto& child : *m_children)
-        child->updateLayersAfterAncestorChange(*this, fixedPositionRect, scrollDelta);
-}
-
-void ScrollingTreeOverflowScrollingNodeIOS::overflowScrollWillStart()
-{
-    scrollingTree().scrollingTreeNodeWillStartScroll();
-}
-
-void ScrollingTreeOverflowScrollingNodeIOS::overflowScrollDidEnd()
-{
-    scrollingTree().scrollingTreeNodeDidEndScroll();
-}
-
-void ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewWillStartPanGesture()
-{
-    scrollingTree().scrollingTreeNodeWillStartPanGesture();
-}
-
-void ScrollingTreeOverflowScrollingNodeIOS::scrollViewDidScroll(const FloatPoint& scrollPosition, bool inUserInteraction)
-{
-    if (m_updatingFromStateNode)
-        return;
-
-    scrollingTree().scrollPositionChangedViaDelegatedScrolling(scrollingNodeID(), scrollPosition, inUserInteraction);
-}
-
-void ScrollingTreeOverflowScrollingNodeIOS::currentSnapPointIndicesDidChange(unsigned horizontal, unsigned vertical)
-{
-    if (m_updatingFromStateNode)
-        return;
-    
-    scrollingTree().currentSnapPointIndicesDidChange(scrollingNodeID(), horizontal, vertical);
+    m_scrollingNodeDelegate->updateChildNodesAfterScroll(scrollPosition);
 }
 
 } // namespace WebCore
diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h b/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h
new file mode 100644 (file)
index 0000000..02a993c
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(IOS) && ENABLE(ASYNC_SCROLLING)
+
+#include <WebCore/ScrollingTreeScrollingNodeDelegate.h>
+
+namespace WebCore {
+
+class FloatPoint;
+class ScrollingTreeScrollingNode;
+
+}
+
+namespace WebKit {
+
+class ScrollingTreeOverflowScrollingNodeIOS;
+
+class ScrollingTreeScrollingNodeDelegateIOS : public WebCore::ScrollingTreeScrollingNodeDelegate {
+    friend class ScrollingTreeOverflowScrollingNodeIOS;
+
+public:
+    explicit ScrollingTreeScrollingNodeDelegateIOS(WebCore::ScrollingTreeScrollingNode&);
+    ~ScrollingTreeScrollingNodeDelegateIOS() final;
+
+    void scrollWillStart() const;
+    void scrollDidEnd() const;
+    void scrollViewWillStartPanGesture() const;
+    void scrollViewDidScroll(const WebCore::FloatPoint& scrollPosition, bool inUserInteraction) const;
+    void currentSnapPointIndicesDidChange(unsigned horizontal, unsigned vertical) const;
+
+private:
+    void updateChildNodesAfterScroll(const WebCore::FloatPoint& scrollPosition);
+
+    bool m_updatingFromStateNode;
+};
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS) && ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm b/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm
new file mode 100644 (file)
index 0000000..8bbbabe
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2017 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "ScrollingTreeScrollingNodeDelegateIOS.h"
+
+#if PLATFORM(IOS) && ENABLE(ASYNC_SCROLLING)
+
+#import <WebCore/ScrollingTree.h>
+#import <WebCore/ScrollingTreeFrameScrollingNode.h>
+#import <WebCore/ScrollingTreeScrollingNode.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ScrollingTreeScrollingNodeDelegateIOS::ScrollingTreeScrollingNodeDelegateIOS(ScrollingTreeScrollingNode& scrollingNode)
+    : ScrollingTreeScrollingNodeDelegate(scrollingNode)
+    , m_updatingFromStateNode(false)
+{
+}
+
+ScrollingTreeScrollingNodeDelegateIOS::~ScrollingTreeScrollingNodeDelegateIOS()
+{
+}
+
+void ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll(const FloatPoint& scrollPosition)
+{
+    if (!scrollingNode().children())
+        return;
+
+    FloatRect fixedPositionRect;
+    ScrollingTreeFrameScrollingNode* frameNode = scrollingNode().enclosingFrameNode();
+    if (frameNode && frameNode->parent())
+        fixedPositionRect = frameNode->fixedPositionRect();
+    else
+        fixedPositionRect = scrollingTree().fixedPositionRect();
+    FloatSize scrollDelta = lastCommittedScrollPosition() - scrollPosition;
+
+    for (auto& child : *scrollingNode().children())
+        child->updateLayersAfterAncestorChange(scrollingNode(), fixedPositionRect, scrollDelta);
+}
+
+void ScrollingTreeScrollingNodeDelegateIOS::scrollWillStart() const
+{
+    scrollingTree().scrollingTreeNodeWillStartScroll();
+}
+
+void ScrollingTreeScrollingNodeDelegateIOS::scrollDidEnd() const
+{
+    scrollingTree().scrollingTreeNodeDidEndScroll();
+}
+
+void ScrollingTreeScrollingNodeDelegateIOS::scrollViewWillStartPanGesture() const
+{
+    scrollingTree().scrollingTreeNodeWillStartPanGesture();
+}
+
+void ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidScroll(const FloatPoint& scrollPosition, bool inUserInteraction) const
+{
+    if (m_updatingFromStateNode)
+        return;
+
+    scrollingTree().scrollPositionChangedViaDelegatedScrolling(scrollingNode().scrollingNodeID(), scrollPosition, inUserInteraction);
+}
+
+void ScrollingTreeScrollingNodeDelegateIOS::currentSnapPointIndicesDidChange(unsigned horizontal, unsigned vertical) const
+{
+    if (m_updatingFromStateNode)
+        return;
+
+    scrollingTree().currentSnapPointIndicesDidChange(scrollingNode().scrollingNodeID(), horizontal, vertical);
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS) && ENABLE(ASYNC_SCROLLING)
index a2a285e..6ec571c 100644 (file)
@@ -90,6 +90,8 @@
                0F850FE71ED7C39F00FB77A7 /* WebPerformanceLoggingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F850FE51ED7C39F00FB77A7 /* WebPerformanceLoggingClient.h */; };
                0F931C1C18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F931C1A18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h */; };
                0F931C1D18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F931C1B18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm */; };
+               0F931C1C18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F931C1A18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.h */; };
+               0F931C1D18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F931C1B18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.mm */; };
                0FB659231208B4DB0044816C /* DrawingAreaInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB659221208B4DB0044816C /* DrawingAreaInfo.h */; };
                0FCB4E4618BBE044000FCFC9 /* PageClientImplIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FCB4E3618BBE044000FCFC9 /* PageClientImplIOS.h */; };
                0FCB4E4718BBE044000FCFC9 /* PageClientImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FCB4E3718BBE044000FCFC9 /* PageClientImplIOS.mm */; };
                0F850FE51ED7C39F00FB77A7 /* WebPerformanceLoggingClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPerformanceLoggingClient.h; sourceTree = "<group>"; };
                0F931C1A18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeOverflowScrollingNodeIOS.h; sourceTree = "<group>"; };
                0F931C1B18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreeOverflowScrollingNodeIOS.mm; sourceTree = "<group>"; };
+               0F931C1A18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeScrollingNodeDelegateIOS.h; sourceTree = "<group>"; };
+               0F931C1B18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreeScrollingNodeDelegateIOS.mm; sourceTree = "<group>"; };
                0FB659221208B4DB0044816C /* DrawingAreaInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingAreaInfo.h; sourceTree = "<group>"; };
                0FC0856E187CE0A900780D86 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; name = __init__.py; path = webkit/__init__.py; sourceTree = "<group>"; };
                0FC0856F187CE0A900780D86 /* messages.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; name = messages.py; path = webkit/messages.py; sourceTree = "<group>"; };
                                0F0C365B18C05CA100F607D7 /* RemoteScrollingCoordinatorProxyIOS.mm */,
                                0F931C1A18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h */,
                                0F931C1B18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm */,
+                               0F931C1A18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.h */,
+                               0F931C1B18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.mm */,
                        );
                        path = ios;
                        sourceTree = "<group>";
                                1AAB4A8D1296F0A20023952F /* SandboxExtension.h in Headers */,
                                E1E552C516AE065F004ED653 /* SandboxInitializationParameters.h in Headers */,
                                0F931C1C18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h in Headers */,
+                               0F931C1C18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.h in Headers */,
                                51D130541382EAC000351EDD /* SecItemRequestData.h in Headers */,
                                51D130561382EAC000351EDD /* SecItemResponseData.h in Headers */,
                                E179088F169BAA6A006904C7 /* SecItemShim.h in Headers */,
                                E1E552C416AE065F004ED653 /* SandboxInitialiationParametersMac.mm in Sources */,
                                E19BDA8B19368D4600B97F57 /* SandboxUtilities.mm in Sources */,
                                0F931C1D18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm in Sources */,
+                               0F931C1D18C5711900DBB8D4 /* ScrollingTreeScrollingNodeDelegateIOS.mm in Sources */,
                                51D130531382EAC000351EDD /* SecItemRequestData.cpp in Sources */,
                                51D130551382EAC000351EDD /* SecItemResponseData.cpp in Sources */,
                                E179088D169BAA62006904C7 /* SecItemShim.cpp in Sources */,