Title: [112977] trunk/Source/WebCore
Revision
112977
Author
[email protected]
Date
2012-04-02 19:44:44 -0700 (Mon, 02 Apr 2012)

Log Message

Fix usage of LayoutUnits and pixel snapping in RenderLayer
https://bugs.webkit.org/show_bug.cgi?id=82498

Reviewed by Julien Chaffraix.

Fix usage of subpixel types and snapping/rounding in RenderLayer in
preparation for turning on subpixel layout.

No new tests, no change in functionality.

* rendering/LayoutTypes.h:
(WebCore::pixelSnappedIntSize):
Add no-op implementation of pixelSnappedIntSize, will be replaced with a
real implementation once we make the switch.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPosition):
Snap RenderBox size when updating the size of the layer.

(WebCore::RenderLayer::resize):
Round position when setting the inline style during resize operation.

(WebCore::RenderLayer::scrollCornerRect):
Remove unnecessary pixelSnappedIntRect call.

(WebCore::RenderLayer::positionOverflowControls):
Remove unnecessary pixelSnappedIntRect call.

(WebCore::RenderLayer::scrollWidth):
(WebCore::RenderLayer::scrollHeight):
Fix implementation of scrollWidth and Height to pixel snap the values.

(WebCore::RenderLayer::computeScrollDimensions):
(WebCore::RenderLayer::paintResizer):
(WebCore::RenderLayer::hitTestOverflowControls):
Remove unnecessary pixelSnappedIntRect calls.

(WebCore::RenderLayer::paintLayerContents):
Pixel snap values just before painting (instead of earlier on).

(WebCore::RenderLayer::hitTest):
(WebCore::RenderLayer::hitTestContents):
Change to use subpixel types.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (112976 => 112977)


--- trunk/Source/WebCore/ChangeLog	2012-04-03 02:39:31 UTC (rev 112976)
+++ trunk/Source/WebCore/ChangeLog	2012-04-03 02:44:44 UTC (rev 112977)
@@ -1,3 +1,49 @@
+2012-04-02  Emil A Eklund  <[email protected]>
+
+        Fix usage of LayoutUnits and pixel snapping in RenderLayer
+        https://bugs.webkit.org/show_bug.cgi?id=82498
+
+        Reviewed by Julien Chaffraix.
+
+        Fix usage of subpixel types and snapping/rounding in RenderLayer in
+        preparation for turning on subpixel layout.
+
+        No new tests, no change in functionality.
+
+        * rendering/LayoutTypes.h:
+        (WebCore::pixelSnappedIntSize):
+        Add no-op implementation of pixelSnappedIntSize, will be replaced with a
+        real implementation once we make the switch.
+        
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateLayerPosition):
+        Snap RenderBox size when updating the size of the layer.
+        
+        (WebCore::RenderLayer::resize):
+        Round position when setting the inline style during resize operation.
+
+        (WebCore::RenderLayer::scrollCornerRect):
+        Remove unnecessary pixelSnappedIntRect call.
+        
+        (WebCore::RenderLayer::positionOverflowControls):
+        Remove unnecessary pixelSnappedIntRect call.
+        
+        (WebCore::RenderLayer::scrollWidth):
+        (WebCore::RenderLayer::scrollHeight):
+        Fix implementation of scrollWidth and Height to pixel snap the values.
+         
+        (WebCore::RenderLayer::computeScrollDimensions):
+        (WebCore::RenderLayer::paintResizer):
+        (WebCore::RenderLayer::hitTestOverflowControls):
+        Remove unnecessary pixelSnappedIntRect calls.
+        
+        (WebCore::RenderLayer::paintLayerContents):
+        Pixel snap values just before painting (instead of earlier on).
+
+        (WebCore::RenderLayer::hitTest):
+        (WebCore::RenderLayer::hitTestContents):
+        Change to use subpixel types.
+
 2012-04-02  Abhishek Arya  <[email protected]>
 
         <select> shouldn't intrude as a run-in.

Modified: trunk/Source/WebCore/rendering/LayoutTypes.h (112976 => 112977)


--- trunk/Source/WebCore/rendering/LayoutTypes.h	2012-04-03 02:39:31 UTC (rev 112976)
+++ trunk/Source/WebCore/rendering/LayoutTypes.h	2012-04-03 02:44:44 UTC (rev 112977)
@@ -80,6 +80,12 @@
     return size;
 }
 
+inline IntSize pixelSnappedIntSize(LayoutSize size, LayoutPoint location)
+{
+    UNUSED_PARAM(location);
+    return size;
+}
+
 inline IntSize roundedIntSize(const LayoutSize& s)
 {
     return s;

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (112976 => 112977)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-04-03 02:39:31 UTC (rev 112976)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-04-03 02:44:44 UTC (rev 112977)
@@ -765,7 +765,8 @@
         inlineBoundingBoxOffset = toSize(lineBox.location());
         localPoint += inlineBoundingBoxOffset;
     } else if (RenderBox* box = renderBox()) {
-        setSize(box->size());
+        // FIXME: Is snapping the size really needed here for the RenderBox case?
+        setSize(pixelSnappedIntSize(box->size(), box->location()));
         localPoint += box->topLeftLocationOffset();
     }
 
@@ -1856,7 +1857,7 @@
         }
         LayoutUnit baseWidth = renderer->width() - (isBoxSizingBorder ? zeroLayoutUnit : renderer->borderAndPaddingWidth());
         baseWidth = baseWidth / zoomFactor;
-        styledElement->setInlineStyleProperty(CSSPropertyWidth, String::number(baseWidth + difference.width()) + "px", false);
+        styledElement->setInlineStyleProperty(CSSPropertyWidth, String::number(roundToInt(baseWidth + difference.width())) + "px", false);
     }
 
     if (resize != RESIZE_HORIZONTAL && difference.height()) {
@@ -1867,7 +1868,7 @@
         }
         LayoutUnit baseHeight = renderer->height() - (isBoxSizingBorder ? zeroLayoutUnit : renderer->borderAndPaddingHeight());
         baseHeight = baseHeight / zoomFactor;
-        styledElement->setInlineStyleProperty(CSSPropertyHeight, String::number(baseHeight + difference.height()) + "px", false);
+        styledElement->setInlineStyleProperty(CSSPropertyHeight, String::number(roundToInt(baseHeight + difference.height())) + "px", false);
     }
 
     document->updateLayout();
@@ -1977,7 +1978,7 @@
     bool hasVerticalBar = verticalScrollbar();
     bool hasResizer = renderer()->style()->resize() != RESIZE_NONE;
     if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar || hasVerticalBar)))
-        return cornerRect(this, pixelSnappedIntRect(renderBox()->borderBoxRect()));
+        return cornerRect(this, renderBox()->borderBoxRect());
     return IntRect();
 }
 
@@ -2301,7 +2302,7 @@
     if (!box)
         return;
 
-    const IntRect borderBox = pixelSnappedIntRect(box->borderBoxRect());
+    const IntRect borderBox = box->borderBoxRect();
     const IntRect& scrollCorner = scrollCornerRect();
     IntRect absBounds(borderBox.location() + offsetFromLayer, borderBox.size());
     if (m_vBar)
@@ -2348,16 +2349,18 @@
 
 int RenderLayer::scrollWidth()
 {
+    ASSERT(renderBox());
     if (m_scrollDimensionsDirty)
         computeScrollDimensions();
-    return m_scrollSize.width();
+    return snapSizeToPixel(m_scrollSize.width(), renderBox()->clientLeft());
 }
 
 int RenderLayer::scrollHeight()
 {
+    ASSERT(renderBox());
     if (m_scrollDimensionsDirty)
         computeScrollDimensions();
-    return m_scrollSize.height();
+    return snapSizeToPixel(m_scrollSize.height(), renderBox()->clientTop());
 }
 
 LayoutUnit RenderLayer::overflowTop() const
@@ -2404,7 +2407,7 @@
 
     m_scrollSize.setWidth(overflowRight() - overflowLeft());
     m_scrollSize.setHeight(overflowBottom() - overflowTop());
-    
+
     setScrollOrigin(IntPoint(-m_scrollOverflow.width(), -m_scrollOverflow.height()));
 
     if (needHBar)
@@ -2633,7 +2636,7 @@
     RenderBox* box = renderBox();
     ASSERT(box);
 
-    IntRect absRect = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect()));
+    IntRect absRect = resizerCornerRect(this, box->borderBoxRect());
     absRect.moveBy(paintOffset);
     if (!absRect.intersects(damageRect))
         return;
@@ -2688,7 +2691,7 @@
     
     IntRect resizeControlRect;
     if (renderer()->style()->resize() != RESIZE_NONE) {
-        resizeControlRect = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect()));
+        resizeControlRect = resizerCornerRect(this, box->borderBoxRect());
         if (resizeControlRect.contains(localPoint))
             return true;
     }
@@ -3019,7 +3022,7 @@
             }
             
             // Paint the background.
-            PaintInfo paintInfo(context, damageRect.rect(), PaintPhaseBlockBackground, false, paintingRootForRenderer, region, 0);
+            PaintInfo paintInfo(context, pixelSnappedIntRect(damageRect.rect()), PaintPhaseBlockBackground, false, paintingRootForRenderer, region, 0);
             renderer()->paint(paintInfo, paintOffset);
 
             if (useClipRect) {
@@ -3044,7 +3047,7 @@
                 clipToRect(rootLayer, context, paintDirtyRect, clipRectToApply);
             }
             
-            PaintInfo paintInfo(context, clipRectToApply.rect(), 
+            PaintInfo paintInfo(context, pixelSnappedIntRect(clipRectToApply.rect()),
                                 selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
                                 forceBlackText, paintingRootForRenderer, region, 0);
             renderer()->paint(paintInfo, paintOffset);
@@ -3066,7 +3069,7 @@
 
         if (shouldPaintOutline && !outlineRect.isEmpty()) {
             // Paint our own outline
-            PaintInfo paintInfo(context, outlineRect.rect(), PaintPhaseSelfOutline, false, paintingRootForRenderer, region, 0);
+            PaintInfo paintInfo(context, pixelSnappedIntRect(outlineRect.rect()), PaintPhaseSelfOutline, false, paintingRootForRenderer, region, 0);
             clipToRect(rootLayer, context, paintDirtyRect, outlineRect, DoNotIncludeSelfForBorderRadius);
             renderer()->paint(paintInfo, paintOffset);
             restoreClip(context, paintDirtyRect, outlineRect);
@@ -3084,7 +3087,7 @@
             clipToRect(rootLayer, context, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self.
 
         // Paint the mask.
-        PaintInfo paintInfo(context, damageRect.rect(), PaintPhaseMask, false, paintingRootForRenderer, region, 0);
+        PaintInfo paintInfo(context, pixelSnappedIntRect(damageRect.rect()), PaintPhaseMask, false, paintingRootForRenderer, region, 0);
         renderer()->paint(paintInfo, paintOffset);
         
         if (useClipRect) {
@@ -3266,9 +3269,9 @@
 {
     renderer()->document()->updateLayout();
     
-    IntRect hitTestArea = renderer()->isRenderFlowThread() ? toRenderFlowThread(renderer())->borderBoxRect() : renderer()->view()->documentRect();
+    LayoutRect hitTestArea = renderer()->isRenderFlowThread() ? toRenderFlowThread(renderer())->borderBoxRect() : renderer()->view()->documentRect();
     if (!request.ignoreClipping())
-        hitTestArea.intersect(pixelSnappedIntRect(frameVisibleRect(renderer())));
+        hitTestArea.intersect(frameVisibleRect(renderer()));
 
     RenderLayer* insideLayer = hitTestLayer(this, 0, request, result, hitTestArea, result.point(), false);
     if (!insideLayer) {
@@ -3558,7 +3561,7 @@
 bool RenderLayer::hitTestContents(const HitTestRequest& request, HitTestResult& result, const LayoutRect& layerBounds, const LayoutPoint& hitTestPoint, HitTestFilter hitTestFilter) const
 {
     if (!renderer()->hitTest(request, result, hitTestPoint,
-                            toPoint(layerBounds.location() - renderBoxLocation()),
+                            toLayoutPoint(layerBounds.location() - renderBoxLocation()),
                             hitTestFilter)) {
         // It's wrong to set innerNode, but then claim that you didn't hit anything, unless it is
         // a rect-based test.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to