Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: Source/WebCore/platform/FractionalLayoutUnit.h

Issue 10996032: Merge 129370 - snapToSize rounds the incorrectly for negative locations (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1271/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/wk2/Skipped ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/platform/FractionalLayoutUnit.h
===================================================================
--- Source/WebCore/platform/FractionalLayoutUnit.h (revision 129686)
+++ Source/WebCore/platform/FractionalLayoutUnit.h (working copy)
@@ -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();
}
« no previous file with comments | « LayoutTests/platform/wk2/Skipped ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698