Title: [135073] branches/safari-536.28-branch/Source/WebCore
Revision
135073
Author
simon.fra...@apple.com
Date
2012-11-18 10:07:08 -0800 (Sun, 18 Nov 2012)

Log Message

<rdar://problem/12726004> Chopin: Don't say there are dirty overlay scrollbars when they are clipped out (102609)
Merge r135064

    2012-11-17  Simon Fraser  <simon.fra...@apple.com>

    Don't say there are dirty overlay scrollbars when they are clipped out
    https://bugs.webkit.org/show_bug.cgi?id=102609

    Reviewed by Brady Eidson.

    Painting overlay scrollbars involves a second painting pass over the entire
    RenderLayer subtree for a compositing layer, which can be very expensive.

    Avoid this when possible by detecting when overflow controls are not in
    the damage rect.

    * rendering/RenderLayer.cpp:
    (WebCore::RenderLayer::rectForHorizontalScrollbar): Compute a local rect
    for the horizontal scrollbar.
    (WebCore::RenderLayer::rectForVerticalScrollbar): Compute a local rect
    for the vertical scrollbar.
    (WebCore::RenderLayer::positionOverflowControls): Use rectForHorizontalScrollbar()
    and rectForVerticalScrollbar().
    (WebCore::RenderLayer::overflowControlsIntersectRect): Return true if any
    of the present overflow controls intersect the given local rect.
    (WebCore::RenderLayer::paintOverflowControls): Bail if the damage rect
    doesn't intersect any of the overflow controls.
    * rendering/RenderLayer.h:
    (RenderLayer):

Modified Paths

Diff

Modified: branches/safari-536.28-branch/Source/WebCore/ChangeLog (135072 => 135073)


--- branches/safari-536.28-branch/Source/WebCore/ChangeLog	2012-11-18 18:07:03 UTC (rev 135072)
+++ branches/safari-536.28-branch/Source/WebCore/ChangeLog	2012-11-18 18:07:08 UTC (rev 135073)
@@ -1,5 +1,37 @@
 2012-11-18  Simon Fraser  <simon.fra...@apple.com>
 
+        <rdar://problem/12726004> Chopin: Don't say there are dirty overlay scrollbars when they are clipped out (102609)
+        Merge r135064
+
+    2012-11-17  Simon Fraser  <simon.fra...@apple.com>
+    
+            Don't say there are dirty overlay scrollbars when they are clipped out
+            https://bugs.webkit.org/show_bug.cgi?id=102609
+    
+            Reviewed by Brady Eidson.
+    
+            Painting overlay scrollbars involves a second painting pass over the entire
+            RenderLayer subtree for a compositing layer, which can be very expensive.
+            
+            Avoid this when possible by detecting when overflow controls are not in
+            the damage rect.
+    
+            * rendering/RenderLayer.cpp:
+            (WebCore::RenderLayer::rectForHorizontalScrollbar): Compute a local rect
+            for the horizontal scrollbar.
+            (WebCore::RenderLayer::rectForVerticalScrollbar): Compute a local rect
+            for the vertical scrollbar.
+            (WebCore::RenderLayer::positionOverflowControls): Use rectForHorizontalScrollbar()
+            and rectForVerticalScrollbar().
+            (WebCore::RenderLayer::overflowControlsIntersectRect): Return true if any
+            of the present overflow controls intersect the given local rect.
+            (WebCore::RenderLayer::paintOverflowControls): Bail if the damage rect
+            doesn't intersect any of the overflow controls.
+            * rendering/RenderLayer.h:
+            (RenderLayer):
+
+2012-11-18  Simon Fraser  <simon.fra...@apple.com>
+
         <rdar://problem/12725998> Simplify bounds computation for the RenderView's layer (102597)
         Merge r135059
 

Modified: branches/safari-536.28-branch/Source/WebCore/rendering/RenderLayer.cpp (135072 => 135073)


--- branches/safari-536.28-branch/Source/WebCore/rendering/RenderLayer.cpp	2012-11-18 18:07:03 UTC (rev 135072)
+++ branches/safari-536.28-branch/Source/WebCore/rendering/RenderLayer.cpp	2012-11-18 18:07:08 UTC (rev 135073)
@@ -2103,6 +2103,34 @@
     return renderer()->frame() ? renderer()->frame()->eventHandler()->currentMousePosition() : IntPoint();
 }
 
+IntRect RenderLayer::rectForHorizontalScrollbar(const IntRect& borderBoxRect) const
+{
+    if (!m_hBar)
+        return IntRect();
+
+    const RenderBox* box = renderBox();
+    const IntRect& scrollCorner = scrollCornerRect();
+
+    return IntRect(horizontalScrollbarStart(borderBoxRect.x()),
+        borderBoxRect.maxY() - box->borderBottom() - m_hBar->height(),
+        borderBoxRect.width() - (box->borderLeft() + box->borderRight()) - scrollCorner.width(),
+        m_hBar->height());
+}
+
+IntRect RenderLayer::rectForVerticalScrollbar(const IntRect& borderBoxRect) const
+{
+    if (!m_vBar)
+        return IntRect();
+
+    const RenderBox* box = renderBox();
+    const IntRect& scrollCorner = scrollCornerRect();
+
+    return IntRect(verticalScrollbarStart(borderBoxRect.x(), borderBoxRect.maxX()),
+        borderBoxRect.y() + box->borderTop(),
+        m_vBar->width(),
+        borderBoxRect.height() - (box->borderTop() + box->borderBottom()) - scrollCorner.height());
+}
+
 LayoutUnit RenderLayer::verticalScrollbarStart(int minX, int maxX) const
 {
     const RenderBox* box = renderBox();
@@ -2318,18 +2346,18 @@
     const IntRect borderBox = box->pixelSnappedBorderBoxRect();
     const IntRect& scrollCorner = scrollCornerRect();
     IntRect absBounds(borderBox.location() + offsetFromRoot, borderBox.size());
-    if (m_vBar)
-        m_vBar->setFrameRect(IntRect(verticalScrollbarStart(absBounds.x(), absBounds.maxX()),
-                                     absBounds.y() + box->borderTop(),
-                                     m_vBar->width(),
-                                     absBounds.height() - (box->borderTop() + box->borderBottom()) - scrollCorner.height()));
-
-    if (m_hBar)
-        m_hBar->setFrameRect(IntRect(horizontalScrollbarStart(absBounds.x()),
-                                     absBounds.maxY() - box->borderBottom() - m_hBar->height(),
-                                     absBounds.width() - (box->borderLeft() + box->borderRight()) - scrollCorner.width(),
-                                     m_hBar->height()));
-
+    if (m_vBar) {
+        IntRect vBarRect = rectForVerticalScrollbar(borderBox);
+        vBarRect.move(offsetFromRoot);
+        m_vBar->setFrameRect(vBarRect);
+    }
+    
+    if (m_hBar) {
+        IntRect hBarRect = rectForHorizontalScrollbar(borderBox);
+        hBarRect.move(offsetFromRoot);
+        m_hBar->setFrameRect(hBarRect);
+    }
+    
     if (m_scrollCorner)
         m_scrollCorner->setFrameRect(scrollCorner);
     if (m_resizer)
@@ -2510,6 +2538,25 @@
         scrollToOffsetWithoutAnimation(IntPoint(scrollXOffset(), scrollYOffset()));
 }
 
+bool RenderLayer::overflowControlsIntersectRect(const IntRect& localRect) const
+{
+    const IntRect borderBox = renderBox()->pixelSnappedBorderBoxRect();
+
+    if (rectForHorizontalScrollbar(borderBox).intersects(localRect))
+        return true;
+
+    if (rectForVerticalScrollbar(borderBox).intersects(localRect))
+        return true;
+
+    if (scrollCornerRect().intersects(localRect))
+        return true;
+    
+    if (resizerCornerRect(this, borderBox).intersects(localRect))
+        return true;
+
+    return false;
+}
+
 void RenderLayer::paintOverflowControls(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayControls)
 {
     // Don't do anything if we have no overflow.
@@ -2529,6 +2576,11 @@
         if ((m_hBar && layerForHorizontalScrollbar()) || (m_vBar && layerForVerticalScrollbar()))
             return;
 #endif
+        IntRect localDamgeRect = damageRect;
+        localDamgeRect.moveBy(-paintOffset);
+        if (!overflowControlsIntersectRect(localDamgeRect))
+            return;
+
         RenderView* renderView = renderer()->view();
 
         RenderLayer* paintingRoot = enclosingCompositingLayer();

Modified: branches/safari-536.28-branch/Source/WebCore/rendering/RenderLayer.h (135072 => 135073)


--- branches/safari-536.28-branch/Source/WebCore/rendering/RenderLayer.h	2012-11-18 18:07:03 UTC (rev 135072)
+++ branches/safari-536.28-branch/Source/WebCore/rendering/RenderLayer.h	2012-11-18 18:07:08 UTC (rev 135073)
@@ -846,9 +846,14 @@
             ;
     }
 
+    IntRect rectForHorizontalScrollbar(const IntRect& borderBoxRect) const;
+    IntRect rectForVerticalScrollbar(const IntRect& borderBoxRect) const;
+
     LayoutUnit verticalScrollbarStart(int minX, int maxX) const;
     LayoutUnit horizontalScrollbarStart(int minX) const;
 
+    bool overflowControlsIntersectRect(const IntRect& localRect) const;
+
 protected:
     // The bitfields are up here so they will fall into the padding from ScrollableArea on 64-bit.
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to