Changeset 161198 in webkit
- Timestamp:
- Jan 1, 2014 3:20:25 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r161197 r161198 1 2014-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 1 51 2014-01-01 Andreas Kling <akling@apple.com> 2 52 -
trunk/Source/WebCore/WebCore.exp.in
r161035 r161198 2864 2864 #if ENABLE(ASYNC_SCROLLING) 2865 2865 __ZN7WebCore13ScrollingTree21setCanRubberBandStateEbbbb 2866 __ZN7WebCore13ScrollingTree21tryToHandleWheelEventERKNS_18PlatformWheelEventE2867 2866 __ZN7WebCore13ScrollingTree37setScrollingPerformanceLoggingEnabledEb 2868 2867 __ZN7WebCore13ScrollingTreeD1Ev -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r161123 r161198 471 471 0F5B7A5510F65D7A00376302 /* RenderEmbeddedObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; 472 472 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, ); }; }; 474 476 0FA24D79162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */; }; 475 477 0FA24D7A162DF91900A3F4C0 /* GraphicsLayerUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2941 2943 931CBD0F161A44E900E4C874 /* ScrollingStateScrollingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD09161A44E900E4C874 /* ScrollingStateScrollingNode.h */; }; 2942 2944 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, ); }; }; 2944 2946 931CBD13161A44F800E4C874 /* ScrollingStateNodeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 931CBD12161A44F800E4C874 /* ScrollingStateNodeMac.mm */; }; 2945 2947 931D72F615FE695300C4C07E /* LayoutMilestones.h in Headers */ = {isa = PBXBuildFile; fileRef = 931D72F515FE695300C4C07E /* LayoutMilestones.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 5468 5470 CE08C3D1152B599A0021B8C2 /* AlternativeTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE08C3CF152B599A0021B8C2 /* AlternativeTextController.cpp */; }; 5469 5471 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 */; };5472 5472 CE7B2DB31586ABAD0098B3FA /* AlternativeTextUIController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5473 5473 CE7B2DB41586ABAD0098B3FA /* AlternativeTextUIController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */; }; … … 6331 6331 FE4AADEE16D2C37400026FFC /* AbstractSQLStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4AADEC16D2C37400026FFC /* AbstractSQLStatement.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6332 6332 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 */; }; 6333 6334 FE6F6AAF169E057500FC30A2 /* DatabaseBackendContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE6F6AAD169E057500FC30A2 /* DatabaseBackendContext.cpp */; }; 6334 6335 FE6F6AB0169E057500FC30A2 /* DatabaseBackendContext.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6F6AAE169E057500FC30A2 /* DatabaseBackendContext.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 6353 6354 FEBC5F3216BD0CC300659BD3 /* DatabaseBase.h in Headers */ = {isa = PBXBuildFile; fileRef = FEBC5F3016BD0CC300659BD3 /* DatabaseBase.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6354 6355 FED13D3A0CEA934600D89466 /* EditorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D390CEA934600D89466 /* EditorIOS.mm */; }; 6356 FED13D3D0CEA936A00D89466 /* FrameIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D3B0CEA936A00D89466 /* FrameIOS.mm */; }; 6355 6357 FED13D520CEA949700D89466 /* RenderThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = FED13D500CEA949700D89466 /* RenderThemeIOS.h */; }; 6356 6358 FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */; }; … … 7100 7102 0F605AEA15F94848004DF0C0 /* ScrollingConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingConstraints.cpp; sourceTree = "<group>"; }; 7101 7103 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>"; }; 7102 7106 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerUpdater.cpp; sourceTree = "<group>"; }; 7103 7107 0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerUpdater.h; sourceTree = "<group>"; }; … … 12626 12630 CE08C3CF152B599A0021B8C2 /* AlternativeTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AlternativeTextController.cpp; sourceTree = "<group>"; }; 12627 12631 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>"; };12630 12632 CE5CB1B314EDAB6F00BB2795 /* EventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSender.h; sourceTree = "<group>"; }; 12631 12633 CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AlternativeTextUIController.h; path = mac/AlternativeTextUIController.h; sourceTree = "<group>"; }; … … 13584 13586 FE4AADEC16D2C37400026FFC /* AbstractSQLStatement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractSQLStatement.h; sourceTree = "<group>"; }; 13585 13587 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>"; }; 13586 13589 FE6F6AAD169E057500FC30A2 /* DatabaseBackendContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseBackendContext.cpp; sourceTree = "<group>"; }; 13587 13590 FE6F6AAE169E057500FC30A2 /* DatabaseBackendContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseBackendContext.h; sourceTree = "<group>"; }; … … 13606 13609 FEBC5F3016BD0CC300659BD3 /* DatabaseBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseBase.h; sourceTree = "<group>"; }; 13607 13610 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>"; }; 13608 13612 FED13D500CEA949700D89466 /* RenderThemeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderThemeIOS.h; sourceTree = "<group>"; }; 13609 13613 FEDEF83F16797108000E444A /* DatabaseStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseStrategy.cpp; sourceTree = "<group>"; }; … … 14278 14282 sourceTree = BUILT_PRODUCTS_DIR; 14279 14283 }; 14284 18A6CD6F0D8F2025001DC3CE /* ios */ = { 14285 isa = PBXGroup; 14286 children = ( 14287 FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */, 14288 FED13D3B0CEA936A00D89466 /* FrameIOS.mm */, 14289 ); 14290 path = ios; 14291 sourceTree = "<group>"; 14292 }; 14280 14293 1A2E6E560CC551E0004A2062 /* sql */ = { 14281 14294 isa = PBXGroup; … … 14477 14490 9391A99A1629D6FF00297330 /* ScrollingTreeScrollingNode.cpp */, 14478 14491 9391A99B1629D70000297330 /* ScrollingTreeScrollingNode.h */, 14492 0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */, 14493 0F6383DC18615B29003E5DB5 /* ThreadedScrollingTree.h */, 14479 14494 ); 14480 14495 path = scrolling; … … 20546 20561 sourceTree = "<group>"; 20547 20562 }; 20548 18A6CD6F0D8F2025001DC3CE /* ios */ = {20549 isa = PBXGroup;20550 children = (20551 FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */,20552 FED13D3B0CEA936A00D89466 /* FrameIOS.mm */,20553 );20554 path = ios;20555 sourceTree = "<group>";20556 };20557 20563 CE79D68617F220ED00815C00 /* ios */ = { 20558 20564 isa = PBXGroup; … … 24182 24188 A8239E0109B3CF8A00B60641 /* Logging.h in Headers */, 24183 24189 510194411836D20800925523 /* IDBIndexWriterLevelDB.h in Headers */, 24190 0F6383DE18615B29003E5DB5 /* ThreadedScrollingTree.h in Headers */, 24184 24191 9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */, 24185 24192 E187056316E54A0D00585E97 /* MainThreadTask.h in Headers */, … … 26890 26897 209B456B16796A7E00E54E4E /* JSCryptoCustom.cpp in Sources */, 26891 26898 BC46C1FA0C0DDC8F0020CFC3 /* JSCSSCharsetRule.cpp in Sources */, 26899 0F6383DD18615B29003E5DB5 /* ThreadedScrollingTree.cpp in Sources */, 26892 26900 409EBDC516B7F3CA00CBA3FC /* JSCSSFontFaceLoadEvent.cpp in Sources */, 26893 26901 BC46C1FC0C0DDC8F0020CFC3 /* JSCSSFontFaceRule.cpp in Sources */, -
trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h
r161191 r161198 73 73 void didRemoveNode(ScrollingNodeID); 74 74 75 PassOwnPtr<ScrollingStateTree> clone();76 77 75 HashMap<ScrollingNodeID, ScrollingStateNode*> m_stateNodeMap; 78 76 OwnPtr<ScrollingStateScrollingNode> m_rootStateNode; -
trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp
r161194 r161198 30 30 31 31 #include "PlatformWheelEvent.h" 32 #include "ScrollingCoordinator.h"33 32 #include "ScrollingStateTree.h" 34 #include "ScrollingThread.h"35 33 #include "ScrollingTreeFixedNode.h" 36 34 #include "ScrollingTreeNode.h" 37 35 #include "ScrollingTreeScrollingNode.h" 38 36 #include "ScrollingTreeStickyNode.h" 39 #include <wtf/MainThread.h>40 37 #include <wtf/TemporaryChange.h> 41 38 42 39 namespace WebCore { 43 40 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) 41 ScrollingTree::ScrollingTree() 42 : m_hasWheelEventHandlers(false) 52 43 , m_rubberBandsAtLeft(true) 53 44 , m_rubberBandsAtRight(true) … … 67 58 ScrollingTree::~ScrollingTree() 68 59 { 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 62 bool 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; 94 77 } 95 78 96 79 void ScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent) 97 80 { 98 ASSERT(ScrollingThread::isCurrentThread());99 100 81 if (m_rootNode) 101 82 m_rootNode->handleWheelEvent(wheelEvent); 102 83 } 103 84 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 ScrollingThread114 // to break the reference cycle between ScrollingTree and ScrollingCoordinator when the115 // 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 124 85 void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree) 125 86 { 126 ASSERT(ScrollingThread::isCurrentThread());127 128 87 bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode(); 129 88 … … 239 198 } 240 199 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 254 200 IntPoint ScrollingTree::mainFrameScrollPosition() 255 201 { … … 258 204 } 259 205 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 206 void ScrollingTree::setMainFrameScrollPosition(IntPoint position) 207 { 208 MutexLocker lock(m_mutex); 209 m_mainFrameScrollPosition = position; 210 } 269 211 270 212 bool ScrollingTree::isRubberBandInProgress() … … 319 261 return m_rubberBandsAtTop; 320 262 } 321 263 264 bool ScrollingTree::isHandlingProgrammaticScroll() 265 { 266 return m_isHandlingProgrammaticScroll; 267 } 268 322 269 void ScrollingTree::setScrollPinningBehavior(ScrollPinningBehavior pinning) 323 270 { -
trunk/Source/WebCore/page/scrolling/ScrollingTree.h
r161194 r161198 36 36 #include <wtf/OwnPtr.h> 37 37 #include <wtf/PassOwnPtr.h> 38 #include <wtf/PassRefPtr.h>39 #include <wtf/RefPtr.h>40 38 #include <wtf/ThreadSafeRefCounted.h> 41 42 #if PLATFORM(MAC)43 #include <wtf/RetainPtr.h>44 OBJC_CLASS CALayer;45 #endif46 39 47 40 namespace WebCore { 48 41 49 42 class IntPoint; 43 class ScrollingStateTree; 50 44 class ScrollingStateNode; 51 class ScrollingStateTree;52 45 class ScrollingTreeNode; 53 46 class ScrollingTreeScrollingNode; 54 47 55 // The ScrollingTree class lives almost exclusively on the scrolling thread and manages the56 // hierarchy of scrollable regions on the page. It's also responsible for dispatching events57 // to the correct scrolling tree nodes or dispatching events back to the ScrollingCoordinator58 // object on the main thread if they can't be handled on the scrolling thread for various reasons.59 48 class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> { 60 49 public: 61 static PassRefPtr<ScrollingTree> create(ScrollingCoordinator*);62 ~ScrollingTree();50 ScrollingTree(); 51 virtual ~ScrollingTree(); 63 52 64 53 enum EventResult { … … 67 56 SendToMainThread 68 57 }; 58 59 virtual bool isThreadedScrollingTree() const { return false; } 69 60 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&); 78 63 79 64 void setMainFrameIsRubberBanding(bool); 80 65 bool isRubberBandInProgress(); 81 66 82 v oid invalidate();83 v oid commitNewTreeState(PassOwnPtr<ScrollingStateTree>);67 virtual void invalidate() { } 68 virtual void commitNewTreeState(PassOwnPtr<ScrollingStateTree>); 84 69 85 70 void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom); 86 71 87 v oid updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition);72 virtual void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) = 0; 88 73 IntPoint mainFrameScrollPosition(); 89 74 90 75 #if PLATFORM(MAC) 91 v oid handleWheelEventPhase(PlatformWheelEventPhase);76 virtual void handleWheelEventPhase(PlatformWheelEventPhase) = 0; 92 77 #endif 93 78 … … 99 84 bool rubberBandsAtTop(); 100 85 bool rubberBandsAtBottom(); 86 bool isHandlingProgrammaticScroll(); 101 87 102 88 void setScrollPinningBehavior(ScrollPinningBehavior); … … 110 96 ScrollingTreeScrollingNode* rootNode() const { return m_rootNode.get(); } 111 97 98 protected: 99 void setMainFrameScrollPosition(IntPoint); 100 virtual void handleWheelEvent(const PlatformWheelEvent&); 101 112 102 private: 113 explicit ScrollingTree(ScrollingCoordinator*);114 115 103 void removeDestroyedNodes(const ScrollingStateTree&); 116 104 void updateTreeFromStateNode(const ScrollingStateNode*); 117 105 118 RefPtr<ScrollingCoordinator> m_scrollingCoordinator;119 106 OwnPtr<ScrollingTreeScrollingNode> m_rootNode; 120 107 … … 144 131 }; 145 132 133 #define SCROLLING_TREE_TYPE_CASTS(ToValueTypeName, predicate) \ 134 TYPE_CASTS_BASE(ToValueTypeName, ScrollingTree, value, value->predicate, value.predicate) 135 146 136 } // namespace WebCore 147 137 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h
r160944 r161198 37 37 class ScrollingStateScrollingNode; 38 38 class ScrollingStateTree; 39 class ThreadedScrollingTree; 39 40 40 41 class ScrollingCoordinatorMac : public ScrollingCoordinator { … … 115 116 116 117 OwnPtr<ScrollingStateTree> m_scrollingStateTree; 117 RefPtr< ScrollingTree> m_scrollingTree;118 RefPtr<ThreadedScrollingTree> m_scrollingTree; 118 119 Timer<ScrollingCoordinatorMac> m_scrollingStateTreeCommitterTimer; 119 120 }; -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
r160944 r161198 47 47 #include "ScrollingStateTree.h" 48 48 #include "ScrollingThread.h" 49 #include " ScrollingTree.h"49 #include "ThreadedScrollingTree.h" 50 50 #include "TiledBacking.h" 51 51 #include <wtf/Functional.h> … … 62 62 : ScrollingCoordinator(page) 63 63 , m_scrollingStateTree(ScrollingStateTree::create()) 64 , m_scrollingTree( ScrollingTree::create(this))64 , m_scrollingTree(ThreadedScrollingTree::create(this)) 65 65 , m_scrollingStateTreeCommitterTimer(this, &ScrollingCoordinatorMac::scrollingStateTreeCommitterTimerFired) 66 66 { … … 233 233 return false; 234 234 235 ScrollingThread::dispatch(bind(&ScrollingTree::handleWheelEvent, m_scrollingTree.get(), wheelEvent)); 236 235 ScrollingThread::dispatch(bind(&ThreadedScrollingTree::handleWheelEvent, m_scrollingTree.get(), wheelEvent)); 237 236 return true; 238 237 } -
trunk/Source/WebKit2/ChangeLog
r161192 r161198 1 2014-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 1 22 2014-01-01 Simon Fraser <simon.fraser@apple.com> 2 23 -
trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp
r161148 r161198 40 40 #include <WebCore/ScrollingCoordinator.h> 41 41 #include <WebCore/ScrollingThread.h> 42 #include <WebCore/ ScrollingTree.h>42 #include <WebCore/ThreadedScrollingTree.h> 43 43 #endif 44 44 … … 68 68 ASSERT(webPage->corePage()->scrollingCoordinator()); 69 69 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())); 71 71 } 72 72 … … 89 89 #if ENABLE(ASYNC_SCROLLING) 90 90 MutexLocker locker(m_scrollingTreesMutex); 91 if ( ScrollingTree* scrollingTree = m_scrollingTrees.get(pageID)) {91 if (ThreadedScrollingTree* scrollingTree = m_scrollingTrees.get(pageID)) { 92 92 PlatformWheelEvent platformWheelEvent = platform(wheelEvent); 93 93 … … 97 97 // We only need to do this at the beginning of the gesture. 98 98 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)); 100 100 101 101 ScrollingTree::EventResult result = scrollingTree->tryToHandleWheelEvent(platformWheelEvent); -
trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h
r161148 r161198 34 34 35 35 namespace WebCore { 36 classScrollingTree;36 class ThreadedScrollingTree; 37 37 } 38 38 … … 75 75 #if ENABLE(ASYNC_SCROLLING) 76 76 Mutex m_scrollingTreesMutex; 77 HashMap<uint64_t, RefPtr<WebCore:: ScrollingTree>> m_scrollingTrees;77 HashMap<uint64_t, RefPtr<WebCore::ThreadedScrollingTree>> m_scrollingTrees; 78 78 #endif 79 79 };
Note: See TracChangeset
for help on using the changeset viewer.