Add a setting to enable composited scrolling for frames
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2013 01:51:14 +0000 (01:51 +0000)
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2013 01:51:14 +0000 (01:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104950

Reviewed by James Robinson.

Source/WebCore:

Test: compositing/iframes/iframe-composited-scrolling.html

* page/FrameView.cpp:
(WebCore::FrameView::usesCompositedScrolling): Returns true if compositedScrollingForFramesEnabled and the frame is in forced compositing mode (which is set when forced compositing mode and compositing for scrollable frames are enabled), so that ScrollingCoordinator won't include the region of the frame in the nonFastScrollableRegion.
(WebCore):
* page/FrameView.h:
(FrameView):
* page/Settings.in: Add compositedScrollingForFramesEnabled setting.
* page/scrolling/chromium/ScrollingCoordinatorChromium.cpp:
(WebCore::ScrollingCoordinatorChromium::frameViewLayoutUpdated): Changed the comment about which ScrollableAreas are non-fast-scrollable.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::frameViewDidScroll): Let ScrollongCoordinator know when the scrolling changes for a frame with composited scrolling enabled.

LayoutTests:

Test case to ensure iframes are not added into nonFastScrollableRegion when acceleratedCompositingForScrollableFramesEnabled and compositedScrollingForFramesEnabled.

* compositing/iframes/iframe-composited-scrolling-expected.txt: Added.
* compositing/iframes/iframe-composited-scrolling.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/compositing/iframes/iframe-composited-scrolling-expected.txt [new file with mode: 0644]
LayoutTests/compositing/iframes/iframe-composited-scrolling.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/page/Settings.in
Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp

index 0379253..19ad353 100644 (file)
@@ -1,3 +1,15 @@
+2013-01-07  Xianzhu Wang  <wangxianzhu@chromium.org>
+
+        Add a setting to enable composited scrolling for frames
+        https://bugs.webkit.org/show_bug.cgi?id=104950
+
+        Reviewed by James Robinson.
+
+        Test case to ensure iframes are not added into nonFastScrollableRegion when acceleratedCompositingForScrollableFramesEnabled and compositedScrollingForFramesEnabled.
+
+        * compositing/iframes/iframe-composited-scrolling-expected.txt: Added.
+        * compositing/iframes/iframe-composited-scrolling.html: Added.
+
 2013-01-07  Adam Barth  <abarth@webkit.org>
 
         HTMLTreeBuilder should not depend on Frame
diff --git a/LayoutTests/compositing/iframes/iframe-composited-scrolling-expected.txt b/LayoutTests/compositing/iframes/iframe-composited-scrolling-expected.txt
new file mode 100644 (file)
index 0000000..3be5dec
--- /dev/null
@@ -0,0 +1,2 @@
+PASS
diff --git a/LayoutTests/compositing/iframes/iframe-composited-scrolling.html b/LayoutTests/compositing/iframes/iframe-composited-scrolling.html
new file mode 100644 (file)
index 0000000..a5c7d80
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style>
+    iframe {
+      height: 150px;
+      width: 150px;
+    }
+  </style>
+  <script>
+    if (window.internals) {
+      internals.settings.setForceCompositingMode(true);
+      internals.settings.setAcceleratedCompositingForScrollableFramesEnabled(true);
+      internals.settings.setCompositedScrollingForFramesEnabled(true);
+    }
+    function doTest()
+    {
+      if (window.testRunner) {
+        testRunner.dumpAsText(false);
+        if (window.internals)
+          document.getElementById("result").innerText = window.internals.nonFastScrollableRects(document).length ? "FAIL" : "PASS";
+      }
+    }
+    window.addEventListener("load", doTest, false);
+  </script>
+</head>
+<body>
+  <iframe id="scrollable-iframe" src="resources/subframe.html" style="width: 100px; height: 100px"></iframe>
+  <iframe id="non-scrollable-iframe" src="resources/subframe.html" style="width: 2000px; height: 2000px"></iframe>
+  <pre id="result"></pre>
+</body>
+</html>
index 2ea1cc3..b34d5ab 100644 (file)
@@ -1,3 +1,23 @@
+2013-01-07  Xianzhu Wang  <wangxianzhu@chromium.org>
+
+        Add a setting to enable composited scrolling for frames
+        https://bugs.webkit.org/show_bug.cgi?id=104950
+
+        Reviewed by James Robinson.
+
+        Test: compositing/iframes/iframe-composited-scrolling.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::usesCompositedScrolling): Returns true if compositedScrollingForFramesEnabled and the frame is in forced compositing mode (which is set when forced compositing mode and compositing for scrollable frames are enabled), so that ScrollingCoordinator won't include the region of the frame in the nonFastScrollableRegion.
+        (WebCore):
+        * page/FrameView.h:
+        (FrameView):
+        * page/Settings.in: Add compositedScrollingForFramesEnabled setting.
+        * page/scrolling/chromium/ScrollingCoordinatorChromium.cpp:
+        (WebCore::ScrollingCoordinatorChromium::frameViewLayoutUpdated): Changed the comment about which ScrollableAreas are non-fast-scrollable.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::frameViewDidScroll): Let ScrollongCoordinator know when the scrolling changes for a frame with composited scrolling enabled.
+
 2013-01-07  Alexandre Elias  <aelias@chromium.org>
 
         Divide gesture scroll delta by scale factor
index a848deb..a272833 100644 (file)
@@ -767,6 +767,15 @@ void FrameView::restoreBackingStores()
     compositor->updateCompositingLayers(CompositingUpdateAfterLayout);
 }
 
+bool FrameView::usesCompositedScrolling() const
+{
+    if (m_frame->settings() && m_frame->settings()->compositedScrollingForFramesEnabled()) {
+        RenderView* root = rootRenderer(this);
+        return root && root->compositor()->inForcedCompositingMode();
+    }
+    return false;
+}
+
 GraphicsLayer* FrameView::layerForHorizontalScrollbar() const
 {
     RenderView* root = rootRenderer(this);
index ae133a9..cafcdbb 100644 (file)
@@ -438,6 +438,7 @@ private:
     virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
     virtual bool scrollAnimatorEnabled() const OVERRIDE;
 #if USE(ACCELERATED_COMPOSITING)
+    virtual bool usesCompositedScrolling() const OVERRIDE;
     virtual GraphicsLayer* layerForHorizontalScrollbar() const OVERRIDE;
     virtual GraphicsLayer* layerForVerticalScrollbar() const OVERRIDE;
     virtual GraphicsLayer* layerForScrollCorner() const OVERRIDE;
index 126630c..fe3c8da 100644 (file)
@@ -92,6 +92,7 @@ acceleratedCompositingForOverflowScrollEnabled initial=false
 
 # Works only in conjunction with forceCompositingMode.
 acceleratedCompositingForScrollableFramesEnabled initial=false
+compositedScrollingForFramesEnabled initial=false
 
 experimentalNotificationsEnabled initial=false
 webGLEnabled initial=false
index 830a533..b43a906 100644 (file)
@@ -111,8 +111,9 @@ void ScrollingCoordinatorChromium::frameViewLayoutUpdated(FrameView*)
     ASSERT(m_page);
 
     // Compute the region of the page that we can't do fast scrolling for. This currently includes
-    // all scrollable areas, such as subframes, overflow divs and list boxes. We need to do this even if the
-    // frame view whose layout was updated is not the main frame.
+    // all scrollable areas, such as subframes, overflow divs and list boxes, whose composited
+    // scrolling are not enabled. We need to do this even if the frame view whose layout was updated
+    // is not the main frame.
     Region nonFastScrollableRegion = computeNonFastScrollableRegion(m_page->mainFrame(), IntPoint());
     setNonFastScrollableRegion(nonFastScrollableRegion);
 #if ENABLE(TOUCH_EVENT_TRACKING)
index 6f01f1a..13dcce0 100644 (file)
@@ -1170,6 +1170,9 @@ void RenderLayerCompositor::frameViewDidScroll()
     if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) {
         if (scrollingCoordinator->coordinatesScrollingForFrameView(frameView))
             return;
+        if (Settings* settings = m_renderView->document()->settings())
+            if (settings->compositedScrollingForFramesEnabled())
+                scrollingCoordinator->scrollableAreaScrollLayerDidChange(frameView, m_scrollLayer.get());
     }
 
     m_scrollLayer->setPosition(FloatPoint(-scrollPosition.x(), -scrollPosition.y()));