Title: [129370] trunk
Revision
129370
Author
e...@chromium.org
Date
2012-09-24 08:35:12 -0700 (Mon, 24 Sep 2012)

Log Message

snapToSize rounds the incorrectly for negative locations
https://bugs.webkit.org/show_bug.cgi?id=97265

Reviewed by Eric Seidel.

Source/WebCore: 

Change snapSizeToPixel to preserve sign for location which
affects rounding.

Test: fast/sub-pixel/snap-negative-location.html

* platform/FractionalLayoutUnit.h:
(WebCore::snapSizeToPixel):

LayoutTests: 

Add test for snapSizeToPixel handling of negative locations.
Skipped on platforms that do not enable subpixel layout.

* fast/sub-pixel/snap-negative-location-expected.html: Added.
* fast/sub-pixel/snap-negative-location.html: Added.
* platform/mac-lion/Skipped:
* platform/mac-snowleopard/Skipped:
* platform/mac-wk2/Skipped:
* platform/mac/Skipped:
* platform/qt-4.8/Skipped:
* platform/qt/Skipped:
* platform/win-wk2/Skipped:
* platform/win-xp/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:
* platform/wk2/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (129369 => 129370)


--- trunk/LayoutTests/ChangeLog	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/ChangeLog	2012-09-24 15:35:12 UTC (rev 129370)
@@ -1,3 +1,27 @@
+2012-09-20  Emil A Eklund  <e...@chromium.org>
+
+        snapToSize rounds the incorrectly for negative locations
+        https://bugs.webkit.org/show_bug.cgi?id=97265
+
+        Reviewed by Eric Seidel.
+
+        Add test for snapSizeToPixel handling of negative locations.
+        Skipped on platforms that do not enable subpixel layout.
+
+        * fast/sub-pixel/snap-negative-location-expected.html: Added.
+        * fast/sub-pixel/snap-negative-location.html: Added.
+        * platform/mac-lion/Skipped:
+        * platform/mac-snowleopard/Skipped:
+        * platform/mac-wk2/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt-4.8/Skipped:
+        * platform/qt/Skipped:
+        * platform/win-wk2/Skipped:
+        * platform/win-xp/Skipped:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+        * platform/wk2/Skipped:
+
 2012-09-24  Zan Dobersek  <zandober...@gmail.com>
 
         REGRESSION (r129211-r129218): http/tests/loading/redirect-with-no-location-crash.html failing on GTK Linux 64-bit Release WK2 (Tests)

Added: trunk/LayoutTests/fast/sub-pixel/snap-negative-location-expected.html (0 => 129370)


--- trunk/LayoutTests/fast/sub-pixel/snap-negative-location-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/sub-pixel/snap-negative-location-expected.html	2012-09-24 15:35:12 UTC (rev 129370)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <div style="position: absolute; top: -4.5px; left: -4.5px; width: 50px; height: 50px; background: navy;">&nbsp;</div>
+    <p style="position: absolute; top: 50px;">
+        Figure above should appear as a solid dark blue square.
+    </p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/sub-pixel/snap-negative-location.html (0 => 129370)


--- trunk/LayoutTests/fast/sub-pixel/snap-negative-location.html	                        (rev 0)
+++ trunk/LayoutTests/fast/sub-pixel/snap-negative-location.html	2012-09-24 15:35:12 UTC (rev 129370)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <div style="position: absolute; top: -4.5px; left: -4.5px; width: 25px; height: 25px; background: navy;">&nbsp;</div>
+    <div style="position: absolute; top: -4.5px; left: 20.5px; width: 25px; height: 25px; background: navy;">&nbsp;</div>
+    <div style="position: absolute; top: 20.5px; left: -4.5px; width: 25px; height: 25px; background: navy;">&nbsp;</div>
+    <div style="position: absolute; top: 20.5px; left: 20.5px; width: 25px; height: 25px; background: navy;">&nbsp;</div>
+    <p style="position: absolute; top: 50px;">
+        Figure above should appear as a solid dark blue square.
+    </p>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/mac/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/mac/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -726,6 +726,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # No CORS support for media elements is implemented yet.
 http/tests/security/video-cross-origin-readback.html

Modified: trunk/LayoutTests/platform/mac-lion/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/mac-lion/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/mac-lion/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -119,6 +119,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # This media test always failed on Lion
 # https://bugs.webkit.org/show_bug.cgi?id=86527 and <rdar://problem/11458493>
@@ -136,4 +137,4 @@
 inspector/debugger/debugger-expand-scope.html
 
 # Lion does not support web notifications
-http/tests/notifications
\ No newline at end of file
+http/tests/notifications

Modified: trunk/LayoutTests/platform/mac-snowleopard/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/mac-snowleopard/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/mac-snowleopard/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -213,6 +213,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # Frame::findString does nothing on pages that prevent selection
 # https://bugs.webkit.org/show_bug.cgi?id=40361

Modified: trunk/LayoutTests/platform/mac-wk2/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/mac-wk2/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/mac-wk2/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -216,6 +216,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # fast/events/pagehide-timeout.html, pageshow-pagehide-on-back-cached-with-frames.html, and
 # pageshow-pagehide-on-back-cached.html flakey on Lion Intel Debug WebKit testers.

Modified: trunk/LayoutTests/platform/qt/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/qt/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -312,6 +312,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # USE(V8)
 

Modified: trunk/LayoutTests/platform/qt-4.8/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/qt-4.8/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/qt-4.8/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -106,6 +106,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # SVG Fonts are only supported when using QRawFont, which is not
 # supported with Qt 4.

Modified: trunk/LayoutTests/platform/win/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/win/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/win/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -1752,6 +1752,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # No CORS support for media elements is implemented yet.
 http/tests/security/video-cross-origin-readback.html

Modified: trunk/LayoutTests/platform/win-wk2/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/win-wk2/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/win-wk2/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -950,6 +950,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # HiDPI tests require test infrastructure enhancements
 fast/hidpi

Modified: trunk/LayoutTests/platform/win-xp/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/win-xp/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/win-xp/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -49,6 +49,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # REGRESSION (r83928 or before): Some tests failing assertions in MarkStack::internalAppend / MarkStack::drain
 # https://bugs.webkit.org/show_bug.cgi?id=58657

Modified: trunk/LayoutTests/platform/wincairo/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/wincairo/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/wincairo/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -2283,6 +2283,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # No CORS support for media elements is implemented yet.
 http/tests/security/video-cross-origin-readback.html

Modified: trunk/LayoutTests/platform/wk2/Skipped (129369 => 129370)


--- trunk/LayoutTests/platform/wk2/Skipped	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/LayoutTests/platform/wk2/Skipped	2012-09-24 15:35:12 UTC (rev 129370)
@@ -98,6 +98,7 @@
 fast/sub-pixel/table-rows-no-gaps.html
 fast/sub-pixel/sub-pixel-accumulates-to-layers.html
 fast/sub-pixel/selection/selection-rect-in-sub-pixel-table.html
+fast/sub-pixel/snap-negative-location.html
 
 # [WK2][WTR] svg/animations/animate-text-nested-transforms.html fails
 # https://bugs.webkit.org/show_bug.cgi?id=95191

Modified: trunk/Source/WebCore/ChangeLog (129369 => 129370)


--- trunk/Source/WebCore/ChangeLog	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/Source/WebCore/ChangeLog	2012-09-24 15:35:12 UTC (rev 129370)
@@ -1,3 +1,18 @@
+2012-09-20  Emil A Eklund  <e...@chromium.org>
+
+        snapToSize rounds the incorrectly for negative locations
+        https://bugs.webkit.org/show_bug.cgi?id=97265
+
+        Reviewed by Eric Seidel.
+
+        Change snapSizeToPixel to preserve sign for location which
+        affects rounding.
+
+        Test: fast/sub-pixel/snap-negative-location.html
+
+        * platform/FractionalLayoutUnit.h:
+        (WebCore::snapSizeToPixel):
+
 2012-09-24  Jonathan Liu  <net...@gmail.com>
 
         Use unsigned char for bitfield instead of unsigned.

Modified: trunk/Source/WebCore/platform/FractionalLayoutUnit.h (129369 => 129370)


--- trunk/Source/WebCore/platform/FractionalLayoutUnit.h	2012-09-24 15:33:42 UTC (rev 129369)
+++ trunk/Source/WebCore/platform/FractionalLayoutUnit.h	2012-09-24 15:35:12 UTC (rev 129370)
@@ -227,6 +227,15 @@
 #endif
     }
 
+    FractionalLayoutUnit fraction() const
+    {   
+        // Add the fraction to the size (as opposed to the full location) to avoid overflows.
+        // Compute fraction using the mod operator to preserve the sign of the value as it may affect rounding.
+        FractionalLayoutUnit fraction;
+        fraction.setRawValue(rawValue() % kFixedPointDenominator);
+        return fraction;
+    }
+
 #if ENABLE(SUBPIXEL_LAYOUT)
     static float epsilon() { return 1.0f / kFixedPointDenominator; }
 #else
@@ -807,7 +816,7 @@
 
 inline int snapSizeToPixel(FractionalLayoutUnit size, FractionalLayoutUnit location) 
 {
-    FractionalLayoutUnit fraction = location - location.floor();
+    FractionalLayoutUnit fraction = location.fraction();
     return (fraction + size).round() - fraction.round();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to