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

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

Issue 10908295: Merge 127933 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1229/
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 | « Source/WebCore/css/CSSPrimitiveValue.cpp ('k') | Source/WebCore/platform/graphics/FractionalLayoutRect.h » ('j') | 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 128804)
+++ Source/WebCore/platform/FractionalLayoutUnit.h (working copy)
@@ -182,6 +182,21 @@
m.m_value = std::numeric_limits<int>::min();
return m;
}
+
+ // Versions of max/min that are slightly smaller/larger than max/min() to allow for roinding without overflowing.
+ static const FractionalLayoutUnit nearlyMax()
+ {
+ FractionalLayoutUnit m;
+ m.m_value = std::numeric_limits<int>::max() - kFixedPointDenominator / 2;
+ return m;
+ }
+ static const FractionalLayoutUnit nearlyMin()
+ {
+ FractionalLayoutUnit m;
+ m.m_value = std::numeric_limits<int>::min() + kFixedPointDenominator / 2;
+ return m;
+ }
+
static FractionalLayoutUnit clamp(double value)
{
return clampTo<FractionalLayoutUnit>(value, FractionalLayoutUnit::min(), FractionalLayoutUnit::max());
@@ -685,7 +700,8 @@
inline int snapSizeToPixel(FractionalLayoutUnit size, FractionalLayoutUnit location)
{
- return (location + size).round() - location.round();
+ FractionalLayoutUnit fraction = location - location.floor();
+ return (fraction + size).round() - fraction.round();
}
#if PLATFORM(QT)
« no previous file with comments | « Source/WebCore/css/CSSPrimitiveValue.cpp ('k') | Source/WebCore/platform/graphics/FractionalLayoutRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698