Scrolling coordinator should handle pages being restored from the page cache
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Feb 2012 23:37:25 +0000 (23:37 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Feb 2012 23:37:25 +0000 (23:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78753
<rdar://problem/10866171>

Reviewed by Sam Weinig.

Replace ScrollingCoordinator::frameViewScrollLayerDidChange with a new member function,
ScrollingCoordinator::frameViewRootLayerDidChange which is called whenever the root layer
of the frame view changes (which happens on back/forward navigation as well).

In this function, reset the scrolling tree state from the frame view.

* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::scrollLayerForFrameView):
Add a helper function.

(WebCore::ScrollingCoordinator::frameViewRootLayerDidChange):
Reset the entire scrolling tree state.

(WebCore::ScrollingCoordinator::updateMainFrameScrollPositionAndScrollLayerPosition):
Call the newly added helper function.

* page/scrolling/ScrollingCoordinator.h:
(ScrollingCoordinator):
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
Remove frameViewScrollLayerDidChange.

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::ensureRootLayer):
Remove call to ScrollingCoordinator::frameViewScrollLayerDidChange.

(WebCore::RenderLayerCompositor::attachRootLayer):
Call ScrollingCoordinator::frameViewRootLayerDidChange.

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

Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
Source/WebCore/rendering/RenderLayerCompositor.cpp

index 73f53bb..714922c 100644 (file)
@@ -1,3 +1,39 @@
+2012-02-15  Anders Carlsson  <andersca@apple.com>
+
+        Scrolling coordinator should handle pages being restored from the page cache
+        https://bugs.webkit.org/show_bug.cgi?id=78753
+        <rdar://problem/10866171>
+
+        Reviewed by Sam Weinig.
+
+        Replace ScrollingCoordinator::frameViewScrollLayerDidChange with a new member function,
+        ScrollingCoordinator::frameViewRootLayerDidChange which is called whenever the root layer
+        of the frame view changes (which happens on back/forward navigation as well).
+
+        In this function, reset the scrolling tree state from the frame view.
+
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::scrollLayerForFrameView):
+        Add a helper function.
+
+        (WebCore::ScrollingCoordinator::frameViewRootLayerDidChange):
+        Reset the entire scrolling tree state.
+
+        (WebCore::ScrollingCoordinator::updateMainFrameScrollPositionAndScrollLayerPosition):
+        Call the newly added helper function.
+
+        * page/scrolling/ScrollingCoordinator.h:
+        (ScrollingCoordinator):
+        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+        Remove frameViewScrollLayerDidChange.
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::ensureRootLayer):
+        Remove call to ScrollingCoordinator::frameViewScrollLayerDidChange.
+
+        (WebCore::RenderLayerCompositor::attachRootLayer):
+        Call ScrollingCoordinator::frameViewRootLayerDidChange.
+
 2012-02-15  Enrica Casucci  <enrica@apple.com>
 
         Refactor ClipboardMac class to use PlatformStrategies.
index db7696a..7ec2765 100644 (file)
@@ -168,6 +168,35 @@ void ScrollingCoordinator::frameViewHasFixedObjectsDidChange(FrameView* frameVie
     updateShouldUpdateScrollLayerPositionOnMainThread();
 }
 
+static GraphicsLayer* scrollLayerForFrameView(FrameView* frameView)
+{
+    Frame* frame = frameView->frame();
+    if (!frame)
+        return 0;
+
+    RenderView* renderView = frame->contentRenderer();
+    if (!renderView)
+        return 0;
+
+    return renderView->compositor()->scrollLayer();
+}
+
+void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
+{
+    ASSERT(isMainThread());
+    ASSERT(m_page);
+
+    if (frameView->frame() != m_page->mainFrame())
+        return;
+
+    frameViewLayoutUpdated(frameView);
+    recomputeWheelEventHandlerCount();
+    updateShouldUpdateScrollLayerPositionOnMainThread();
+    m_scrollingTreeState->setScrollLayer(scrollLayerForFrameView(frameView));
+
+    scheduleTreeStateCommit();
+}
+
 bool ScrollingCoordinator::requestScrollPositionUpdate(FrameView* frameView, const IntPoint& scrollPosition)
 {
     ASSERT(isMainThread());
@@ -211,12 +240,7 @@ void ScrollingCoordinator::updateMainFrameScrollPosition(const IntPoint& scrollP
 void ScrollingCoordinator::updateMainFrameScrollPositionAndScrollLayerPosition(const IntPoint& scrollPosition)
 {
     FrameView* frameView = m_page->mainFrame()->view();
-
-    RenderView* renderView = m_page->mainFrame()->contentRenderer();
-    if (!renderView)
-        return;
-
-    GraphicsLayer* scrollLayer = renderView->compositor()->scrollLayer();
+    GraphicsLayer* scrollLayer = scrollLayerForFrameView(frameView);
     if (!scrollLayer)
         return;
 
index fd30453..53c20bf 100644 (file)
@@ -80,8 +80,8 @@ public:
     // so it can make sure they stay fixed even when we scroll on the scrolling thread.
     void frameViewHasFixedObjectsDidChange(FrameView*);
 
-    // Should be called whenever the scroll layer for the given frame view changes.
-    void frameViewScrollLayerDidChange(FrameView*, const GraphicsLayer*);
+    // Should be called whenever the root layer for the given frame view changes.
+    void frameViewRootLayerDidChange(FrameView*);
 
     // Should be called whenever the horizontal scrollbar layer for the given frame view changes.
     void frameViewHorizontalScrollbarLayerDidChange(FrameView*, GraphicsLayer* horizontalScrollbarLayer);
index 31fa766..a713cd4 100644 (file)
@@ -64,18 +64,6 @@ void ScrollingCoordinator::frameViewVerticalScrollbarLayerDidChange(FrameView* f
     // FIXME: Implement.
 }
 
-void ScrollingCoordinator::frameViewScrollLayerDidChange(FrameView* frameView, const GraphicsLayer* scrollLayer)
-{
-    ASSERT(isMainThread());
-    ASSERT(m_page);
-
-    if (frameView->frame() != m_page->mainFrame())
-        return;
-
-    m_scrollingTreeState->setScrollLayer(scrollLayer);
-    scheduleTreeStateCommit();
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(THREADED_SCROLLING)
index f4f9da7..d5d25d2 100644 (file)
@@ -1936,11 +1936,6 @@ void RenderLayerCompositor::ensureRootLayer()
 
             frameViewDidChangeSize();
             frameViewDidScroll();
-
-#if ENABLE(THREADED_SCROLLING)
-            if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
-                scrollingCoordinator->frameViewScrollLayerDidChange(m_renderView->frameView(), m_scrollLayer.get());
-#endif
         }
     } else {
         if (m_overflowControlsHostLayer) {
@@ -2024,7 +2019,12 @@ void RenderLayerCompositor::attachRootLayer(RootLayerAttachment attachment)
             break;
         }
     }
-    
+
+#if ENABLE(THREADED_SCROLLING)
+    if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
+        scrollingCoordinator->frameViewRootLayerDidChange(m_renderView->frameView());
+#endif
+
     m_rootLayerAttachment = attachment;
     rootLayerAttachmentChanged();
 }