Changeset 161198 in webkit


Ignore:
Timestamp:
Jan 1, 2014 3:20:25 PM (10 years ago)
Author:
Simon Fraser
Message:

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.

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:
Location:
trunk/Source
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r161197 r161198  
     12014-01-01  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Create a ThreadedScrollingTree subclass of ScrollingTree, and push all knowledge of the scrolling thread into it
     4        https://bugs.webkit.org/show_bug.cgi?id=126362
     5
     6        Reviewed by Sam Weinig.
     7
     8        Eventually we'll have a ScrollingTree in situations where there is no scrolling
     9        thread, so make the ScrollingTree base class thread-agnostic (but threadsafe),
     10        and subclass it in ThreadedScrollingTree for scrolling-thread-specific functionality.
     11       
     12        The ScrollingTree base class also no longer needs to know about the
     13        ScrollingCoordinator.
     14
     15        ScrollingCoordinatorMac creates a ThreadedScrollingTree.
     16
     17        * WebCore.exp.in:
     18        * WebCore.xcodeproj/project.pbxproj: Add ThreadedScrollingTree.*
     19        Make some headers Private that we'll need in WebKit2 soon.
     20        * page/scrolling/ScrollingStateTree.h: Drive-by cleanup: clone() was unimplemented.
     21        * page/scrolling/ScrollingTree.cpp:
     22        (WebCore::ScrollingTree::ScrollingTree):
     23        (WebCore::ScrollingTree::~ScrollingTree):
     24        (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously): Wrap up some logic that
     25        involves taking the mutex, so ThreadedScrollingTree can conveniently call it.
     26        (WebCore::ScrollingTree::handleWheelEvent):
     27        (WebCore::ScrollingTree::commitNewTreeState):
     28        (WebCore::ScrollingTree::setMainFrameScrollPosition):
     29        (WebCore::ScrollingTree::isHandlingProgrammaticScroll):
     30        * page/scrolling/ScrollingTree.h:
     31        (WebCore::ScrollingTree::isThreadedScrollingTree):
     32        (WebCore::ScrollingTree::invalidate):
     33        * page/scrolling/ThreadedScrollingTree.cpp: Added.
     34        (WebCore::ThreadedScrollingTree::create):
     35        (WebCore::ThreadedScrollingTree::ThreadedScrollingTree):
     36        (WebCore::ThreadedScrollingTree::~ThreadedScrollingTree):
     37        (WebCore::ThreadedScrollingTree::tryToHandleWheelEvent):
     38        (WebCore::ThreadedScrollingTree::handleWheelEvent):
     39        (WebCore::derefScrollingCoordinator):
     40        (WebCore::ThreadedScrollingTree::invalidate):
     41        (WebCore::ThreadedScrollingTree::commitNewTreeState):
     42        (WebCore::ThreadedScrollingTree::updateMainFrameScrollPosition):
     43        (WebCore::ThreadedScrollingTree::handleWheelEventPhase):
     44        * page/scrolling/ThreadedScrollingTree.h: Added.
     45        (WebCore::ThreadedScrollingTree::isThreadedScrollingTree):
     46        * page/scrolling/mac/ScrollingCoordinatorMac.h:
     47        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
     48        (WebCore::ScrollingCoordinatorMac::ScrollingCoordinatorMac):
     49        (WebCore::ScrollingCoordinatorMac::handleWheelEvent):
     50
    1512014-01-01  Andreas Kling  <akling@apple.com>
    252
  • trunk/Source/WebCore/WebCore.exp.in

    r161035 r161198  
    28642864#if ENABLE(ASYNC_SCROLLING)
    28652865__ZN7WebCore13ScrollingTree21setCanRubberBandStateEbbbb
    2866 __ZN7WebCore13ScrollingTree21tryToHandleWheelEventERKNS_18PlatformWheelEventE
    28672866__ZN7WebCore13ScrollingTree37setScrollingPerformanceLoggingEnabledEb
    28682867__ZN7WebCore13ScrollingTreeD1Ev
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r161123 r161198  
    471471                0F5B7A5510F65D7A00376302 /* RenderEmbeddedObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
    472472                0F605AEC15F94848004DF0C0 /* ScrollingConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F605AEA15F94848004DF0C0 /* ScrollingConstraints.cpp */; };
    473                 0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */; };
     473                0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
     474                0F6383DD18615B29003E5DB5 /* ThreadedScrollingTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */; };
     475                0F6383DE18615B29003E5DB5 /* ThreadedScrollingTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F6383DC18615B29003E5DB5 /* ThreadedScrollingTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
    474476                0FA24D79162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */; };
    475477                0FA24D7A162DF91900A3F4C0 /* GraphicsLayerUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    29412943                931CBD0F161A44E900E4C874 /* ScrollingStateScrollingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD09161A44E900E4C874 /* ScrollingStateScrollingNode.h */; };
    29422944                931CBD10161A44E900E4C874 /* ScrollingStateTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 931CBD0A161A44E900E4C874 /* ScrollingStateTree.cpp */; };
    2943                 931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD0B161A44E900E4C874 /* ScrollingStateTree.h */; };
     2945                931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD0B161A44E900E4C874 /* ScrollingStateTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
    29442946                931CBD13161A44F800E4C874 /* ScrollingStateNodeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 931CBD12161A44F800E4C874 /* ScrollingStateNodeMac.mm */; };
    29452947                931D72F615FE695300C4C07E /* LayoutMilestones.h in Headers */ = {isa = PBXBuildFile; fileRef = 931D72F515FE695300C4C07E /* LayoutMilestones.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    54685470                CE08C3D1152B599A0021B8C2 /* AlternativeTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE08C3CF152B599A0021B8C2 /* AlternativeTextController.cpp */; };
    54695471                CE08C3D2152B599A0021B8C2 /* AlternativeTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */; settings = {ATTRIBUTES = (); }; };
    5470                 FE6938B61045D67E008EABB6 /* EventHandlerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */; };
    5471                 FED13D3D0CEA936A00D89466 /* FrameIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D3B0CEA936A00D89466 /* FrameIOS.mm */; };
    54725472                CE7B2DB31586ABAD0098B3FA /* AlternativeTextUIController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */; settings = {ATTRIBUTES = (Private, ); }; };
    54735473                CE7B2DB41586ABAD0098B3FA /* AlternativeTextUIController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */; };
     
    63316331                FE4AADEE16D2C37400026FFC /* AbstractSQLStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4AADEC16D2C37400026FFC /* AbstractSQLStatement.h */; settings = {ATTRIBUTES = (Private, ); }; };
    63326332                FE4AADEF16D2C37400026FFC /* AbstractSQLStatementBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4AADED16D2C37400026FFC /* AbstractSQLStatementBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
     6333                FE6938B61045D67E008EABB6 /* EventHandlerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */; };
    63336334                FE6F6AAF169E057500FC30A2 /* DatabaseBackendContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE6F6AAD169E057500FC30A2 /* DatabaseBackendContext.cpp */; };
    63346335                FE6F6AB0169E057500FC30A2 /* DatabaseBackendContext.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6F6AAE169E057500FC30A2 /* DatabaseBackendContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    63536354                FEBC5F3216BD0CC300659BD3 /* DatabaseBase.h in Headers */ = {isa = PBXBuildFile; fileRef = FEBC5F3016BD0CC300659BD3 /* DatabaseBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
    63546355                FED13D3A0CEA934600D89466 /* EditorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D390CEA934600D89466 /* EditorIOS.mm */; };
     6356                FED13D3D0CEA936A00D89466 /* FrameIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D3B0CEA936A00D89466 /* FrameIOS.mm */; };
    63556357                FED13D520CEA949700D89466 /* RenderThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = FED13D500CEA949700D89466 /* RenderThemeIOS.h */; };
    63566358                FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */; };
     
    71007102                0F605AEA15F94848004DF0C0 /* ScrollingConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingConstraints.cpp; sourceTree = "<group>"; };
    71017103                0F605AEB15F94848004DF0C0 /* ScrollingConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingConstraints.h; sourceTree = "<group>"; };
     7104                0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadedScrollingTree.cpp; sourceTree = "<group>"; };
     7105                0F6383DC18615B29003E5DB5 /* ThreadedScrollingTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadedScrollingTree.h; sourceTree = "<group>"; };
    71027106                0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerUpdater.cpp; sourceTree = "<group>"; };
    71037107                0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerUpdater.h; sourceTree = "<group>"; };
     
    1262612630                CE08C3CF152B599A0021B8C2 /* AlternativeTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AlternativeTextController.cpp; sourceTree = "<group>"; };
    1262712631                CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlternativeTextController.h; sourceTree = "<group>"; };
    12628                 FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventHandlerIOS.mm; sourceTree = "<group>"; };
    12629                 FED13D3B0CEA936A00D89466 /* FrameIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameIOS.mm; sourceTree = "<group>"; };
    1263012632                CE5CB1B314EDAB6F00BB2795 /* EventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSender.h; sourceTree = "<group>"; };
    1263112633                CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AlternativeTextUIController.h; path = mac/AlternativeTextUIController.h; sourceTree = "<group>"; };
     
    1358413586                FE4AADEC16D2C37400026FFC /* AbstractSQLStatement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractSQLStatement.h; sourceTree = "<group>"; };
    1358513587                FE4AADED16D2C37400026FFC /* AbstractSQLStatementBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractSQLStatementBackend.h; sourceTree = "<group>"; };
     13588                FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventHandlerIOS.mm; sourceTree = "<group>"; };
    1358613589                FE6F6AAD169E057500FC30A2 /* DatabaseBackendContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseBackendContext.cpp; sourceTree = "<group>"; };
    1358713590                FE6F6AAE169E057500FC30A2 /* DatabaseBackendContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseBackendContext.h; sourceTree = "<group>"; };
     
    1360613609                FEBC5F3016BD0CC300659BD3 /* DatabaseBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseBase.h; sourceTree = "<group>"; };
    1360713610                FED13D390CEA934600D89466 /* EditorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditorIOS.mm; sourceTree = "<group>"; };
     13611                FED13D3B0CEA936A00D89466 /* FrameIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameIOS.mm; sourceTree = "<group>"; };
    1360813612                FED13D500CEA949700D89466 /* RenderThemeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderThemeIOS.h; sourceTree = "<group>"; };
    1360913613                FEDEF83F16797108000E444A /* DatabaseStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseStrategy.cpp; sourceTree = "<group>"; };
     
    1427814282                        sourceTree = BUILT_PRODUCTS_DIR;
    1427914283                };
     14284                18A6CD6F0D8F2025001DC3CE /* ios */ = {
     14285                        isa = PBXGroup;
     14286                        children = (
     14287                                FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */,
     14288                                FED13D3B0CEA936A00D89466 /* FrameIOS.mm */,
     14289                        );
     14290                        path = ios;
     14291                        sourceTree = "<group>";
     14292                };
    1428014293                1A2E6E560CC551E0004A2062 /* sql */ = {
    1428114294                        isa = PBXGroup;
     
    1447714490                                9391A99A1629D6FF00297330 /* ScrollingTreeScrollingNode.cpp */,
    1447814491                                9391A99B1629D70000297330 /* ScrollingTreeScrollingNode.h */,
     14492                                0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */,
     14493                                0F6383DC18615B29003E5DB5 /* ThreadedScrollingTree.h */,
    1447914494                        );
    1448014495                        path = scrolling;
     
    2054620561                        sourceTree = "<group>";
    2054720562                };
    20548                 18A6CD6F0D8F2025001DC3CE /* ios */ = {
    20549                         isa = PBXGroup;
    20550                         children = (
    20551                                 FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */,
    20552                                 FED13D3B0CEA936A00D89466 /* FrameIOS.mm */,
    20553                         );
    20554                         path = ios;
    20555                         sourceTree = "<group>";
    20556                 };
    2055720563                CE79D68617F220ED00815C00 /* ios */ = {
    2055820564                        isa = PBXGroup;
     
    2418224188                                A8239E0109B3CF8A00B60641 /* Logging.h in Headers */,
    2418324189                                510194411836D20800925523 /* IDBIndexWriterLevelDB.h in Headers */,
     24190                                0F6383DE18615B29003E5DB5 /* ThreadedScrollingTree.h in Headers */,
    2418424191                                9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */,
    2418524192                                E187056316E54A0D00585E97 /* MainThreadTask.h in Headers */,
     
    2689026897                                209B456B16796A7E00E54E4E /* JSCryptoCustom.cpp in Sources */,
    2689126898                                BC46C1FA0C0DDC8F0020CFC3 /* JSCSSCharsetRule.cpp in Sources */,
     26899                                0F6383DD18615B29003E5DB5 /* ThreadedScrollingTree.cpp in Sources */,
    2689226900                                409EBDC516B7F3CA00CBA3FC /* JSCSSFontFaceLoadEvent.cpp in Sources */,
    2689326901                                BC46C1FC0C0DDC8F0020CFC3 /* JSCSSFontFaceRule.cpp in Sources */,
  • trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h

    r161191 r161198  
    7373    void didRemoveNode(ScrollingNodeID);
    7474
    75     PassOwnPtr<ScrollingStateTree> clone();
    76 
    7775    HashMap<ScrollingNodeID, ScrollingStateNode*> m_stateNodeMap;
    7876    OwnPtr<ScrollingStateScrollingNode> m_rootStateNode;
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r161194 r161198  
    3030
    3131#include "PlatformWheelEvent.h"
    32 #include "ScrollingCoordinator.h"
    3332#include "ScrollingStateTree.h"
    34 #include "ScrollingThread.h"
    3533#include "ScrollingTreeFixedNode.h"
    3634#include "ScrollingTreeNode.h"
    3735#include "ScrollingTreeScrollingNode.h"
    3836#include "ScrollingTreeStickyNode.h"
    39 #include <wtf/MainThread.h>
    4037#include <wtf/TemporaryChange.h>
    4138
    4239namespace WebCore {
    4340
    44 PassRefPtr<ScrollingTree> ScrollingTree::create(ScrollingCoordinator* scrollingCoordinator)
    45 {
    46     return adoptRef(new ScrollingTree(scrollingCoordinator));
    47 }
    48 
    49 ScrollingTree::ScrollingTree(ScrollingCoordinator* scrollingCoordinator)
    50     : m_scrollingCoordinator(scrollingCoordinator)
    51     , m_hasWheelEventHandlers(false)
     41ScrollingTree::ScrollingTree()
     42    : m_hasWheelEventHandlers(false)
    5243    , m_rubberBandsAtLeft(true)
    5344    , m_rubberBandsAtRight(true)
     
    6758ScrollingTree::~ScrollingTree()
    6859{
    69     ASSERT(!m_scrollingCoordinator);
    70 }
    71 
    72 ScrollingTree::EventResult ScrollingTree::tryToHandleWheelEvent(const PlatformWheelEvent& wheelEvent)
    73 {
    74     {
    75         MutexLocker lock(m_mutex);
    76 
    77         if (m_hasWheelEventHandlers)
    78             return SendToMainThread;
    79 
    80         if (!m_nonFastScrollableRegion.isEmpty()) {
    81             // FIXME: This is not correct for non-default scroll origins.
    82             IntPoint position = wheelEvent.position();
    83             position.moveBy(m_mainFrameScrollPosition);
    84             if (m_nonFastScrollableRegion.contains(position))
    85                 return SendToMainThread;
    86         }
    87     }
    88 
    89     if (willWheelEventStartSwipeGesture(wheelEvent))
    90         return DidNotHandleEvent;
    91 
    92     ScrollingThread::dispatch(bind(&ScrollingTree::handleWheelEvent, this, wheelEvent));
    93     return DidHandleEvent;
     60}
     61
     62bool ScrollingTree::shouldHandleWheelEventSynchronously(const PlatformWheelEvent& wheelEvent)
     63{
     64    MutexLocker lock(m_mutex);
     65
     66    if (m_hasWheelEventHandlers)
     67        return true;
     68
     69    if (!m_nonFastScrollableRegion.isEmpty()) {
     70        // FIXME: This is not correct for non-default scroll origins.
     71        IntPoint position = wheelEvent.position();
     72        position.moveBy(m_mainFrameScrollPosition);
     73        if (m_nonFastScrollableRegion.contains(position))
     74            return true;
     75    }
     76    return false;
    9477}
    9578
    9679void ScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
    9780{
    98     ASSERT(ScrollingThread::isCurrentThread());
    99    
    10081    if (m_rootNode)
    10182        m_rootNode->handleWheelEvent(wheelEvent);
    10283}
    10384
    104 static void derefScrollingCoordinator(ScrollingCoordinator* scrollingCoordinator)
    105 {
    106     ASSERT(isMainThread());
    107 
    108     scrollingCoordinator->deref();
    109 }
    110 
    111 void ScrollingTree::invalidate()
    112 {
    113     // Invalidate is dispatched by the ScrollingCoordinator class on the ScrollingThread
    114     // to break the reference cycle between ScrollingTree and ScrollingCoordinator when the
    115     // ScrollingCoordinator's page is destroyed.
    116     ASSERT(ScrollingThread::isCurrentThread());
    117 
    118     // Since this can potentially be the last reference to the scrolling coordinator,
    119     // we need to release it on the main thread since it has member variables (such as timers)
    120     // that expect to be destroyed from the main thread.
    121     callOnMainThread(bind(derefScrollingCoordinator, m_scrollingCoordinator.release().leakRef()));
    122 }
    123 
    12485void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree)
    12586{
    126     ASSERT(ScrollingThread::isCurrentThread());
    127 
    12887    bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode();
    12988   
     
    239198}
    240199
    241 void ScrollingTree::updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
    242 {
    243     if (!m_scrollingCoordinator)
    244         return;
    245 
    246     {
    247         MutexLocker lock(m_mutex);
    248         m_mainFrameScrollPosition = scrollPosition;
    249     }
    250 
    251     callOnMainThread(bind(&ScrollingCoordinator::scheduleUpdateMainFrameScrollPosition, m_scrollingCoordinator.get(), scrollPosition, m_isHandlingProgrammaticScroll, scrollingLayerPositionAction));
    252 }
    253 
    254200IntPoint ScrollingTree::mainFrameScrollPosition()
    255201{
     
    258204}
    259205
    260 #if PLATFORM(MAC)
    261 void ScrollingTree::handleWheelEventPhase(PlatformWheelEventPhase phase)
    262 {
    263     if (!m_scrollingCoordinator)
    264         return;
    265 
    266     callOnMainThread(bind(&ScrollingCoordinator::handleWheelEventPhase, m_scrollingCoordinator.get(), phase));
    267 }
    268 #endif
     206void ScrollingTree::setMainFrameScrollPosition(IntPoint position)
     207{
     208    MutexLocker lock(m_mutex);
     209    m_mainFrameScrollPosition = position;
     210}
    269211
    270212bool ScrollingTree::isRubberBandInProgress()
     
    319261    return m_rubberBandsAtTop;
    320262}
    321    
     263
     264bool ScrollingTree::isHandlingProgrammaticScroll()
     265{
     266    return m_isHandlingProgrammaticScroll;
     267}
     268
    322269void ScrollingTree::setScrollPinningBehavior(ScrollPinningBehavior pinning)
    323270{
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r161194 r161198  
    3636#include <wtf/OwnPtr.h>
    3737#include <wtf/PassOwnPtr.h>
    38 #include <wtf/PassRefPtr.h>
    39 #include <wtf/RefPtr.h>
    4038#include <wtf/ThreadSafeRefCounted.h>
    41 
    42 #if PLATFORM(MAC)
    43 #include <wtf/RetainPtr.h>
    44 OBJC_CLASS CALayer;
    45 #endif
    4639
    4740namespace WebCore {
    4841
    4942class IntPoint;
     43class ScrollingStateTree;
    5044class ScrollingStateNode;
    51 class ScrollingStateTree;
    5245class ScrollingTreeNode;
    5346class ScrollingTreeScrollingNode;
    5447
    55 // The ScrollingTree class lives almost exclusively on the scrolling thread and manages the
    56 // hierarchy of scrollable regions on the page. It's also responsible for dispatching events
    57 // to the correct scrolling tree nodes or dispatching events back to the ScrollingCoordinator
    58 // object on the main thread if they can't be handled on the scrolling thread for various reasons.
    5948class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
    6049public:
    61     static PassRefPtr<ScrollingTree> create(ScrollingCoordinator*);
    62     ~ScrollingTree();
     50    ScrollingTree();
     51    virtual ~ScrollingTree();
    6352
    6453    enum EventResult {
     
    6756        SendToMainThread
    6857    };
     58   
     59    virtual bool isThreadedScrollingTree() const { return false; }
    6960
    70     // Can be called from any thread. Will try to handle the wheel event on the scrolling thread.
    71     // Returns true if the wheel event can be handled on the scrolling thread and false if the
    72     // event must be sent again to the WebCore event handler.
    73     EventResult tryToHandleWheelEvent(const PlatformWheelEvent&);
    74     bool hasWheelEventHandlers() const { return m_hasWheelEventHandlers; }
    75 
    76     // Must be called from the scrolling thread. Handles the wheel event.
    77     void handleWheelEvent(const PlatformWheelEvent&);
     61    virtual EventResult tryToHandleWheelEvent(const PlatformWheelEvent&) = 0;
     62    bool shouldHandleWheelEventSynchronously(const PlatformWheelEvent&);
    7863
    7964    void setMainFrameIsRubberBanding(bool);
    8065    bool isRubberBandInProgress();
    8166
    82     void invalidate();
    83     void commitNewTreeState(PassOwnPtr<ScrollingStateTree>);
     67    virtual void invalidate() { }
     68    virtual void commitNewTreeState(PassOwnPtr<ScrollingStateTree>);
    8469
    8570    void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom);
    8671
    87     void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition);
     72    virtual void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) = 0;
    8873    IntPoint mainFrameScrollPosition();
    8974
    9075#if PLATFORM(MAC)
    91     void handleWheelEventPhase(PlatformWheelEventPhase);
     76    virtual void handleWheelEventPhase(PlatformWheelEventPhase) = 0;
    9277#endif
    9378
     
    9984    bool rubberBandsAtTop();
    10085    bool rubberBandsAtBottom();
     86    bool isHandlingProgrammaticScroll();
    10187   
    10288    void setScrollPinningBehavior(ScrollPinningBehavior);
     
    11096    ScrollingTreeScrollingNode* rootNode() const { return m_rootNode.get(); }
    11197
     98protected:
     99    void setMainFrameScrollPosition(IntPoint);
     100    virtual void handleWheelEvent(const PlatformWheelEvent&);
     101
    112102private:
    113     explicit ScrollingTree(ScrollingCoordinator*);
    114 
    115103    void removeDestroyedNodes(const ScrollingStateTree&);
    116104    void updateTreeFromStateNode(const ScrollingStateNode*);
    117105
    118     RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
    119106    OwnPtr<ScrollingTreeScrollingNode> m_rootNode;
    120107
     
    144131};
    145132
     133#define SCROLLING_TREE_TYPE_CASTS(ToValueTypeName, predicate) \
     134    TYPE_CASTS_BASE(ToValueTypeName, ScrollingTree, value, value->predicate, value.predicate)
     135
    146136} // namespace WebCore
    147137
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h

    r160944 r161198  
    3737class ScrollingStateScrollingNode;
    3838class ScrollingStateTree;
     39class ThreadedScrollingTree;
    3940
    4041class ScrollingCoordinatorMac : public ScrollingCoordinator {
     
    115116
    116117    OwnPtr<ScrollingStateTree> m_scrollingStateTree;
    117     RefPtr<ScrollingTree> m_scrollingTree;
     118    RefPtr<ThreadedScrollingTree> m_scrollingTree;
    118119    Timer<ScrollingCoordinatorMac> m_scrollingStateTreeCommitterTimer;
    119120};
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm

    r160944 r161198  
    4747#include "ScrollingStateTree.h"
    4848#include "ScrollingThread.h"
    49 #include "ScrollingTree.h"
     49#include "ThreadedScrollingTree.h"
    5050#include "TiledBacking.h"
    5151#include <wtf/Functional.h>
     
    6262    : ScrollingCoordinator(page)
    6363    , m_scrollingStateTree(ScrollingStateTree::create())
    64     , m_scrollingTree(ScrollingTree::create(this))
     64    , m_scrollingTree(ThreadedScrollingTree::create(this))
    6565    , m_scrollingStateTreeCommitterTimer(this, &ScrollingCoordinatorMac::scrollingStateTreeCommitterTimerFired)
    6666{
     
    233233        return false;
    234234
    235     ScrollingThread::dispatch(bind(&ScrollingTree::handleWheelEvent, m_scrollingTree.get(), wheelEvent));
    236 
     235    ScrollingThread::dispatch(bind(&ThreadedScrollingTree::handleWheelEvent, m_scrollingTree.get(), wheelEvent));
    237236    return true;
    238237}
  • trunk/Source/WebKit2/ChangeLog

    r161192 r161198  
     12014-01-01  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Create a ThreadedScrollingTree subclass of ScrollingTree, and push all knowledge of the scrolling thread into it
     4        https://bugs.webkit.org/show_bug.cgi?id=126362
     5
     6        Reviewed by Sam Weinig.
     7
     8        Eventually we'll have a ScrollingTree in situations where there is no scrolling
     9        thread, so make the ScrollingTree base class thread-agnostic (but threadsafe),
     10        and subclass it in ThreadedScrollingTree for scrolling-thread-specific functionality.
     11       
     12        The ScrollingTree base class also no longer needs to know about the
     13        ScrollingCoordinator.
     14
     15        ScrollingCoordinatorMac creates a ThreadedScrollingTree.
     16
     17        * WebProcess/WebPage/EventDispatcher.cpp:
     18        (WebKit::EventDispatcher::addScrollingTreeForPage):
     19        (WebKit::EventDispatcher::wheelEvent):
     20        * WebProcess/WebPage/EventDispatcher.h:
     21
    1222014-01-01  Simon Fraser  <simon.fraser@apple.com>
    223
  • trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp

    r161148 r161198  
    4040#include <WebCore/ScrollingCoordinator.h>
    4141#include <WebCore/ScrollingThread.h>
    42 #include <WebCore/ScrollingTree.h>
     42#include <WebCore/ThreadedScrollingTree.h>
    4343#endif
    4444
     
    6868    ASSERT(webPage->corePage()->scrollingCoordinator());
    6969    ASSERT(!m_scrollingTrees.contains(webPage->pageID()));
    70     m_scrollingTrees.set(webPage->pageID(), webPage->corePage()->scrollingCoordinator()->scrollingTree());
     70    m_scrollingTrees.set(webPage->pageID(), toThreadedScrollingTree(webPage->corePage()->scrollingCoordinator()->scrollingTree()));
    7171}
    7272
     
    8989#if ENABLE(ASYNC_SCROLLING)
    9090    MutexLocker locker(m_scrollingTreesMutex);
    91     if (ScrollingTree* scrollingTree = m_scrollingTrees.get(pageID)) {
     91    if (ThreadedScrollingTree* scrollingTree = m_scrollingTrees.get(pageID)) {
    9292        PlatformWheelEvent platformWheelEvent = platform(wheelEvent);
    9393
     
    9797        // We only need to do this at the beginning of the gesture.
    9898        if (platformWheelEvent.phase() == PlatformWheelEventPhaseBegan)
    99             ScrollingThread::dispatch(bind(&ScrollingTree::setCanRubberBandState, scrollingTree, canRubberBandAtLeft, canRubberBandAtRight, canRubberBandAtTop, canRubberBandAtBottom));
     99            ScrollingThread::dispatch(bind(&ThreadedScrollingTree::setCanRubberBandState, scrollingTree, canRubberBandAtLeft, canRubberBandAtRight, canRubberBandAtTop, canRubberBandAtBottom));
    100100
    101101        ScrollingTree::EventResult result = scrollingTree->tryToHandleWheelEvent(platformWheelEvent);
  • trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h

    r161148 r161198  
    3434
    3535namespace WebCore {
    36     class ScrollingTree;
     36class ThreadedScrollingTree;
    3737}
    3838
     
    7575#if ENABLE(ASYNC_SCROLLING)
    7676    Mutex m_scrollingTreesMutex;
    77     HashMap<uint64_t, RefPtr<WebCore::ScrollingTree>> m_scrollingTrees;
     77    HashMap<uint64_t, RefPtr<WebCore::ThreadedScrollingTree>> m_scrollingTrees;
    7878#endif
    7979};
Note: See TracChangeset for help on using the changeset viewer.