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

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

Issue 901193002: De-ExceptionState-ify SVGLengthContext (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 5 years, 10 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/svg/SVGLengthList.cpp ('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 4706375632785d7d0968c17400b926015bf833b3..e43a606269c486143342e911471eff1a46cbf7b6 100644
--- a/Source/core/svg/SVGLengthTearOff.cpp
+++ b/Source/core/svg/SVGLengthTearOff.cpp
@@ -46,6 +46,11 @@ inline SVGLengthType toSVGLengthType(unsigned short type)
return static_cast<SVGLengthType>(type);
}
+inline bool canResolveRelativeUnits(const SVGElement* contextElement)
+{
+ return contextElement && contextElement->inDocument();
+}
+
} // namespace
SVGLengthType SVGLengthTearOff::unitType()
@@ -58,21 +63,31 @@ SVGLengthMode SVGLengthTearOff::unitMode()
return target()->unitMode();
}
-float SVGLengthTearOff::value(ExceptionState& es)
+float SVGLengthTearOff::value(ExceptionState& exceptionState)
{
+ if (target()->isRelative() && !canResolveRelativeUnits(contextElement())) {
+ exceptionState.throwDOMException(NotSupportedError, "Could not resolve relative length.");
+ return 0;
+ }
+
SVGLengthContext lengthContext(contextElement());
- return target()->value(lengthContext, es);
+ return target()->value(lengthContext);
}
-void SVGLengthTearOff::setValue(float value, ExceptionState& es)
+void SVGLengthTearOff::setValue(float value, ExceptionState& exceptionState)
{
if (isImmutable()) {
- es.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
+ exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
+ return;
+ }
+
+ if (target()->isRelative() && !canResolveRelativeUnits(contextElement())) {
+ exceptionState.throwDOMException(NotSupportedError, "Could not resolve relative length.");
return;
}
SVGLengthContext lengthContext(contextElement());
- target()->setValue(value, lengthContext, es);
+ target()->setValue(value, lengthContext);
commitChange();
}
@@ -135,8 +150,14 @@ void SVGLengthTearOff::convertToSpecifiedUnits(unsigned short unitType, Exceptio
return;
}
+ if ((target()->isRelative() || SVGLength::isRelativeUnit(toSVGLengthType(unitType)))
+ && !canResolveRelativeUnits(contextElement())) {
+ exceptionState.throwDOMException(NotSupportedError, "Could not resolve relative length.");
+ return;
+ }
+
SVGLengthContext lengthContext(contextElement());
- target()->convertToSpecifiedUnits(toSVGLengthType(unitType), lengthContext, exceptionState);
+ target()->convertToSpecifiedUnits(toSVGLengthType(unitType), lengthContext);
commitChange();
}
« no previous file with comments | « Source/core/svg/SVGLengthList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698