This source file includes following definitions.
- toSVGLengthType
- unitType
- unitMode
- value
- setValue
- valueInSpecifiedUnits
- setValueInSpecifiedUnits
- valueAsString
- setValueAsString
- newValueSpecifiedUnits
- convertToSpecifiedUnits
#include "config.h"
#include "core/svg/SVGLengthTearOff.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
namespace WebCore {
namespace {
inline SVGLengthType toSVGLengthType(unsigned short type)
{
ASSERT(type >= LengthTypeUnknown && type <= LengthTypePC);
return static_cast<SVGLengthType>(type);
}
}
SVGLengthType SVGLengthTearOff::unitType()
{
return target()->unitType();
}
SVGLengthMode SVGLengthTearOff::unitMode()
{
return target()->unitMode();
}
float SVGLengthTearOff::value(ExceptionState& es)
{
SVGLengthContext lengthContext(contextElement());
return target()->value(lengthContext, es);
}
void SVGLengthTearOff::setValue(float value, ExceptionState& es)
{
if (isImmutable()) {
es.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
return;
}
SVGLengthContext lengthContext(contextElement());
target()->setValue(value, lengthContext, es);
commitChange();
}
float SVGLengthTearOff::valueInSpecifiedUnits()
{
return target()->valueInSpecifiedUnits();
}
void SVGLengthTearOff::setValueInSpecifiedUnits(float value, ExceptionState& es)
{
if (isImmutable()) {
es.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
return;
}
target()->setValueInSpecifiedUnits(value);
commitChange();
}
String SVGLengthTearOff::valueAsString()
{
return target()->valueAsString();
}
void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& es)
{
if (isImmutable()) {
es.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
return;
}
target()->setValueAsString(str, es);
commitChange();
}
void SVGLengthTearOff::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits, ExceptionState& exceptionState)
{
if (isImmutable()) {
exceptionState.throwDOMException(NoModificationAllowedError, "The object is read-only.");
return;
}
if (unitType == LengthTypeUnknown || unitType > LengthTypePC) {
exceptionState.throwDOMException(NotSupportedError, "Cannot set value with unknown or invalid units (" + String::number(unitType) + ").");
return;
}
target()->newValueSpecifiedUnits(toSVGLengthType(unitType), valueInSpecifiedUnits);
commitChange();
}
void SVGLengthTearOff::convertToSpecifiedUnits(unsigned short unitType, ExceptionState& exceptionState)
{
if (isImmutable()) {
exceptionState.throwDOMException(NoModificationAllowedError, "The object is read-only.");
return;
}
if (unitType == LengthTypeUnknown || unitType > LengthTypePC) {
exceptionState.throwDOMException(NotSupportedError, "Cannot convert to unknown or invalid units (" + String::number(unitType) + ").");
return;
}
SVGLengthContext lengthContext(contextElement());
target()->convertToSpecifiedUnits(toSVGLengthType(unitType), lengthContext, exceptionState);
commitChange();
}
SVGLengthTearOff::SVGLengthTearOff(PassRefPtr<SVGLength> target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName)
: SVGPropertyTearOff<SVGLength>(target, contextElement, propertyIsAnimVal, attributeName)
{
ScriptWrappable::init(this);
}
}