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

Unified Diff: Source/core/css/CSSLengthFunctions.cpp

Issue 122973002: Refactor the length functions to remove passing around the extra bool parameter for rounding behavi… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Try again Created 6 years, 12 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/core/css/CSSLengthFunctions.h ('k') | Source/core/rendering/RenderBoxModelObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSLengthFunctions.cpp
diff --git a/Source/core/css/CSSLengthFunctions.cpp b/Source/core/css/CSSLengthFunctions.cpp
index dcc768cec4b87118250fd12268725a03b4516ed5..91d52286e5d74d2a67bc6346042de91cbdb98d67 100644
--- a/Source/core/css/CSSLengthFunctions.cpp
+++ b/Source/core/css/CSSLengthFunctions.cpp
@@ -31,24 +31,22 @@
namespace WebCore {
-int minimumIntValueForLength(const Length& length, LayoutUnit maximumValue, bool roundPercentages)
+int minimumIntValueForLength(const Length& length, LayoutUnit maximumValue)
{
- return static_cast<int>(minimumValueForLength(length, maximumValue, roundPercentages));
+ return static_cast<int>(minimumValueForLength(length, maximumValue));
}
-int intValueForLength(const Length& length, LayoutUnit maximumValue, bool roundPercentages)
+int intValueForLength(const Length& length, LayoutUnit maximumValue)
{
- return static_cast<int>(valueForLength(length, maximumValue, roundPercentages));
+ return static_cast<int>(valueForLength(length, maximumValue));
}
-LayoutUnit minimumValueForLength(const Length& length, LayoutUnit maximumValue, bool roundPercentages)
+LayoutUnit minimumValueForLength(const Length& length, LayoutUnit maximumValue)
{
switch (length.type()) {
case Fixed:
return length.value();
case Percent:
- if (roundPercentages)
- return static_cast<LayoutUnit>(round(maximumValue * length.percent() / 100.0f));
// Don't remove the extra cast to float. It is needed for rounding on 32-bit Intel machines that use the FPU stack.
return static_cast<float>(maximumValue * length.percent() / 100.0f);
case Calculated:
@@ -72,13 +70,20 @@ LayoutUnit minimumValueForLength(const Length& length, LayoutUnit maximumValue,
return 0;
}
-LayoutUnit valueForLength(const Length& length, LayoutUnit maximumValue, bool roundPercentages)
+LayoutUnit roundedMinimumValueForLength(const Length& length, LayoutUnit maximumValue)
+{
+ if (length.type() == Percent)
+ return static_cast<LayoutUnit>(round(maximumValue * length.percent() / 100.0f));
+ return minimumValueForLength(length, maximumValue);
+}
+
+LayoutUnit valueForLength(const Length& length, LayoutUnit maximumValue)
{
switch (length.type()) {
case Fixed:
case Percent:
case Calculated:
- return minimumValueForLength(length, maximumValue, roundPercentages);
+ return minimumValueForLength(length, maximumValue);
case FillAvailable:
case Auto:
return maximumValue;
« no previous file with comments | « Source/core/css/CSSLengthFunctions.h ('k') | Source/core/rendering/RenderBoxModelObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698