Chromium Code Reviews| Index: Source/core/svg/SVGLengthTearOff.cpp |
| diff --git a/Source/core/svg/SVGLengthTearOff.cpp b/Source/core/svg/SVGLengthTearOff.cpp |
| index e43a606269c486143342e911471eff1a46cbf7b6..88eefe79623908eb0835d73f8e78b9f80f4dd6f6 100644 |
| --- a/Source/core/svg/SVGLengthTearOff.cpp |
| +++ b/Source/core/svg/SVGLengthTearOff.cpp |
| @@ -55,7 +55,7 @@ inline bool canResolveRelativeUnits(const SVGElement* contextElement) |
| SVGLengthType SVGLengthTearOff::unitType() |
| { |
| - return target()->unitType(); |
| + return hasExposedLengthUnit() ? target()->unitType() : LengthTypeUnknown; |
| } |
| SVGLengthMode SVGLengthTearOff::unitMode() |
| @@ -108,7 +108,8 @@ void SVGLengthTearOff::setValueInSpecifiedUnits(float value, ExceptionState& es) |
| String SVGLengthTearOff::valueAsString() |
| { |
| - return target()->valueAsString(); |
| + // TODO(shanmuga.m@samsung.com): Not all <length> properties have 0 (with no unit) as the default (lacuna) value, Need to return default value or previous valid value instead of 0 |
|
Erik Dahlström (inactive)
2015/04/02 13:37:25
Returning the previous value would be entirely wro
Shanmuga Pandi
2015/04/02 13:43:57
I have checked the behavior in gecko with the foll
|
| + return hasExposedLengthUnit() ? target()->valueAsString() : String::number(0); |
| } |
| void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& es) |
| @@ -118,7 +119,16 @@ void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& es) |
| return; |
| } |
| + String oldValue = target()->valueAsString(); |
| + |
| target()->setValueAsString(str, es); |
| + |
| + if (!es.hadException() && !hasExposedLengthUnit()) { |
| + target()->setValueAsString(oldValue, ASSERT_NO_EXCEPTION); // rollback to old value |
| + es.throwDOMException(SyntaxError, "The value provided ('" + str + "') is invalid."); |
| + return; |
| + } |
| + |
| commitChange(); |
| } |