Title: [115678] trunk/Source
Revision
115678
Author
[email protected]
Date
2012-04-30 15:21:56 -0700 (Mon, 30 Apr 2012)

Log Message

Add a way to asynchronously call a function once the scroll position of a page has been updated
https://bugs.webkit.org/show_bug.cgi?id=85237

Reviewed by Sam Weinig.

Source/WebCore:

* WebCore.exp.in:
Export functions needed by WebKit2.

* page/scrolling/ScrollingCoordinator.h:
Make commitTreeStateIfNeeded public.

Source/WebKit2:

Add DrawingArea::dispatchAfterEnsuringUpdatedScrollPosition, which will call the given function object after
making sure that the scroll position has been updated correctly. This is important for TiledCoreAnimationDrawingArea,
which updates the scrolling position asynchronously.

* WebProcess/WebPage/DrawingArea.cpp:
(WebKit::DrawingArea::dispatchAfterEnsuringUpdatedScrollPosition):
Since scroll position updates are synchronous by default, just call function directly.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition):
Commit the layer tree state and then use ScrollingThread::dispatchBarrier to make sure that the function is called when any
scroll position changes have been made. If possible, freeze the layer tree to make sure that the update is atomic.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (115677 => 115678)


--- trunk/Source/WebCore/ChangeLog	2012-04-30 22:14:15 UTC (rev 115677)
+++ trunk/Source/WebCore/ChangeLog	2012-04-30 22:21:56 UTC (rev 115678)
@@ -1,3 +1,16 @@
+2012-04-30  Anders Carlsson  <[email protected]>
+
+        Add a way to asynchronously call a function once the scroll position of a page has been updated
+        https://bugs.webkit.org/show_bug.cgi?id=85237
+
+        Reviewed by Sam Weinig.
+
+        * WebCore.exp.in:
+        Export functions needed by WebKit2.
+
+        * page/scrolling/ScrollingCoordinator.h:
+        Make commitTreeStateIfNeeded public.
+
 2012-04-30  Kentaro Hara  <[email protected]>
 
         WebGLRenderingContext methods should throw TypeError for not enough arguments

Modified: trunk/Source/WebCore/WebCore.exp.in (115677 => 115678)


--- trunk/Source/WebCore/WebCore.exp.in	2012-04-30 22:14:15 UTC (rev 115677)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-04-30 22:21:56 UTC (rev 115678)
@@ -2177,7 +2177,9 @@
 __ZN7WebCore13ScrollingTree21tryToHandleWheelEventERKNS_18PlatformWheelEventE
 __ZN7WebCore13ScrollingTree22updateBackForwardStateEbb
 __ZN7WebCore13ScrollingTreeD1Ev
+__ZN7WebCore15ScrollingThread15dispatchBarrierERKN3WTF8FunctionIFvvEEE
 __ZN7WebCore15ScrollingThread8dispatchERKN3WTF8FunctionIFvvEEE
+__ZN7WebCore20ScrollingCoordinator23commitTreeStateIfNeededEv
 __ZN7WebCore20ScrollingCoordinator44setForceMainThreadScrollLayerPositionUpdatesEb
 __ZN7WebCore4Page20scrollingCoordinatorEv
 __ZNK7WebCore20ScrollingCoordinator13scrollingTreeEv

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h (115677 => 115678)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2012-04-30 22:14:15 UTC (rev 115677)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2012-04-30 22:21:56 UTC (rev 115678)
@@ -64,6 +64,7 @@
 
 #if ENABLE(THREADED_SCROLLING)
     ScrollingTree* scrollingTree() const;
+    void commitTreeStateIfNeeded();
 #endif
 
     // Return whether this scrolling coordinator handles scrolling for the given frame view.
@@ -150,7 +151,6 @@
     void scheduleTreeStateCommit();
 
     void scrollingTreeStateCommitterTimerFired(Timer<ScrollingCoordinator>*);
-    void commitTreeStateIfNeeded();
     void commitTreeState();
 
     OwnPtr<ScrollingTreeState> m_scrollingTreeState;

Modified: trunk/Source/WebKit2/ChangeLog (115677 => 115678)


--- trunk/Source/WebKit2/ChangeLog	2012-04-30 22:14:15 UTC (rev 115677)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-30 22:21:56 UTC (rev 115678)
@@ -1,5 +1,25 @@
 2012-04-30  Anders Carlsson  <[email protected]>
 
+        Add a way to asynchronously call a function once the scroll position of a page has been updated
+        https://bugs.webkit.org/show_bug.cgi?id=85237
+
+        Reviewed by Sam Weinig.
+
+        Add DrawingArea::dispatchAfterEnsuringUpdatedScrollPosition, which will call the given function object after
+        making sure that the scroll position has been updated correctly. This is important for TiledCoreAnimationDrawingArea,
+        which updates the scrolling position asynchronously.
+
+        * WebProcess/WebPage/DrawingArea.cpp:
+        (WebKit::DrawingArea::dispatchAfterEnsuringUpdatedScrollPosition):
+        Since scroll position updates are synchronous by default, just call function directly.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition):
+        Commit the layer tree state and then use ScrollingThread::dispatchBarrier to make sure that the function is called when any
+        scroll position changes have been made. If possible, freeze the layer tree to make sure that the update is atomic.
+
+2012-04-30  Anders Carlsson  <[email protected]>
+
         Fix ALL the build failures!
 
         * UIProcess/API/mac/WKView.mm:

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp (115677 => 115678)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp	2012-04-30 22:14:15 UTC (rev 115677)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp	2012-04-30 22:21:56 UTC (rev 115678)
@@ -61,4 +61,10 @@
 {
 }
 
+void DrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>& function)
+{
+    // Scroll position updates are synchronous by default so we can just call the function right away here.
+    function();
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (115677 => 115678)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h	2012-04-30 22:14:15 UTC (rev 115677)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h	2012-04-30 22:21:56 UTC (rev 115678)
@@ -29,6 +29,7 @@
 #include "DrawingAreaInfo.h"
 #include <WebCore/FloatPoint.h>
 #include <WebCore/IntRect.h>
+#include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
 
@@ -96,6 +97,8 @@
     virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&) = 0;
 #endif
 
+    virtual void dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>&);
+
 protected:
     DrawingArea(DrawingAreaType, WebPage*);
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (115677 => 115678)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2012-04-30 22:14:15 UTC (rev 115677)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2012-04-30 22:21:56 UTC (rev 115678)
@@ -66,6 +66,8 @@
     virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) OVERRIDE;
     virtual void updatePreferences() OVERRIDE;
 
+    virtual void dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>&) OVERRIDE;
+
     // WebCore::GraphicsLayerClient
     virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) OVERRIDE;
     virtual void notifySyncRequired(const WebCore::GraphicsLayer*) OVERRIDE;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (115677 => 115678)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2012-04-30 22:14:15 UTC (rev 115677)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2012-04-30 22:21:56 UTC (rev 115678)
@@ -223,6 +223,25 @@
     ScrollingThread::dispatch(bind(&ScrollingTree::setDebugRootLayer, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), m_debugInfoLayer));
 }
 
+void TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>& functionRef)
+{
+    m_webPage->ref();
+    m_webPage->corePage()->scrollingCoordinator()->commitTreeStateIfNeeded();
+
+    if (!m_layerTreeStateIsFrozen)
+        m_layerFlushScheduler.suspend();
+
+    Function<void ()> function = functionRef;
+    ScrollingThread::dispatchBarrier(bind(^{
+        function();
+
+        if (!m_layerTreeStateIsFrozen)
+            m_layerFlushScheduler.resume();
+
+        m_webPage->deref();
+    }));
+}
+
 void TiledCoreAnimationDrawingArea::notifyAnimationStarted(const GraphicsLayer*, double)
 {
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to