Title: [127943] trunk
Revision
127943
Author
simon.fra...@apple.com
Date
2012-09-07 17:48:40 -0700 (Fri, 07 Sep 2012)

Log Message

box-shadow causes overlay scrollbars to be in the wrong position when element is composited
https://bugs.webkit.org/show_bug.cgi?id=85647

Reviewed by James Robinson.

Test overlay scrollbars in composited layers.

* ManualTests/scrollbars/scrollbars-in-composited-layers.html: Added.

Source/WebCore:

The code that positioned the GraphicsLayers for scrollbars failed to take
into account any offset between the origin of the compositing layer,
and the renderer. This caused scrollbar layers to be misplaced or hidden
on layers with, for example, box-shadows.

Also moved the code that positions the scrollbar layers into RendderLayerBacking,
since this is where all the rest of the GraphicsLayer-positioning code lives.

Renamed an "offsetFromLayer" param to "offsetFromRoot" which is more accurate.

Manual test, since overlay scrollbars are not enabled in DRT/WTR:
    ManualTests/scrollbars/scrollbars-in-composited-layers.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::positionOverflowControls):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::positionOverflowControlsLayers):
* rendering/RenderLayerBacking.h:
(RenderLayerBacking):

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (127942 => 127943)


--- trunk/ChangeLog	2012-09-08 00:42:47 UTC (rev 127942)
+++ trunk/ChangeLog	2012-09-08 00:48:40 UTC (rev 127943)
@@ -1,3 +1,14 @@
+2012-09-07  Simon Fraser  <simon.fra...@apple.com>
+
+        box-shadow causes overlay scrollbars to be in the wrong position when element is composited
+        https://bugs.webkit.org/show_bug.cgi?id=85647
+
+        Reviewed by James Robinson.
+
+        Test overlay scrollbars in composited layers.
+
+        * ManualTests/scrollbars/scrollbars-in-composited-layers.html: Added.
+
 2012-09-07  Martin Robinson  <mrobin...@igalia.com>
 
         [GTK] Move user agent helpers to WebCore

Added: trunk/ManualTests/scrollbars/scrollbars-in-composited-layers.html (0 => 127943)


--- trunk/ManualTests/scrollbars/scrollbars-in-composited-layers.html	                        (rev 0)
+++ trunk/ManualTests/scrollbars/scrollbars-in-composited-layers.html	2012-09-08 00:48:40 UTC (rev 127943)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+    .scroll {
+        width: 200px;
+        height: 200px;
+        border: 1px solid black;
+        margin: 15px;
+        padding: 5px;
+        overflow-y: scroll;
+        -webkit-transform: translateZ(0);
+        box-shadow: 0 0 15px black;
+    }
+
+    .rotated {
+        -webkit-transform: rotate3d(0, 0, 1, 45deg);
+    }
+    .scroll > div {
+        background-color: silver;
+        width: 500px;
+        height: 1000px;
+    }
+    </style>
+</head>
+<body>
+
+    <p>Overlay scrollbars (on Mac) should show in the correct place when scrolling.</p>
+    <div class="scroll">
+        <div></div>
+    </div>
+
+    <p>Overlay scrollbars (on Mac) should show in the correct place when scrolling, and the resize corner should show in the correct place.</p>
+    <div class="scroll" style="resize: both; overflow:hiddens">
+        <div></div>
+    </div>
+
+    <p>Overlay scrollbars (on Mac) should show in the correct place when scrolling, and the resize corner should show in the correct place.</p>
+    <div class="rotated scroll" style="resize: both; overflow:hiddens">
+        <div></div>
+    </div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (127942 => 127943)


--- trunk/Source/WebCore/ChangeLog	2012-09-08 00:42:47 UTC (rev 127942)
+++ trunk/Source/WebCore/ChangeLog	2012-09-08 00:48:40 UTC (rev 127943)
@@ -1,3 +1,30 @@
+2012-09-07  Simon Fraser  <simon.fra...@apple.com>
+
+        box-shadow causes overlay scrollbars to be in the wrong position when element is composited
+        https://bugs.webkit.org/show_bug.cgi?id=85647
+
+        Reviewed by James Robinson.
+
+        The code that positioned the GraphicsLayers for scrollbars failed to take
+        into account any offset between the origin of the compositing layer,
+        and the renderer. This caused scrollbar layers to be misplaced or hidden
+        on layers with, for example, box-shadows.
+        
+        Also moved the code that positions the scrollbar layers into RendderLayerBacking,
+        since this is where all the rest of the GraphicsLayer-positioning code lives.
+        
+        Renamed an "offsetFromLayer" param to "offsetFromRoot" which is more accurate.
+
+        Manual test, since overlay scrollbars are not enabled in DRT/WTR:
+            ManualTests/scrollbars/scrollbars-in-composited-layers.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::positionOverflowControls):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::positionOverflowControlsLayers):
+        * rendering/RenderLayerBacking.h:
+        (RenderLayerBacking):
+
 2012-09-07  David Reveman  <reve...@chromium.org>
 
         [Chromium] Multiple commits without invalidation allowed per redraw.

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (127942 => 127943)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-09-08 00:42:47 UTC (rev 127942)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-09-08 00:48:40 UTC (rev 127943)
@@ -2430,7 +2430,7 @@
     return m_hBar || m_vBar || m_scrollCorner || renderer()->style()->resize() != RESIZE_NONE;
 }
 
-void RenderLayer::positionOverflowControls(const IntSize& offsetFromLayer)
+void RenderLayer::positionOverflowControls(const IntSize& offsetFromRoot)
 {
     if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZE_NONE))
         return;
@@ -2441,7 +2441,7 @@
 
     const IntRect borderBox = box->pixelSnappedBorderBoxRect();
     const IntRect& scrollCorner = scrollCornerRect();
-    IntRect absBounds(borderBox.location() + offsetFromLayer, borderBox.size());
+    IntRect absBounds(borderBox.location() + offsetFromRoot, borderBox.size());
     if (m_vBar)
         m_vBar->setFrameRect(IntRect(verticalScrollbarStart(absBounds.x(), absBounds.maxX()),
                                      absBounds.y() + box->borderTop(),
@@ -2454,34 +2454,15 @@
                                      absBounds.width() - (box->borderLeft() + box->borderRight()) - scrollCorner.width(),
                                      m_hBar->height()));
 
-#if USE(ACCELERATED_COMPOSITING)
-    if (GraphicsLayer* layer = layerForHorizontalScrollbar()) {
-        if (m_hBar) {
-            layer->setPosition(m_hBar->frameRect().location() - offsetFromLayer);
-            layer->setSize(m_hBar->frameRect().size());
-        }
-        layer->setDrawsContent(m_hBar);
-    }
-    if (GraphicsLayer* layer = layerForVerticalScrollbar()) {
-        if (m_vBar) {
-            layer->setPosition(m_vBar->frameRect().location() - offsetFromLayer);
-            layer->setSize(m_vBar->frameRect().size());
-        }
-        layer->setDrawsContent(m_vBar);
-    }
-
-    if (GraphicsLayer* layer = layerForScrollCorner()) {
-        const LayoutRect& scrollCornerAndResizer = scrollCornerAndResizerRect();
-        layer->setPosition(scrollCornerAndResizer.location());
-        layer->setSize(scrollCornerAndResizer.size());
-        layer->setDrawsContent(!scrollCornerAndResizer.isEmpty());
-    }
-#endif
-
     if (m_scrollCorner)
         m_scrollCorner->setFrameRect(scrollCorner);
     if (m_resizer)
         m_resizer->setFrameRect(resizerCornerRect(this, borderBox));
+
+#if USE(ACCELERATED_COMPOSITING)    
+    if (isComposited())
+        backing()->positionOverflowControlsLayers(offsetFromRoot);
+#endif
 }
 
 int RenderLayer::scrollWidth() const

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (127942 => 127943)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-09-08 00:42:47 UTC (rev 127942)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-09-08 00:48:40 UTC (rev 127943)
@@ -848,6 +848,35 @@
     return layersChanged;
 }
 
+void RenderLayerBacking::positionOverflowControlsLayers(const IntSize& offsetFromRoot)
+{
+    IntSize offsetFromRenderer = m_graphicsLayer->offsetFromRenderer();
+    if (GraphicsLayer* layer = layerForHorizontalScrollbar()) {
+        Scrollbar* hBar = m_owningLayer->horizontalScrollbar();
+        if (hBar) {
+            layer->setPosition(hBar->frameRect().location() - offsetFromRoot - offsetFromRenderer);
+            layer->setSize(hBar->frameRect().size());
+        }
+        layer->setDrawsContent(hBar);
+    }
+    
+    if (GraphicsLayer* layer = layerForVerticalScrollbar()) {
+        Scrollbar* vBar = m_owningLayer->verticalScrollbar();
+        if (vBar) {
+            layer->setPosition(vBar->frameRect().location() - offsetFromRoot - offsetFromRenderer);
+            layer->setSize(vBar->frameRect().size());
+        }
+        layer->setDrawsContent(vBar);
+    }
+
+    if (GraphicsLayer* layer = layerForScrollCorner()) {
+        const LayoutRect& scrollCornerAndResizer = m_owningLayer->scrollCornerAndResizerRect();
+        layer->setPosition(scrollCornerAndResizer.location() - offsetFromRenderer);
+        layer->setSize(scrollCornerAndResizer.size());
+        layer->setDrawsContent(!scrollCornerAndResizer.isEmpty());
+    }
+}
+
 bool RenderLayerBacking::updateForegroundLayer(bool needsForegroundLayer)
 {
     bool layerChanged = false;

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (127942 => 127943)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2012-09-08 00:42:47 UTC (rev 127942)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2012-09-08 00:48:40 UTC (rev 127943)
@@ -131,6 +131,7 @@
     void updateCompositedBounds();
     
     void updateAfterWidgetResize();
+    void positionOverflowControlsLayers(const IntSize& offsetFromRoot);
 
     // GraphicsLayerClient interface
     virtual bool shouldUseTileCache(const GraphicsLayer*) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to