Title: [139013] trunk
Revision
139013
Author
[email protected]
Date
2013-01-07 16:39:06 -0800 (Mon, 07 Jan 2013)

Log Message

REGRESSION(SUBPIXEL_LAYOUT): el.offsetWidth < el.clientWidth for elements of a certain size
https://bugs.webkit.org/show_bug.cgi?id=106107

Source/WebCore:

Reviewed by Levi Weintraub.

Add overloaded pixelSnappedOffsetWidth|Height methods to
RenderBox that do pixel snapping with the same offset
as clientWidth/height to ensure consistent rounding.

Test: fast/sub-pixel/client-and-offset-width.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::pixelSnappedOffsetWidth):
(WebCore::RenderBox::pixelSnappedOffsetHeight):
Snap using the same offset as the clientWidth/height versions.

* rendering/RenderBox.h:
Remove out of date FIXME and add OVERRIDE keyword.

* rendering/RenderBoxModelObject.h:
Mark pixelSnappedOffsetWidth|Height as virtual.

LayoutTests:

Reviewed by Levi Weintraub.

Add test for clientWidth/offsetWidth rounding.

* fast/sub-pixel/client-and-offset-width-expected.txt: Added.
* fast/sub-pixel/client-and-offset-width.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139012 => 139013)


--- trunk/LayoutTests/ChangeLog	2013-01-08 00:38:54 UTC (rev 139012)
+++ trunk/LayoutTests/ChangeLog	2013-01-08 00:39:06 UTC (rev 139013)
@@ -1,3 +1,15 @@
+2013-01-07  Emil A Eklund  <[email protected]>
+
+        REGRESSION(SUBPIXEL_LAYOUT): el.offsetWidth < el.clientWidth for elements of a certain size
+        https://bugs.webkit.org/show_bug.cgi?id=106107
+
+        Reviewed by Levi Weintraub.
+        
+        Add test for clientWidth/offsetWidth rounding.
+
+        * fast/sub-pixel/client-and-offset-width-expected.txt: Added.
+        * fast/sub-pixel/client-and-offset-width.html: Added.
+
 2013-01-07  Ryosuke Niwa  <[email protected]>
 
         Add Mac Lion result after r138986.

Added: trunk/LayoutTests/fast/sub-pixel/client-and-offset-width-expected.txt (0 => 139013)


--- trunk/LayoutTests/fast/sub-pixel/client-and-offset-width-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/sub-pixel/client-and-offset-width-expected.txt	2013-01-08 00:39:06 UTC (rev 139013)
@@ -0,0 +1,2 @@
+PASS offsetWidth and clientWidth are the same
+Tests that a block without overflow, borders, margin or padding reports the same clientWidth as offsetWidth.

Added: trunk/LayoutTests/fast/sub-pixel/client-and-offset-width.html (0 => 139013)


--- trunk/LayoutTests/fast/sub-pixel/client-and-offset-width.html	                        (rev 0)
+++ trunk/LayoutTests/fast/sub-pixel/client-and-offset-width.html	2013-01-08 00:39:06 UTC (rev 139013)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+    </head>
+
+    <body>
+        <div style="margin: 1.1em;">
+            <div id="test"></div>
+        </div>
+        
+        <p>
+            Tests that a block without overflow, borders, margin or padding reports the same clientWidth as offsetWidth.
+        </p>
+
+        <script>
+            var el = document.getElementById("test");
+            if (el.offsetWidth == el.clientWidth)
+                testPassed('offsetWidth and clientWidth are the same');
+            else
+                testFailed('offsetWidth is ' + el.offsetWidth + ' but clientWidth is ' + el.clientWidth);
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (139012 => 139013)


--- trunk/Source/WebCore/ChangeLog	2013-01-08 00:38:54 UTC (rev 139012)
+++ trunk/Source/WebCore/ChangeLog	2013-01-08 00:39:06 UTC (rev 139013)
@@ -1,3 +1,27 @@
+2013-01-07  Emil A Eklund  <[email protected]>
+
+        REGRESSION(SUBPIXEL_LAYOUT): el.offsetWidth < el.clientWidth for elements of a certain size
+        https://bugs.webkit.org/show_bug.cgi?id=106107
+
+        Reviewed by Levi Weintraub.
+        
+        Add overloaded pixelSnappedOffsetWidth|Height methods to
+        RenderBox that do pixel snapping with the same offset
+        as clientWidth/height to ensure consistent rounding.
+
+        Test: fast/sub-pixel/client-and-offset-width.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::pixelSnappedOffsetWidth):
+        (WebCore::RenderBox::pixelSnappedOffsetHeight):
+        Snap using the same offset as the clientWidth/height versions.
+        
+        * rendering/RenderBox.h:
+        Remove out of date FIXME and add OVERRIDE keyword.
+        
+        * rendering/RenderBoxModelObject.h:
+        Mark pixelSnappedOffsetWidth|Height as virtual.
+
 2013-01-07  Adam Barth  <[email protected]>
 
         Introduce HTMLParserOptions to encapsulate HTML parser options

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (139012 => 139013)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-01-08 00:38:54 UTC (rev 139012)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-01-08 00:39:06 UTC (rev 139013)
@@ -392,6 +392,16 @@
     return snapSizeToPixel(clientHeight(), y() + clientTop());
 }
 
+int RenderBox::pixelSnappedOffsetWidth() const
+{
+    return snapSizeToPixel(offsetWidth(), x() + clientLeft());
+}
+
+int RenderBox::pixelSnappedOffsetHeight() const
+{
+    return snapSizeToPixel(offsetHeight(), y() + clientTop());
+}
+
 int RenderBox::scrollWidth() const
 {
     if (hasOverflowClip())

Modified: trunk/Source/WebCore/rendering/RenderBox.h (139012 => 139013)


--- trunk/Source/WebCore/rendering/RenderBox.h	2013-01-08 00:38:54 UTC (rev 139012)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2013-01-08 00:39:06 UTC (rev 139013)
@@ -205,9 +205,8 @@
     virtual LayoutUnit offsetWidth() const { return width(); }
     virtual LayoutUnit offsetHeight() const { return height(); }
 
-    // FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318.
-    virtual int pixelSnappedOffsetWidth() const { return pixelSnappedWidth(); }
-    virtual int pixelSnappedOffsetHeight() const { return pixelSnappedHeight(); }
+    virtual int pixelSnappedOffsetWidth() const OVERRIDE;
+    virtual int pixelSnappedOffsetHeight() const OVERRIDE;
 
     // More IE extensions.  clientWidth and clientHeight represent the interior of an object
     // excluding border and scrollbar.  clientLeft/Top are just the borderLeftWidth and borderTopWidth.

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (139012 => 139013)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-01-08 00:38:54 UTC (rev 139012)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-01-08 00:39:06 UTC (rev 139013)
@@ -80,8 +80,8 @@
 
     int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); }
     int pixelSnappedOffsetTop() const { return roundToInt(offsetTop()); }
-    int pixelSnappedOffsetWidth() const;
-    int pixelSnappedOffsetHeight() const;
+    virtual int pixelSnappedOffsetWidth() const;
+    virtual int pixelSnappedOffsetHeight() const;
 
     virtual void updateFromStyle() OVERRIDE;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to