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

Unified Diff: Source/core/svg/SVGLengthContext.cpp

Issue 963733002: [svg2] Make 'width' and 'height' presentation attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: test fixes Created 5 years, 9 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
Index: Source/core/svg/SVGLengthContext.cpp
diff --git a/Source/core/svg/SVGLengthContext.cpp b/Source/core/svg/SVGLengthContext.cpp
index f1b5ffceebe4232d09b09d7adb8a71706b85bf90..926db764d6617bcd63b6f22d4c3a662dd99aa059 100644
--- a/Source/core/svg/SVGLengthContext.cpp
+++ b/Source/core/svg/SVGLengthContext.cpp
@@ -24,6 +24,7 @@
#include "core/svg/SVGLengthContext.h"
#include "core/css/CSSHelper.h"
+#include "core/css/CSSPrimitiveValue.h"
#include "core/layout/LayoutObject.h"
#include "core/layout/style/LayoutStyle.h"
#include "core/svg/SVGSVGElement.h"
@@ -48,7 +49,7 @@ static inline float dimensionForLengthMode(SVGLengthMode mode, const FloatSize&
static float convertValueFromPercentageToUserUnits(const SVGLength& value, const FloatSize& viewportSize)
{
- return value.scaleByPercentage(dimensionForLengthMode(value.unitMode(), viewportSize));
+ return CSSPrimitiveValue::clampToCSSLengthRange(value.scaleByPercentage(dimensionForLengthMode(value.unitMode(), viewportSize)));
}
SVGLengthContext::SVGLengthContext(const SVGElement* context)
@@ -135,29 +136,29 @@ float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
case LengthTypeUnknown:
return 0;
case LengthTypeNumber:
- return value;
+ return CSSPrimitiveValue::clampToCSSLengthRange(value);
fs 2015/03/12 14:28:48 This is begging to be sunk out of the switch in on
Erik Dahlström (inactive) 2015/03/12 16:14:56 Done.
case LengthTypePX:
- return value;
+ return CSSPrimitiveValue::clampToCSSLengthRange(value);
case LengthTypePercentage: {
FloatSize viewportSize;
if (!determineViewport(viewportSize))
return 0;
- return value * dimensionForLengthMode(mode, viewportSize) / 100;
+ return CSSPrimitiveValue::clampToCSSLengthRange(value * dimensionForLengthMode(mode, viewportSize) / 100);
}
case LengthTypeEMS:
- return convertValueFromEMSToUserUnits(value);
+ return CSSPrimitiveValue::clampToCSSLengthRange(convertValueFromEMSToUserUnits(value));
case LengthTypeEXS:
- return convertValueFromEXSToUserUnits(value);
+ return CSSPrimitiveValue::clampToCSSLengthRange(convertValueFromEXSToUserUnits(value));
case LengthTypeCM:
- return value * cssPixelsPerCentimeter;
+ return CSSPrimitiveValue::clampToCSSLengthRange(value * cssPixelsPerCentimeter);
case LengthTypeMM:
- return value * cssPixelsPerMillimeter;
+ return CSSPrimitiveValue::clampToCSSLengthRange(value * cssPixelsPerMillimeter);
case LengthTypeIN:
- return value * cssPixelsPerInch;
+ return CSSPrimitiveValue::clampToCSSLengthRange(value * cssPixelsPerInch);
case LengthTypePT:
- return value * cssPixelsPerPoint;
+ return CSSPrimitiveValue::clampToCSSLengthRange(value * cssPixelsPerPoint);
case LengthTypePC:
- return value * cssPixelsPerPica;
+ return CSSPrimitiveValue::clampToCSSLengthRange(value * cssPixelsPerPica);
}
ASSERT_NOT_REACHED();

Powered by Google App Engine
This is Rietveld 408576698