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

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

Issue 112003003: [SVG] SVGLength{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaselined Created 7 years 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
Index: Source/core/svg/SVGLength.cpp
diff --git a/Source/core/svg/SVGLength.cpp b/Source/core/svg/SVGLength.cpp
index b6a95967feab3665b91b59a50558792b64a162e7..982a9b75f7512afb3ad15982526e835fb02b27d8 100644
--- a/Source/core/svg/SVGLength.cpp
+++ b/Source/core/svg/SVGLength.cpp
@@ -1,22 +1,31 @@
/*
- * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
@@ -24,46 +33,32 @@
#include "core/svg/SVGLength.h"
#include "SVGNames.h"
-#include "bindings/v8/ExceptionStatePlaceholder.h"
+#include "bindings/v8/ExceptionState.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/dom/ExceptionCode.h"
+#include "core/svg/SVGAnimationElement.h"
#include "core/svg/SVGParserUtilities.h"
+#include "platform/animation/AnimationUtilities.h"
#include "wtf/MathExtras.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
-static inline SVGLengthMode toSVGLengthMode(unsigned short mode)
+namespace {
+
+inline SVGLengthMode toSVGLengthMode(unsigned short mode)
{
ASSERT(mode >= LengthModeWidth && mode <= LengthModeOther);
return static_cast<SVGLengthMode>(mode);
}
-static inline SVGLengthType toSVGLengthType(unsigned short type)
+inline SVGLengthType toSVGLengthType(unsigned short type)
{
ASSERT(type >= LengthTypeUnknown && type <= LengthTypePC);
return static_cast<SVGLengthType>(type);
}
-static inline unsigned int storeUnit(SVGLengthMode mode, SVGLengthType type)
-{
- return (mode << 4) | type;
-}
-
-static inline SVGLengthMode extractMode(unsigned int unit)
-{
- unsigned int mode = unit >> 4;
- return toSVGLengthMode(mode);
-}
-
-static inline SVGLengthType extractType(unsigned int unit)
-{
- unsigned int mode = unit >> 4;
- unsigned int type = unit ^ (mode << 4);
- return toSVGLengthType(type);
-}
-
-static inline String lengthTypeToString(SVGLengthType type)
+inline String lengthTypeToString(SVGLengthType type)
{
switch (type) {
case LengthTypeUnknown:
@@ -94,7 +89,7 @@ static inline String lengthTypeToString(SVGLengthType type)
}
template<typename CharType>
-static SVGLengthType stringToLengthType(const CharType*& ptr, const CharType* end)
+SVGLengthType stringToLengthType(const CharType*& ptr, const CharType* end)
{
if (ptr == end)
return LengthTypeNumber;
@@ -129,99 +124,72 @@ static SVGLengthType stringToLengthType(const CharType*& ptr, const CharType* en
return LengthTypeUnknown;
}
-SVGLength::SVGLength(SVGLengthMode mode, const String& valueAsString)
- : m_valueInSpecifiedUnits(0)
- , m_unit(storeUnit(mode, LengthTypeNumber))
-{
- setValueAsString(valueAsString, IGNORE_EXCEPTION);
-}
+} // namespace
-SVGLength::SVGLength(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType)
+SVGLength::SVGLength(SVGLengthMode mode)
: m_valueInSpecifiedUnits(0)
- , m_unit(storeUnit(mode, unitType))
-{
- setValue(value, context, ASSERT_NO_EXCEPTION);
-}
-
-SVGLength::SVGLength(const SVGLength& other)
- : m_valueInSpecifiedUnits(other.m_valueInSpecifiedUnits)
- , m_unit(other.m_unit)
+ , m_unitMode(mode)
+ , m_unitType(LengthTypeNumber)
{
}
-void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode, ExceptionState& exceptionState)
+PassRefPtr<SVGLength> SVGLength::clone() const
{
- m_valueInSpecifiedUnits = 0;
- m_unit = storeUnit(mode, LengthTypeNumber);
- setValueAsString(valueAsString, exceptionState);
-}
+ RefPtr<SVGLength> length = create();
pdr. 2014/01/07 06:42:53 This function may be hot on performance. It could
kouhei (in TOK) 2014/01/08 08:12:07 Done.
-bool SVGLength::operator==(const SVGLength& other) const
-{
- return m_unit == other.m_unit
- && m_valueInSpecifiedUnits == other.m_valueInSpecifiedUnits;
-}
+ length->m_valueInSpecifiedUnits = m_valueInSpecifiedUnits;
+ length->m_unitMode = m_unitMode;
+ length->m_unitType = m_unitType;
-bool SVGLength::operator!=(const SVGLength& other) const
-{
- return !operator==(other);
+ return length.release();
}
-SVGLength SVGLength::construct(SVGLengthMode mode, const String& valueAsString, SVGParsingError& parseError, SVGLengthNegativeValuesMode negativeValuesMode)
+PassRefPtr<NewSVGPropertyBase> SVGLength::cloneForAnimation(const String& value) const
{
- TrackExceptionState exceptionState;
- SVGLength length(mode);
-
- length.setValueAsString(valueAsString, exceptionState);
+ RefPtr<SVGLength> length = create();
- if (exceptionState.hadException())
- parseError = ParsingAttributeFailedError;
- else if (negativeValuesMode == ForbidNegativeLengths && length.valueInSpecifiedUnits() < 0)
- parseError = NegativeValueForbiddenError;
+ length->m_unitMode = m_unitMode;
+ length->m_unitType = m_unitType;
+ length->setValueAsString(value, IGNORE_EXCEPTION);
- return length;
-}
-
-SVGLengthType SVGLength::unitType() const
-{
- return extractType(m_unit);
-}
-
-SVGLengthMode SVGLength::unitMode() const
-{
- return extractMode(m_unit);
+ return length.release();
}
-float SVGLength::value(const SVGLengthContext& context) const
+bool SVGLength::operator==(const SVGLength& other) const
{
- return value(context, IGNORE_EXCEPTION);
+ return m_unitMode == other.m_unitMode
+ && m_unitType == other.m_unitType
+ && m_valueInSpecifiedUnits == other.m_valueInSpecifiedUnits;
}
-float SVGLength::value(const SVGLengthContext& context, ExceptionState& exceptionState) const
+void SVGLength::setUnitType(SVGLengthType unitType)
{
- return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit), exceptionState);
+ ASSERT(unitType != LengthTypeUnknown && unitType <= LengthTypePC);
+ m_unitType = unitType;
}
-void SVGLength::setValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType, ExceptionState& exceptionState)
+float SVGLength::value(const SVGLengthContext& context, ExceptionState& es) const
{
- m_unit = storeUnit(mode, unitType);
- setValue(value, context, exceptionState);
+ return context.convertValueToUserUnits(m_valueInSpecifiedUnits, unitMode(), unitType(), es);
}
-void SVGLength::setValue(float value, const SVGLengthContext& context, ExceptionState& exceptionState)
+void SVGLength::setValue(float value, const SVGLengthContext& context, ExceptionState& es)
{
// 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
- if (extractType(m_unit) == LengthTypePercentage)
+ if (m_unitType == LengthTypePercentage)
value = value / 100;
- float convertedValue = context.convertValueFromUserUnits(value, extractMode(m_unit), extractType(m_unit), exceptionState);
- if (!exceptionState.hadException())
- m_valueInSpecifiedUnits = convertedValue;
+ float convertedValue = context.convertValueFromUserUnits(value, unitMode(), unitType(), es);
+ if (es.hadException())
+ return;
+
+ m_valueInSpecifiedUnits = convertedValue;
}
+
float SVGLength::valueAsPercentage() const
{
// 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
- if (extractType(m_unit) == LengthTypePercentage)
+ if (m_unitType == LengthTypePercentage)
return m_valueInSpecifiedUnits / 100;
return m_valueInSpecifiedUnits;
@@ -244,10 +212,13 @@ static bool parseValueInternal(const String& string, float& convertedNumber, SVG
return true;
}
-void SVGLength::setValueAsString(const String& string, ExceptionState& exceptionState)
+void SVGLength::setValueAsString(const String& string, ExceptionState& es)
{
- if (string.isEmpty())
+ if (string.isEmpty()) {
+ m_unitType = LengthTypeUnknown;
+ m_valueInSpecifiedUnits = 0;
return;
+ }
float convertedNumber = 0;
SVGLengthType type = LengthTypeUnknown;
@@ -257,52 +228,43 @@ void SVGLength::setValueAsString(const String& string, ExceptionState& exception
parseValueInternal<UChar>(string, convertedNumber, type);
if (!success) {
- exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
+ m_valueInSpecifiedUnits = 0;
+ es.throwDOMException(SyntaxError, "Invalid value");
return;
}
- m_unit = storeUnit(extractMode(m_unit), type);
+ m_unitType = type;
m_valueInSpecifiedUnits = convertedNumber;
}
String SVGLength::valueAsString() const
{
- return String::number(m_valueInSpecifiedUnits) + lengthTypeToString(extractType(m_unit));
+ return String::number(m_valueInSpecifiedUnits) + lengthTypeToString(unitType());
}
-void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, ExceptionState& exceptionState)
+void SVGLength::newValueSpecifiedUnits(SVGLengthType type, float value)
{
- if (type == LengthTypeUnknown || type > LengthTypePC) {
- exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError);
- return;
- }
-
- m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type));
+ m_unitType = type;
m_valueInSpecifiedUnits = value;
}
-void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGLengthContext& context, ExceptionState& exceptionState)
+void SVGLength::convertToSpecifiedUnits(SVGLengthType type, const SVGLengthContext& context, ExceptionState& es)
{
- if (type == LengthTypeUnknown || type > LengthTypePC) {
- exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError);
- return;
- }
-
- float valueInUserUnits = value(context, exceptionState);
- if (exceptionState.hadException())
+ float valueInUserUnits = value(context, es);
+ if (es.hadException())
return;
- unsigned int originalUnitAndType = m_unit;
- m_unit = storeUnit(extractMode(m_unit), toSVGLengthType(type));
- setValue(valueInUserUnits, context, exceptionState);
- if (!exceptionState.hadException())
+ SVGLengthType originalType = unitType();
+ m_unitType = toSVGLengthType(type);
+ setValue(valueInUserUnits, context, es);
+ if (!es.hadException())
return;
- // Eventually restore old unit and type
- m_unit = originalUnitAndType;
+ // Eventually restore old type
+ m_unitType = originalType;
}
-SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value)
+PassRefPtr<SVGLength> SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value)
{
ASSERT(value);
@@ -345,21 +307,19 @@ SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value)
};
if (svgType == LengthTypeUnknown)
- return SVGLength();
-
- TrackExceptionState exceptionState;
- SVGLength length;
- length.newValueSpecifiedUnits(svgType, value->getFloatValue(), exceptionState);
- if (exceptionState.hadException())
- return SVGLength();
+ return SVGLength::create();
+ RefPtr<SVGLength> length = SVGLength::create();
+ length->newValueSpecifiedUnits(svgType, value->getFloatValue());
return length;
}
-PassRefPtr<CSSPrimitiveValue> SVGLength::toCSSPrimitiveValue(const SVGLength& length)
+PassRefPtr<CSSPrimitiveValue> SVGLength::toCSSPrimitiveValue(PassRefPtr<SVGLength> passLength)
{
+ RefPtr<SVGLength> length = passLength;
+
CSSPrimitiveValue::UnitTypes cssType = CSSPrimitiveValue::CSS_UNKNOWN;
- switch (length.unitType()) {
+ switch (length->unitType()) {
case LengthTypeUnknown:
break;
case LengthTypeNumber:
@@ -394,7 +354,7 @@ PassRefPtr<CSSPrimitiveValue> SVGLength::toCSSPrimitiveValue(const SVGLength& le
break;
};
- return CSSPrimitiveValue::create(length.valueInSpecifiedUnits(), cssType);
+ return CSSPrimitiveValue::create(length->valueInSpecifiedUnits(), cssType);
}
SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedName& attrName)
@@ -412,6 +372,8 @@ SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedNam
s_lengthModeMap.set(SVGNames::fxAttr, LengthModeWidth);
s_lengthModeMap.set(SVGNames::fyAttr, LengthModeHeight);
s_lengthModeMap.set(SVGNames::rAttr, LengthModeOther);
+ s_lengthModeMap.set(SVGNames::rxAttr, LengthModeWidth);
+ s_lengthModeMap.set(SVGNames::ryAttr, LengthModeHeight);
s_lengthModeMap.set(SVGNames::widthAttr, LengthModeWidth);
s_lengthModeMap.set(SVGNames::heightAttr, LengthModeHeight);
s_lengthModeMap.set(SVGNames::x1Attr, LengthModeWidth);
@@ -432,4 +394,183 @@ SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedNam
return LengthModeOther;
}
+PassRefPtr<SVGLength> SVGLength::blend(const SVGLength* from, float progress) const
+{
+ SVGLengthType toType = unitType();
+ SVGLengthType fromType = from->unitType();
+ if ((from->isZero() && isZero())
+ || fromType == LengthTypeUnknown
+ || toType == LengthTypeUnknown
+ || (!from->isZero() && fromType != LengthTypePercentage && toType == LengthTypePercentage)
+ || (!isZero() && fromType == LengthTypePercentage && toType != LengthTypePercentage)
+ || (!from->isZero() && !isZero() && (fromType == LengthTypeEMS || fromType == LengthTypeEXS) && fromType != toType))
+ return clone();
+
+ RefPtr<SVGLength> length = create();
+
+ if (fromType == LengthTypePercentage || toType == LengthTypePercentage) {
+ float fromPercent = from->valueAsPercentage() * 100;
+ float toPercent = valueAsPercentage() * 100;
+ length->newValueSpecifiedUnits(LengthTypePercentage, WebCore::blend(fromPercent, toPercent, progress));
+ return length;
+ }
+
+ if (fromType == toType || from->isZero() || isZero() || fromType == LengthTypeEMS || fromType == LengthTypeEXS) {
+ float fromValue = from->valueInSpecifiedUnits();
+ float toValue = valueInSpecifiedUnits();
+ if (isZero())
+ length->newValueSpecifiedUnits(fromType, WebCore::blend(fromValue, toValue, progress));
+ else
+ length->newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue, progress));
+ return length;
+ }
+
+ ASSERT(!isRelative());
+ ASSERT(!from->isRelative());
+
+ TrackExceptionState es;
+ SVGLengthContext nonRelativeLengthContext(0);
+ float fromValueInUserUnits = nonRelativeLengthContext.convertValueToUserUnits(from->valueInSpecifiedUnits(), from->unitMode(), fromType, es);
+ if (es.hadException())
+ return create();
+
+ float fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fromValueInUserUnits, unitMode(), toType, es);
+ if (es.hadException())
+ return create();
+
+ float toValue = valueInSpecifiedUnits();
+ length->newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue, progress));
+ return length;
+}
+
+void SVGLength::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* contextElement)
+{
+ SVGLengthContext lengthContext(contextElement);
+
+ SVGLength* otherLength = toSVGLength(other.get());
+
+ setValue(value(lengthContext) + otherLength->value(lengthContext), lengthContext, ASSERT_NO_EXCEPTION);
+}
+
+void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValue, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement)
+{
+ SVGLengthContext lengthContext(contextElement);
+ const SVGLength* fromLength = toSVGLength(fromValue.get());
+ const SVGLength* toLength = toSVGLength(toValue.get());
+ const SVGLength* toAtEndOfDurationLength = toSVGLength(toAtEndOfDurationValue.get());
+ float animatedNumber = value(lengthContext, IGNORE_EXCEPTION);
+ SVGLengthType unitType = percentage < 0.5 ? fromLength->unitType() : toLength->unitType();
+ animationElement->animateAdditiveNumber(percentage, repeatCount, fromLength->value(lengthContext, IGNORE_EXCEPTION), toLength->value(lengthContext, IGNORE_EXCEPTION), toAtEndOfDurationLength->value(lengthContext, IGNORE_EXCEPTION), animatedNumber);
+ ASSERT(unitMode() == SVGLength::lengthModeForAnimatedLengthAttribute(animationElement->attributeName()));
+
+ setUnitType(unitType);
+ setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION);
+}
+
+float SVGLength::calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElement* contextElement)
+{
+ SVGLengthContext lengthContext(contextElement);
+ const SVGLength* toLength = toSVGLength(to.get());
+
+ return fabsf(toLength->value(lengthContext, IGNORE_EXCEPTION) - value(lengthContext, IGNORE_EXCEPTION));
+}
+
+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, ExceptionMessages::failedToSet("value", "SVGLength", "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, ExceptionMessages::failedToSet("valueInSpecifiedUnits", "SVGLength", "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, ExceptionMessages::failedToSet("valueAsString", "SVGLength", "The attribute is read-only."));
+ return;
+ }
+
+ target()->setValueAsString(str, es);
+ commitChange();
+}
+
+void SVGLengthTearOff::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits, ExceptionState& es)
+{
+ if (isImmutable()) {
+ es.throwDOMException(NoModificationAllowedError, ExceptionMessages::failedToSet("newValueSpecifiedUnits", "SVGLength", "The object is read-only."));
+ return;
+ }
+
+ if (unitType == LengthTypeUnknown || unitType > LengthTypePC) {
+ es.throwDOMException(NoModificationAllowedError, ExceptionMessages::failedToSet("newValueSpecifiedUnits", "SVGLength", "The specified SVGLengthMode is invalid."));
+ return;
+ }
+
+ target()->newValueSpecifiedUnits(toSVGLengthType(unitType), valueInSpecifiedUnits);
+ commitChange();
+}
+
+void SVGLengthTearOff::convertToSpecifiedUnits(unsigned short unitType, ExceptionState& es)
+{
+ if (isImmutable()) {
+ es.throwDOMException(NoModificationAllowedError, ExceptionMessages::failedToSet("convertToSpecifiedUnits", "SVGLength", "The object is read-only."));
+ return;
+ }
+
+ if (unitType == LengthTypeUnknown || unitType > LengthTypePC) {
+ es.throwDOMException(NoModificationAllowedError, ExceptionMessages::failedToSet("convertToSpecifiedUnits", "SVGLength", "The specified SVGLengthMode is invalid."));
+ return;
+ }
+
+ SVGLengthContext lengthContext(contextElement());
+ target()->convertToSpecifiedUnits(toSVGLengthType(unitType), lengthContext, es);
+ commitChange();
+}
+
+SVGLengthTearOff::SVGLengthTearOff(PassRefPtr<SVGLength> target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName)
+ : NewSVGPropertyTearOff<SVGLength>(target, contextElement, propertyIsAnimVal, attributeName)
+{
+ ScriptWrappable::init(this);
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698