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

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

Issue 1031223003: SVG doesn't recognize rem units (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Align with review comments 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
« Source/core/svg/SVGLengthContext.cpp ('K') | « Source/core/svg/SVGLengthTearOff.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGLengthTearOff.cpp
diff --git a/Source/core/svg/SVGLengthTearOff.cpp b/Source/core/svg/SVGLengthTearOff.cpp
index e43a606269c486143342e911471eff1a46cbf7b6..baa44f1f7f079b862be56b53477b59147f8f12b6 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: Not all <length> properties have 0 (with no unit) as the default (lacuna) value, Need to return default value instead of 0
Erik Dahlström (inactive) 2015/04/02 07:58:41 Nit: should be TODO(name), see http://google-style
Shanmuga Pandi 2015/04/02 13:06:51 Done.
+ 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 t o old value
Erik Dahlström (inactive) 2015/04/02 07:58:41 Nit: s/t o/to/
Shanmuga Pandi 2015/04/02 13:06:51 Done.
+ es.throwDOMException(SyntaxError, "The value provided ('" + str + "') is invalid.");
+ return;
+ }
+
commitChange();
}
« Source/core/svg/SVGLengthContext.cpp ('K') | « Source/core/svg/SVGLengthTearOff.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698