[chromium] Simplify RTL root layer adjustment
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 06:44:09 +0000 (06:44 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 06:44:09 +0000 (06:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85672

Patch by Alexandre Elias <aelias@google.com> on 2012-05-21
Reviewed by Adrienne Walker.

The compositor needs a translation to compensate for a nonzero
scrollOrigin to avoid painting at negative coordinates on RTL pages.
Previously, we were recomputing it from first principles; this change
directly reads it off the actual scrollOrigin.

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::updateLayerTreeViewport):
* src/WebViewImpl.h:
(WebViewImpl):

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

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h

index 1eaba40..33ce059 100644 (file)
@@ -1,3 +1,20 @@
+2012-05-21  Alexandre Elias  <aelias@google.com>
+
+        [chromium] Simplify RTL root layer adjustment
+        https://bugs.webkit.org/show_bug.cgi?id=85672
+
+        Reviewed by Adrienne Walker.
+
+        The compositor needs a translation to compensate for a nonzero
+        scrollOrigin to avoid painting at negative coordinates on RTL pages.
+        Previously, we were recomputing it from first principles; this change
+        directly reads it off the actual scrollOrigin.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::updateLayerTreeViewport):
+        * src/WebViewImpl.h:
+        (WebViewImpl):
+
 2012-05-21  James Robinson  <jamesr@chromium.org>
 
         Chromium compile fix, unreviewed.
index d3ff7cd..4ee5810 100644 (file)
@@ -3304,22 +3304,6 @@ bool WebViewImpl::allowsAcceleratedCompositing()
     return !m_compositorCreationFailed;
 }
 
-bool WebViewImpl::pageHasRTLStyle() const
-{
-    if (!page())
-        return false;
-    Document* document = page()->mainFrame()->document();
-    if (!document)
-        return false;
-    RenderView* renderView = document->renderView();
-    if (!renderView)
-        return false;
-    RenderStyle* style = renderView->style();
-    if (!style)
-        return false;
-    return (style->direction() == RTL);
-}
-
 void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer)
 {
     m_rootGraphicsLayer = layer;
@@ -3614,14 +3598,10 @@ void WebViewImpl::updateLayerTreeViewport()
     IntRect visibleRect = view->visibleContentRect(true /* include scrollbars */);
     IntPoint scroll(view->scrollX(), view->scrollY());
 
-    int layerAdjustX = 0;
-    if (pageHasRTLStyle()) {
-        // The origin of the initial containing block for RTL root layers is not
-        // at the far left side of the layer bounds. Instead, it's one viewport
-        // width (not including scrollbars) to the left of the right side of the
-        // layer.
-        layerAdjustX = -view->contentsSize().width() + view->visibleContentRect(false).width();
-    }
+    // In RTL-style pages, the origin of the initial containing block for the
+    // root layer may be positive; translate the layer to avoid negative
+    // coordinates.
+    int layerAdjustX = -view->scrollOrigin().x();
 
     // This part of the deviceScale will be used to scale the contents of
     // the NCCH's GraphicsLayer.
index 963c1e2..1f891c7 100644 (file)
@@ -495,7 +495,6 @@ public:
 
 #if USE(ACCELERATED_COMPOSITING)
     bool allowsAcceleratedCompositing();
-    bool pageHasRTLStyle() const;
     void setRootGraphicsLayer(WebCore::GraphicsLayer*);
     void scheduleCompositingLayerSync();
     void scrollRootLayerRect(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& clipRect);