Title: [110505] trunk/Source/WebCore
Revision
110505
Author
e...@chromium.org
Date
2012-03-12 16:51:09 -0700 (Mon, 12 Mar 2012)

Log Message

Fix rounding in scrollbar rect calculations
https://bugs.webkit.org/show_bug.cgi?id=80894

Reviewed by Eric Seidel.

Fix usage of subpixel units in RenderScrollbar::buttonRect and
RenderScrollbar::trackRect.

No new tests, no new functionality.

* rendering/LayoutTypes.h:
(WebCore::isIntegerValue):
Add dummy isIntegerValue function, will be replaced with actual
implementation once LayoutUnit is remapped to FractionalLayoutUnit.

* rendering/RenderScrollbar.cpp:
(WebCore::RenderScrollbar::buttonRect):
(WebCore::RenderScrollbar::trackRect):
Change rect calculations to use pixel snapped values.

* rendering/RenderScrollbarPart.h:
(RenderScrollbarPart):
(WebCore::RenderScrollbarPart::marginTop):
(WebCore::RenderScrollbarPart::marginBottom):
(WebCore::RenderScrollbarPart::marginLeft):
(WebCore::RenderScrollbarPart::marginRight):
Add ASSERT to ensure that scrollbar parts are always aligned to device
pixels.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110504 => 110505)


--- trunk/Source/WebCore/ChangeLog	2012-03-12 23:46:17 UTC (rev 110504)
+++ trunk/Source/WebCore/ChangeLog	2012-03-12 23:51:09 UTC (rev 110505)
@@ -1,3 +1,34 @@
+2012-03-12  Emil A Eklund  <e...@chromium.org>
+
+        Fix rounding in scrollbar rect calculations
+        https://bugs.webkit.org/show_bug.cgi?id=80894
+
+        Reviewed by Eric Seidel.
+
+        Fix usage of subpixel units in RenderScrollbar::buttonRect and
+        RenderScrollbar::trackRect.
+
+        No new tests, no new functionality.
+
+        * rendering/LayoutTypes.h:
+        (WebCore::isIntegerValue):
+        Add dummy isIntegerValue function, will be replaced with actual
+        implementation once LayoutUnit is remapped to FractionalLayoutUnit.
+        
+        * rendering/RenderScrollbar.cpp:
+        (WebCore::RenderScrollbar::buttonRect):
+        (WebCore::RenderScrollbar::trackRect):
+        Change rect calculations to use pixel snapped values.
+
+        * rendering/RenderScrollbarPart.h:
+        (RenderScrollbarPart):
+        (WebCore::RenderScrollbarPart::marginTop):
+        (WebCore::RenderScrollbarPart::marginBottom):
+        (WebCore::RenderScrollbarPart::marginLeft):
+        (WebCore::RenderScrollbarPart::marginRight):
+        Add ASSERT to ensure that scrollbar parts are always aligned to device
+        pixels.
+
 2012-03-12  C Anthony Risinger  <anth...@xtfx.me>
 
         [GObject IDL Parser] STRING argument should be HASHREF

Modified: trunk/Source/WebCore/rendering/LayoutTypes.h (110504 => 110505)


--- trunk/Source/WebCore/rendering/LayoutTypes.h	2012-03-12 23:46:17 UTC (rev 110504)
+++ trunk/Source/WebCore/rendering/LayoutTypes.h	2012-03-12 23:51:09 UTC (rev 110505)
@@ -150,6 +150,11 @@
     return clampToInteger(value);
 }
 
+inline bool isIntegerValue(const LayoutUnit)
+{
+    return true;
+}
+
 } // namespace WebCore
 
 #endif // LayoutTypes_h

Modified: trunk/Source/WebCore/rendering/RenderScrollbar.cpp (110504 => 110505)


--- trunk/Source/WebCore/rendering/RenderScrollbar.cpp	2012-03-12 23:46:17 UTC (rev 110504)
+++ trunk/Source/WebCore/rendering/RenderScrollbar.cpp	2012-03-12 23:51:09 UTC (rev 110505)
@@ -297,27 +297,26 @@
     
     bool isHorizontal = orientation() == HorizontalScrollbar;
     if (partType == BackButtonStartPart)
-        return IntRect(location(), IntSize(isHorizontal ? partRenderer->width() : width(), isHorizontal ? height() : partRenderer->height()));
+        return IntRect(location(), IntSize(isHorizontal ? partRenderer->pixelSnappedWidth() : width(), isHorizontal ? height() : partRenderer->pixelSnappedHeight()));
     if (partType == ForwardButtonEndPart)
-        return IntRect(isHorizontal ? x() + width() - partRenderer->width() : x(),
-        
-                       isHorizontal ? y() : y() + height() - partRenderer->height(),
-                       isHorizontal ? partRenderer->width() : width(),
-                       isHorizontal ? height() : partRenderer->height());
+        return IntRect(isHorizontal ? x() + width() - partRenderer->pixelSnappedWidth() : x(),
+                       isHorizontal ? y() : y() + height() - partRenderer->pixelSnappedHeight(),
+                       isHorizontal ? partRenderer->pixelSnappedWidth() : width(),
+                       isHorizontal ? height() : partRenderer->pixelSnappedHeight());
     
     if (partType == ForwardButtonStartPart) {
         IntRect previousButton = buttonRect(BackButtonStartPart);
         return IntRect(isHorizontal ? x() + previousButton.width() : x(),
                        isHorizontal ? y() : y() + previousButton.height(),
-                       isHorizontal ? partRenderer->width() : width(),
-                       isHorizontal ? height() : partRenderer->height());
+                       isHorizontal ? partRenderer->pixelSnappedWidth() : width(),
+                       isHorizontal ? height() : partRenderer->pixelSnappedHeight());
     }
     
     IntRect followingButton = buttonRect(ForwardButtonEndPart);
-    return IntRect(isHorizontal ? x() + width() - followingButton.width() - partRenderer->width() : x(),
-                   isHorizontal ? y() : y() + height() - followingButton.height() - partRenderer->height(),
-                   isHorizontal ? partRenderer->width() : width(),
-                   isHorizontal ? height() : partRenderer->height());
+    return IntRect(isHorizontal ? x() + width() - followingButton.width() - partRenderer->pixelSnappedWidth() : x(),
+                   isHorizontal ? y() : y() + height() - followingButton.height() - partRenderer->pixelSnappedHeight(),
+                   isHorizontal ? partRenderer->pixelSnappedWidth() : width(),
+                   isHorizontal ? height() : partRenderer->pixelSnappedHeight());
 }
 
 IntRect RenderScrollbar::trackRect(int startLength, int endLength)
@@ -327,16 +326,16 @@
         part->layout();
 
     if (orientation() == HorizontalScrollbar) {
-        int marginLeft = part ? part->marginLeft() : 0;
-        int marginRight = part ? part->marginRight() : 0;
+        int marginLeft = part ? static_cast<int>(part->marginLeft()) : 0;
+        int marginRight = part ? static_cast<int>(part->marginRight()) : 0;
         startLength += marginLeft;
         endLength += marginRight;
         int totalLength = startLength + endLength;
         return IntRect(x() + startLength, y(), width() - totalLength, height());
     }
     
-    int marginTop = part ? part->marginTop() : 0;
-    int marginBottom = part ? part->marginBottom() : 0;
+    int marginTop = part ? static_cast<int>(part->marginTop()) : 0;
+    int marginBottom = part ? static_cast<int>(part->marginBottom()) : 0;
     startLength += marginTop;
     endLength += marginBottom;
     int totalLength = startLength + endLength;

Modified: trunk/Source/WebCore/rendering/RenderScrollbarPart.h (110504 => 110505)


--- trunk/Source/WebCore/rendering/RenderScrollbarPart.h	2012-03-12 23:46:17 UTC (rev 110504)
+++ trunk/Source/WebCore/rendering/RenderScrollbarPart.h	2012-03-12 23:51:09 UTC (rev 110505)
@@ -46,7 +46,13 @@
     virtual void computePreferredLogicalWidths();
     
     void paintIntoRect(GraphicsContext*, const LayoutPoint&, const LayoutRect&);
-    
+
+    // Scrollbar parts needs to be rendered at device pixel boundaries.
+    virtual LayoutUnit marginTop() const { ASSERT(isIntegerValue(m_marginTop)); return m_marginTop; }
+    virtual LayoutUnit marginBottom() const { ASSERT(isIntegerValue(m_marginBottom)); return m_marginBottom; }
+    virtual LayoutUnit marginLeft() const { ASSERT(isIntegerValue(m_marginLeft)); return m_marginLeft; }
+    virtual LayoutUnit marginRight() const { ASSERT(isIntegerValue(m_marginRight)); return m_marginRight; }
+
 protected:
     virtual void styleWillChange(StyleDifference diff, const RenderStyle* newStyle);
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to