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

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

Issue 901193002: De-ExceptionState-ify SVGLengthContext (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« Source/core/svg/SVGLength.h ('K') | « 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..d02e2608fa68b6d693ef0dec48f382d3022949d3 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, "No context could be found.");
+ 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, "No context could be found.");
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, "No context could be found.");
pdr. 2015/02/05 22:12:32 Bikeshed: is the concept of a length context somet
fs 2015/02/06 12:26:04 Funny you should say that, because that's pretty m
+ return;
+ }
+
SVGLengthContext lengthContext(contextElement());
- target()->convertToSpecifiedUnits(toSVGLengthType(unitType), lengthContext, exceptionState);
+ target()->convertToSpecifiedUnits(toSVGLengthType(unitType), lengthContext);
commitChange();
}
« Source/core/svg/SVGLength.h ('K') | « Source/core/svg/SVGLengthList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698