Title: [129688] branches/chromium/1271
Revision
129688
Author
e...@chromium.org
Date
2012-09-26 12:44:07 -0700 (Wed, 26 Sep 2012)

Log Message

Merge 129370 - 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:


TBR=e...@chromium.org
Review URL: https://codereview.chromium.org/10996032

Modified Paths

Added Paths

Diff

Copied: branches/chromium/1271/LayoutTests/fast/sub-pixel/snap-negative-location-expected.html (from rev 129370, trunk/LayoutTests/fast/sub-pixel/snap-negative-location-expected.html) (0 => 129688)


--- branches/chromium/1271/LayoutTests/fast/sub-pixel/snap-negative-location-expected.html	                        (rev 0)
+++ branches/chromium/1271/LayoutTests/fast/sub-pixel/snap-negative-location-expected.html	2012-09-26 19:44:07 UTC (rev 129688)
@@ -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>

Copied: branches/chromium/1271/LayoutTests/fast/sub-pixel/snap-negative-location.html (from rev 129370, trunk/LayoutTests/fast/sub-pixel/snap-negative-location.html) (0 => 129688)


--- branches/chromium/1271/LayoutTests/fast/sub-pixel/snap-negative-location.html	                        (rev 0)
+++ branches/chromium/1271/LayoutTests/fast/sub-pixel/snap-negative-location.html	2012-09-26 19:44:07 UTC (rev 129688)
@@ -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: branches/chromium/1271/LayoutTests/platform/mac/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/mac/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/mac/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -825,6 +825,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: branches/chromium/1271/LayoutTests/platform/mac-lion/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/mac-lion/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/mac-lion/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -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: branches/chromium/1271/LayoutTests/platform/mac-snowleopard/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/mac-snowleopard/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/mac-snowleopard/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -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: branches/chromium/1271/LayoutTests/platform/mac-wk2/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/mac-wk2/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/mac-wk2/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -217,6 +217,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: branches/chromium/1271/LayoutTests/platform/qt/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/qt/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/qt/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -309,6 +309,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
 
 # CSS Regions support not yet enabled. http://webkit.org/b/57312
 fast/regions

Modified: branches/chromium/1271/LayoutTests/platform/qt-4.8/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/qt-4.8/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/qt-4.8/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -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: branches/chromium/1271/LayoutTests/platform/win/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/win/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/win/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -1746,6 +1746,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: branches/chromium/1271/LayoutTests/platform/win-wk2/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/win-wk2/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/win-wk2/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -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: branches/chromium/1271/LayoutTests/platform/win-xp/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/win-xp/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/win-xp/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -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: branches/chromium/1271/LayoutTests/platform/wincairo/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/wincairo/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/wincairo/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -2135,6 +2135,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
 
 #Battery Status API is not implemented.
 batterystatus

Modified: branches/chromium/1271/LayoutTests/platform/wk2/Skipped (129687 => 129688)


--- branches/chromium/1271/LayoutTests/platform/wk2/Skipped	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/LayoutTests/platform/wk2/Skipped	2012-09-26 19:44:07 UTC (rev 129688)
@@ -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: branches/chromium/1271/Source/WebCore/platform/FractionalLayoutUnit.h (129687 => 129688)


--- branches/chromium/1271/Source/WebCore/platform/FractionalLayoutUnit.h	2012-09-26 19:43:20 UTC (rev 129687)
+++ branches/chromium/1271/Source/WebCore/platform/FractionalLayoutUnit.h	2012-09-26 19:44:07 UTC (rev 129688)
@@ -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