Rubber-banding should not affect the visibleRect of the TileCache
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2013 01:29:39 +0000 (01:29 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2013 01:29:39 +0000 (01:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110278

Reviewed by Beth Dakin.

When rubber-banding a slow-scrolling page, or image document, we would constantly re-create
the bottom tile because of the logic that adapts the tile size to the visible rect when slow
scrolling.

Avoid that by ensuring that the visibleRect is not affected by rubber-banding. This is done
via a GraphicsLayerClient function that allows RenderLayerCompositor to provide a custom
position for the scroll layer. We constrain that scroll position to remove the overhang that
results from rubber-banding.

I wasn't able to make a test for this, even with internals.setScrollViewPosition().

* platform/graphics/GraphicsLayerClient.h:
(GraphicsLayerClient):
(WebCore::GraphicsLayerClient::customPositionForVisibleRectComputation):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::computeVisibleRect):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::customPositionForVisibleRectComputation):
* rendering/RenderLayerCompositor.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayerClient.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h

index 668109e..050600f 100644 (file)
@@ -1,3 +1,30 @@
+2013-02-19  Simon Fraser  <simon.fraser@apple.com>
+
+        Rubber-banding should not affect the visibleRect of the TileCache
+        https://bugs.webkit.org/show_bug.cgi?id=110278
+
+        Reviewed by Beth Dakin.
+        
+        When rubber-banding a slow-scrolling page, or image document, we would constantly re-create
+        the bottom tile because of the logic that adapts the tile size to the visible rect when slow
+        scrolling.
+        
+        Avoid that by ensuring that the visibleRect is not affected by rubber-banding. This is done
+        via a GraphicsLayerClient function that allows RenderLayerCompositor to provide a custom
+        position for the scroll layer. We constrain that scroll position to remove the overhang that
+        results from rubber-banding.
+
+        I wasn't able to make a test for this, even with internals.setScrollViewPosition().
+
+        * platform/graphics/GraphicsLayerClient.h:
+        (GraphicsLayerClient):
+        (WebCore::GraphicsLayerClient::customPositionForVisibleRectComputation):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::computeVisibleRect):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::customPositionForVisibleRectComputation):
+        * rendering/RenderLayerCompositor.h:
+
 2013-02-19  Tony Gentilcore  <tonyg@chromium.org>
 
         Fix crash in preloading scanning base tags with no href attribute for background parser
index 8b6bffd..3f8c51d 100644 (file)
@@ -77,6 +77,10 @@ public:
     // initialized to identity already. Returns false if the layer has no transform.
     virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const { return false; }
 
+    // Allows the client to modify a layer position used during the visibleRect calculation, for example to ignore
+    // scroll overhang.
+    virtual void customPositionForVisibleRectComputation(const GraphicsLayer*, FloatPoint&) const { }
+
     // Multiplier for backing store size, related to high DPI.
     virtual float deviceScaleFactor() const { return 1; }
     // Page scale factor.
index 18d364b..6c2c7b2 100644 (file)
@@ -917,7 +917,11 @@ FloatRect GraphicsLayerCA::computeVisibleRect(TransformState& state) const
     TransformState::TransformAccumulation accumulation = preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
 
     TransformationMatrix layerTransform;
-    layerTransform.translate(m_position.x(), m_position.y());
+    FloatPoint position = m_position;
+    if (m_client)
+        m_client->customPositionForVisibleRectComputation(this, position);
+
+    layerTransform.translate(position.x(), position.y());
 
     TransformationMatrix currentTransform;
     if (client() && client()->getCurrentTransform(this, currentTransform) && !currentTransform.isIdentity()) {
index a6db8fd..bd49597 100644 (file)
@@ -302,6 +302,20 @@ void RenderLayerCompositor::setCompositingLayersNeedRebuild(bool needRebuild)
         m_compositingLayersNeedRebuild = needRebuild;
 }
 
+void RenderLayerCompositor::customPositionForVisibleRectComputation(const GraphicsLayer* graphicsLayer, FloatPoint& position) const
+{
+    if (graphicsLayer != m_scrollLayer.get())
+        return;
+
+    FrameView* frameView = m_renderView ? m_renderView->frameView() : 0;
+    if (!frameView)
+        return;
+
+    FloatPoint scrollPosition = -position;
+    scrollPosition = frameView->constrainScrollPositionForOverhang(roundedIntPoint(scrollPosition));
+    position = -scrollPosition;
+}
+
 void RenderLayerCompositor::scheduleLayerFlush()
 {
     if (Page* page = this->page())
index cbe1d9b..9571641 100644 (file)
@@ -249,6 +249,7 @@ private:
     
     // GraphicsLayerUpdaterClient implementation
     virtual void flushLayers(GraphicsLayerUpdater*) OVERRIDE;
+    virtual void customPositionForVisibleRectComputation(const GraphicsLayer*, FloatPoint&) const OVERRIDE;
     
     // Whether the given RL needs a compositing layer.
     bool needsToBeComposited(const RenderLayer*, RenderLayer::ViewportConstrainedNotCompositedReason* = 0) const;