Create a ThreadedScrollingTree subclass of ScrollingTree, and push all knowledge...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jan 2014 23:20:25 +0000 (23:20 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jan 2014 23:20:25 +0000 (23:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126362

Reviewed by Sam Weinig.

Eventually we'll have a ScrollingTree in situations where there is no scrolling
thread, so make the ScrollingTree base class thread-agnostic (but threadsafe),
and subclass it in ThreadedScrollingTree for scrolling-thread-specific functionality.

The ScrollingTree base class also no longer needs to know about the
ScrollingCoordinator.

ScrollingCoordinatorMac creates a ThreadedScrollingTree.

Source/WebCore:

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj: Add ThreadedScrollingTree.*
Make some headers Private that we'll need in WebKit2 soon.
* page/scrolling/ScrollingStateTree.h: Drive-by cleanup: clone() was unimplemented.
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::ScrollingTree):
(WebCore::ScrollingTree::~ScrollingTree):
(WebCore::ScrollingTree::shouldHandleWheelEventSynchronously): Wrap up some logic that
involves taking the mutex, so ThreadedScrollingTree can conveniently call it.
(WebCore::ScrollingTree::handleWheelEvent):
(WebCore::ScrollingTree::commitNewTreeState):
(WebCore::ScrollingTree::setMainFrameScrollPosition):
(WebCore::ScrollingTree::isHandlingProgrammaticScroll):
* page/scrolling/ScrollingTree.h:
(WebCore::ScrollingTree::isThreadedScrollingTree):
(WebCore::ScrollingTree::invalidate):
* page/scrolling/ThreadedScrollingTree.cpp: Added.
(WebCore::ThreadedScrollingTree::create):
(WebCore::ThreadedScrollingTree::ThreadedScrollingTree):
(WebCore::ThreadedScrollingTree::~ThreadedScrollingTree):
(WebCore::ThreadedScrollingTree::tryToHandleWheelEvent):
(WebCore::ThreadedScrollingTree::handleWheelEvent):
(WebCore::derefScrollingCoordinator):
(WebCore::ThreadedScrollingTree::invalidate):
(WebCore::ThreadedScrollingTree::commitNewTreeState):
(WebCore::ThreadedScrollingTree::updateMainFrameScrollPosition):
(WebCore::ThreadedScrollingTree::handleWheelEventPhase):
* page/scrolling/ThreadedScrollingTree.h: Added.
(WebCore::ThreadedScrollingTree::isThreadedScrollingTree):
* page/scrolling/mac/ScrollingCoordinatorMac.h:
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::ScrollingCoordinatorMac):
(WebCore::ScrollingCoordinatorMac::handleWheelEvent):

Source/WebKit2:

* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::addScrollingTreeForPage):
(WebKit::EventDispatcher::wheelEvent):
* WebProcess/WebPage/EventDispatcher.h:

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/scrolling/ScrollingStateTree.h
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp [new file with mode: 0644]
Source/WebCore/page/scrolling/ThreadedScrollingTree.h [new file with mode: 0644]
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp
Source/WebKit2/WebProcess/WebPage/EventDispatcher.h

index cee714e..4f8e3d3 100644 (file)
@@ -1,3 +1,53 @@
+2014-01-01  Simon Fraser  <simon.fraser@apple.com>
+
+        Create a ThreadedScrollingTree subclass of ScrollingTree, and push all knowledge of the scrolling thread into it
+        https://bugs.webkit.org/show_bug.cgi?id=126362
+
+        Reviewed by Sam Weinig.
+
+        Eventually we'll have a ScrollingTree in situations where there is no scrolling
+        thread, so make the ScrollingTree base class thread-agnostic (but threadsafe),
+        and subclass it in ThreadedScrollingTree for scrolling-thread-specific functionality.
+        
+        The ScrollingTree base class also no longer needs to know about the
+        ScrollingCoordinator.
+
+        ScrollingCoordinatorMac creates a ThreadedScrollingTree.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj: Add ThreadedScrollingTree.*
+        Make some headers Private that we'll need in WebKit2 soon.
+        * page/scrolling/ScrollingStateTree.h: Drive-by cleanup: clone() was unimplemented.
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::ScrollingTree):
+        (WebCore::ScrollingTree::~ScrollingTree):
+        (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously): Wrap up some logic that
+        involves taking the mutex, so ThreadedScrollingTree can conveniently call it.
+        (WebCore::ScrollingTree::handleWheelEvent):
+        (WebCore::ScrollingTree::commitNewTreeState):
+        (WebCore::ScrollingTree::setMainFrameScrollPosition):
+        (WebCore::ScrollingTree::isHandlingProgrammaticScroll):
+        * page/scrolling/ScrollingTree.h:
+        (WebCore::ScrollingTree::isThreadedScrollingTree):
+        (WebCore::ScrollingTree::invalidate):
+        * page/scrolling/ThreadedScrollingTree.cpp: Added.
+        (WebCore::ThreadedScrollingTree::create):
+        (WebCore::ThreadedScrollingTree::ThreadedScrollingTree):
+        (WebCore::ThreadedScrollingTree::~ThreadedScrollingTree):
+        (WebCore::ThreadedScrollingTree::tryToHandleWheelEvent):
+        (WebCore::ThreadedScrollingTree::handleWheelEvent):
+        (WebCore::derefScrollingCoordinator):
+        (WebCore::ThreadedScrollingTree::invalidate):
+        (WebCore::ThreadedScrollingTree::commitNewTreeState):
+        (WebCore::ThreadedScrollingTree::updateMainFrameScrollPosition):
+        (WebCore::ThreadedScrollingTree::handleWheelEventPhase):
+        * page/scrolling/ThreadedScrollingTree.h: Added.
+        (WebCore::ThreadedScrollingTree::isThreadedScrollingTree):
+        * page/scrolling/mac/ScrollingCoordinatorMac.h:
+        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+        (WebCore::ScrollingCoordinatorMac::ScrollingCoordinatorMac):
+        (WebCore::ScrollingCoordinatorMac::handleWheelEvent):
+
 2014-01-01  Andreas Kling  <akling@apple.com>
 
         FrameView: Store scroll corner renderer in a RenderPtr.
index c8678b5..b8958e1 100644 (file)
@@ -2863,7 +2863,6 @@ __ZN7WebCore8Document19accessSVGExtensionsEv
 
 #if ENABLE(ASYNC_SCROLLING)
 __ZN7WebCore13ScrollingTree21setCanRubberBandStateEbbbb
-__ZN7WebCore13ScrollingTree21tryToHandleWheelEventERKNS_18PlatformWheelEventE
 __ZN7WebCore13ScrollingTree37setScrollingPerformanceLoggingEnabledEb
 __ZN7WebCore13ScrollingTreeD1Ev
 __ZN7WebCore15ScrollingThread15dispatchBarrierERKN3WTF8FunctionIFvvEEE
index 7a0b0f8..807e294 100644 (file)
                0F5B7A5410F65D7A00376302 /* RenderEmbeddedObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5B7A5210F65D7A00376302 /* RenderEmbeddedObject.cpp */; };
                0F5B7A5510F65D7A00376302 /* RenderEmbeddedObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F605AEC15F94848004DF0C0 /* ScrollingConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F605AEA15F94848004DF0C0 /* ScrollingConstraints.cpp */; };
-               0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */; };
+               0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               0F6383DD18615B29003E5DB5 /* ThreadedScrollingTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */; };
+               0F6383DE18615B29003E5DB5 /* ThreadedScrollingTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F6383DC18615B29003E5DB5 /* ThreadedScrollingTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FA24D79162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */; };
                0FA24D7A162DF91900A3F4C0 /* GraphicsLayerUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FA88EBD16A8D1BD00F99984 /* ScrollingStateScrollingNodeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FA88EBC16A8D1BD00F99984 /* ScrollingStateScrollingNodeMac.mm */; };
                931CBD0E161A44E900E4C874 /* ScrollingStateScrollingNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 931CBD08161A44E900E4C874 /* ScrollingStateScrollingNode.cpp */; };
                931CBD0F161A44E900E4C874 /* ScrollingStateScrollingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD09161A44E900E4C874 /* ScrollingStateScrollingNode.h */; };
                931CBD10161A44E900E4C874 /* ScrollingStateTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 931CBD0A161A44E900E4C874 /* ScrollingStateTree.cpp */; };
-               931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD0B161A44E900E4C874 /* ScrollingStateTree.h */; };
+               931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD0B161A44E900E4C874 /* ScrollingStateTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
                931CBD13161A44F800E4C874 /* ScrollingStateNodeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 931CBD12161A44F800E4C874 /* ScrollingStateNodeMac.mm */; };
                931D72F615FE695300C4C07E /* LayoutMilestones.h in Headers */ = {isa = PBXBuildFile; fileRef = 931D72F515FE695300C4C07E /* LayoutMilestones.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9326DC0C09DAD5D600AFC847 /* CharsetData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 656581AC09D14EE6000E61D7 /* CharsetData.cpp */; };
                CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE057FA41220731100A476D5 /* DocumentMarkerController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CE08C3D1152B599A0021B8C2 /* AlternativeTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE08C3CF152B599A0021B8C2 /* AlternativeTextController.cpp */; };
                CE08C3D2152B599A0021B8C2 /* AlternativeTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */; settings = {ATTRIBUTES = (); }; };
-               FE6938B61045D67E008EABB6 /* EventHandlerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */; };
-               FED13D3D0CEA936A00D89466 /* FrameIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D3B0CEA936A00D89466 /* FrameIOS.mm */; };
                CE7B2DB31586ABAD0098B3FA /* AlternativeTextUIController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CE7B2DB41586ABAD0098B3FA /* AlternativeTextUIController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */; };
                CE7B2DB51586ABAD0098B3FA /* TextAlternativeWithRange.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7B2DB11586ABAD0098B3FA /* TextAlternativeWithRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE456F191677D74E005EDDF9 /* DatabaseManager.h in Headers */ = {isa = PBXBuildFile; fileRef = FE456F171677D74E005EDDF9 /* DatabaseManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE4AADEE16D2C37400026FFC /* AbstractSQLStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4AADEC16D2C37400026FFC /* AbstractSQLStatement.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE4AADEF16D2C37400026FFC /* AbstractSQLStatementBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4AADED16D2C37400026FFC /* AbstractSQLStatementBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               FE6938B61045D67E008EABB6 /* EventHandlerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */; };
                FE6F6AAF169E057500FC30A2 /* DatabaseBackendContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE6F6AAD169E057500FC30A2 /* DatabaseBackendContext.cpp */; };
                FE6F6AB0169E057500FC30A2 /* DatabaseBackendContext.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6F6AAE169E057500FC30A2 /* DatabaseBackendContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE6FD48D0F676E9300092873 /* JSCoordinates.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE6FD48B0F676E9300092873 /* JSCoordinates.cpp */; };
                FEBC5F3116BD0CC300659BD3 /* DatabaseBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEBC5F2F16BD0CC300659BD3 /* DatabaseBase.cpp */; };
                FEBC5F3216BD0CC300659BD3 /* DatabaseBase.h in Headers */ = {isa = PBXBuildFile; fileRef = FEBC5F3016BD0CC300659BD3 /* DatabaseBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FED13D3A0CEA934600D89466 /* EditorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D390CEA934600D89466 /* EditorIOS.mm */; };
+               FED13D3D0CEA936A00D89466 /* FrameIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D3B0CEA936A00D89466 /* FrameIOS.mm */; };
                FED13D520CEA949700D89466 /* RenderThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = FED13D500CEA949700D89466 /* RenderThemeIOS.h */; };
                FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */; };
                FEDEF84116797108000E444A /* DatabaseStrategy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDEF83F16797108000E444A /* DatabaseStrategy.cpp */; };
                0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderEmbeddedObject.h; sourceTree = "<group>"; };
                0F605AEA15F94848004DF0C0 /* ScrollingConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingConstraints.cpp; sourceTree = "<group>"; };
                0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingConstraints.h; sourceTree = "<group>"; };
+               0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadedScrollingTree.cpp; sourceTree = "<group>"; };
+               0F6383DC18615B29003E5DB5 /* ThreadedScrollingTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadedScrollingTree.h; sourceTree = "<group>"; };
                0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerUpdater.cpp; sourceTree = "<group>"; };
                0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerUpdater.h; sourceTree = "<group>"; };
                0FA88EBC16A8D1BD00F99984 /* ScrollingStateScrollingNodeMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingStateScrollingNodeMac.mm; sourceTree = "<group>"; };
                CE057FA41220731100A476D5 /* DocumentMarkerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentMarkerController.h; sourceTree = "<group>"; };
                CE08C3CF152B599A0021B8C2 /* AlternativeTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AlternativeTextController.cpp; sourceTree = "<group>"; };
                CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlternativeTextController.h; sourceTree = "<group>"; };
-               FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventHandlerIOS.mm; sourceTree = "<group>"; };
-               FED13D3B0CEA936A00D89466 /* FrameIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameIOS.mm; sourceTree = "<group>"; };
                CE5CB1B314EDAB6F00BB2795 /* EventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSender.h; sourceTree = "<group>"; };
                CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AlternativeTextUIController.h; path = mac/AlternativeTextUIController.h; sourceTree = "<group>"; };
                CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AlternativeTextUIController.mm; path = mac/AlternativeTextUIController.mm; sourceTree = "<group>"; };
                FE456F171677D74E005EDDF9 /* DatabaseManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseManager.h; sourceTree = "<group>"; };
                FE4AADEC16D2C37400026FFC /* AbstractSQLStatement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractSQLStatement.h; sourceTree = "<group>"; };
                FE4AADED16D2C37400026FFC /* AbstractSQLStatementBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractSQLStatementBackend.h; sourceTree = "<group>"; };
+               FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventHandlerIOS.mm; sourceTree = "<group>"; };
                FE6F6AAD169E057500FC30A2 /* DatabaseBackendContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseBackendContext.cpp; sourceTree = "<group>"; };
                FE6F6AAE169E057500FC30A2 /* DatabaseBackendContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseBackendContext.h; sourceTree = "<group>"; };
                FE6FD48B0F676E9300092873 /* JSCoordinates.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCoordinates.cpp; sourceTree = "<group>"; };
                FEBC5F2F16BD0CC300659BD3 /* DatabaseBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseBase.cpp; sourceTree = "<group>"; };
                FEBC5F3016BD0CC300659BD3 /* DatabaseBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseBase.h; sourceTree = "<group>"; };
                FED13D390CEA934600D89466 /* EditorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditorIOS.mm; sourceTree = "<group>"; };
+               FED13D3B0CEA936A00D89466 /* FrameIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameIOS.mm; sourceTree = "<group>"; };
                FED13D500CEA949700D89466 /* RenderThemeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderThemeIOS.h; sourceTree = "<group>"; };
                FEDEF83F16797108000E444A /* DatabaseStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseStrategy.cpp; sourceTree = "<group>"; };
                FEDEF84016797108000E444A /* DatabaseStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseStrategy.h; sourceTree = "<group>"; };
                        path = DerivedSources/WebCore;
                        sourceTree = BUILT_PRODUCTS_DIR;
                };
+               18A6CD6F0D8F2025001DC3CE /* ios */ = {
+                       isa = PBXGroup;
+                       children = (
+                               FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */,
+                               FED13D3B0CEA936A00D89466 /* FrameIOS.mm */,
+                       );
+                       path = ios;
+                       sourceTree = "<group>";
+               };
                1A2E6E560CC551E0004A2062 /* sql */ = {
                        isa = PBXGroup;
                        children = (
                                1AAADDE214DC8C8F00AF64B3 /* ScrollingTreeNode.h */,
                                9391A99A1629D6FF00297330 /* ScrollingTreeScrollingNode.cpp */,
                                9391A99B1629D70000297330 /* ScrollingTreeScrollingNode.h */,
+                               0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */,
+                               0F6383DC18615B29003E5DB5 /* ThreadedScrollingTree.h */,
                        );
                        path = scrolling;
                        sourceTree = "<group>";
                        path = mediasource;
                        sourceTree = "<group>";
                };
-               18A6CD6F0D8F2025001DC3CE /* ios */ = {
-                       isa = PBXGroup;
-                       children = (
-                               FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */,
-                               FED13D3B0CEA936A00D89466 /* FrameIOS.mm */,
-                       );
-                       path = ios;
-                       sourceTree = "<group>";
-               };
                CE79D68617F220ED00815C00 /* ios */ = {
                        isa = PBXGroup;
                        children = (
                                BCE1C41B0D982980003B02F2 /* Location.h in Headers */,
                                A8239E0109B3CF8A00B60641 /* Logging.h in Headers */,
                                510194411836D20800925523 /* IDBIndexWriterLevelDB.h in Headers */,
+                               0F6383DE18615B29003E5DB5 /* ThreadedScrollingTree.h in Headers */,
                                9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */,
                                E187056316E54A0D00585E97 /* MainThreadTask.h in Headers */,
                                1A8F6BC60DB55CDC001DB794 /* ManifestParser.h in Headers */,
                                975CA2A11303679D00E99AD9 /* JSCrypto.cpp in Sources */,
                                209B456B16796A7E00E54E4E /* JSCryptoCustom.cpp in Sources */,
                                BC46C1FA0C0DDC8F0020CFC3 /* JSCSSCharsetRule.cpp in Sources */,
+                               0F6383DD18615B29003E5DB5 /* ThreadedScrollingTree.cpp in Sources */,
                                409EBDC516B7F3CA00CBA3FC /* JSCSSFontFaceLoadEvent.cpp in Sources */,
                                BC46C1FC0C0DDC8F0020CFC3 /* JSCSSFontFaceRule.cpp in Sources */,
                                BC46C1FE0C0DDC8F0020CFC3 /* JSCSSImportRule.cpp in Sources */,
index 8330fdb..25f8b96 100644 (file)
@@ -72,8 +72,6 @@ private:
     void removeNode(ScrollingStateNode*);
     void didRemoveNode(ScrollingNodeID);
 
-    PassOwnPtr<ScrollingStateTree> clone();
-
     HashMap<ScrollingNodeID, ScrollingStateNode*> m_stateNodeMap;
     OwnPtr<ScrollingStateScrollingNode> m_rootStateNode;
     Vector<ScrollingNodeID> m_nodesRemovedSinceLastCommit;
index ee694b8..840c33c 100644 (file)
 #if ENABLE(ASYNC_SCROLLING)
 
 #include "PlatformWheelEvent.h"
-#include "ScrollingCoordinator.h"
 #include "ScrollingStateTree.h"
-#include "ScrollingThread.h"
 #include "ScrollingTreeFixedNode.h"
 #include "ScrollingTreeNode.h"
 #include "ScrollingTreeScrollingNode.h"
 #include "ScrollingTreeStickyNode.h"
-#include <wtf/MainThread.h>
 #include <wtf/TemporaryChange.h>
 
 namespace WebCore {
 
-PassRefPtr<ScrollingTree> ScrollingTree::create(ScrollingCoordinator* scrollingCoordinator)
-{
-    return adoptRef(new ScrollingTree(scrollingCoordinator));
-}
-
-ScrollingTree::ScrollingTree(ScrollingCoordinator* scrollingCoordinator)
-    : m_scrollingCoordinator(scrollingCoordinator)
-    , m_hasWheelEventHandlers(false)
+ScrollingTree::ScrollingTree()
+    : m_hasWheelEventHandlers(false)
     , m_rubberBandsAtLeft(true)
     , m_rubberBandsAtRight(true)
     , m_rubberBandsAtTop(true)
@@ -66,65 +57,33 @@ ScrollingTree::ScrollingTree(ScrollingCoordinator* scrollingCoordinator)
 
 ScrollingTree::~ScrollingTree()
 {
-    ASSERT(!m_scrollingCoordinator);
 }
 
-ScrollingTree::EventResult ScrollingTree::tryToHandleWheelEvent(const PlatformWheelEvent& wheelEvent)
+bool ScrollingTree::shouldHandleWheelEventSynchronously(const PlatformWheelEvent& wheelEvent)
 {
-    {
-        MutexLocker lock(m_mutex);
+    MutexLocker lock(m_mutex);
 
-        if (m_hasWheelEventHandlers)
-            return SendToMainThread;
+    if (m_hasWheelEventHandlers)
+        return true;
 
-        if (!m_nonFastScrollableRegion.isEmpty()) {
-            // FIXME: This is not correct for non-default scroll origins.
-            IntPoint position = wheelEvent.position();
-            position.moveBy(m_mainFrameScrollPosition);
-            if (m_nonFastScrollableRegion.contains(position))
-                return SendToMainThread;
-        }
+    if (!m_nonFastScrollableRegion.isEmpty()) {
+        // FIXME: This is not correct for non-default scroll origins.
+        IntPoint position = wheelEvent.position();
+        position.moveBy(m_mainFrameScrollPosition);
+        if (m_nonFastScrollableRegion.contains(position))
+            return true;
     }
-
-    if (willWheelEventStartSwipeGesture(wheelEvent))
-        return DidNotHandleEvent;
-
-    ScrollingThread::dispatch(bind(&ScrollingTree::handleWheelEvent, this, wheelEvent));
-    return DidHandleEvent;
+    return false;
 }
 
 void ScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 {
-    ASSERT(ScrollingThread::isCurrentThread());
-    
     if (m_rootNode)
         m_rootNode->handleWheelEvent(wheelEvent);
 }
 
-static void derefScrollingCoordinator(ScrollingCoordinator* scrollingCoordinator)
-{
-    ASSERT(isMainThread());
-
-    scrollingCoordinator->deref();
-}
-
-void ScrollingTree::invalidate()
-{
-    // Invalidate is dispatched by the ScrollingCoordinator class on the ScrollingThread
-    // to break the reference cycle between ScrollingTree and ScrollingCoordinator when the
-    // ScrollingCoordinator's page is destroyed.
-    ASSERT(ScrollingThread::isCurrentThread());
-
-    // Since this can potentially be the last reference to the scrolling coordinator,
-    // we need to release it on the main thread since it has member variables (such as timers)
-    // that expect to be destroyed from the main thread.
-    callOnMainThread(bind(derefScrollingCoordinator, m_scrollingCoordinator.release().leakRef()));
-}
-
 void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree)
 {
-    ASSERT(ScrollingThread::isCurrentThread());
-
     bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode();
     
     ScrollingStateScrollingNode* rootNode = scrollingStateTree->rootStateNode();
@@ -238,34 +197,17 @@ void ScrollingTree::setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheR
     m_mainFramePinnedToTheBottom = pinnedToTheBottom;
 }
 
-void ScrollingTree::updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
-{
-    if (!m_scrollingCoordinator)
-        return;
-
-    {
-        MutexLocker lock(m_mutex);
-        m_mainFrameScrollPosition = scrollPosition;
-    }
-
-    callOnMainThread(bind(&ScrollingCoordinator::scheduleUpdateMainFrameScrollPosition, m_scrollingCoordinator.get(), scrollPosition, m_isHandlingProgrammaticScroll, scrollingLayerPositionAction));
-}
-
 IntPoint ScrollingTree::mainFrameScrollPosition()
 {
     MutexLocker lock(m_mutex);
     return m_mainFrameScrollPosition;
 }
 
-#if PLATFORM(MAC)
-void ScrollingTree::handleWheelEventPhase(PlatformWheelEventPhase phase)
+void ScrollingTree::setMainFrameScrollPosition(IntPoint position)
 {
-    if (!m_scrollingCoordinator)
-        return;
-
-    callOnMainThread(bind(&ScrollingCoordinator::handleWheelEventPhase, m_scrollingCoordinator.get(), phase));
+    MutexLocker lock(m_mutex);
+    m_mainFrameScrollPosition = position;
 }
-#endif
 
 bool ScrollingTree::isRubberBandInProgress()
 {
@@ -318,7 +260,12 @@ bool ScrollingTree::rubberBandsAtTop()
 
     return m_rubberBandsAtTop;
 }
-    
+
+bool ScrollingTree::isHandlingProgrammaticScroll()
+{
+    return m_isHandlingProgrammaticScroll;
+}
+
 void ScrollingTree::setScrollPinningBehavior(ScrollPinningBehavior pinning)
 {
     MutexLocker locker(m_swipeStateMutex);
index f1b28a5..0de3548 100644 (file)
 #include <wtf/HashMap.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
 #include <wtf/ThreadSafeRefCounted.h>
 
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-OBJC_CLASS CALayer;
-#endif
-
 namespace WebCore {
 
 class IntPoint;
-class ScrollingStateNode;
 class ScrollingStateTree;
+class ScrollingStateNode;
 class ScrollingTreeNode;
 class ScrollingTreeScrollingNode;
 
-// The ScrollingTree class lives almost exclusively on the scrolling thread and manages the
-// hierarchy of scrollable regions on the page. It's also responsible for dispatching events
-// to the correct scrolling tree nodes or dispatching events back to the ScrollingCoordinator
-// object on the main thread if they can't be handled on the scrolling thread for various reasons.
 class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
 public:
-    static PassRefPtr<ScrollingTree> create(ScrollingCoordinator*);
-    ~ScrollingTree();
+    ScrollingTree();
+    virtual ~ScrollingTree();
 
     enum EventResult {
         DidNotHandleEvent,
         DidHandleEvent,
         SendToMainThread
     };
+    
+    virtual bool isThreadedScrollingTree() const { return false; }
 
-    // Can be called from any thread. Will try to handle the wheel event on the scrolling thread.
-    // Returns true if the wheel event can be handled on the scrolling thread and false if the
-    // event must be sent again to the WebCore event handler.
-    EventResult tryToHandleWheelEvent(const PlatformWheelEvent&);
-    bool hasWheelEventHandlers() const { return m_hasWheelEventHandlers; }
-
-    // Must be called from the scrolling thread. Handles the wheel event.
-    void handleWheelEvent(const PlatformWheelEvent&);
+    virtual EventResult tryToHandleWheelEvent(const PlatformWheelEvent&) = 0;
+    bool shouldHandleWheelEventSynchronously(const PlatformWheelEvent&);
 
     void setMainFrameIsRubberBanding(bool);
     bool isRubberBandInProgress();
 
-    void invalidate();
-    void commitNewTreeState(PassOwnPtr<ScrollingStateTree>);
+    virtual void invalidate() { }
+    virtual void commitNewTreeState(PassOwnPtr<ScrollingStateTree>);
 
     void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom);
 
-    void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition);
+    virtual void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) = 0;
     IntPoint mainFrameScrollPosition();
 
 #if PLATFORM(MAC)
-    void handleWheelEventPhase(PlatformWheelEventPhase);
+    virtual void handleWheelEventPhase(PlatformWheelEventPhase) = 0;
 #endif
 
     // Can be called from any thread. Will update what edges allow rubber-banding.
@@ -98,6 +83,7 @@ public:
     bool rubberBandsAtRight();
     bool rubberBandsAtTop();
     bool rubberBandsAtBottom();
+    bool isHandlingProgrammaticScroll();
     
     void setScrollPinningBehavior(ScrollPinningBehavior);
     ScrollPinningBehavior scrollPinningBehavior();
@@ -109,13 +95,14 @@ public:
 
     ScrollingTreeScrollingNode* rootNode() const { return m_rootNode.get(); }
 
-private:
-    explicit ScrollingTree(ScrollingCoordinator*);
+protected:
+    void setMainFrameScrollPosition(IntPoint);
+    virtual void handleWheelEvent(const PlatformWheelEvent&);
 
+private:
     void removeDestroyedNodes(const ScrollingStateTree&);
     void updateTreeFromStateNode(const ScrollingStateNode*);
 
-    RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
     OwnPtr<ScrollingTreeScrollingNode> m_rootNode;
 
     typedef HashMap<ScrollingNodeID, ScrollingTreeNode*> ScrollingTreeNodeMap;
@@ -143,6 +130,9 @@ private:
     bool m_isHandlingProgrammaticScroll;
 };
 
+#define SCROLLING_TREE_TYPE_CASTS(ToValueTypeName, predicate) \
+    TYPE_CASTS_BASE(ToValueTypeName, ScrollingTree, value, value->predicate, value.predicate)
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp b/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
new file mode 100644 (file)
index 0000000..d857daf
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 Apple Inc. 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.
+ */
+
+#include "config.h"
+#include "ThreadedScrollingTree.h"
+
+#if ENABLE(ASYNC_SCROLLING)
+
+#include "PlatformWheelEvent.h"
+#include "ScrollingCoordinator.h"
+#include "ScrollingThread.h"
+#include "ScrollingTreeFixedNode.h"
+#include "ScrollingTreeNode.h"
+#include "ScrollingTreeScrollingNode.h"
+#include "ScrollingTreeStickyNode.h"
+#include <wtf/MainThread.h>
+#include <wtf/TemporaryChange.h>
+
+namespace WebCore {
+
+RefPtr<ThreadedScrollingTree> ThreadedScrollingTree::create(ScrollingCoordinator* scrollingCoordinator)
+{
+    return adoptRef(new ThreadedScrollingTree(scrollingCoordinator));
+}
+
+ThreadedScrollingTree::ThreadedScrollingTree(ScrollingCoordinator* scrollingCoordinator)
+    : m_scrollingCoordinator(scrollingCoordinator)
+{
+}
+
+ThreadedScrollingTree::~ThreadedScrollingTree()
+{
+    // invalidate() should have cleared m_scrollingCoordinator.
+    ASSERT(!m_scrollingCoordinator);
+}
+
+ScrollingTree::EventResult ThreadedScrollingTree::tryToHandleWheelEvent(const PlatformWheelEvent& wheelEvent)
+{
+    if (shouldHandleWheelEventSynchronously(wheelEvent))
+        return SendToMainThread;
+
+    if (willWheelEventStartSwipeGesture(wheelEvent))
+        return DidNotHandleEvent;
+
+    ScrollingThread::dispatch(bind(&ThreadedScrollingTree::handleWheelEvent, this, wheelEvent));
+    return DidHandleEvent;
+}
+
+void ThreadedScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+{
+    ASSERT(ScrollingThread::isCurrentThread());
+    ScrollingTree::handleWheelEvent(wheelEvent);
+}
+
+static void derefScrollingCoordinator(ScrollingCoordinator* scrollingCoordinator)
+{
+    ASSERT(isMainThread());
+
+    scrollingCoordinator->deref();
+}
+
+void ThreadedScrollingTree::invalidate()
+{
+    // Invalidate is dispatched by the ScrollingCoordinator class on the ScrollingThread
+    // to break the reference cycle between ScrollingTree and ScrollingCoordinator when the
+    // ScrollingCoordinator's page is destroyed.
+    ASSERT(ScrollingThread::isCurrentThread());
+
+    // Since this can potentially be the last reference to the scrolling coordinator,
+    // we need to release it on the main thread since it has member variables (such as timers)
+    // that expect to be destroyed from the main thread.
+    callOnMainThread(bind(derefScrollingCoordinator, m_scrollingCoordinator.release().leakRef()));
+}
+
+void ThreadedScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree)
+{
+    ASSERT(ScrollingThread::isCurrentThread());
+    ScrollingTree::commitNewTreeState(scrollingStateTree);
+}
+
+void ThreadedScrollingTree::updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
+{
+    if (!m_scrollingCoordinator)
+        return;
+
+    setMainFrameScrollPosition(scrollPosition);
+
+    callOnMainThread(bind(&ScrollingCoordinator::scheduleUpdateMainFrameScrollPosition, m_scrollingCoordinator.get(), scrollPosition, isHandlingProgrammaticScroll(), scrollingLayerPositionAction));
+}
+
+#if PLATFORM(MAC)
+void ThreadedScrollingTree::handleWheelEventPhase(PlatformWheelEventPhase phase)
+{
+    if (!m_scrollingCoordinator)
+        return;
+
+    callOnMainThread(bind(&ScrollingCoordinator::handleWheelEventPhase, m_scrollingCoordinator.get(), phase));
+}
+#endif
+
+} // namespace WebCore
+
+#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ThreadedScrollingTree.h b/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
new file mode 100644 (file)
index 0000000..b065187
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2014 Apple Inc. 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.
+ */
+
+#ifndef ThreadedScrollingTree_h
+#define ThreadedScrollingTree_h
+
+#if ENABLE(ASYNC_SCROLLING)
+
+#include "ScrollingStateTree.h"
+#include "ScrollingTree.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+// The ThreadedScrollingTree class lives almost exclusively on the scrolling thread and manages the
+// hierarchy of scrollable regions on the page. It's also responsible for dispatching events
+// to the correct scrolling tree nodes or dispatching events back to the ScrollingCoordinator
+// object on the main thread if they can't be handled on the scrolling thread for various reasons.
+class ThreadedScrollingTree : public ScrollingTree {
+public:
+    static RefPtr<ThreadedScrollingTree> create(ScrollingCoordinator*);
+
+    virtual ~ThreadedScrollingTree();
+
+    virtual bool isThreadedScrollingTree() const { return true; }
+
+    virtual void handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
+
+    // Can be called from any thread. Will try to handle the wheel event on the scrolling thread.
+    // Returns true if the wheel event can be handled on the scrolling thread and false if the
+    // event must be sent again to the WebCore event handler.
+    virtual EventResult tryToHandleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
+
+    virtual void invalidate() OVERRIDE;
+
+private:
+    explicit ThreadedScrollingTree(ScrollingCoordinator*);
+
+    virtual void commitNewTreeState(PassOwnPtr<ScrollingStateTree>) OVERRIDE;
+    virtual void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) OVERRIDE;
+#if PLATFORM(MAC)
+    virtual void handleWheelEventPhase(PlatformWheelEventPhase) OVERRIDE;
+#endif
+
+    RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
+};
+
+SCROLLING_TREE_TYPE_CASTS(ThreadedScrollingTree, isThreadedScrollingTree());
+
+} // namespace WebCore
+
+#endif // ENABLE(ASYNC_SCROLLING)
+
+#endif // ThreadedScrollingTree_h
index 360e3b1..a417c71 100644 (file)
@@ -36,6 +36,7 @@ class Scrollbar;
 class ScrollingStateNode;
 class ScrollingStateScrollingNode;
 class ScrollingStateTree;
+class ThreadedScrollingTree;
 
 class ScrollingCoordinatorMac : public ScrollingCoordinator {
 public:
@@ -114,7 +115,7 @@ private:
     void commitTreeState();
 
     OwnPtr<ScrollingStateTree> m_scrollingStateTree;
-    RefPtr<ScrollingTree> m_scrollingTree;
+    RefPtr<ThreadedScrollingTree> m_scrollingTree;
     Timer<ScrollingCoordinatorMac> m_scrollingStateTreeCommitterTimer;
 };
 
index a2836bd..798a195 100644 (file)
@@ -46,7 +46,7 @@
 #include "ScrollingStateStickyNode.h"
 #include "ScrollingStateTree.h"
 #include "ScrollingThread.h"
-#include "ScrollingTree.h"
+#include "ThreadedScrollingTree.h"
 #include "TiledBacking.h"
 #include <wtf/Functional.h>
 #include <wtf/MainThread.h>
@@ -61,7 +61,7 @@ class ScrollingCoordinatorPrivate {
 ScrollingCoordinatorMac::ScrollingCoordinatorMac(Page* page)
     : ScrollingCoordinator(page)
     , m_scrollingStateTree(ScrollingStateTree::create())
-    , m_scrollingTree(ScrollingTree::create(this))
+    , m_scrollingTree(ThreadedScrollingTree::create(this))
     , m_scrollingStateTreeCommitterTimer(this, &ScrollingCoordinatorMac::scrollingStateTreeCommitterTimerFired)
 {
 }
@@ -232,8 +232,7 @@ bool ScrollingCoordinatorMac::handleWheelEvent(FrameView*, const PlatformWheelEv
     if (m_scrollingTree->willWheelEventStartSwipeGesture(wheelEvent))
         return false;
 
-    ScrollingThread::dispatch(bind(&ScrollingTree::handleWheelEvent, m_scrollingTree.get(), wheelEvent));
-
+    ScrollingThread::dispatch(bind(&ThreadedScrollingTree::handleWheelEvent, m_scrollingTree.get(), wheelEvent));
     return true;
 }
 
index dc7f6a2..95ba55e 100644 (file)
@@ -1,5 +1,26 @@
 2014-01-01  Simon Fraser  <simon.fraser@apple.com>
 
+        Create a ThreadedScrollingTree subclass of ScrollingTree, and push all knowledge of the scrolling thread into it
+        https://bugs.webkit.org/show_bug.cgi?id=126362
+
+        Reviewed by Sam Weinig.
+
+        Eventually we'll have a ScrollingTree in situations where there is no scrolling
+        thread, so make the ScrollingTree base class thread-agnostic (but threadsafe),
+        and subclass it in ThreadedScrollingTree for scrolling-thread-specific functionality.
+        
+        The ScrollingTree base class also no longer needs to know about the
+        ScrollingCoordinator.
+
+        ScrollingCoordinatorMac creates a ThreadedScrollingTree.
+
+        * WebProcess/WebPage/EventDispatcher.cpp:
+        (WebKit::EventDispatcher::addScrollingTreeForPage):
+        (WebKit::EventDispatcher::wheelEvent):
+        * WebProcess/WebPage/EventDispatcher.h:
+
+2014-01-01  Simon Fraser  <simon.fraser@apple.com>
+
         Add a typedef for PlatformLayerID on GraphicsLayer, and migrate RemoteLayerTreeTransaction to use it
         https://bugs.webkit.org/show_bug.cgi?id=126346
 
index 77da100..be47fe7 100644 (file)
@@ -39,7 +39,7 @@
 #if ENABLE(ASYNC_SCROLLING)
 #include <WebCore/ScrollingCoordinator.h>
 #include <WebCore/ScrollingThread.h>
-#include <WebCore/ScrollingTree.h>
+#include <WebCore/ThreadedScrollingTree.h>
 #endif
 
 using namespace WebCore;
@@ -67,7 +67,7 @@ void EventDispatcher::addScrollingTreeForPage(WebPage* webPage)
 
     ASSERT(webPage->corePage()->scrollingCoordinator());
     ASSERT(!m_scrollingTrees.contains(webPage->pageID()));
-    m_scrollingTrees.set(webPage->pageID(), webPage->corePage()->scrollingCoordinator()->scrollingTree());
+    m_scrollingTrees.set(webPage->pageID(), toThreadedScrollingTree(webPage->corePage()->scrollingCoordinator()->scrollingTree()));
 }
 
 void EventDispatcher::removeScrollingTreeForPage(WebPage* webPage)
@@ -88,7 +88,7 @@ void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEven
 {
 #if ENABLE(ASYNC_SCROLLING)
     MutexLocker locker(m_scrollingTreesMutex);
-    if (ScrollingTree* scrollingTree = m_scrollingTrees.get(pageID)) {
+    if (ThreadedScrollingTree* scrollingTree = m_scrollingTrees.get(pageID)) {
         PlatformWheelEvent platformWheelEvent = platform(wheelEvent);
 
         // FIXME: It's pretty horrible that we're updating the back/forward state here.
@@ -96,7 +96,7 @@ void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEven
         // scrolling tree can be notified.
         // We only need to do this at the beginning of the gesture.
         if (platformWheelEvent.phase() == PlatformWheelEventPhaseBegan)
-            ScrollingThread::dispatch(bind(&ScrollingTree::setCanRubberBandState, scrollingTree, canRubberBandAtLeft, canRubberBandAtRight, canRubberBandAtTop, canRubberBandAtBottom));
+            ScrollingThread::dispatch(bind(&ThreadedScrollingTree::setCanRubberBandState, scrollingTree, canRubberBandAtLeft, canRubberBandAtRight, canRubberBandAtTop, canRubberBandAtBottom));
 
         ScrollingTree::EventResult result = scrollingTree->tryToHandleWheelEvent(platformWheelEvent);
         if (result == ScrollingTree::DidHandleEvent || result == ScrollingTree::DidNotHandleEvent) {
index a63c803..7103f8e 100644 (file)
@@ -33,7 +33,7 @@
 #include <wtf/ThreadingPrimitives.h>
 
 namespace WebCore {
-    class ScrollingTree;
+class ThreadedScrollingTree;
 }
 
 namespace WebKit {
@@ -74,7 +74,7 @@ private:
 
 #if ENABLE(ASYNC_SCROLLING)
     Mutex m_scrollingTreesMutex;
-    HashMap<uint64_t, RefPtr<WebCore::ScrollingTree>> m_scrollingTrees;
+    HashMap<uint64_t, RefPtr<WebCore::ThreadedScrollingTree>> m_scrollingTrees;
 #endif
 };