diff options
Diffstat (limited to 'WebCore/svg')
114 files changed, 1759 insertions, 1158 deletions
diff --git a/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h b/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h index ab23bae..e20a4c7 100644 --- a/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h +++ b/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h @@ -23,8 +23,6 @@ #if ENABLE(SVG) #include "PlatformString.h" -#include "SVGNumberList.h" -#include "SVGPreserveAspectRatio.h" #include "SVGTransformList.h" namespace WebCore { @@ -32,54 +30,6 @@ namespace WebCore { template<typename Type> struct DeprecatedSVGAnimatedPropertyTraits : public Noncopyable { }; -// SVGAnimatedNumber -template<> -struct DeprecatedSVGAnimatedPropertyTraits<float> : public Noncopyable { - typedef const float& PassType; - typedef float ReturnType; - typedef float StoredType; - - static ReturnType null() { return 0.0f; } - static ReturnType toReturnType(const StoredType& type) { return type; } - static String toString(PassType type) { return String::number(type); } -}; - -// SVGAnimatedNumberList -template<> -struct DeprecatedSVGAnimatedPropertyTraits<SVGNumberList*> : public Noncopyable { - typedef SVGNumberList* PassType; - typedef SVGNumberList* ReturnType; - typedef RefPtr<SVGNumberList> StoredType; - - static ReturnType null() { return 0; } - static ReturnType toReturnType(const StoredType& type) { return type.get(); } - static String toString(PassType type) { return type ? type->valueAsString() : String(); } -}; - -// SVGAnimatedPreserveAspectRatio -template<> -struct DeprecatedSVGAnimatedPropertyTraits<SVGPreserveAspectRatio> : public Noncopyable { - typedef const SVGPreserveAspectRatio& PassType; - typedef SVGPreserveAspectRatio ReturnType; - typedef SVGPreserveAspectRatio StoredType; - - static ReturnType null() { return SVGPreserveAspectRatio(); } - static ReturnType toReturnType(const StoredType& type) { return type; } - static String toString(PassType type) { return type.valueAsString(); } -}; - -// SVGAnimatedString -template<> -struct DeprecatedSVGAnimatedPropertyTraits<String> : public Noncopyable { - typedef const String& PassType; - typedef String ReturnType; - typedef String StoredType; - - static ReturnType null() { return String(); } - static ReturnType toReturnType(const StoredType& type) { return type; } - static String toString(PassType type) { return type; } -}; - // SVGAnimatedTransformList template<> struct DeprecatedSVGAnimatedPropertyTraits<SVGTransformList*> : public Noncopyable { diff --git a/WebCore/svg/DeprecatedSVGAnimatedTemplate.h b/WebCore/svg/DeprecatedSVGAnimatedTemplate.h index 939db59..9258692 100644 --- a/WebCore/svg/DeprecatedSVGAnimatedTemplate.h +++ b/WebCore/svg/DeprecatedSVGAnimatedTemplate.h @@ -23,16 +23,14 @@ #if ENABLE(SVG) #include "DeprecatedSVGAnimatedPropertyTraits.h" +#include "QualifiedName.h" #include <wtf/Forward.h> #include <wtf/HashMap.h> namespace WebCore { class SVGElement; - class SVGNumberList; - class SVGPreserveAspectRatio; class SVGTransformList; - class QualifiedName; struct DeprecatedSVGAnimatedTypeWrapperKey { // Empty value @@ -154,10 +152,6 @@ namespace WebCore { } // Common type definitions, to ease IDL generation. - typedef DeprecatedSVGAnimatedTemplate<float> SVGAnimatedNumber; - typedef DeprecatedSVGAnimatedTemplate<SVGNumberList*> SVGAnimatedNumberList; - typedef DeprecatedSVGAnimatedTemplate<SVGPreserveAspectRatio> SVGAnimatedPreserveAspectRatio; - typedef DeprecatedSVGAnimatedTemplate<String> SVGAnimatedString; typedef DeprecatedSVGAnimatedTemplate<SVGTransformList*> SVGAnimatedTransformList; } diff --git a/WebCore/svg/SVGAElement.cpp b/WebCore/svg/SVGAElement.cpp index 56078ad..8e429d0 100644 --- a/WebCore/svg/SVGAElement.cpp +++ b/WebCore/svg/SVGAElement.cpp @@ -71,7 +71,7 @@ String SVGAElement::title() const void SVGAElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::targetAttr) - setTargetBaseValue(attr->value()); + setSVGTargetBaseValue(attr->value()); else { if (SVGURIReference::parseMappedAttribute(attr)) return; @@ -105,14 +105,14 @@ void SVGAElement::synchronizeProperty(const QualifiedName& attrName) SVGStyledTransformableElement::synchronizeProperty(attrName); if (attrName == anyQName()) { - synchronizeTarget(); + synchronizeSVGTarget(); synchronizeHref(); synchronizeExternalResourcesRequired(); return; } if (attrName == SVGNames::targetAttr) - synchronizeTarget(); + synchronizeSVGTarget(); else if (SVGURIReference::isKnownAttribute(attrName)) synchronizeHref(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) diff --git a/WebCore/svg/SVGAElement.h b/WebCore/svg/SVGAElement.h index 0effda2..f919a6e 100644 --- a/WebCore/svg/SVGAElement.h +++ b/WebCore/svg/SVGAElement.h @@ -46,6 +46,7 @@ namespace WebCore { virtual bool isValid() const { return SVGTests::isValid(); } virtual String title() const; + virtual String target() const { return svgTarget(); } virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); @@ -62,10 +63,13 @@ namespace WebCore { virtual bool childShouldCreateRenderer(Node*) const; - DECLARE_ANIMATED_PROPERTY(SVGAElement, SVGNames::targetAttr, String, Target, target) + // This defines a non-virtual "String& target() const" method before, that would clash with "virtual String target() const" + // in Element. That's why it's now named "String& svgTarget() const", to avoid the clash. The CodeGenerators take care + // of calling svgTargetAnimated() instead of targetAnimated(), see CodeGenerator.pm. + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGAElement, SVGNames::targetAttr, String, SVGTarget, svgTarget) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGAElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGAElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGAElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGAllInOne.cpp b/WebCore/svg/SVGAllInOne.cpp index 2cb63af..e01af2c 100644 --- a/WebCore/svg/SVGAllInOne.cpp +++ b/WebCore/svg/SVGAllInOne.cpp @@ -31,7 +31,6 @@ #include "SVGAngle.cpp" #include "SVGAnimateColorElement.cpp" #include "SVGAnimatedPathData.cpp" -#include "SVGAnimatedPoints.cpp" #include "SVGAnimateElement.cpp" #include "SVGAnimateMotionElement.cpp" #include "SVGAnimateTransformElement.cpp" diff --git a/WebCore/svg/SVGAltGlyphElement.h b/WebCore/svg/SVGAltGlyphElement.h index ae0903a..b9d0bc0 100644 --- a/WebCore/svg/SVGAltGlyphElement.h +++ b/WebCore/svg/SVGAltGlyphElement.h @@ -52,7 +52,7 @@ namespace WebCore { virtual bool childShouldCreateRenderer(Node*) const; // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGAltGlyphElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGAltGlyphElement, XLinkNames::hrefAttr, String, Href, href) }; } // namespace WebCore diff --git a/WebCore/svg/SVGAngle.idl b/WebCore/svg/SVGAngle.idl index b36670a..be01ff9 100644 --- a/WebCore/svg/SVGAngle.idl +++ b/WebCore/svg/SVGAngle.idl @@ -37,10 +37,10 @@ module svg { attribute [ConvertNullToNullString] DOMString valueAsString setter raises(DOMException); - void newValueSpecifiedUnits(in unsigned short unitType, in float valueInSpecifiedUnits) + [StrictTypeChecking, RequiresAllArguments=Raise] void newValueSpecifiedUnits(in unsigned short unitType, in float valueInSpecifiedUnits) raises(DOMException); - void convertToSpecifiedUnits(in unsigned short unitType) + [StrictTypeChecking, RequiresAllArguments=Raise] void convertToSpecifiedUnits(in unsigned short unitType) raises(DOMException); }; diff --git a/WebCore/svg/SVGAnimateElement.cpp b/WebCore/svg/SVGAnimateElement.cpp index c47a378..152b342 100644 --- a/WebCore/svg/SVGAnimateElement.cpp +++ b/WebCore/svg/SVGAnimateElement.cpp @@ -170,12 +170,12 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat else if (percentage == 1.f) results->m_animatedPoints = m_toPoints; else { - if (m_fromPoints && m_toPoints) - results->m_animatedPoints = SVGPointList::createAnimated(m_fromPoints.get(), m_toPoints.get(), percentage); + if (!m_fromPoints.isEmpty() && !m_toPoints.isEmpty()) + SVGPointList::createAnimated(m_fromPoints, m_toPoints, results->m_animatedPoints, percentage); else results->m_animatedPoints.clear(); // Fall back to discrete animation if the points are not compatible - if (!results->m_animatedPoints) + if (results->m_animatedPoints.isEmpty()) results->m_animatedPoints = ((animationMode == FromToAnimation && percentage > 0.5f) || animationMode == ToAnimation || percentage == 1.0f) ? m_toPoints : m_fromPoints; } @@ -215,14 +215,12 @@ bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const m_fromPath.clear(); m_toPath.clear(); } else if (m_propertyType == PointsProperty) { - m_fromPoints = SVGPointList::create(SVGNames::pointsAttr); - if (pointsListFromSVGData(m_fromPoints.get(), fromString)) { - m_toPoints = SVGPointList::create(SVGNames::pointsAttr); - if (pointsListFromSVGData(m_toPoints.get(), toString)) + m_fromPoints.clear(); + if (pointsListFromSVGData(m_fromPoints, fromString)) { + m_toPoints.clear(); + if (pointsListFromSVGData(m_toPoints, toString)) return true; } - m_fromPoints.clear(); - m_toPoints.clear(); } m_fromString = fromString; m_toString = toString; @@ -299,12 +297,9 @@ void SVGAnimateElement::applyResultsToTarget() SVGPathParserFactory* factory = SVGPathParserFactory::self(); factory->buildStringFromByteStream(m_animatedPathPointer, valueToApply, UnalteredParsing); } - } else if (m_propertyType == PointsProperty) { - if (!m_animatedPoints || !m_animatedPoints->numberOfItems()) - valueToApply = m_animatedString; - else - valueToApply = m_animatedPoints->valueAsString(); - } else + } else if (m_propertyType == PointsProperty) + valueToApply = m_animatedPoints.isEmpty() ? m_animatedString : m_animatedPoints.valueAsString(); + else valueToApply = m_animatedString; setTargetAttributeAnimatedValue(valueToApply); diff --git a/WebCore/svg/SVGAnimateElement.h b/WebCore/svg/SVGAnimateElement.h index 9993d84..e478cf8 100644 --- a/WebCore/svg/SVGAnimateElement.h +++ b/WebCore/svg/SVGAnimateElement.h @@ -27,12 +27,12 @@ #include "Color.h" #include "SVGAnimationElement.h" #include "SVGPathByteStream.h" +#include "SVGPointList.h" #include <wtf/OwnPtr.h> namespace WebCore { class SVGPathSegList; - class SVGPointList; class SVGAnimateElement : public SVGAnimationElement { public: @@ -69,9 +69,9 @@ namespace WebCore { OwnPtr<SVGPathByteStream> m_toPath; OwnPtr<SVGPathByteStream> m_animatedPath; SVGPathByteStream* m_animatedPathPointer; - RefPtr<SVGPointList> m_fromPoints; - RefPtr<SVGPointList> m_toPoints; - RefPtr<SVGPointList> m_animatedPoints; + SVGPointList m_fromPoints; + SVGPointList m_toPoints; + SVGPointList m_animatedPoints; }; } // namespace WebCore diff --git a/WebCore/svg/SVGAnimatedBoolean.idl b/WebCore/svg/SVGAnimatedBoolean.idl index 2591c50..3e41e3c 100644 --- a/WebCore/svg/SVGAnimatedBoolean.idl +++ b/WebCore/svg/SVGAnimatedBoolean.idl @@ -27,7 +27,7 @@ module svg { interface [Conditional=SVG] SVGAnimatedBoolean { attribute [StrictTypeChecking] boolean baseVal; - readonly attribute [StrictTypeChecking] boolean animVal; + readonly attribute boolean animVal; }; } diff --git a/WebCore/svg/SVGAnimatedEnumeration.idl b/WebCore/svg/SVGAnimatedEnumeration.idl index 8a9d3b4..c0840f2 100644 --- a/WebCore/svg/SVGAnimatedEnumeration.idl +++ b/WebCore/svg/SVGAnimatedEnumeration.idl @@ -26,7 +26,7 @@ module svg { interface [Conditional=SVG] SVGAnimatedEnumeration { - attribute unsigned short baseVal; + attribute [StrictTypeChecking] unsigned short baseVal; readonly attribute unsigned short animVal; }; diff --git a/WebCore/svg/SVGAnimatedInteger.idl b/WebCore/svg/SVGAnimatedInteger.idl index 6ea9138..61de26c 100644 --- a/WebCore/svg/SVGAnimatedInteger.idl +++ b/WebCore/svg/SVGAnimatedInteger.idl @@ -26,8 +26,7 @@ module svg { interface [Conditional=SVG] SVGAnimatedInteger { - attribute long baseVal - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] long baseVal; readonly attribute long animVal; }; diff --git a/WebCore/svg/SVGAnimatedPoints.h b/WebCore/svg/SVGAnimatedNumber.h index a62f60c..6897aad 100644 --- a/WebCore/svg/SVGAnimatedPoints.h +++ b/WebCore/svg/SVGAnimatedNumber.h @@ -1,6 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> + * Copyright (C) Research In Motion Limited 2010. 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 @@ -18,27 +17,17 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SVGAnimatedPoints_h -#define SVGAnimatedPoints_h +#ifndef SVGAnimatedNumber_h +#define SVGAnimatedNumber_h #if ENABLE(SVG) +#include "SVGAnimatedStaticPropertyTearOff.h" namespace WebCore { - class SVGPointList; - - class SVGAnimatedPoints { - public: - virtual ~SVGAnimatedPoints() { } - - // 'SVGAnimatedPoints' functions - virtual SVGPointList* points() const = 0; - virtual SVGPointList* animatedPoints() const = 0; - }; +typedef SVGAnimatedStaticPropertyTearOff<float> SVGAnimatedNumber; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGAnimatedNumber.idl b/WebCore/svg/SVGAnimatedNumber.idl index dea9d96..c3b0419 100644 --- a/WebCore/svg/SVGAnimatedNumber.idl +++ b/WebCore/svg/SVGAnimatedNumber.idl @@ -27,8 +27,7 @@ module svg { interface [Conditional=SVG] SVGAnimatedNumber { - attribute float baseVal - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float baseVal; readonly attribute float animVal; }; diff --git a/WebCore/svg/SVGAnimatedNumberList.h b/WebCore/svg/SVGAnimatedNumberList.h new file mode 100644 index 0000000..f86b3c2 --- /dev/null +++ b/WebCore/svg/SVGAnimatedNumberList.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) Research In Motion Limited 2010. 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. + * + * 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. + * + * 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. + */ + +#ifndef SVGAnimatedNumberList_h +#define SVGAnimatedNumberList_h + +#if ENABLE(SVG) +#include "SVGAnimatedListPropertyTearOff.h" +#include "SVGNumberList.h" + +namespace WebCore { + +typedef SVGAnimatedListPropertyTearOff<SVGNumberList> SVGAnimatedNumberList; + +} // namespace WebCore + +#endif // ENABLE(SVG) +#endif diff --git a/WebCore/svg/SVGAnimatedPoints.cpp b/WebCore/svg/SVGAnimatedPoints.cpp deleted file mode 100644 index 6f54888..0000000 --- a/WebCore/svg/SVGAnimatedPoints.cpp +++ /dev/null @@ -1 +0,0 @@ -// This file is now intentionally empty. Delete it after removing it from all the build systems and project files. diff --git a/WebCore/svg/SVGAnimatedPoints.idl b/WebCore/svg/SVGAnimatedPoints.idl deleted file mode 100644 index 11314df..0000000 --- a/WebCore/svg/SVGAnimatedPoints.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2006 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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. - */ - -module svg { - - interface [Conditional=SVG, ObjCProtocol, OmitConstructor] SVGAnimatedPoints { - readonly attribute SVGPointList points; - readonly attribute SVGPointList animatedPoints; - }; - -} diff --git a/WebCore/svg/SVGAnimatedPreserveAspectRatio.h b/WebCore/svg/SVGAnimatedPreserveAspectRatio.h new file mode 100644 index 0000000..57d8621 --- /dev/null +++ b/WebCore/svg/SVGAnimatedPreserveAspectRatio.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) Research In Motion Limited 2010. 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. + * + * 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. + * + * 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. + */ + +#ifndef SVGAnimatedPreserveAspectRatio_h +#define SVGAnimatedPreserveAspectRatio_h + +#if ENABLE(SVG) +#include "SVGAnimatedPropertyTearOff.h" +#include "SVGPreserveAspectRatio.h" + +namespace WebCore { + +typedef SVGAnimatedPropertyTearOff<SVGPreserveAspectRatio> SVGAnimatedPreserveAspectRatio; + +} // namespace WebCore + +#endif // ENABLE(SVG) +#endif diff --git a/WebCore/svg/SVGAnimatedString.h b/WebCore/svg/SVGAnimatedString.h new file mode 100644 index 0000000..c8b842f --- /dev/null +++ b/WebCore/svg/SVGAnimatedString.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) Research In Motion Limited 2010. 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. + * + * 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. + * + * 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. + */ + +#ifndef SVGAnimatedString_h +#define SVGAnimatedString_h + +#if ENABLE(SVG) +#include "SVGAnimatedStaticPropertyTearOff.h" +#include <wtf/text/WTFString.h> + +namespace WebCore { + +typedef SVGAnimatedStaticPropertyTearOff<String> SVGAnimatedString; + +} // namespace WebCore + +#endif // ENABLE(SVG) +#endif diff --git a/WebCore/svg/SVGComponentTransferFunctionElement.cpp b/WebCore/svg/SVGComponentTransferFunctionElement.cpp index c1750d7..078b30d 100644 --- a/WebCore/svg/SVGComponentTransferFunctionElement.cpp +++ b/WebCore/svg/SVGComponentTransferFunctionElement.cpp @@ -33,7 +33,6 @@ namespace WebCore { SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement(const QualifiedName& tagName, Document* document) : SVGElement(tagName, document) , m_type(FECOMPONENTTRANSFER_TYPE_UNKNOWN) - , m_tableValues(SVGNumberList::create(SVGNames::tableValuesAttr)) , m_slope(1) , m_amplitude(1) , m_exponent(1) @@ -54,10 +53,12 @@ void SVGComponentTransferFunctionElement::parseMappedAttribute(Attribute* attr) setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_LINEAR); else if (value == "gamma") setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_GAMMA); - } - else if (attr->name() == SVGNames::tableValuesAttr) - tableValuesBaseValue()->parse(value); - else if (attr->name() == SVGNames::slopeAttr) + } else if (attr->name() == SVGNames::tableValuesAttr) { + SVGNumberList newList; + newList.parse(value); + detachAnimatedTableValuesListWrappers(newList.size()); + tableValuesBaseValue() = newList; + } else if (attr->name() == SVGNames::slopeAttr) setSlopeBaseValue(value.toFloat()); else if (attr->name() == SVGNames::interceptAttr) setInterceptBaseValue(value.toFloat()); @@ -105,18 +106,13 @@ void SVGComponentTransferFunctionElement::synchronizeProperty(const QualifiedNam ComponentTransferFunction SVGComponentTransferFunctionElement::transferFunction() const { ComponentTransferFunction func; - func.type = (ComponentTransferType) type(); + func.type = static_cast<ComponentTransferType>(type()); func.slope = slope(); func.intercept = intercept(); func.amplitude = amplitude(); func.exponent = exponent(); func.offset = offset(); - SVGNumberList* numbers = tableValues(); - - ExceptionCode ec = 0; - unsigned int nr = numbers->numberOfItems(); - for (unsigned int i = 0; i < nr; i++) - func.tableValues.append(numbers->getItem(i, ec)); + func.tableValues = tableValues(); return func; } diff --git a/WebCore/svg/SVGComponentTransferFunctionElement.h b/WebCore/svg/SVGComponentTransferFunctionElement.h index d46668b..e02fc16 100644 --- a/WebCore/svg/SVGComponentTransferFunctionElement.h +++ b/WebCore/svg/SVGComponentTransferFunctionElement.h @@ -22,9 +22,9 @@ #define SVGComponentTransferFunctionElement_h #if ENABLE(SVG) && ENABLE(FILTERS) +#include "FEComponentTransfer.h" #include "SVGAnimatedPropertyMacros.h" #include "SVGNumberList.h" -#include "FEComponentTransfer.h" namespace WebCore { @@ -40,12 +40,12 @@ namespace WebCore { private: DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGComponentTransferFunctionElement, SVGNames::typeAttr, int, Type, type) - DECLARE_ANIMATED_PROPERTY(SVGComponentTransferFunctionElement, SVGNames::tableValuesAttr, SVGNumberList*, TableValues, tableValues) - DECLARE_ANIMATED_PROPERTY(SVGComponentTransferFunctionElement, SVGNames::slopeAttr, float, Slope, slope) - DECLARE_ANIMATED_PROPERTY(SVGComponentTransferFunctionElement, SVGNames::interceptAttr, float, Intercept, intercept) - DECLARE_ANIMATED_PROPERTY(SVGComponentTransferFunctionElement, SVGNames::amplitudeAttr, float, Amplitude, amplitude) - DECLARE_ANIMATED_PROPERTY(SVGComponentTransferFunctionElement, SVGNames::exponentAttr, float, Exponent, exponent) - DECLARE_ANIMATED_PROPERTY(SVGComponentTransferFunctionElement, SVGNames::offsetAttr, float, Offset, offset) + DECLARE_ANIMATED_LIST_PROPERTY_NEW(SVGComponentTransferFunctionElement, SVGNames::tableValuesAttr, SVGNumberList, TableValues, tableValues) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGComponentTransferFunctionElement, SVGNames::slopeAttr, float, Slope, slope) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGComponentTransferFunctionElement, SVGNames::interceptAttr, float, Intercept, intercept) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGComponentTransferFunctionElement, SVGNames::amplitudeAttr, float, Amplitude, amplitude) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGComponentTransferFunctionElement, SVGNames::exponentAttr, float, Exponent, exponent) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGComponentTransferFunctionElement, SVGNames::offsetAttr, float, Offset, offset) }; } // namespace WebCore diff --git a/WebCore/svg/SVGCursorElement.h b/WebCore/svg/SVGCursorElement.h index e09739a..d3bcb8b 100644 --- a/WebCore/svg/SVGCursorElement.h +++ b/WebCore/svg/SVGCursorElement.h @@ -58,7 +58,7 @@ namespace WebCore { DECLARE_ANIMATED_PROPERTY_NEW(SVGCursorElement, SVGNames::yAttr, SVGLength, Y, y) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGCursorElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGCursorElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGCursorElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGFEBlendElement.h b/WebCore/svg/SVGFEBlendElement.h index a0010be..44d45bf 100644 --- a/WebCore/svg/SVGFEBlendElement.h +++ b/WebCore/svg/SVGFEBlendElement.h @@ -38,8 +38,8 @@ private: virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); - DECLARE_ANIMATED_PROPERTY(SVGFEBlendElement, SVGNames::inAttr, String, In1, in1) - DECLARE_ANIMATED_PROPERTY(SVGFEBlendElement, SVGNames::in2Attr, String, In2, in2) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEBlendElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEBlendElement, SVGNames::in2Attr, String, In2, in2) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEBlendElement, SVGNames::modeAttr, int, Mode, mode) }; diff --git a/WebCore/svg/SVGFEColorMatrixElement.cpp b/WebCore/svg/SVGFEColorMatrixElement.cpp index 83d112c..eed728d 100644 --- a/WebCore/svg/SVGFEColorMatrixElement.cpp +++ b/WebCore/svg/SVGFEColorMatrixElement.cpp @@ -32,7 +32,6 @@ namespace WebCore { inline SVGFEColorMatrixElement::SVGFEColorMatrixElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m_type(FECOLORMATRIX_TYPE_UNKNOWN) - , m_values(SVGNumberList::create(SVGNames::valuesAttr)) { } @@ -56,9 +55,12 @@ void SVGFEColorMatrixElement::parseMappedAttribute(Attribute* attr) } else if (attr->name() == SVGNames::inAttr) setIn1BaseValue(value); - else if (attr->name() == SVGNames::valuesAttr) - valuesBaseValue()->parse(value); - else + else if (attr->name() == SVGNames::valuesAttr) { + SVGNumberList newList; + newList.parse(value); + detachAnimatedValuesListWrappers(newList.size()); + valuesBaseValue() = newList; + } else SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); } @@ -99,7 +101,6 @@ PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filter return 0; Vector<float> filterValues; - SVGNumberList* numbers = values(); const ColorMatrixType filterType(static_cast<ColorMatrixType>(type())); // Use defaults if values is empty (SVG 1.1 15.10). @@ -119,12 +120,8 @@ PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filter break; } } else { - size_t size = numbers->numberOfItems(); - for (size_t i = 0; i < size; i++) { - ExceptionCode ec = 0; - filterValues.append(numbers->getItem(i, ec)); - } - size = filterValues.size(); + filterValues = values(); + unsigned size = filterValues.size(); if ((filterType == FECOLORMATRIX_TYPE_MATRIX && size != 20) || (filterType == FECOLORMATRIX_TYPE_HUEROTATE && size != 1) diff --git a/WebCore/svg/SVGFEColorMatrixElement.h b/WebCore/svg/SVGFEColorMatrixElement.h index 5ec301f..dcdeb41 100644 --- a/WebCore/svg/SVGFEColorMatrixElement.h +++ b/WebCore/svg/SVGFEColorMatrixElement.h @@ -40,9 +40,9 @@ private: virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); - DECLARE_ANIMATED_PROPERTY(SVGFEColorMatrixElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEColorMatrixElement, SVGNames::inAttr, String, In1, in1) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEColorMatrixElement, SVGNames::typeAttr, int, Type, type) - DECLARE_ANIMATED_PROPERTY(SVGFEColorMatrixElement, SVGNames::valuesAttr, SVGNumberList*, Values, values) + DECLARE_ANIMATED_LIST_PROPERTY_NEW(SVGFEColorMatrixElement, SVGNames::valuesAttr, SVGNumberList, Values, values) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEComponentTransferElement.h b/WebCore/svg/SVGFEComponentTransferElement.h index 957661e..fe0e562 100644 --- a/WebCore/svg/SVGFEComponentTransferElement.h +++ b/WebCore/svg/SVGFEComponentTransferElement.h @@ -38,7 +38,7 @@ private: virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); - DECLARE_ANIMATED_PROPERTY(SVGFEComponentTransferElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEComponentTransferElement, SVGNames::inAttr, String, In1, in1) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFECompositeElement.h b/WebCore/svg/SVGFECompositeElement.h index 95443e4..4870848 100644 --- a/WebCore/svg/SVGFECompositeElement.h +++ b/WebCore/svg/SVGFECompositeElement.h @@ -39,13 +39,13 @@ private: virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); - DECLARE_ANIMATED_PROPERTY(SVGFECompositeElement, SVGNames::inAttr, String, In1, in1) - DECLARE_ANIMATED_PROPERTY(SVGFECompositeElement, SVGNames::in2Attr, String, In2, in2) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFECompositeElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFECompositeElement, SVGNames::in2Attr, String, In2, in2) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFECompositeElement, SVGNames::operatorAttr, int, _operator, _operator) - DECLARE_ANIMATED_PROPERTY(SVGFECompositeElement, SVGNames::k1Attr, float, K1, k1) - DECLARE_ANIMATED_PROPERTY(SVGFECompositeElement, SVGNames::k2Attr, float, K2, k2) - DECLARE_ANIMATED_PROPERTY(SVGFECompositeElement, SVGNames::k3Attr, float, K3, k3) - DECLARE_ANIMATED_PROPERTY(SVGFECompositeElement, SVGNames::k4Attr, float, K4, k4) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFECompositeElement, SVGNames::k1Attr, float, K1, k1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFECompositeElement, SVGNames::k2Attr, float, K2, k2) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFECompositeElement, SVGNames::k3Attr, float, K3, k3) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFECompositeElement, SVGNames::k4Attr, float, K4, k4) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEConvolveMatrixElement.cpp b/WebCore/svg/SVGFEConvolveMatrixElement.cpp index d7f14a2..1137543 100644 --- a/WebCore/svg/SVGFEConvolveMatrixElement.cpp +++ b/WebCore/svg/SVGFEConvolveMatrixElement.cpp @@ -35,12 +35,8 @@ namespace WebCore { -char SVGKernelUnitLengthXAttrIdentifier[] = "SVGKernelUnitLengthXAttr"; -char SVGKernelUnitLengthYAttrIdentifier[] = "SVGKernelUnitLengthYAttr"; - inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) - , m_kernelMatrix(SVGNumberList::create(SVGNames::kernelMatrixAttr)) , m_edgeMode(EDGEMODE_DUPLICATE) { } @@ -50,6 +46,30 @@ PassRefPtr<SVGFEConvolveMatrixElement> SVGFEConvolveMatrixElement::create(const return adoptRef(new SVGFEConvolveMatrixElement(tagName, document)); } +const AtomicString& SVGFEConvolveMatrixElement::kernelUnitLengthXIdentifier() +{ + DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGKernelUnitLengthX")); + return s_identifier; +} + +const AtomicString& SVGFEConvolveMatrixElement::kernelUnitLengthYIdentifier() +{ + DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGKernelUnitLengthY")); + return s_identifier; +} + +const AtomicString& SVGFEConvolveMatrixElement::orderXIdentifier() +{ + DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGOrderX")); + return s_identifier; +} + +const AtomicString& SVGFEConvolveMatrixElement::orderYIdentifier() +{ + DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGOrderY")); + return s_identifier; +} + void SVGFEConvolveMatrixElement::parseMappedAttribute(Attribute* attr) { const String& value = attr->value(); @@ -68,9 +88,12 @@ void SVGFEConvolveMatrixElement::parseMappedAttribute(Attribute* attr) setEdgeModeBaseValue(EDGEMODE_WRAP); else if (value == "none") setEdgeModeBaseValue(EDGEMODE_NONE); - } else if (attr->name() == SVGNames::kernelMatrixAttr) - kernelMatrixBaseValue()->parse(value); - else if (attr->name() == SVGNames::divisorAttr) + } else if (attr->name() == SVGNames::kernelMatrixAttr) { + SVGNumberList newList; + newList.parse(value); + detachAnimatedKernelMatrixListWrappers(newList.size()); + kernelMatrixBaseValue() = newList; + } else if (attr->name() == SVGNames::divisorAttr) setDivisorBaseValue(value.toFloat()); else if (attr->name() == SVGNames::biasAttr) setBiasBaseValue(value.toFloat()); @@ -131,22 +154,16 @@ PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil if (!input1) return 0; - Vector<float> kernelMatrixValues; - SVGNumberList* numbers = kernelMatrix(); - - ExceptionCode ec = 0; - int numberOfItems = numbers->numberOfItems(); - for (int i = 0; i < numberOfItems; ++i) - kernelMatrixValues.append(numbers->getItem(i, ec)); - int orderXValue = orderX(); int orderYValue = orderY(); if (!hasAttribute(SVGNames::orderAttr)) { orderXValue = 3; orderYValue = 3; } + SVGNumberList& kernelMatrix = this->kernelMatrix(); + int kernelMatrixSize = kernelMatrix.size(); // The spec says this is a requirement, and should bail out if fails - if (orderXValue * orderYValue != numberOfItems) + if (orderXValue * orderYValue != kernelMatrixSize) return 0; int targetXValue = targetX(); @@ -166,8 +183,8 @@ PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil if (hasAttribute(SVGNames::divisorAttr) && !divisorValue) return 0; if (!hasAttribute(SVGNames::divisorAttr)) { - for (int i = 0; i < numberOfItems; ++i) - divisorValue += kernelMatrixValues[i]; + for (int i = 0; i < kernelMatrixSize; ++i) + divisorValue += kernelMatrix.at(i); if (!divisorValue) divisorValue = 1; } @@ -175,7 +192,7 @@ PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil RefPtr<FilterEffect> effect = FEConvolveMatrix::create( IntSize(orderXValue, orderYValue), divisorValue, bias(), IntPoint(targetXValue, targetYValue), static_cast<EdgeModeType>(edgeMode()), - FloatPoint(kernelUnitLengthX(), kernelUnitLengthX()), preserveAlpha(), kernelMatrixValues); + FloatPoint(kernelUnitLengthX(), kernelUnitLengthX()), preserveAlpha(), kernelMatrix); effect->inputEffects().append(input1); return effect.release(); } diff --git a/WebCore/svg/SVGFEConvolveMatrixElement.h b/WebCore/svg/SVGFEConvolveMatrixElement.h index cb31949..b36b7f1 100644 --- a/WebCore/svg/SVGFEConvolveMatrixElement.h +++ b/WebCore/svg/SVGFEConvolveMatrixElement.h @@ -40,18 +40,23 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + static const AtomicString& orderXIdentifier(); + static const AtomicString& orderYIdentifier(); - DECLARE_ANIMATED_PROPERTY(SVGFEConvolveMatrixElement, SVGNames::inAttr, String, In1, in1) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::orderXAttr, long, OrderX, orderX) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::orderYAttr, long, OrderY, orderY) - DECLARE_ANIMATED_PROPERTY(SVGFEConvolveMatrixElement, SVGNames::kernelMatrixAttr, SVGNumberList*, KernelMatrix, kernelMatrix) - DECLARE_ANIMATED_PROPERTY(SVGFEConvolveMatrixElement, SVGNames::divisorAttr, float, Divisor, divisor) - DECLARE_ANIMATED_PROPERTY(SVGFEConvolveMatrixElement, SVGNames::biasAttr, float, Bias, bias) + static const AtomicString& kernelUnitLengthXIdentifier(); + static const AtomicString& kernelUnitLengthYIdentifier(); + + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEConvolveMatrixElement, SVGNames::orderAttr, orderXIdentifier(), long, OrderX, orderX) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEConvolveMatrixElement, SVGNames::orderAttr, orderYIdentifier(), long, OrderY, orderY) + DECLARE_ANIMATED_LIST_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::kernelMatrixAttr, SVGNumberList, KernelMatrix, kernelMatrix) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::divisorAttr, float, Divisor, divisor) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::biasAttr, float, Bias, bias) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::targetXAttr, long, TargetX, targetX) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::targetYAttr, long, TargetY, targetY) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::operatorAttr, int, EdgeMode, edgeMode) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFEConvolveMatrixElement, SVGNames::kernelUnitLengthAttr, SVGKernelUnitLengthXIdentifier, float, KernelUnitLengthX, kernelUnitLengthX) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFEConvolveMatrixElement, SVGNames::kernelUnitLengthAttr, SVGKernelUnitLengthYIdentifier, float, KernelUnitLengthY, kernelUnitLengthY) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEConvolveMatrixElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthXIdentifier(), float, KernelUnitLengthX, kernelUnitLengthX) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEConvolveMatrixElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthYIdentifier(), float, KernelUnitLengthY, kernelUnitLengthY) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEConvolveMatrixElement, SVGNames::preserveAlphaAttr, bool, PreserveAlpha, preserveAlpha) }; diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.cpp b/WebCore/svg/SVGFEDiffuseLightingElement.cpp index ccdf8a0..6da804f 100644 --- a/WebCore/svg/SVGFEDiffuseLightingElement.cpp +++ b/WebCore/svg/SVGFEDiffuseLightingElement.cpp @@ -47,13 +47,13 @@ PassRefPtr<SVGFEDiffuseLightingElement> SVGFEDiffuseLightingElement::create(cons const AtomicString& SVGFEDiffuseLightingElement::kernelUnitLengthXIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGKernelUnitLengthX")); - return s_identifier; + return s_identifier; } const AtomicString& SVGFEDiffuseLightingElement::kernelUnitLengthYIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGKernelUnitLengthY")); - return s_identifier; + return s_identifier; } void SVGFEDiffuseLightingElement::parseMappedAttribute(Attribute* attr) diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.h b/WebCore/svg/SVGFEDiffuseLightingElement.h index b8f56a6..fa946e6 100644 --- a/WebCore/svg/SVGFEDiffuseLightingElement.h +++ b/WebCore/svg/SVGFEDiffuseLightingElement.h @@ -46,11 +46,11 @@ private: static const AtomicString& kernelUnitLengthXIdentifier(); static const AtomicString& kernelUnitLengthYIdentifier(); - DECLARE_ANIMATED_PROPERTY(SVGFEDiffuseLightingElement, SVGNames::inAttr, String, In1, in1) - DECLARE_ANIMATED_PROPERTY(SVGFEDiffuseLightingElement, SVGNames::diffuseConstantAttr, float, DiffuseConstant, diffuseConstant) - DECLARE_ANIMATED_PROPERTY(SVGFEDiffuseLightingElement, SVGNames::surfaceScaleAttr, float, SurfaceScale, surfaceScale) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFEDiffuseLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthXIdentifier(), float, KernelUnitLengthX, kernelUnitLengthX) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFEDiffuseLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthYIdentifier(), float, KernelUnitLengthY, kernelUnitLengthY) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEDiffuseLightingElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEDiffuseLightingElement, SVGNames::diffuseConstantAttr, float, DiffuseConstant, diffuseConstant) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEDiffuseLightingElement, SVGNames::surfaceScaleAttr, float, SurfaceScale, surfaceScale) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEDiffuseLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthXIdentifier(), float, KernelUnitLengthX, kernelUnitLengthX) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEDiffuseLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthYIdentifier(), float, KernelUnitLengthY, kernelUnitLengthY) PassRefPtr<LightSource> findLights() const; }; diff --git a/WebCore/svg/SVGFEDisplacementMapElement.h b/WebCore/svg/SVGFEDisplacementMapElement.h index c42783c..a2c9e43 100644 --- a/WebCore/svg/SVGFEDisplacementMapElement.h +++ b/WebCore/svg/SVGFEDisplacementMapElement.h @@ -39,11 +39,11 @@ private: virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); - DECLARE_ANIMATED_PROPERTY(SVGFEDisplacementMapElement, SVGNames::inAttr, String, In1, in1) - DECLARE_ANIMATED_PROPERTY(SVGFEDisplacementMapElement, SVGNames::in2Attr, String, In2, in2) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEDisplacementMapElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEDisplacementMapElement, SVGNames::in2Attr, String, In2, in2) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEDisplacementMapElement, SVGNames::xChannelSelectorAttr, int, XChannelSelector, xChannelSelector) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEDisplacementMapElement, SVGNames::yChannelSelectorAttr, int, YChannelSelector, yChannelSelector) - DECLARE_ANIMATED_PROPERTY(SVGFEDisplacementMapElement, SVGNames::scaleAttr, float, Scale, scale) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEDisplacementMapElement, SVGNames::scaleAttr, float, Scale, scale) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEGaussianBlurElement.cpp b/WebCore/svg/SVGFEGaussianBlurElement.cpp index e307a8ea..c17c748 100644 --- a/WebCore/svg/SVGFEGaussianBlurElement.cpp +++ b/WebCore/svg/SVGFEGaussianBlurElement.cpp @@ -42,13 +42,13 @@ PassRefPtr<SVGFEGaussianBlurElement> SVGFEGaussianBlurElement::create(const Qual const AtomicString& SVGFEGaussianBlurElement::stdDeviationXIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGStdDeviationX")); - return s_identifier; + return s_identifier; } const AtomicString& SVGFEGaussianBlurElement::stdDeviationYIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGStdDeviationY")); - return s_identifier; + return s_identifier; } void SVGFEGaussianBlurElement::setStdDeviation(float x, float y) diff --git a/WebCore/svg/SVGFEGaussianBlurElement.h b/WebCore/svg/SVGFEGaussianBlurElement.h index d1579a5..3ddb437 100644 --- a/WebCore/svg/SVGFEGaussianBlurElement.h +++ b/WebCore/svg/SVGFEGaussianBlurElement.h @@ -44,9 +44,9 @@ private: static const AtomicString& stdDeviationXIdentifier(); static const AtomicString& stdDeviationYIdentifier(); - DECLARE_ANIMATED_PROPERTY(SVGFEGaussianBlurElement, SVGNames::inAttr, String, In1, in1) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFEGaussianBlurElement, SVGNames::stdDeviationAttr, stdDeviationXIdentifier(), float, StdDeviationX, stdDeviationX) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFEGaussianBlurElement, SVGNames::stdDeviationAttr, stdDeviationYIdentifier(), float, StdDeviationY, stdDeviationY) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEGaussianBlurElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEGaussianBlurElement, SVGNames::stdDeviationAttr, stdDeviationXIdentifier(), float, StdDeviationX, stdDeviationX) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEGaussianBlurElement, SVGNames::stdDeviationAttr, stdDeviationYIdentifier(), float, StdDeviationY, stdDeviationY) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEImageElement.h b/WebCore/svg/SVGFEImageElement.h index 901cb19..0dcf2c8 100644 --- a/WebCore/svg/SVGFEImageElement.h +++ b/WebCore/svg/SVGFEImageElement.h @@ -56,10 +56,10 @@ private: void requestImageResource(); - DECLARE_ANIMATED_PROPERTY(SVGFEImageElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + DECLARE_ANIMATED_PROPERTY_NEW(SVGFEImageElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGFEImageElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEImageElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEImageElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGFELightElement.h b/WebCore/svg/SVGFELightElement.h index d594475..986a0dc 100644 --- a/WebCore/svg/SVGFELightElement.h +++ b/WebCore/svg/SVGFELightElement.h @@ -24,8 +24,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "LightSource.h" +#include "SVGAnimatedPropertyMacros.h" #include "SVGElement.h" -#include "SVGNames.h" namespace WebCore { @@ -42,16 +42,16 @@ private: virtual void synchronizeProperty(const QualifiedName&); virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::azimuthAttr, float, Azimuth, azimuth) - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::elevationAttr, float, Elevation, elevation) - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::xAttr, float, X, x) - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::yAttr, float, Y, y) - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::zAttr, float, Z, z) - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::pointsAtXAttr, float, PointsAtX, pointsAtX) - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::pointsAtYAttr, float, PointsAtY, pointsAtY) - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::pointsAtZAttr, float, PointsAtZ, pointsAtZ) - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::specularExponentAttr, float, SpecularExponent, specularExponent) - DECLARE_ANIMATED_PROPERTY(SVGFELightElement, SVGNames::limitingConeAngleAttr, float, LimitingConeAngle, limitingConeAngle) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::azimuthAttr, float, Azimuth, azimuth) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::elevationAttr, float, Elevation, elevation) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::xAttr, float, X, x) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::yAttr, float, Y, y) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::zAttr, float, Z, z) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::pointsAtXAttr, float, PointsAtX, pointsAtX) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::pointsAtYAttr, float, PointsAtY, pointsAtY) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::pointsAtZAttr, float, PointsAtZ, pointsAtZ) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::specularExponentAttr, float, SpecularExponent, specularExponent) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFELightElement, SVGNames::limitingConeAngleAttr, float, LimitingConeAngle, limitingConeAngle) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEMergeNodeElement.h b/WebCore/svg/SVGFEMergeNodeElement.h index 89506dc..a40d7a2 100644 --- a/WebCore/svg/SVGFEMergeNodeElement.h +++ b/WebCore/svg/SVGFEMergeNodeElement.h @@ -22,8 +22,8 @@ #define SVGFEMergeNodeElement_h #if ENABLE(SVG) && ENABLE(FILTERS) +#include "SVGAnimatedPropertyMacros.h" #include "SVGElement.h" -#include "SVGNames.h" namespace WebCore { @@ -38,7 +38,7 @@ namespace WebCore { virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - DECLARE_ANIMATED_PROPERTY(SVGFEMergeNodeElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEMergeNodeElement, SVGNames::inAttr, String, In1, in1) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEMorphologyElement.cpp b/WebCore/svg/SVGFEMorphologyElement.cpp index bfd0c0f..c7954b2 100644 --- a/WebCore/svg/SVGFEMorphologyElement.cpp +++ b/WebCore/svg/SVGFEMorphologyElement.cpp @@ -28,9 +28,6 @@ namespace WebCore { -char SVGRadiusXAttrIdentifier[] = "SVGRadiusXAttr"; -char SVGRadiusYAttrIdentifier[] = "SVGRadiusYAttr"; - inline SVGFEMorphologyElement::SVGFEMorphologyElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m__operator(FEMORPHOLOGY_OPERATOR_ERODE) @@ -42,6 +39,18 @@ PassRefPtr<SVGFEMorphologyElement> SVGFEMorphologyElement::create(const Qualifie return adoptRef(new SVGFEMorphologyElement(tagName, document)); } +const AtomicString& SVGFEMorphologyElement::radiusXIdentifier() +{ + DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGRadiusX")); + return s_identifier; +} + +const AtomicString& SVGFEMorphologyElement::radiusYIdentifier() +{ + DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGRadiusY")); + return s_identifier; +} + void SVGFEMorphologyElement::setRadius(float x, float y) { setRadiusXBaseValue(x); diff --git a/WebCore/svg/SVGFEMorphologyElement.h b/WebCore/svg/SVGFEMorphologyElement.h index 671e7f0..845294b 100644 --- a/WebCore/svg/SVGFEMorphologyElement.h +++ b/WebCore/svg/SVGFEMorphologyElement.h @@ -26,9 +26,6 @@ namespace WebCore { -extern char SVGRadiusXAttrIdentifier[]; -extern char SVGRadiusYAttrIdentifier[]; - class SVGFEMorphologyElement : public SVGFilterPrimitiveStandardAttributes { public: static PassRefPtr<SVGFEMorphologyElement> create(const QualifiedName&, Document*); @@ -46,10 +43,10 @@ private: static const AtomicString& radiusXIdentifier(); static const AtomicString& radiusYIdentifier(); - DECLARE_ANIMATED_PROPERTY(SVGFEMorphologyElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEMorphologyElement, SVGNames::inAttr, String, In1, in1) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEMorphologyElement, SVGNames::operatorAttr, int, _operator, _operator) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFEMorphologyElement, SVGNames::radiusAttr, SVGRadiusXAttrIdentifier, float, RadiusX, radiusX) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFEMorphologyElement, SVGNames::radiusAttr, SVGRadiusYAttrIdentifier, float, RadiusY, radiusY) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEMorphologyElement, SVGNames::radiusAttr, radiusXIdentifier(), float, RadiusX, radiusX) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFEMorphologyElement, SVGNames::radiusAttr, radiusYIdentifier(), float, RadiusY, radiusY) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEOffsetElement.h b/WebCore/svg/SVGFEOffsetElement.h index 2d522a2..6f5e843 100644 --- a/WebCore/svg/SVGFEOffsetElement.h +++ b/WebCore/svg/SVGFEOffsetElement.h @@ -39,9 +39,9 @@ private: virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); - DECLARE_ANIMATED_PROPERTY(SVGFEOffsetElement, SVGNames::inAttr, String, In1, in1) - DECLARE_ANIMATED_PROPERTY(SVGFEOffsetElement, SVGNames::dxAttr, float, Dx, dx) - DECLARE_ANIMATED_PROPERTY(SVGFEOffsetElement, SVGNames::dyAttr, float, Dy, dy) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEOffsetElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEOffsetElement, SVGNames::dxAttr, float, Dx, dx) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEOffsetElement, SVGNames::dyAttr, float, Dy, dy) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFESpecularLightingElement.cpp b/WebCore/svg/SVGFESpecularLightingElement.cpp index 949b183..548eb15 100644 --- a/WebCore/svg/SVGFESpecularLightingElement.cpp +++ b/WebCore/svg/SVGFESpecularLightingElement.cpp @@ -48,13 +48,13 @@ PassRefPtr<SVGFESpecularLightingElement> SVGFESpecularLightingElement::create(co const AtomicString& SVGFESpecularLightingElement::kernelUnitLengthXIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGKernelUnitLengthX")); - return s_identifier; + return s_identifier; } const AtomicString& SVGFESpecularLightingElement::kernelUnitLengthYIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGKernelUnitLengthY")); - return s_identifier; + return s_identifier; } void SVGFESpecularLightingElement::parseMappedAttribute(Attribute* attr) diff --git a/WebCore/svg/SVGFESpecularLightingElement.h b/WebCore/svg/SVGFESpecularLightingElement.h index 82093eb..c5d3ac4 100644 --- a/WebCore/svg/SVGFESpecularLightingElement.h +++ b/WebCore/svg/SVGFESpecularLightingElement.h @@ -42,12 +42,12 @@ private: static const AtomicString& kernelUnitLengthXIdentifier(); static const AtomicString& kernelUnitLengthYIdentifier(); - DECLARE_ANIMATED_PROPERTY(SVGFESpecularLightingElement, SVGNames::inAttr, String, In1, in1) - DECLARE_ANIMATED_PROPERTY(SVGFESpecularLightingElement, SVGNames::specularConstantAttr, float, SpecularConstant, specularConstant) - DECLARE_ANIMATED_PROPERTY(SVGFESpecularLightingElement, SVGNames::specularExponentAttr, float, SpecularExponent, specularExponent) - DECLARE_ANIMATED_PROPERTY(SVGFESpecularLightingElement, SVGNames::surfaceScaleAttr, float, SurfaceScale, surfaceScale) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFESpecularLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthXIdentifier(), float, KernelUnitLengthX, kernelUnitLengthX) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFESpecularLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthYIdentifier(), float, KernelUnitLengthY, kernelUnitLengthY) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFESpecularLightingElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFESpecularLightingElement, SVGNames::specularConstantAttr, float, SpecularConstant, specularConstant) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFESpecularLightingElement, SVGNames::specularExponentAttr, float, SpecularExponent, specularExponent) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFESpecularLightingElement, SVGNames::surfaceScaleAttr, float, SurfaceScale, surfaceScale) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFESpecularLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthXIdentifier(), float, KernelUnitLengthX, kernelUnitLengthX) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFESpecularLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthYIdentifier(), float, KernelUnitLengthY, kernelUnitLengthY) PassRefPtr<LightSource> findLights() const; }; diff --git a/WebCore/svg/SVGFETileElement.h b/WebCore/svg/SVGFETileElement.h index b943c55..ffa9d81 100644 --- a/WebCore/svg/SVGFETileElement.h +++ b/WebCore/svg/SVGFETileElement.h @@ -38,7 +38,7 @@ private: virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); - DECLARE_ANIMATED_PROPERTY(SVGFETileElement, SVGNames::inAttr, String, In1, in1) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFETileElement, SVGNames::inAttr, String, In1, in1) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFETurbulenceElement.cpp b/WebCore/svg/SVGFETurbulenceElement.cpp index 7a4d7d4..53b8fb0 100644 --- a/WebCore/svg/SVGFETurbulenceElement.cpp +++ b/WebCore/svg/SVGFETurbulenceElement.cpp @@ -44,13 +44,13 @@ PassRefPtr<SVGFETurbulenceElement> SVGFETurbulenceElement::create(const Qualifie const AtomicString& SVGFETurbulenceElement::baseFrequencyXIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGBaseFrequencyX")); - return s_identifier; + return s_identifier; } const AtomicString& SVGFETurbulenceElement::baseFrequencyYIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGBaseFrequencyY")); - return s_identifier; + return s_identifier; } void SVGFETurbulenceElement::parseMappedAttribute(Attribute* attr) diff --git a/WebCore/svg/SVGFETurbulenceElement.h b/WebCore/svg/SVGFETurbulenceElement.h index cbe0643..5c41fdd 100644 --- a/WebCore/svg/SVGFETurbulenceElement.h +++ b/WebCore/svg/SVGFETurbulenceElement.h @@ -48,10 +48,10 @@ private: static const AtomicString& baseFrequencyXIdentifier(); static const AtomicString& baseFrequencyYIdentifier(); - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFETurbulenceElement, SVGNames::baseFrequencyAttr, baseFrequencyXIdentifier(), float, BaseFrequencyX, baseFrequencyX) - DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGFETurbulenceElement, SVGNames::baseFrequencyAttr, baseFrequencyYIdentifier(), float, BaseFrequencyY, baseFrequencyY) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFETurbulenceElement, SVGNames::baseFrequencyAttr, baseFrequencyXIdentifier(), float, BaseFrequencyX, baseFrequencyX) + DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFETurbulenceElement, SVGNames::baseFrequencyAttr, baseFrequencyYIdentifier(), float, BaseFrequencyY, baseFrequencyY) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFETurbulenceElement, SVGNames::numOctavesAttr, long, NumOctaves, numOctaves) - DECLARE_ANIMATED_PROPERTY(SVGFETurbulenceElement, SVGNames::seedAttr, float, Seed, seed) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFETurbulenceElement, SVGNames::seedAttr, float, Seed, seed) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFETurbulenceElement, SVGNames::stitchTilesAttr, int, StitchTiles, stitchTiles) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFETurbulenceElement, SVGNames::typeAttr, int, Type, type) }; diff --git a/WebCore/svg/SVGFilterElement.cpp b/WebCore/svg/SVGFilterElement.cpp index 8c56c46..323dd4c 100644 --- a/WebCore/svg/SVGFilterElement.cpp +++ b/WebCore/svg/SVGFilterElement.cpp @@ -63,13 +63,13 @@ PassRefPtr<SVGFilterElement> SVGFilterElement::create(const QualifiedName& tagNa const AtomicString& SVGFilterElement::filterResXIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGFilterResX")); - return s_identifier; + return s_identifier; } const AtomicString& SVGFilterElement::filterResYIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGFilterResY")); - return s_identifier; + return s_identifier; } void SVGFilterElement::setFilterRes(unsigned long filterResX, unsigned long filterResY) diff --git a/WebCore/svg/SVGFilterElement.h b/WebCore/svg/SVGFilterElement.h index ce9f75e..4efb958 100644 --- a/WebCore/svg/SVGFilterElement.h +++ b/WebCore/svg/SVGFilterElement.h @@ -72,7 +72,7 @@ private: DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFilterElement, SVGNames::filterResAttr, filterResYIdentifier(), long, FilterResY, filterResY) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGFilterElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFilterElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFilterElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h index 6202888..6ac1962 100644 --- a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h +++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h @@ -66,7 +66,7 @@ private: DECLARE_ANIMATED_PROPERTY_NEW(SVGFilterPrimitiveStandardAttributes, SVGNames::yAttr, SVGLength, Y, y) DECLARE_ANIMATED_PROPERTY_NEW(SVGFilterPrimitiveStandardAttributes, SVGNames::widthAttr, SVGLength, Width, width) DECLARE_ANIMATED_PROPERTY_NEW(SVGFilterPrimitiveStandardAttributes, SVGNames::heightAttr, SVGLength, Height, height) - DECLARE_ANIMATED_PROPERTY(SVGFilterPrimitiveStandardAttributes, SVGNames::resultAttr, String, Result, result) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFilterPrimitiveStandardAttributes, SVGNames::resultAttr, String, Result, result) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFitToViewBox.cpp b/WebCore/svg/SVGFitToViewBox.cpp index 5297e8f..e5bd5db 100644 --- a/WebCore/svg/SVGFitToViewBox.cpp +++ b/WebCore/svg/SVGFitToViewBox.cpp @@ -27,6 +27,7 @@ #include "Attr.h" #include "Document.h" #include "FloatRect.h" +#include "SVGDocumentExtensions.h" #include "SVGNames.h" #include "SVGParserUtilities.h" #include "SVGPreserveAspectRatio.h" @@ -85,7 +86,7 @@ AffineTransform SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBox if (!viewBoxRect.width() || !viewBoxRect.height()) return AffineTransform(); - return preserveAspectRatio.getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), 0, 0, viewWidth, viewHeight); + return preserveAspectRatio.getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), viewWidth, viewHeight); } bool SVGFitToViewBox::parseMappedAttribute(Document* document, Attribute* attr) diff --git a/WebCore/svg/SVGFitToViewBox.h b/WebCore/svg/SVGFitToViewBox.h index df41fce..3d62271 100644 --- a/WebCore/svg/SVGFitToViewBox.h +++ b/WebCore/svg/SVGFitToViewBox.h @@ -22,12 +22,16 @@ #define SVGFitToViewBox_h #if ENABLE(SVG) -#include "SVGElement.h" -#include "SVGPreserveAspectRatio.h" +#include <wtf/text/WTFString.h> namespace WebCore { class AffineTransform; +class Attribute; +class Document; +class FloatRect; +class QualifiedName; +class SVGPreserveAspectRatio; class SVGFitToViewBox { public: @@ -40,7 +44,7 @@ public: bool isKnownAttribute(const QualifiedName&); virtual void setViewBoxBaseValue(const FloatRect&) = 0; - virtual void setPreserveAspectRatioBaseValue(DeprecatedSVGAnimatedPropertyTraits<SVGPreserveAspectRatio>::PassType) = 0; + virtual void setPreserveAspectRatioBaseValue(const SVGPreserveAspectRatio&) = 0; private: bool parseViewBox(Document*, const String&, FloatRect&); diff --git a/WebCore/svg/SVGForeignObjectElement.h b/WebCore/svg/SVGForeignObjectElement.h index 55ddb3c..ee17c19 100644 --- a/WebCore/svg/SVGForeignObjectElement.h +++ b/WebCore/svg/SVGForeignObjectElement.h @@ -58,7 +58,7 @@ namespace WebCore { DECLARE_ANIMATED_PROPERTY_NEW(SVGForeignObjectElement, SVGNames::heightAttr, SVGLength, Height, height) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGForeignObjectElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGForeignObjectElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGForeignObjectElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGGradientElement.h b/WebCore/svg/SVGGradientElement.h index fdfb72c..6e23608 100644 --- a/WebCore/svg/SVGGradientElement.h +++ b/WebCore/svg/SVGGradientElement.h @@ -54,7 +54,7 @@ namespace WebCore { DECLARE_ANIMATED_PROPERTY(SVGGradientElement, SVGNames::gradientTransformAttr, SVGTransformList*, GradientTransform, gradientTransform) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGGradientElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGImageElement.h b/WebCore/svg/SVGImageElement.h index ee105d2..b9f3865 100644 --- a/WebCore/svg/SVGImageElement.h +++ b/WebCore/svg/SVGImageElement.h @@ -70,10 +70,10 @@ namespace WebCore { DECLARE_ANIMATED_PROPERTY_NEW(SVGImageElement, SVGNames::yAttr, SVGLength, Y, y) DECLARE_ANIMATED_PROPERTY_NEW(SVGImageElement, SVGNames::widthAttr, SVGLength, Width, width) DECLARE_ANIMATED_PROPERTY_NEW(SVGImageElement, SVGNames::heightAttr, SVGLength, Height, height) - DECLARE_ANIMATED_PROPERTY(SVGImageElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + DECLARE_ANIMATED_PROPERTY_NEW(SVGImageElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGImageElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGImageElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGImageElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGLength.cpp b/WebCore/svg/SVGLength.cpp index a8cfb4e..f8381bf 100644 --- a/WebCore/svg/SVGLength.cpp +++ b/WebCore/svg/SVGLength.cpp @@ -27,14 +27,13 @@ #include "CSSHelper.h" #include "FloatConversion.h" #include "FrameView.h" -#include "NotImplemented.h" #include "RenderObject.h" #include "RenderView.h" #include "SVGParserUtilities.h" #include "SVGSVGElement.h" -#include <math.h> -#include <wtf/Assertions.h> +#include <wtf/MathExtras.h> +#include <wtf/text/StringConcatenate.h> namespace WebCore { @@ -83,6 +82,7 @@ static inline String lengthTypeToString(SVGLengthType type) return "pc"; } + ASSERT_NOT_REACHED(); return String(); } @@ -126,10 +126,11 @@ inline SVGLengthType stringToLengthType(const UChar*& ptr, const UChar* end) } SVGLength::SVGLength(SVGLengthMode mode, const String& valueAsString) - : m_valueInSpecifiedUnits(0.0f) + : m_valueInSpecifiedUnits(0) , m_unit(storeUnit(mode, LengthTypeNumber)) { - setValueAsString(valueAsString); + ExceptionCode ec = 0; + setValueAsString(valueAsString, ec); } SVGLength::SVGLength(const SVGLength& other) @@ -156,35 +157,24 @@ SVGLengthType SVGLength::unitType() const float SVGLength::value(const SVGElement* context) const { - SVGLengthType type = extractType(m_unit); - if (type == LengthTypeUnknown) - return 0.0f; + ExceptionCode ec = 0; + return value(context, ec); +} - switch (type) { +float SVGLength::value(const SVGElement* context, ExceptionCode& ec) const +{ + switch (extractType(m_unit)) { + case LengthTypeUnknown: + ec = NOT_SUPPORTED_ERR; + return 0; case LengthTypeNumber: return m_valueInSpecifiedUnits; case LengthTypePercentage: - return SVGLength::PercentageOfViewport(m_valueInSpecifiedUnits / 100.0f, context, extractMode(m_unit)); + return convertValueFromPercentageToUserUnits(m_valueInSpecifiedUnits / 100, context, ec); case LengthTypeEMS: + return convertValueFromEMSToUserUnits(m_valueInSpecifiedUnits, context, ec); case LengthTypeEXS: - { - RenderStyle* style = 0; - if (context && context->renderer()) - style = context->renderer()->style(); - if (style) { - float useSize = style->fontSize(); - ASSERT(useSize > 0); - if (type == LengthTypeEMS) - return m_valueInSpecifiedUnits * useSize; - else { - float xHeight = style->font().xHeight(); - // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg - // if this causes problems in real world cases maybe it would be best to remove this - return m_valueInSpecifiedUnits * ceilf(xHeight); - } - } - return 0.0f; - } + return convertValueFromEXSToUserUnits(m_valueInSpecifiedUnits, context, ec); case LengthTypePX: return m_valueInSpecifiedUnits; case LengthTypeCM: @@ -194,31 +184,45 @@ float SVGLength::value(const SVGElement* context) const case LengthTypeIN: return m_valueInSpecifiedUnits * cssPixelsPerInch; case LengthTypePT: - return m_valueInSpecifiedUnits / 72.0f * cssPixelsPerInch; + return m_valueInSpecifiedUnits / 72 * cssPixelsPerInch; case LengthTypePC: - return m_valueInSpecifiedUnits / 6.0f * cssPixelsPerInch; - default: - break; + return m_valueInSpecifiedUnits / 6 * cssPixelsPerInch; } ASSERT_NOT_REACHED(); - return 0.0f; + return 0; } -void SVGLength::setValue(float value) +void SVGLength::setValue(float value, const SVGElement* context, ExceptionCode& ec) { - SVGLengthType type = extractType(m_unit); - ASSERT(type != LengthTypeUnknown); - - switch (type) { + switch (extractType(m_unit)) { + case LengthTypeUnknown: + ec = NOT_SUPPORTED_ERR; + break; case LengthTypeNumber: m_valueInSpecifiedUnits = value; break; case LengthTypePercentage: + { + float result = convertValueFromUserUnitsToPercentage(value, context, ec); + if (!ec) + m_valueInSpecifiedUnits = result; + break; + } case LengthTypeEMS: + { + float result = convertValueFromUserUnitsToEMS(value, context, ec); + if (!ec) + m_valueInSpecifiedUnits = result; + break; + } case LengthTypeEXS: - notImplemented(); + { + float result = convertValueFromUserUnitsToEXS(value, context, ec); + if (!ec) + m_valueInSpecifiedUnits = result; break; + } case LengthTypePX: m_valueInSpecifiedUnits = value; break; @@ -232,97 +236,104 @@ void SVGLength::setValue(float value) m_valueInSpecifiedUnits = value / cssPixelsPerInch; break; case LengthTypePT: - m_valueInSpecifiedUnits = value * 72.0f / cssPixelsPerInch; + m_valueInSpecifiedUnits = value * 72 / cssPixelsPerInch; break; case LengthTypePC: - m_valueInSpecifiedUnits = value / 6.0f * cssPixelsPerInch; - break; - default: + m_valueInSpecifiedUnits = value * 6 / cssPixelsPerInch; break; } } -void SVGLength::setValueInSpecifiedUnits(float value) -{ - m_valueInSpecifiedUnits = value; -} - -float SVGLength::valueInSpecifiedUnits() const -{ - return m_valueInSpecifiedUnits; -} - float SVGLength::valueAsPercentage() const { // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed if (extractType(m_unit) == LengthTypePercentage) - return valueInSpecifiedUnits() / 100.0f; + return m_valueInSpecifiedUnits / 100; - return valueInSpecifiedUnits(); + return m_valueInSpecifiedUnits; } -bool SVGLength::setValueAsString(const String& s) +void SVGLength::setValueAsString(const String& string, ExceptionCode& ec) { - if (s.isEmpty()) - return false; + if (string.isEmpty()) + return; - float convertedNumber = 0.0f; - const UChar* ptr = s.characters(); - const UChar* end = ptr + s.length(); + float convertedNumber = 0; + const UChar* ptr = string.characters(); + const UChar* end = ptr + string.length(); - if (!parseNumber(ptr, end, convertedNumber, false)) - return false; + if (!parseNumber(ptr, end, convertedNumber, false)) { + ec = SYNTAX_ERR; + return; + } SVGLengthType type = stringToLengthType(ptr, end); - if (type == LengthTypeUnknown) - return false; + if (type == LengthTypeUnknown) { + ec = SYNTAX_ERR; + return; + } m_unit = storeUnit(extractMode(m_unit), type); m_valueInSpecifiedUnits = convertedNumber; - return true; } String SVGLength::valueAsString() const { - return String::number(m_valueInSpecifiedUnits) + lengthTypeToString(extractType(m_unit)); + return makeString(String::number(m_valueInSpecifiedUnits), lengthTypeToString(extractType(m_unit))); } -void SVGLength::newValueSpecifiedUnits(unsigned short type, float value) +void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, ExceptionCode& ec) { - if (type == LengthTypeUnknown || type > LengthTypePC) + if (type == LengthTypeUnknown || type > LengthTypePC) { + ec = NOT_SUPPORTED_ERR; return; + } - m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type); + m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type)); m_valueInSpecifiedUnits = value; } -void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGElement* context) +void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGElement* context, ExceptionCode& ec) { - if (type == LengthTypeUnknown || type > LengthTypePC) + if (type == LengthTypeUnknown || type > LengthTypePC) { + ec = NOT_SUPPORTED_ERR; return; + } - float valueInUserUnits = value(context); - m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type); - setValue(valueInUserUnits); + float valueInUserUnits = value(context, ec); + if (ec) + return; + + unsigned int originalUnitAndType = m_unit; + m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type)); + setValue(valueInUserUnits, context, ec); + if (!ec) + return; + + // Eventually restore old unit and type + m_unit = originalUnitAndType; } -float SVGLength::PercentageOfViewport(float value, const SVGElement* context, SVGLengthMode mode) +bool SVGLength::determineViewport(const SVGElement* context, float& width, float& height) const { - ASSERT(context); - - float width = 0.0f, height = 0.0f; - SVGElement* viewportElement = context->viewportElement(); + if (!context) + return false; - // PercentageOfViewport() is used to resolve all relative-positioned values within a SVG document (fragment) - Document* doc = context->document(); - if (doc->documentElement() == context) { - // Resolve value against outermost <svg> element - if (RenderView* view = toRenderView(doc->renderer())) { + // Take size from outermost <svg> element. + Document* document = context->document(); + if (document->documentElement() == context) { + if (RenderView* view = toRenderView(document->renderer())) { width = view->viewWidth(); height = view->viewHeight(); - } - } else if (viewportElement && viewportElement->isSVG()) { - // Resolve value against nearest viewport element (common case: inner <svg> elements) + return true; + } + + return false; + } + + // Resolve value against nearest viewport element (common case: inner <svg> elements) + SVGElement* viewportElement = context->viewportElement(); + if (viewportElement && viewportElement->isSVG()) { const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement); if (svg->hasAttribute(SVGNames::viewBoxAttr)) { width = svg->viewBox().width(); @@ -331,25 +342,127 @@ float SVGLength::PercentageOfViewport(float value, const SVGElement* context, SV width = svg->width().value(svg); height = svg->height().value(svg); } - } else if (context->parent() && !context->parent()->isSVGElement()) { - // Resolve value against enclosing non-SVG RenderBox - if (RenderObject* renderer = context->renderer()) { - if (renderer->isBox()) { - RenderBox* box = toRenderBox(renderer); - width = box->width(); - height = box->height(); - } - } + + return true; } + + // Resolve value against enclosing non-SVG RenderBox + if (!context->parent() || context->parent()->isSVGElement()) + return false; - if (mode == LengthModeWidth) + RenderObject* renderer = context->renderer(); + if (!renderer || !renderer->isBox()) + return false; + + RenderBox* box = toRenderBox(renderer); + width = box->width(); + height = box->height(); + return true; +} + +float SVGLength::convertValueFromUserUnitsToPercentage(float value, const SVGElement* context, ExceptionCode& ec) const +{ + float width = 0; + float height = 0; + if (!determineViewport(context, width, height)) { + ec = NOT_SUPPORTED_ERR; + return 0; + } + + switch (extractMode(m_unit)) { + case LengthModeWidth: + return value / width * 100; + case LengthModeHeight: + return value / height * 100; + case LengthModeOther: + return value / (sqrtf((width * width + height * height) / 2)) * 100; + }; + + ASSERT_NOT_REACHED(); + return 0; +} + +float SVGLength::convertValueFromPercentageToUserUnits(float value, const SVGElement* context, ExceptionCode& ec) const +{ + float width = 0; + float height = 0; + if (!determineViewport(context, width, height)) { + ec = NOT_SUPPORTED_ERR; + return 0; + } + + switch (extractMode(m_unit)) { + case LengthModeWidth: return value * width; - else if (mode == LengthModeHeight) + case LengthModeHeight: return value * height; - else if (mode == LengthModeOther) - return value * sqrtf(powf(width, 2) + powf(height, 2)) / sqrtf(2.0f); + case LengthModeOther: + return value * sqrtf((width * width + height * height) / 2); + }; - return 0.0f; + ASSERT_NOT_REACHED(); + return 0; +} + +float SVGLength::convertValueFromUserUnitsToEMS(float value, const SVGElement* context, ExceptionCode& ec) const +{ + if (!context || !context->renderer() || !context->renderer()->style()) { + ec = NOT_SUPPORTED_ERR; + return 0; + } + + RenderStyle* style = context->renderer()->style(); + float fontSize = style->fontSize(); + if (!fontSize) { + ec = NOT_SUPPORTED_ERR; + return 0; + } + + return value / fontSize; +} + +float SVGLength::convertValueFromEMSToUserUnits(float value, const SVGElement* context, ExceptionCode& ec) const +{ + if (!context || !context->renderer() || !context->renderer()->style()) { + ec = NOT_SUPPORTED_ERR; + return 0; + } + + RenderStyle* style = context->renderer()->style(); + return value * style->fontSize(); +} + +float SVGLength::convertValueFromUserUnitsToEXS(float value, const SVGElement* context, ExceptionCode& ec) const +{ + if (!context || !context->renderer() || !context->renderer()->style()) { + ec = NOT_SUPPORTED_ERR; + return 0; + } + + RenderStyle* style = context->renderer()->style(); + + // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg + // if this causes problems in real world cases maybe it would be best to remove this + float xHeight = ceilf(style->font().xHeight()); + if (!xHeight) { + ec = NOT_SUPPORTED_ERR; + return 0; + } + + return value / xHeight; +} + +float SVGLength::convertValueFromEXSToUserUnits(float value, const SVGElement* context, ExceptionCode& ec) const +{ + if (!context || !context->renderer() || !context->renderer()->style()) { + ec = NOT_SUPPORTED_ERR; + return 0; + } + + RenderStyle* style = context->renderer()->style(); + // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg + // if this causes problems in real world cases maybe it would be best to remove this + return value * ceilf(style->font().xHeight()); } SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value) @@ -397,8 +510,12 @@ SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value) if (svgType == LengthTypeUnknown) return SVGLength(); + ExceptionCode ec = 0; SVGLength length; - length.newValueSpecifiedUnits(svgType, value->getFloatValue()); + length.newValueSpecifiedUnits(svgType, value->getFloatValue(), ec); + if (ec) + return SVGLength(); + return length; } @@ -438,8 +555,6 @@ PassRefPtr<CSSPrimitiveValue> SVGLength::toCSSPrimitiveValue(const SVGLength& le case LengthTypePC: cssType = CSSPrimitiveValue::CSS_PC; break; - default: - ASSERT_NOT_REACHED(); }; return CSSPrimitiveValue::create(length.valueInSpecifiedUnits(), cssType); diff --git a/WebCore/svg/SVGLength.h b/WebCore/svg/SVGLength.h index a0551f7..ccd22ee 100644 --- a/WebCore/svg/SVGLength.h +++ b/WebCore/svg/SVGLength.h @@ -22,7 +22,8 @@ #define SVGLength_h #if ENABLE(SVG) -#include "PlatformString.h" +#include "ExceptionCode.h" +#include <wtf/text/WTFString.h> namespace WebCore { @@ -76,32 +77,43 @@ public: bool operator!=(const SVGLength&) const; float value(const SVGElement* context) const; - void setValue(float); + float value(const SVGElement* context, ExceptionCode&) const; + void setValue(float, const SVGElement* context, ExceptionCode&); + + float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; } + void setValueInSpecifiedUnits(float value) { m_valueInSpecifiedUnits = value; } - float valueInSpecifiedUnits() const; - void setValueInSpecifiedUnits(float); - float valueAsPercentage() const; String valueAsString() const; - bool setValueAsString(const String&); + void setValueAsString(const String&, ExceptionCode&); - void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits); - void convertToSpecifiedUnits(unsigned short, const SVGElement* context); + void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits, ExceptionCode&); + void convertToSpecifiedUnits(unsigned short, const SVGElement* context, ExceptionCode&); // Helper functions - static float PercentageOfViewport(float value, const SVGElement* context, SVGLengthMode); - inline bool isRelative() const { SVGLengthType type = unitType(); - return (type == LengthTypePercentage || type == LengthTypeEMS || type == LengthTypeEXS); + return type == LengthTypePercentage || type == LengthTypeEMS || type == LengthTypeEXS; } static SVGLength fromCSSPrimitiveValue(CSSPrimitiveValue*); static PassRefPtr<CSSPrimitiveValue> toCSSPrimitiveValue(const SVGLength&); private: + bool determineViewport(const SVGElement* context, float& width, float& height) const; + + float convertValueFromPercentageToUserUnits(float value, const SVGElement* context, ExceptionCode&) const; + float convertValueFromUserUnitsToPercentage(float value, const SVGElement* context, ExceptionCode&) const; + + float convertValueFromUserUnitsToEMS(float value, const SVGElement* context, ExceptionCode&) const; + float convertValueFromEMSToUserUnits(float value, const SVGElement* context, ExceptionCode&) const; + + float convertValueFromUserUnitsToEXS(float value, const SVGElement* context, ExceptionCode&) const; + float convertValueFromEXSToUserUnits(float value, const SVGElement* context, ExceptionCode&) const; + +private: float m_valueInSpecifiedUnits; unsigned int m_unit; }; diff --git a/WebCore/svg/SVGLength.idl b/WebCore/svg/SVGLength.idl index 166019e..0e6807f 100644 --- a/WebCore/svg/SVGLength.idl +++ b/WebCore/svg/SVGLength.idl @@ -37,14 +37,20 @@ module svg { const unsigned short SVG_LENGTHTYPE_PC = 10; readonly attribute unsigned short unitType; - attribute [CustomGetter] float value; - attribute float valueInSpecifiedUnits; - attribute [ConvertNullToNullString] DOMString valueAsString; + attribute [Custom, StrictTypeChecking] float value + setter raises(DOMException), + getter raises(DOMException); - void newValueSpecifiedUnits(in unsigned short unitType, - in float valueInSpecifiedUnits); + attribute [StrictTypeChecking] float valueInSpecifiedUnits; + attribute [ConvertNullToNullString, StrictTypeChecking] DOMString valueAsString + setter raises(DOMException); - [Custom] void convertToSpecifiedUnits(in unsigned short unitType); + [StrictTypeChecking, RequiresAllArguments=Raise] void newValueSpecifiedUnits(in unsigned short unitType, + in float valueInSpecifiedUnits) + raises(DOMException); + + [Custom, StrictTypeChecking, RequiresAllArguments=Raise] void convertToSpecifiedUnits(in unsigned short unitType) + raises(DOMException); }; } diff --git a/WebCore/svg/SVGLengthList.cpp b/WebCore/svg/SVGLengthList.cpp index 3ab7c1a..a05ea4b 100644 --- a/WebCore/svg/SVGLengthList.cpp +++ b/WebCore/svg/SVGLengthList.cpp @@ -31,6 +31,7 @@ namespace WebCore { void SVGLengthList::parse(const String& value, SVGLengthMode mode) { clear(); + ExceptionCode ec = 0; const UChar* ptr = value.characters(); const UChar* end = ptr + value.length(); @@ -40,8 +41,13 @@ void SVGLengthList::parse(const String& value, SVGLengthMode mode) ptr++; if (ptr == start) break; + SVGLength length(mode); - if (!length.setValueAsString(String(start, ptr - start))) + String valueString(start, ptr - start); + if (valueString.isEmpty()) + return; + length.setValueAsString(valueString, ec); + if (ec) return; append(length); skipOptionalSpacesOrDelimiter(ptr, end); diff --git a/WebCore/svg/SVGLengthList.idl b/WebCore/svg/SVGLengthList.idl index 73a8d21..a5771d2 100644 --- a/WebCore/svg/SVGLengthList.idl +++ b/WebCore/svg/SVGLengthList.idl @@ -26,7 +26,7 @@ module svg { - interface [Conditional=SVG, SVGListProperty=SVGLengthList] SVGLengthList { + interface [Conditional=SVG] SVGLengthList { readonly attribute unsigned long numberOfItems; void clear() diff --git a/WebCore/svg/SVGLocatable.cpp b/WebCore/svg/SVGLocatable.cpp index 9a823ff..b3dce01 100644 --- a/WebCore/svg/SVGLocatable.cpp +++ b/WebCore/svg/SVGLocatable.cpp @@ -26,8 +26,9 @@ #include "SVGLocatable.h" #include "RenderObject.h" -#include "SVGStyledLocatableElement.h" #include "SVGException.h" +#include "SVGNames.h" +#include "SVGStyledLocatableElement.h" namespace WebCore { diff --git a/WebCore/svg/SVGMPathElement.h b/WebCore/svg/SVGMPathElement.h index c025cf9..3d10e5b 100644 --- a/WebCore/svg/SVGMPathElement.h +++ b/WebCore/svg/SVGMPathElement.h @@ -44,7 +44,7 @@ namespace WebCore { virtual void synchronizeProperty(const QualifiedName&); // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGMPathElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGMPathElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGMPathElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGMarkerElement.cpp b/WebCore/svg/SVGMarkerElement.cpp index ef2b3dd..8b6d41c 100644 --- a/WebCore/svg/SVGMarkerElement.cpp +++ b/WebCore/svg/SVGMarkerElement.cpp @@ -55,13 +55,13 @@ PassRefPtr<SVGMarkerElement> SVGMarkerElement::create(const QualifiedName& tagNa const AtomicString& SVGMarkerElement::orientTypeIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGOrientType")); - return s_identifier; + return s_identifier; } const AtomicString& SVGMarkerElement::orientAngleIdentifier() { DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGOrientAngle")); - return s_identifier; + return s_identifier; } AffineTransform SVGMarkerElement::viewBoxToViewTransform(float viewWidth, float viewHeight) const diff --git a/WebCore/svg/SVGMarkerElement.h b/WebCore/svg/SVGMarkerElement.h index fd67cfc..e84357e 100644 --- a/WebCore/svg/SVGMarkerElement.h +++ b/WebCore/svg/SVGMarkerElement.h @@ -89,7 +89,7 @@ private: // SVGFitToViewBox DECLARE_ANIMATED_PROPERTY_NEW(SVGMarkerElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox) - DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + DECLARE_ANIMATED_PROPERTY_NEW(SVGMarkerElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) }; } diff --git a/WebCore/svg/SVGNumber.idl b/WebCore/svg/SVGNumber.idl index 32e9620..83e3b6b 100644 --- a/WebCore/svg/SVGNumber.idl +++ b/WebCore/svg/SVGNumber.idl @@ -22,8 +22,8 @@ module svg { - interface [Conditional=SVG, PODType=float] SVGNumber { - attribute float value; + interface [Conditional=SVG] SVGNumber { + attribute [StrictTypeChecking] float value; }; } diff --git a/WebCore/svg/SVGNumberList.cpp b/WebCore/svg/SVGNumberList.cpp index 96fe55f..a1dc430 100644 --- a/WebCore/svg/SVGNumberList.cpp +++ b/WebCore/svg/SVGNumberList.cpp @@ -24,45 +24,39 @@ #include "SVGNumberList.h" #include "SVGParserUtilities.h" +#include <wtf/text/StringBuilder.h> namespace WebCore { -SVGNumberList::SVGNumberList(const QualifiedName& attributeName) - : SVGPODList<float>(attributeName) -{ -} - void SVGNumberList::parse(const String& value) { - ExceptionCode ec = 0; - clear(ec); + clear(); - float number = 0.0f; - + float number = 0; const UChar* ptr = value.characters(); const UChar* end = ptr + value.length(); + // The spec strangely doesn't allow leading whitespace. We might choose to violate that intentionally. (section 4.1) while (ptr < end) { if (!parseNumber(ptr, end, number)) return; - appendItem(number, ec); + append(number); } } String SVGNumberList::valueAsString() const { - String result; + StringBuilder builder; - ExceptionCode ec = 0; - for (unsigned int i = 0; i < numberOfItems(); ++i) { + unsigned size = this->size(); + for (unsigned i = 0; i < size; ++i) { if (i > 0) - result += ", "; + builder.append(", "); - result += String::number(getItem(i, ec)); - ASSERT(ec == 0); + builder.append(String::number(at(i))); } - return result; + return builder.toString(); } } diff --git a/WebCore/svg/SVGNumberList.h b/WebCore/svg/SVGNumberList.h index e64b0b7..abc82da 100644 --- a/WebCore/svg/SVGNumberList.h +++ b/WebCore/svg/SVGNumberList.h @@ -22,23 +22,18 @@ #define SVGNumberList_h #if ENABLE(SVG) -#include "SVGList.h" -#include <wtf/Forward.h> -#include <wtf/PassRefPtr.h> +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> namespace WebCore { - class SVGNumberList : public SVGPODList<float> { - public: - static PassRefPtr<SVGNumberList> create(const QualifiedName& attributeName) { return adoptRef(new SVGNumberList(attributeName)); } +class SVGNumberList : public Vector<float> { +public: + SVGNumberList() { } - void parse(const String& value); - - String valueAsString() const; - - private: - SVGNumberList(const QualifiedName&); - }; + void parse(const String&); + String valueAsString() const; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGParserUtilities.cpp b/WebCore/svg/SVGParserUtilities.cpp index c37d207..5a77ce2 100644 --- a/WebCore/svg/SVGParserUtilities.cpp +++ b/WebCore/svg/SVGParserUtilities.cpp @@ -26,9 +26,7 @@ #include "SVGParserUtilities.h" #include "Document.h" -#include "ExceptionCode.h" #include "FloatPoint.h" -#include "PlatformString.h" #include "SVGPointList.h" #include <wtf/ASCIICType.h> @@ -167,7 +165,7 @@ bool parseNumberOptionalNumber(const String& s, float& x, float& y) return cur == end; } -bool pointsListFromSVGData(SVGPointList* pointsList, const String& points) +bool pointsListFromSVGData(SVGPointList& pointsList, const String& points) { if (points.isEmpty()) return true; @@ -195,8 +193,7 @@ bool pointsListFromSVGData(SVGPointList* pointsList, const String& points) } skipOptionalSpaces(cur, end); - ExceptionCode ec = 0; - pointsList->appendItem(FloatPoint(xPos, yPos), ec); + pointsList.append(FloatPoint(xPos, yPos)); } return cur == end && !delimParsed; } diff --git a/WebCore/svg/SVGParserUtilities.h b/WebCore/svg/SVGParserUtilities.h index 4e9362d..0718d50 100644 --- a/WebCore/svg/SVGParserUtilities.h +++ b/WebCore/svg/SVGParserUtilities.h @@ -63,7 +63,7 @@ namespace WebCore { return ptr < end; } - bool pointsListFromSVGData(SVGPointList* pointsList, const String& points); + bool pointsListFromSVGData(SVGPointList& pointsList, const String& points); Vector<String> parseDelimitedString(const String& input, const char seperator); bool parseKerningUnicodeString(const String& input, UnicodeRanges&, HashSet<String>& stringList); bool parseGlyphName(const String& input, HashSet<String>& values); diff --git a/WebCore/svg/SVGPathElement.h b/WebCore/svg/SVGPathElement.h index f4e2b8a..91d55b1 100644 --- a/WebCore/svg/SVGPathElement.h +++ b/WebCore/svg/SVGPathElement.h @@ -105,7 +105,7 @@ namespace WebCore { mutable RefPtr<SVGPathSegList> m_pathSegList; - DECLARE_ANIMATED_PROPERTY(SVGPathElement, SVGNames::pathLengthAttr, float, PathLength, pathLength) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPathElement, SVGNames::pathLengthAttr, float, PathLength, pathLength) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPathElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGPatternElement.h b/WebCore/svg/SVGPatternElement.h index 84e0415..ce63a22 100644 --- a/WebCore/svg/SVGPatternElement.h +++ b/WebCore/svg/SVGPatternElement.h @@ -73,14 +73,14 @@ namespace WebCore { DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::patternTransformAttr, SVGTransformList*, PatternTransform, patternTransform) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGPatternElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPatternElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPatternElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) // SVGPatternElement DECLARE_ANIMATED_PROPERTY_NEW(SVGPatternElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox) - DECLARE_ANIMATED_PROPERTY(SVGPatternElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + DECLARE_ANIMATED_PROPERTY_NEW(SVGPatternElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) }; } // namespace WebCore diff --git a/WebCore/svg/SVGPoint.idl b/WebCore/svg/SVGPoint.idl index 46ca671..19c6292 100644 --- a/WebCore/svg/SVGPoint.idl +++ b/WebCore/svg/SVGPoint.idl @@ -22,9 +22,9 @@ module svg { - interface [Conditional=SVG, PODType=FloatPoint] SVGPoint { - attribute float x; - attribute float y; + interface [Conditional=SVG] SVGPoint { + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; SVGPoint matrixTransform(in SVGMatrix matrix); }; diff --git a/WebCore/svg/SVGPointList.cpp b/WebCore/svg/SVGPointList.cpp index 0d8e10c..ae460a1 100644 --- a/WebCore/svg/SVGPointList.cpp +++ b/WebCore/svg/SVGPointList.cpp @@ -22,32 +22,27 @@ #if ENABLE(SVG) #include "SVGPointList.h" -#include "SVGPathSegList.h" -#include "PlatformString.h" -namespace WebCore { +#include "FloatPoint.h" +#include <wtf/text/StringBuilder.h> +#include <wtf/text/StringConcatenate.h> -SVGPointList::SVGPointList(const QualifiedName& attributeName) - : SVGPODList<FloatPoint>(attributeName) -{ -} +namespace WebCore { String SVGPointList::valueAsString() const { - String result; + StringBuilder builder; - ExceptionCode ec = 0; - for (unsigned int i = 0; i < numberOfItems(); ++i) { + unsigned size = this->size(); + for (unsigned i = 0; i < size; ++i) { if (i > 0) - result += " "; - - FloatPoint point = getItem(i, ec); - ASSERT(ec == 0); + builder.append(" "); // FIXME: Shouldn't we use commas to seperate? - result += String::format("%.6lg %.6lg", point.x(), point.y()); + const FloatPoint& point = at(i); + builder.append(makeString(String::number(point.x()), ' ', String::number(point.y()))); } - return result; + return builder.toString(); } float inline adjustAnimatedValue(float from, float to, float progress) @@ -55,27 +50,19 @@ float inline adjustAnimatedValue(float from, float to, float progress) return (to - from) * progress + from; } -PassRefPtr<SVGPointList> SVGPointList::createAnimated(const SVGPointList* fromList, const SVGPointList* toList, float progress) +bool SVGPointList::createAnimated(const SVGPointList& fromList, const SVGPointList& toList, SVGPointList& resultList, float progress) { - unsigned itemCount = fromList->numberOfItems(); - if (!itemCount || itemCount != toList->numberOfItems()) - return 0; - RefPtr<SVGPointList> result = create(fromList->associatedAttributeName()); - ExceptionCode ec = 0; + unsigned itemCount = fromList.size(); + if (!itemCount || itemCount != toList.size()) + return false; for (unsigned n = 0; n < itemCount; ++n) { - FloatPoint from = fromList->getItem(n, ec); - if (ec) - return 0; - FloatPoint to = toList->getItem(n, ec); - if (ec) - return 0; + const FloatPoint& from = fromList.at(n); + const FloatPoint& to = toList.at(n); FloatPoint segment = FloatPoint(adjustAnimatedValue(from.x(), to.x(), progress), adjustAnimatedValue(from.y(), to.y(), progress)); - result->appendItem(segment, ec); - if (ec) - return 0; + resultList.append(segment); } - return result.release(); + return true; } } diff --git a/WebCore/svg/SVGPointList.h b/WebCore/svg/SVGPointList.h index 43edbbb..9f2efc9 100644 --- a/WebCore/svg/SVGPointList.h +++ b/WebCore/svg/SVGPointList.h @@ -22,24 +22,22 @@ #define SVGPointList_h #if ENABLE(SVG) -#include "SVGList.h" -#include "FloatPoint.h" -#include <wtf/Forward.h> -#include <wtf/PassRefPtr.h> +#include "QualifiedName.h" +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> namespace WebCore { - class SVGPointList : public SVGPODList<FloatPoint> { - public: - static PassRefPtr<SVGPointList> create(const QualifiedName& attributeName) { return adoptRef(new SVGPointList(attributeName)); } +class FloatPoint; - String valueAsString() const; +class SVGPointList : public Vector<FloatPoint> { +public: + SVGPointList() { } - static PassRefPtr<SVGPointList> createAnimated(const SVGPointList* fromList, const SVGPointList* toList, float progress); + String valueAsString() const; - private: - SVGPointList(const QualifiedName&); - }; + static bool createAnimated(const SVGPointList& fromList, const SVGPointList& toList, SVGPointList& resultList, float progress); +}; } // namespace WebCore diff --git a/WebCore/svg/SVGPolyElement.cpp b/WebCore/svg/SVGPolyElement.cpp index 6e935f1..7b95a32 100644 --- a/WebCore/svg/SVGPolyElement.cpp +++ b/WebCore/svg/SVGPolyElement.cpp @@ -39,29 +39,18 @@ SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document* document) { } -SVGPointList* SVGPolyElement::points() const -{ - if (!m_points) - m_points = SVGPointList::create(SVGNames::pointsAttr); - - return m_points.get(); -} - -SVGPointList* SVGPolyElement::animatedPoints() const -{ - // FIXME! - return 0; -} - void SVGPolyElement::parseMappedAttribute(Attribute* attr) { const AtomicString& value = attr->value(); if (attr->name() == SVGNames::pointsAttr) { - ExceptionCode ec = 0; - points()->clear(ec); - - if (!pointsListFromSVGData(points(), value)) + SVGPointList newList; + if (!pointsListFromSVGData(newList, value)) document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value + "\""); + + if (SVGAnimatedListPropertyTearOff<SVGPointList>* list = m_animatablePointsList.get()) + list->detachListWrappers(newList.size()); + + m_points.value = newList; } else { if (SVGTests::parseMappedAttribute(attr)) return; @@ -77,10 +66,6 @@ void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName) { SVGStyledTransformableElement::svgAttributeChanged(attrName); - // The points property is not a regular SVGAnimatedProperty, still we use the same SVG<->XML DOM synchronization framework. - if (attrName == SVGNames::pointsAttr) - invalidateSVGAttributes(); - RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer()); if (!renderer) return; @@ -109,14 +94,44 @@ void SVGPolyElement::synchronizeProperty(const QualifiedName& attrName) if (attrName == anyQName()) { synchronizeExternalResourcesRequired(); - SVGAnimatedPropertySynchronizer<true>::synchronize(this, SVGNames::pointsAttr, points()->valueAsString()); + synchronizePoints(); return; } if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); else if (attrName == SVGNames::pointsAttr) - SVGAnimatedPropertySynchronizer<true>::synchronize(this, attrName, points()->valueAsString()); + synchronizePoints(); +} + +void SVGPolyElement::synchronizePoints() +{ + if (!m_points.shouldSynchronize) + return; + + SVGAnimatedPropertySynchronizer<true>::synchronize(this, SVGNames::pointsAttr, m_points.value.valueAsString()); +} + +SVGListPropertyTearOff<SVGPointList>* SVGPolyElement::points() +{ + if (!m_animatablePointsList) { + m_points.shouldSynchronize = true; + m_animatablePointsList = SVGAnimatedProperty::lookupOrCreateWrapper<SVGAnimatedListPropertyTearOff<SVGPointList> , SVGPointList> + (this, SVGNames::pointsAttr, SVGNames::pointsAttr.localName(), m_points.value); + } + + return static_cast<SVGListPropertyTearOff<SVGPointList>*>(m_animatablePointsList->baseVal()); +} + +SVGListPropertyTearOff<SVGPointList>* SVGPolyElement::animatedPoints() +{ + if (!m_animatablePointsList) { + m_points.shouldSynchronize = true; + m_animatablePointsList = SVGAnimatedProperty::lookupOrCreateWrapper<SVGAnimatedListPropertyTearOff<SVGPointList> , SVGPointList> + (this, SVGNames::pointsAttr, SVGNames::pointsAttr.localName(), m_points.value); + } + + return static_cast<SVGListPropertyTearOff<SVGPointList>*>(m_animatablePointsList->animVal()); } } diff --git a/WebCore/svg/SVGPolyElement.h b/WebCore/svg/SVGPolyElement.h index 64d4abb..0855218 100644 --- a/WebCore/svg/SVGPolyElement.h +++ b/WebCore/svg/SVGPolyElement.h @@ -22,41 +22,46 @@ #define SVGPolyElement_h #if ENABLE(SVG) -#include "SVGAnimatedPoints.h" #include "SVGAnimatedPropertyMacros.h" #include "SVGExternalResourcesRequired.h" #include "SVGLangSpace.h" +#include "SVGPointList.h" #include "SVGStyledTransformableElement.h" #include "SVGTests.h" namespace WebCore { - class SVGPolyElement : public SVGStyledTransformableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired, - public SVGAnimatedPoints { - public: - virtual SVGPointList* points() const; - virtual SVGPointList* animatedPoints() const; +class SVGPolyElement : public SVGStyledTransformableElement + , public SVGTests + , public SVGLangSpace + , public SVGExternalResourcesRequired { +public: + SVGListPropertyTearOff<SVGPointList>* points(); + SVGListPropertyTearOff<SVGPointList>* animatedPoints(); - protected: - SVGPolyElement(const QualifiedName&, Document*); + SVGPointList& pointList() const { return m_points.value; } - private: - virtual bool isValid() const { return SVGTests::isValid(); } +protected: + SVGPolyElement(const QualifiedName&, Document*); - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); +private: + virtual bool isValid() const { return SVGTests::isValid(); } - virtual bool supportsMarkers() const { return true; } + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPolyElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) + virtual bool supportsMarkers() const { return true; } - mutable RefPtr<SVGPointList> m_points; - }; + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPolyElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) + + void synchronizePoints(); + +protected: + mutable SVGSynchronizableAnimatedProperty<SVGPointList> m_points; + RefPtr<SVGAnimatedListPropertyTearOff<SVGPointList> > m_animatablePointsList; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGPolygonElement.cpp b/WebCore/svg/SVGPolygonElement.cpp index 38f5bce..3439a78 100644 --- a/WebCore/svg/SVGPolygonElement.cpp +++ b/WebCore/svg/SVGPolygonElement.cpp @@ -23,8 +23,6 @@ #if ENABLE(SVG) #include "SVGPolygonElement.h" -#include "SVGPointList.h" - namespace WebCore { inline SVGPolygonElement::SVGPolygonElement(const QualifiedName& tagName, Document* document) @@ -41,15 +39,15 @@ void SVGPolygonElement::toPathData(Path& path) const { ASSERT(path.isEmpty()); - int len = points()->numberOfItems(); - if (len < 1) + SVGPointList& points = pointList(); + if (points.isEmpty()) return; - - ExceptionCode ec = 0; - path.moveTo(points()->getItem(0, ec)); - for (int i = 1; i < len; ++i) - path.addLineTo(points()->getItem(i, ec)); + path.moveTo(points.first()); + + unsigned size = points.size(); + for (unsigned i = 1; i < size; ++i) + path.addLineTo(points.at(i)); path.closeSubpath(); } diff --git a/WebCore/svg/SVGPolygonElement.idl b/WebCore/svg/SVGPolygonElement.idl index e58ec38..b767aaa 100644 --- a/WebCore/svg/SVGPolygonElement.idl +++ b/WebCore/svg/SVGPolygonElement.idl @@ -30,8 +30,9 @@ module svg { SVGLangSpace, SVGExternalResourcesRequired, SVGStylable, - SVGTransformable, - SVGAnimatedPoints { + SVGTransformable { + readonly attribute SVGPointList points; + readonly attribute SVGPointList animatedPoints; }; } diff --git a/WebCore/svg/SVGPolylineElement.cpp b/WebCore/svg/SVGPolylineElement.cpp index c9750b2..8bd6d7b 100644 --- a/WebCore/svg/SVGPolylineElement.cpp +++ b/WebCore/svg/SVGPolylineElement.cpp @@ -23,8 +23,6 @@ #if ENABLE(SVG) #include "SVGPolylineElement.h" -#include "SVGPointList.h" - namespace WebCore { inline SVGPolylineElement::SVGPolylineElement(const QualifiedName& tagName, Document* document) @@ -41,15 +39,15 @@ void SVGPolylineElement::toPathData(Path& path) const { ASSERT(path.isEmpty()); - int len = points()->numberOfItems(); - if (len < 1) + SVGPointList& points = pointList(); + if (points.isEmpty()) return; - ExceptionCode ec = 0; - path.moveTo(points()->getItem(0, ec)); + path.moveTo(points.first()); - for (int i = 1; i < len; ++i) - path.addLineTo(points()->getItem(i, ec)); + unsigned size = points.size(); + for (unsigned i = 1; i < size; ++i) + path.addLineTo(points.at(i)); } } diff --git a/WebCore/svg/SVGPolylineElement.idl b/WebCore/svg/SVGPolylineElement.idl index e3f1cd7..b7af89f 100644 --- a/WebCore/svg/SVGPolylineElement.idl +++ b/WebCore/svg/SVGPolylineElement.idl @@ -30,8 +30,9 @@ module svg { SVGLangSpace, SVGExternalResourcesRequired, SVGStylable, - SVGTransformable, - SVGAnimatedPoints { + SVGTransformable { + readonly attribute SVGPointList points; + readonly attribute SVGPointList animatedPoints; }; } diff --git a/WebCore/svg/SVGPreserveAspectRatio.cpp b/WebCore/svg/SVGPreserveAspectRatio.cpp index a129fe6..c9c452e 100644 --- a/WebCore/svg/SVGPreserveAspectRatio.cpp +++ b/WebCore/svg/SVGPreserveAspectRatio.cpp @@ -25,8 +25,9 @@ #include "SVGPreserveAspectRatio.h" #include "AffineTransform.h" +#include "FloatRect.h" #include "SVGParserUtilities.h" -#include "SVGSVGElement.h" +#include <wtf/text/StringConcatenate.h> namespace WebCore { @@ -34,27 +35,26 @@ SVGPreserveAspectRatio::SVGPreserveAspectRatio() : m_align(SVG_PRESERVEASPECTRATIO_XMIDYMID) , m_meetOrSlice(SVG_MEETORSLICE_MEET) { - // FIXME: Should the two values default to UNKNOWN instead? } -void SVGPreserveAspectRatio::setAlign(unsigned short align) +void SVGPreserveAspectRatio::setAlign(unsigned short align, ExceptionCode& ec) { - m_align = align; -} + if (align == SVG_PRESERVEASPECTRATIO_UNKNOWN || align > SVG_PRESERVEASPECTRATIO_XMAXYMAX) { + ec = NOT_SUPPORTED_ERR; + return; + } -unsigned short SVGPreserveAspectRatio::align() const -{ - return m_align; + m_align = static_cast<SVGPreserveAspectRatioType>(align); } -void SVGPreserveAspectRatio::setMeetOrSlice(unsigned short meetOrSlice) +void SVGPreserveAspectRatio::setMeetOrSlice(unsigned short meetOrSlice, ExceptionCode& ec) { - m_meetOrSlice = meetOrSlice; -} + if (meetOrSlice == SVG_MEETORSLICE_UNKNOWN || meetOrSlice > SVG_MEETORSLICE_SLICE) { + ec = NOT_SUPPORTED_ERR; + return; + } -unsigned short SVGPreserveAspectRatio::meetOrSlice() const -{ - return m_meetOrSlice; + m_meetOrSlice = static_cast<SVGMeetOrSliceType>(meetOrSlice); } SVGPreserveAspectRatio SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result) @@ -64,6 +64,7 @@ SVGPreserveAspectRatio SVGPreserveAspectRatio::parsePreserveAspectRatio(const UC aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET; result = false; + // FIXME: Rewrite this parser, without gotos! if (!skipOptionalSpaces(currParam, end)) goto bail_out; @@ -160,167 +161,184 @@ void SVGPreserveAspectRatio::transformRect(FloatRect& destRect, FloatRect& srcRe FloatSize imageSize = srcRect.size(); float origDestWidth = destRect.width(); float origDestHeight = destRect.height(); - if (meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET) { + switch (m_meetOrSlice) { + case SVGPreserveAspectRatio::SVG_MEETORSLICE_UNKNOWN: + break; + case SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET: + { float widthToHeightMultiplier = srcRect.height() / srcRect.width(); - if (origDestHeight > (origDestWidth * widthToHeightMultiplier)) { + if (origDestHeight > origDestWidth * widthToHeightMultiplier) { destRect.setHeight(origDestWidth * widthToHeightMultiplier); - switch (align()) { + switch (m_align) { case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID: - destRect.setY(destRect.y() + origDestHeight / 2.0f - destRect.height() / 2.0f); + destRect.setY(destRect.y() + origDestHeight / 2 - destRect.height() / 2); break; case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX: destRect.setY(destRect.y() + origDestHeight - destRect.height()); break; + default: + break; } } - if (origDestWidth > (origDestHeight / widthToHeightMultiplier)) { + if (origDestWidth > origDestHeight / widthToHeightMultiplier) { destRect.setWidth(origDestHeight / widthToHeightMultiplier); - switch (align()) { + switch (m_align) { case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX: - destRect.setX(destRect.x() + origDestWidth / 2.0f - destRect.width() / 2.0f); + destRect.setX(destRect.x() + origDestWidth / 2 - destRect.width() / 2); break; case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX: destRect.setX(destRect.x() + origDestWidth - destRect.width()); break; + default: + break; } } - } else if (meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE) { + break; + } + case SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE: + { float widthToHeightMultiplier = srcRect.height() / srcRect.width(); // if the destination height is less than the height of the image we'll be drawing - if (origDestHeight < (origDestWidth * widthToHeightMultiplier)) { + if (origDestHeight < origDestWidth * widthToHeightMultiplier) { float destToSrcMultiplier = srcRect.width() / destRect.width(); srcRect.setHeight(destRect.height() * destToSrcMultiplier); - switch (align()) { + switch (m_align) { case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID: - srcRect.setY(destRect.y() + imageSize.height() / 2.0f - srcRect.height() / 2.0f); + srcRect.setY(destRect.y() + imageSize.height() / 2 - srcRect.height() / 2); break; case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX: srcRect.setY(destRect.y() + imageSize.height() - srcRect.height()); break; + default: + break; } } // if the destination width is less than the width of the image we'll be drawing - if (origDestWidth < (origDestHeight / widthToHeightMultiplier)) { + if (origDestWidth < origDestHeight / widthToHeightMultiplier) { float destToSrcMultiplier = srcRect.height() / destRect.height(); srcRect.setWidth(destRect.width() * destToSrcMultiplier); - switch (align()) { + switch (m_align) { case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX: - srcRect.setX(destRect.x() + imageSize.width() / 2.0f - srcRect.width() / 2.0f); + srcRect.setX(destRect.x() + imageSize.width() / 2 - srcRect.width() / 2); break; case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID: case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX: srcRect.setX(destRect.x() + imageSize.width() - srcRect.width()); break; + default: + break; } } + break; + } } } -AffineTransform SVGPreserveAspectRatio::getCTM(double logicX, double logicY, - double logicWidth, double logicHeight, - double /*physX*/, double /*physY*/, - double physWidth, double physHeight) const +// FIXME: We should use floats here, like everywhere else! +AffineTransform SVGPreserveAspectRatio::getCTM(double logicX, double logicY, double logicWidth, double logicHeight, double physWidth, double physHeight) const { - AffineTransform temp; + AffineTransform transform; + if (m_align == SVG_PRESERVEASPECTRATIO_UNKNOWN) + return transform; - if (align() == SVG_PRESERVEASPECTRATIO_UNKNOWN) - return temp; + double logicalRatio = logicWidth / logicHeight; + double physRatio = physWidth / physHeight; - double vpar = logicWidth / logicHeight; - double svgar = physWidth / physHeight; + if (m_align == SVG_PRESERVEASPECTRATIO_NONE) { + transform.scaleNonUniform(physWidth / logicWidth, physHeight / logicHeight); + transform.translate(-logicX, -logicY); + return transform; + } - if (align() == SVG_PRESERVEASPECTRATIO_NONE) { - temp.scaleNonUniform(physWidth / logicWidth, physHeight / logicHeight); - temp.translate(-logicX, -logicY); - } else if ((vpar < svgar && (meetOrSlice() == SVG_MEETORSLICE_MEET)) || (vpar >= svgar && (meetOrSlice() == SVG_MEETORSLICE_SLICE))) { - temp.scaleNonUniform(physHeight / logicHeight, physHeight / logicHeight); + if ((logicalRatio < physRatio && (m_meetOrSlice == SVG_MEETORSLICE_MEET)) || (logicalRatio >= physRatio && (m_meetOrSlice == SVG_MEETORSLICE_SLICE))) { + transform.scaleNonUniform(physHeight / logicHeight, physHeight / logicHeight); - if (align() == SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVG_PRESERVEASPECTRATIO_XMINYMAX) - temp.translate(-logicX, -logicY); - else if (align() == SVG_PRESERVEASPECTRATIO_XMIDYMIN || align() == SVG_PRESERVEASPECTRATIO_XMIDYMID || align() == SVG_PRESERVEASPECTRATIO_XMIDYMAX) - temp.translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight) / 2, -logicY); + if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMINYMID || m_align == SVG_PRESERVEASPECTRATIO_XMINYMAX) + transform.translate(-logicX, -logicY); + else if (m_align == SVG_PRESERVEASPECTRATIO_XMIDYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMID || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMAX) + transform.translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight) / 2, -logicY); else - temp.translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight), -logicY); - } else { - temp.scaleNonUniform(physWidth / logicWidth, physWidth / logicWidth); - - if (align() == SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVG_PRESERVEASPECTRATIO_XMIDYMIN || align() == SVG_PRESERVEASPECTRATIO_XMAXYMIN) - temp.translate(-logicX, -logicY); - else if (align() == SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVG_PRESERVEASPECTRATIO_XMIDYMID || align() == SVG_PRESERVEASPECTRATIO_XMAXYMID) - temp.translate(-logicX, -logicY - (logicHeight - physHeight * logicWidth / physWidth) / 2); - else - temp.translate(-logicX, -logicY - (logicHeight - physHeight * logicWidth / physWidth)); + transform.translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight), -logicY); + + return transform; } - return temp; + transform.scaleNonUniform(physWidth / logicWidth, physWidth / logicWidth); + + if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMAXYMIN) + transform.translate(-logicX, -logicY); + else if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMID || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMID || m_align == SVG_PRESERVEASPECTRATIO_XMAXYMID) + transform.translate(-logicX, -logicY - (logicHeight - physHeight * logicWidth / physWidth) / 2); + else + transform.translate(-logicX, -logicY - (logicHeight - physHeight * logicWidth / physWidth)); + + return transform; } String SVGPreserveAspectRatio::valueAsString() const { - String result; + String alignType; - switch ((SVGPreserveAspectRatioType) align()) { - default: + switch (m_align) { case SVG_PRESERVEASPECTRATIO_NONE: - result = "none"; + alignType = "none"; break; case SVG_PRESERVEASPECTRATIO_XMINYMIN: - result = "xMinYMin"; + alignType = "xMinYMin"; break; case SVG_PRESERVEASPECTRATIO_XMIDYMIN: - result = "xMidYMin"; + alignType = "xMidYMin"; break; case SVG_PRESERVEASPECTRATIO_XMAXYMIN: - result = "xMaxYMin"; + alignType = "xMaxYMin"; break; case SVG_PRESERVEASPECTRATIO_XMINYMID: - result = "xMinYMid"; + alignType = "xMinYMid"; break; case SVG_PRESERVEASPECTRATIO_XMIDYMID: - result = "xMidYMid"; + alignType = "xMidYMid"; break; case SVG_PRESERVEASPECTRATIO_XMAXYMID: - result = "xMaxYMid"; + alignType = "xMaxYMid"; break; case SVG_PRESERVEASPECTRATIO_XMINYMAX: - result = "xMinYMax"; + alignType = "xMinYMax"; break; case SVG_PRESERVEASPECTRATIO_XMIDYMAX: - result = "xMidYMax"; + alignType = "xMidYMax"; break; case SVG_PRESERVEASPECTRATIO_XMAXYMAX: - result = "xMaxYMax"; + alignType = "xMaxYMax"; + break; + case SVG_PRESERVEASPECTRATIO_UNKNOWN: + alignType = "unknown"; break; }; - switch ((SVGMeetOrSliceType) meetOrSlice()) { + switch (m_meetOrSlice) { default: case SVG_MEETORSLICE_UNKNOWN: - break; + return alignType; case SVG_MEETORSLICE_MEET: - result += " meet"; - break; + return makeString(alignType, " meet"); case SVG_MEETORSLICE_SLICE: - result += " slice"; - break; + return makeString(alignType, " slice"); }; - - return result; } } diff --git a/WebCore/svg/SVGPreserveAspectRatio.h b/WebCore/svg/SVGPreserveAspectRatio.h index f29b7d3..eda82d4 100644 --- a/WebCore/svg/SVGPreserveAspectRatio.h +++ b/WebCore/svg/SVGPreserveAspectRatio.h @@ -22,72 +22,70 @@ #define SVGPreserveAspectRatio_h #if ENABLE(SVG) -#include "FloatRect.h" -#include "PlatformString.h" -#include "SVGNames.h" -#include <wtf/Forward.h> +#include "ExceptionCode.h" +#include <wtf/text/WTFString.h> namespace WebCore { - class AffineTransform; - - class SVGPreserveAspectRatio { - public: - enum SVGPreserveAspectRatioType { - SVG_PRESERVEASPECTRATIO_UNKNOWN = 0, - SVG_PRESERVEASPECTRATIO_NONE = 1, - SVG_PRESERVEASPECTRATIO_XMINYMIN = 2, - SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3, - SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4, - SVG_PRESERVEASPECTRATIO_XMINYMID = 5, - SVG_PRESERVEASPECTRATIO_XMIDYMID = 6, - SVG_PRESERVEASPECTRATIO_XMAXYMID = 7, - SVG_PRESERVEASPECTRATIO_XMINYMAX = 8, - SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9, - SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10 - }; - - enum SVGMeetOrSliceType { - SVG_MEETORSLICE_UNKNOWN = 0, - SVG_MEETORSLICE_MEET = 1, - SVG_MEETORSLICE_SLICE = 2 - }; - - SVGPreserveAspectRatio(); - - void setAlign(unsigned short); - unsigned short align() const; - - void setMeetOrSlice(unsigned short); - unsigned short meetOrSlice() const; - - void transformRect(FloatRect& destRect, FloatRect& srcRect); - - AffineTransform getCTM(double logicX, double logicY, - double logicWidth, double logicHeight, - double physX, double physY, - double physWidth, double physHeight) const; - - template<class Consumer> - static bool parsePreserveAspectRatio(Consumer* consumer, const String& value, bool validate = true) - { - bool result = false; - const UChar* begin = value.characters(); - const UChar* end = begin + value.length(); - consumer->setPreserveAspectRatioBaseValue(parsePreserveAspectRatio(begin, end, validate, result)); - return result; - } - - // It's recommended to use the method above, only SVGViewSpec needs this parsing method - static SVGPreserveAspectRatio parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result); - - String valueAsString() const; - - private: - unsigned short m_align; - unsigned short m_meetOrSlice; +class AffineTransform; +class FloatRect; + +class SVGPreserveAspectRatio { +public: + enum SVGPreserveAspectRatioType { + SVG_PRESERVEASPECTRATIO_UNKNOWN = 0, + SVG_PRESERVEASPECTRATIO_NONE = 1, + SVG_PRESERVEASPECTRATIO_XMINYMIN = 2, + SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3, + SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4, + SVG_PRESERVEASPECTRATIO_XMINYMID = 5, + SVG_PRESERVEASPECTRATIO_XMIDYMID = 6, + SVG_PRESERVEASPECTRATIO_XMAXYMID = 7, + SVG_PRESERVEASPECTRATIO_XMINYMAX = 8, + SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9, + SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10 }; + enum SVGMeetOrSliceType { + SVG_MEETORSLICE_UNKNOWN = 0, + SVG_MEETORSLICE_MEET = 1, + SVG_MEETORSLICE_SLICE = 2 + }; + + SVGPreserveAspectRatio(); + + void setAlign(unsigned short align, ExceptionCode&); + unsigned short align() const { return m_align; } + + void setMeetOrSlice(unsigned short, ExceptionCode&); + unsigned short meetOrSlice() const { return m_meetOrSlice; } + + void transformRect(FloatRect& destRect, FloatRect& srcRect); + + AffineTransform getCTM(double logicX, double logicY, + double logicWidth, double logicHeight, + double physWidth, double physHeight) const; + + template<class Consumer> + static bool parsePreserveAspectRatio(Consumer* consumer, const String& value, bool validate = true) + { + bool result = false; + const UChar* begin = value.characters(); + const UChar* end = begin + value.length(); + consumer->setPreserveAspectRatioBaseValue(parsePreserveAspectRatio(begin, end, validate, result)); + return result; + } + + // It's recommended to use the method above, only SVGViewSpec needs this parsing method + static SVGPreserveAspectRatio parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result); + + String valueAsString() const; + +private: + SVGPreserveAspectRatioType m_align; + SVGMeetOrSliceType m_meetOrSlice; +}; + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGPreserveAspectRatio.idl b/WebCore/svg/SVGPreserveAspectRatio.idl index 7537e9b..80696e7 100644 --- a/WebCore/svg/SVGPreserveAspectRatio.idl +++ b/WebCore/svg/SVGPreserveAspectRatio.idl @@ -25,10 +25,10 @@ module svg { - interface [Conditional=SVG, PODType=SVGPreserveAspectRatio] SVGPreserveAspectRatio { + interface [Conditional=SVG] SVGPreserveAspectRatio { // Alignment Types - const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN = 0; - const unsigned short SVG_PRESERVEASPECTRATIO_NONE = 1; + const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN = 0; + const unsigned short SVG_PRESERVEASPECTRATIO_NONE = 1; const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMIN = 2; const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3; const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4; @@ -38,15 +38,17 @@ module svg { const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMAX = 8; const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9; const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10; + // Meet-or-slice Types - const unsigned short SVG_MEETORSLICE_UNKNOWN = 0; - const unsigned short SVG_MEETORSLICE_MEET = 1; - const unsigned short SVG_MEETORSLICE_SLICE = 2; + const unsigned short SVG_MEETORSLICE_UNKNOWN = 0; + const unsigned short SVG_MEETORSLICE_MEET = 1; + const unsigned short SVG_MEETORSLICE_SLICE = 2; + + attribute [StrictTypeChecking] unsigned short align + setter raises(DOMException); - attribute unsigned short align - /*setter raises(DOMException)*/; - attribute unsigned short meetOrSlice - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] unsigned short meetOrSlice + setter raises(DOMException); }; } diff --git a/WebCore/svg/SVGSVGElement.cpp b/WebCore/svg/SVGSVGElement.cpp index 2354b27..314f522 100644 --- a/WebCore/svg/SVGSVGElement.cpp +++ b/WebCore/svg/SVGSVGElement.cpp @@ -213,14 +213,14 @@ void SVGSVGElement::setCurrentScale(float scale) RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); } -FloatPoint SVGSVGElement::currentTranslate() const +void SVGSVGElement::setCurrentTranslate(const FloatPoint& translation) { - return m_translation; + m_translation = translation; + updateCurrentTranslate(); } -void SVGSVGElement::setCurrentTranslate(const FloatPoint &translation) +void SVGSVGElement::updateCurrentTranslate() { - m_translation = translation; if (RenderObject* object = renderer()) object->setNeedsLayout(true); diff --git a/WebCore/svg/SVGSVGElement.h b/WebCore/svg/SVGSVGElement.h index b2a5812..dca3ac2 100644 --- a/WebCore/svg/SVGSVGElement.h +++ b/WebCore/svg/SVGSVGElement.h @@ -78,9 +78,12 @@ namespace WebCore { float currentScale() const; void setCurrentScale(float scale); - FloatPoint currentTranslate() const; + FloatPoint& currentTranslate() { return m_translation; } void setCurrentTranslate(const FloatPoint&); - + + // Only used from the bindings. + void updateCurrentTranslate(); + SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); } void pauseAnimations(); @@ -147,7 +150,7 @@ namespace WebCore { // SVGFitToViewBox DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox) - DECLARE_ANIMATED_PROPERTY(SVGSVGElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) virtual void documentWillBecomeInactive(); virtual void documentDidBecomeActive(); diff --git a/WebCore/svg/SVGScriptElement.h b/WebCore/svg/SVGScriptElement.h index d4eb61d..e8695fb 100644 --- a/WebCore/svg/SVGScriptElement.h +++ b/WebCore/svg/SVGScriptElement.h @@ -76,7 +76,7 @@ namespace WebCore { virtual void dispatchErrorEvent(); // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGScriptElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGScriptElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGScriptElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGStopElement.h b/WebCore/svg/SVGStopElement.h index 232b97a..8da2655 100644 --- a/WebCore/svg/SVGStopElement.h +++ b/WebCore/svg/SVGStopElement.h @@ -22,7 +22,7 @@ #define SVGStopElement_h #if ENABLE(SVG) -#include "SVGNames.h" +#include "SVGAnimatedPropertyMacros.h" #include "SVGStyledElement.h" namespace WebCore { @@ -44,7 +44,7 @@ namespace WebCore { virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - DECLARE_ANIMATED_PROPERTY(SVGStopElement, SVGNames::offsetAttr, float, Offset, offset) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGStopElement, SVGNames::offsetAttr, float, Offset, offset) }; } // namespace WebCore diff --git a/WebCore/svg/SVGStringList.cpp b/WebCore/svg/SVGStringList.cpp index 9f4809f..3eb392a 100644 --- a/WebCore/svg/SVGStringList.cpp +++ b/WebCore/svg/SVGStringList.cpp @@ -23,29 +23,31 @@ #if ENABLE(SVG) #include "SVGStringList.h" +#include "SVGElement.h" #include "SVGParserUtilities.h" namespace WebCore { -SVGStringList::SVGStringList(const QualifiedName& attributeName) - : SVGList<String>(attributeName) +void SVGStringList::commitChange(SVGElement* contextElement) { + ASSERT(contextElement); + contextElement->invalidateSVGAttributes(); + contextElement->svgAttributeChanged(m_attributeName); } -void SVGStringList::reset(const String& str) +void SVGStringList::reset(const String& string) { - ExceptionCode ec = 0; + parse(string, ' '); - parse(str, ' '); - if (numberOfItems() == 0) - appendItem(String(""), ec); // Create empty string... + // Add empty string, if list is empty. + if (isEmpty()) + append(String("")); } void SVGStringList::parse(const String& data, UChar delimiter) { // TODO : more error checking/reporting - ExceptionCode ec = 0; - clear(ec); + clear(); const UChar* ptr = data.characters(); const UChar* end = ptr + data.length(); @@ -55,7 +57,7 @@ void SVGStringList::parse(const String& data, UChar delimiter) ptr++; if (ptr == start) break; - appendItem(String(start, ptr - start), ec); + append(String(start, ptr - start)); skipOptionalSpacesOrDelimiter(ptr, end, delimiter); } } diff --git a/WebCore/svg/SVGStringList.h b/WebCore/svg/SVGStringList.h index e8841ea..c741b9d 100644 --- a/WebCore/svg/SVGStringList.h +++ b/WebCore/svg/SVGStringList.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> * * This library is free software; you can redistribute it and/or @@ -22,23 +22,32 @@ #define SVGStringList_h #if ENABLE(SVG) -#include "PlatformString.h" -#include "SVGList.h" +#include "QualifiedName.h" +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> namespace WebCore { - class SVGStringList : public SVGList<String> { - public: - static PassRefPtr<SVGStringList> create(const QualifiedName& attributeName) { return adoptRef(new SVGStringList(attributeName)); } +class SVGElement; - void reset(const String& str); - void parse(const String& data, UChar delimiter = ','); - - private: - SVGStringList(const QualifiedName&); - }; +class SVGStringList : public Vector<String> { +public: + SVGStringList(const QualifiedName& attributeName) + : m_attributeName(attributeName) + { + } + + void reset(const String&); + void parse(const String&, UChar delimiter = ','); + + // Only used by SVGStringListPropertyTearOff. + void commitChange(SVGElement* contextElement); + +private: + const QualifiedName& m_attributeName; +}; } // namespace WebCore #endif // ENABLE(SVG) -#endif // SVGStringList_h +#endif diff --git a/WebCore/svg/SVGStyledElement.h b/WebCore/svg/SVGStyledElement.h index 5e996b3..4f796b8 100644 --- a/WebCore/svg/SVGStyledElement.h +++ b/WebCore/svg/SVGStyledElement.h @@ -22,8 +22,8 @@ #define SVGStyledElement_h #if ENABLE(SVG) +#include "SVGAnimatedPropertyMacros.h" #include "HTMLNames.h" -#include "SVGElement.h" #include "SVGLocatable.h" #include "SVGStylable.h" #include <wtf/HashSet.h> @@ -83,7 +83,7 @@ namespace WebCore { HashSet<SVGStyledElement*> m_elementsWithRelativeLengths; - DECLARE_ANIMATED_PROPERTY(SVGStyledElement, HTMLNames::classAttr, String, ClassName, className) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGStyledElement, HTMLNames::classAttr, String, ClassName, className) }; } // namespace WebCore diff --git a/WebCore/svg/SVGStyledTransformableElement.cpp b/WebCore/svg/SVGStyledTransformableElement.cpp index 9b34203..87d812c 100644 --- a/WebCore/svg/SVGStyledTransformableElement.cpp +++ b/WebCore/svg/SVGStyledTransformableElement.cpp @@ -54,7 +54,7 @@ AffineTransform SVGStyledTransformableElement::getScreenCTM(StyleUpdateStrategy AffineTransform SVGStyledTransformableElement::animatedLocalTransform() const { - return m_supplementalTransform ? transform()->concatenate().matrix() * *m_supplementalTransform : transform()->concatenate().matrix(); + return m_supplementalTransform ? *m_supplementalTransform * transform()->concatenate().matrix() : transform()->concatenate().matrix(); } AffineTransform* SVGStyledTransformableElement::supplementalTransform() diff --git a/WebCore/svg/SVGStyledTransformableElement.h b/WebCore/svg/SVGStyledTransformableElement.h index 5349cfa..f6309dd 100644 --- a/WebCore/svg/SVGStyledTransformableElement.h +++ b/WebCore/svg/SVGStyledTransformableElement.h @@ -23,6 +23,7 @@ #if ENABLE(SVG) #include "Path.h" +#include "SVGAnimatedPropertyMacros.h" #include "SVGStyledLocatableElement.h" #include "SVGTransformable.h" diff --git a/WebCore/svg/SVGSymbolElement.h b/WebCore/svg/SVGSymbolElement.h index 6c561f2..1aa7cbf 100644 --- a/WebCore/svg/SVGSymbolElement.h +++ b/WebCore/svg/SVGSymbolElement.h @@ -52,7 +52,7 @@ namespace WebCore { // SVGFitToViewBox DECLARE_ANIMATED_PROPERTY_NEW(SVGSymbolElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox) - DECLARE_ANIMATED_PROPERTY(SVGSymbolElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + DECLARE_ANIMATED_PROPERTY_NEW(SVGSymbolElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) }; } // namespace WebCore diff --git a/WebCore/svg/SVGTRefElement.h b/WebCore/svg/SVGTRefElement.h index 7a79ae5..ffbfa55 100644 --- a/WebCore/svg/SVGTRefElement.h +++ b/WebCore/svg/SVGTRefElement.h @@ -45,7 +45,7 @@ namespace WebCore { void updateReferencedText(); // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGTRefElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTRefElement, XLinkNames::hrefAttr, String, Href, href) }; } // namespace WebCore diff --git a/WebCore/svg/SVGTests.cpp b/WebCore/svg/SVGTests.cpp index e4813cd..3317964 100644 --- a/WebCore/svg/SVGTests.cpp +++ b/WebCore/svg/SVGTests.cpp @@ -26,63 +26,41 @@ #include "Attribute.h" #include "DOMImplementation.h" #include "Language.h" -#include "SVGElement.h" #include "SVGNames.h" #include "SVGStringList.h" namespace WebCore { SVGTests::SVGTests() + : m_features(SVGNames::requiredFeaturesAttr) + , m_extensions(SVGNames::requiredExtensionsAttr) + , m_systemLanguage(SVGNames::systemLanguageAttr) { } -SVGTests::~SVGTests() +bool SVGTests::hasExtension(const String&) const { -} - -SVGStringList* SVGTests::requiredFeatures() const -{ - if (!m_features) - m_features = SVGStringList::create(SVGNames::requiredFeaturesAttr); - - return m_features.get(); -} - -SVGStringList* SVGTests::requiredExtensions() const -{ - if (!m_extensions) - m_extensions = SVGStringList::create(SVGNames::requiredExtensionsAttr); - - return m_extensions.get(); -} - -SVGStringList* SVGTests::systemLanguage() const -{ - if (!m_systemLanguage) - m_systemLanguage = SVGStringList::create(SVGNames::systemLanguageAttr); - - return m_systemLanguage.get(); + // FIXME: Implement me! + return false; } bool SVGTests::isValid() const { - ExceptionCode ec = 0; - - if (m_features) { - for (unsigned long i = 0; i < m_features->numberOfItems(); i++) { - String value = m_features->getItem(i, ec); - if (value.isEmpty() || !DOMImplementation::hasFeature(value, String())) - return false; - } + unsigned featuresSize = m_features.size(); + for (unsigned i = 0; i < featuresSize; ++i) { + String value = m_features.at(i); + if (value.isEmpty() || !DOMImplementation::hasFeature(value, String())) + return false; } - if (m_systemLanguage) { - for (unsigned long i = 0; i < m_systemLanguage->numberOfItems(); i++) - if (m_systemLanguage->getItem(i, ec) != defaultLanguage().substring(0, 2)) - return false; + unsigned systemLanguageSize = m_systemLanguage.size(); + for (unsigned i = 0; i < systemLanguageSize; ++i) { + String value = m_systemLanguage.at(i); + if (value != defaultLanguage().substring(0, 2)) + return false; } - if (m_extensions && m_extensions->numberOfItems() > 0) + if (!m_extensions.isEmpty()) return false; return true; @@ -91,13 +69,13 @@ bool SVGTests::isValid() const bool SVGTests::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::requiredFeaturesAttr) { - requiredFeatures()->reset(attr->value()); + m_features.reset(attr->value()); return true; } else if (attr->name() == SVGNames::requiredExtensionsAttr) { - requiredExtensions()->reset(attr->value()); + m_extensions.reset(attr->value()); return true; } else if (attr->name() == SVGNames::systemLanguageAttr) { - systemLanguage()->reset(attr->value()); + m_systemLanguage.reset(attr->value()); return true; } @@ -106,9 +84,9 @@ bool SVGTests::parseMappedAttribute(Attribute* attr) bool SVGTests::isKnownAttribute(const QualifiedName& attrName) { - return (attrName == SVGNames::requiredFeaturesAttr || - attrName == SVGNames::requiredExtensionsAttr || - attrName == SVGNames::systemLanguageAttr); + return attrName == SVGNames::requiredFeaturesAttr + || attrName == SVGNames::requiredExtensionsAttr + || attrName == SVGNames::systemLanguageAttr; } } diff --git a/WebCore/svg/SVGTests.h b/WebCore/svg/SVGTests.h index c5bb70f..f662e9a 100644 --- a/WebCore/svg/SVGTests.h +++ b/WebCore/svg/SVGTests.h @@ -22,37 +22,33 @@ #define SVGTests_h #if ENABLE(SVG) -#include <wtf/Forward.h> -#include <wtf/RefPtr.h> +#include "SVGStringList.h" namespace WebCore { - class Attribute; - class QualifiedName; - class SVGStringList; +class Attribute; +class QualifiedName; - class SVGTests { - public: - SVGStringList* requiredFeatures() const; - SVGStringList* requiredExtensions() const; - SVGStringList* systemLanguage() const; +class SVGTests { +public: + SVGStringList& requiredFeatures() { return m_features; } + SVGStringList& requiredExtensions() { return m_extensions; } + SVGStringList& systemLanguage() { return m_systemLanguage; } - bool hasExtension(const String&) const { return false; } + bool hasExtension(const String&) const; + bool isValid() const; - bool isValid() const; - - bool parseMappedAttribute(Attribute*); - bool isKnownAttribute(const QualifiedName&); + bool parseMappedAttribute(Attribute*); + bool isKnownAttribute(const QualifiedName&); - protected: - SVGTests(); - ~SVGTests(); +protected: + SVGTests(); - private: - mutable RefPtr<SVGStringList> m_features; - mutable RefPtr<SVGStringList> m_extensions; - mutable RefPtr<SVGStringList> m_systemLanguage; - }; +private: + SVGStringList m_features; + SVGStringList m_extensions; + SVGStringList m_systemLanguage; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGTextPathElement.h b/WebCore/svg/SVGTextPathElement.h index b06c2bf..2375078 100644 --- a/WebCore/svg/SVGTextPathElement.h +++ b/WebCore/svg/SVGTextPathElement.h @@ -72,7 +72,7 @@ namespace WebCore { DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextPathElement, SVGNames::spacingAttr, int, Spacing, spacing) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGTextPathElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextPathElement, XLinkNames::hrefAttr, String, Href, href) }; } // namespace WebCore diff --git a/WebCore/svg/SVGTextPositioningElement.cpp b/WebCore/svg/SVGTextPositioningElement.cpp index d64dd1f..dc1f915 100644 --- a/WebCore/svg/SVGTextPositioningElement.cpp +++ b/WebCore/svg/SVGTextPositioningElement.cpp @@ -34,7 +34,6 @@ namespace WebCore { SVGTextPositioningElement::SVGTextPositioningElement(const QualifiedName& tagName, Document* document) : SVGTextContentElement(tagName, document) - , m_rotate(SVGNumberList::create(SVGNames::rotateAttr)) { } @@ -60,9 +59,12 @@ void SVGTextPositioningElement::parseMappedAttribute(Attribute* attr) newList.parse(attr->value(), LengthModeHeight); detachAnimatedDyListWrappers(newList.size()); dyBaseValue() = newList; - } else if (attr->name() == SVGNames::rotateAttr) - rotateBaseValue()->parse(attr->value()); - else + } else if (attr->name() == SVGNames::rotateAttr) { + SVGNumberList newList; + newList.parse(attr->value()); + detachAnimatedRotateListWrappers(newList.size()); + rotateBaseValue() = newList; + } else SVGTextContentElement::parseMappedAttribute(attr); } diff --git a/WebCore/svg/SVGTextPositioningElement.h b/WebCore/svg/SVGTextPositioningElement.h index 1fb1c3c..e1798de 100644 --- a/WebCore/svg/SVGTextPositioningElement.h +++ b/WebCore/svg/SVGTextPositioningElement.h @@ -46,7 +46,7 @@ namespace WebCore { DECLARE_ANIMATED_LIST_PROPERTY_NEW(SVGTextPositioningElement, SVGNames::yAttr, SVGLengthList, Y, y) DECLARE_ANIMATED_LIST_PROPERTY_NEW(SVGTextPositioningElement, SVGNames::dxAttr, SVGLengthList, Dx, dx) DECLARE_ANIMATED_LIST_PROPERTY_NEW(SVGTextPositioningElement, SVGNames::dyAttr, SVGLengthList, Dy, dy) - DECLARE_ANIMATED_PROPERTY(SVGTextPositioningElement, SVGNames::rotateAttr, SVGNumberList*, Rotate, rotate) + DECLARE_ANIMATED_LIST_PROPERTY_NEW(SVGTextPositioningElement, SVGNames::rotateAttr, SVGNumberList, Rotate, rotate) }; } // namespace WebCore diff --git a/WebCore/svg/SVGURIReference.h b/WebCore/svg/SVGURIReference.h index 096f5a5..3804791 100644 --- a/WebCore/svg/SVGURIReference.h +++ b/WebCore/svg/SVGURIReference.h @@ -27,20 +27,20 @@ namespace WebCore { - class Attribute; +class Attribute; - class SVGURIReference { - public: - virtual ~SVGURIReference() { } +class SVGURIReference { +public: + virtual ~SVGURIReference() { } - bool parseMappedAttribute(Attribute*); - bool isKnownAttribute(const QualifiedName&); + bool parseMappedAttribute(Attribute*); + bool isKnownAttribute(const QualifiedName&); - static String getTarget(const String& url); + static String getTarget(const String& url); - protected: - virtual void setHrefBaseValue(DeprecatedSVGAnimatedPropertyTraits<String>::PassType) = 0; - }; +protected: + virtual void setHrefBaseValue(const String&) = 0; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGUseElement.cpp b/WebCore/svg/SVGUseElement.cpp index 474b0a4..75ed4c5 100644 --- a/WebCore/svg/SVGUseElement.cpp +++ b/WebCore/svg/SVGUseElement.cpp @@ -948,6 +948,9 @@ void SVGUseElement::associateInstancesWithShadowTreeElements(Node* target, SVGEl while (node && !node->isSVGElement()) node = node->nextSibling(); + if (!node) + break; + associateInstancesWithShadowTreeElements(node, instance); node = node->nextSibling(); } diff --git a/WebCore/svg/SVGUseElement.h b/WebCore/svg/SVGUseElement.h index bb7e6d0..b127450 100644 --- a/WebCore/svg/SVGUseElement.h +++ b/WebCore/svg/SVGUseElement.h @@ -87,7 +87,7 @@ namespace WebCore { DECLARE_ANIMATED_PROPERTY_NEW(SVGUseElement, SVGNames::heightAttr, SVGLength, Height, height) // SVGURIReference - DECLARE_ANIMATED_PROPERTY(SVGUseElement, XLinkNames::hrefAttr, String, Href, href) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGUseElement, XLinkNames::hrefAttr, String, Href, href) // SVGExternalResourcesRequired DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGUseElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) diff --git a/WebCore/svg/SVGViewElement.cpp b/WebCore/svg/SVGViewElement.cpp index 6a83066..c59a080 100644 --- a/WebCore/svg/SVGViewElement.cpp +++ b/WebCore/svg/SVGViewElement.cpp @@ -34,6 +34,7 @@ namespace WebCore { inline SVGViewElement::SVGViewElement(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) + , m_viewTarget(SVGNames::viewTargetAttr) { } @@ -42,18 +43,10 @@ PassRefPtr<SVGViewElement> SVGViewElement::create(const QualifiedName& tagName, return adoptRef(new SVGViewElement(tagName, document)); } -SVGStringList* SVGViewElement::viewTarget() const -{ - if (!m_viewTarget) - m_viewTarget = SVGStringList::create(SVGNames::viewTargetAttr); - - return m_viewTarget.get(); -} - void SVGViewElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::viewTargetAttr) - viewTarget()->reset(attr->value()); + viewTarget().reset(attr->value()); else { if (SVGExternalResourcesRequired::parseMappedAttribute(attr) || SVGFitToViewBox::parseMappedAttribute(document(), attr) diff --git a/WebCore/svg/SVGViewElement.h b/WebCore/svg/SVGViewElement.h index f0e756f..7e239e3 100644 --- a/WebCore/svg/SVGViewElement.h +++ b/WebCore/svg/SVGViewElement.h @@ -23,6 +23,7 @@ #if ENABLE(SVG) #include "SVGAnimatedPropertyMacros.h" +#include "SVGStringList.h" #include "SVGStyledElement.h" #include "SVGExternalResourcesRequired.h" #include "SVGFitToViewBox.h" @@ -30,7 +31,6 @@ namespace WebCore { - class SVGStringList; class SVGViewElement : public SVGStyledElement, public SVGExternalResourcesRequired, public SVGFitToViewBox, @@ -38,7 +38,7 @@ namespace WebCore { public: static PassRefPtr<SVGViewElement> create(const QualifiedName&, Document*); - SVGStringList* viewTarget() const; + SVGStringList& viewTarget() { return m_viewTarget; } private: SVGViewElement(const QualifiedName&, Document*); @@ -53,9 +53,9 @@ namespace WebCore { // SVGFitToViewBox DECLARE_ANIMATED_PROPERTY_NEW(SVGViewElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox) - DECLARE_ANIMATED_PROPERTY(SVGViewElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) - - mutable RefPtr<SVGStringList> m_viewTarget; + DECLARE_ANIMATED_PROPERTY_NEW(SVGViewElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + + SVGStringList m_viewTarget; }; } // namespace WebCore diff --git a/WebCore/svg/SVGViewSpec.h b/WebCore/svg/SVGViewSpec.h index 6fcc94e..f557d23 100644 --- a/WebCore/svg/SVGViewSpec.h +++ b/WebCore/svg/SVGViewSpec.h @@ -59,7 +59,7 @@ namespace WebCore { // SVGFitToViewBox DECLARE_ANIMATED_PROPERTY_NEW(SVGViewSpec, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox) - DECLARE_ANIMATED_PROPERTY(SVGViewSpec, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + DECLARE_ANIMATED_PROPERTY_NEW(SVGViewSpec, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) mutable RefPtr<SVGTransformList> m_transform; String m_viewTargetString; diff --git a/WebCore/svg/animation/SVGSMILElement.cpp b/WebCore/svg/animation/SVGSMILElement.cpp index a90b444..6757fee 100644 --- a/WebCore/svg/animation/SVGSMILElement.cpp +++ b/WebCore/svg/animation/SVGSMILElement.cpp @@ -528,7 +528,8 @@ SMILTime SVGSMILElement::repeatDur() const return m_cachedRepeatDur; const AtomicString& value = getAttribute(SVGNames::repeatDurAttr); SMILTime clockValue = parseClockValue(value); - return m_cachedRepeatDur = clockValue < 0 ? SMILTime::unresolved() : clockValue; + m_cachedRepeatDur = clockValue <= 0 ? SMILTime::unresolved() : clockValue; + return m_cachedRepeatDur; } // So a count is not really a time but let just all pretend we did not notice. diff --git a/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h b/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h index c002d09..0777b6a 100644 --- a/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h +++ b/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h @@ -23,6 +23,7 @@ #if ENABLE(SVG) #include "SVGAnimatedProperty.h" #include "SVGListPropertyTearOff.h" +#include "SVGStaticListPropertyTearOff.h" namespace WebCore { @@ -32,17 +33,21 @@ class SVGPropertyTearOff; template<typename PropertyType> class SVGAnimatedListPropertyTearOff : public SVGAnimatedProperty { public: + typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType; + typedef SVGPropertyTearOff<ListItemType> ListItemTearOff; + typedef Vector<RefPtr<ListItemTearOff> > ListWrapperCache; + SVGProperty* baseVal() { if (!m_baseVal) - m_baseVal = SVGListPropertyTearOff<PropertyType>::create(this, BaseValRole, m_property); + m_baseVal = SVGListPropertyTearOff<PropertyType>::create(this, BaseValRole); return m_baseVal.get(); } SVGProperty* animVal() { if (!m_animVal) - m_animVal = SVGListPropertyTearOff<PropertyType>::create(this, AnimValRole, m_property); + m_animVal = SVGListPropertyTearOff<PropertyType>::create(this, AnimValRole); return m_animVal.get(); } @@ -50,39 +55,56 @@ public: int removeItemFromList(SVGProperty* property, bool shouldSynchronizeWrappers) { - // FIXME: No animVal support. - if (!m_baseVal) - return -1; - + // This should ever be called for our baseVal, as animVal can't modify the list. typedef SVGPropertyTearOff<typename SVGPropertyTraits<PropertyType>::ListItemType> ListItemTearOff; return static_pointer_cast<SVGListPropertyTearOff<PropertyType> >(m_baseVal)->removeItemFromList(static_cast<ListItemTearOff*>(property), shouldSynchronizeWrappers); } void detachListWrappers(unsigned newListSize) { - if (m_baseVal) - static_pointer_cast<SVGListPropertyTearOff<PropertyType> >(m_baseVal)->detachListWrappers(newListSize); - if (m_animVal) - static_pointer_cast<SVGListPropertyTearOff<PropertyType> >(m_animVal)->detachListWrappers(newListSize); + // See SVGPropertyTearOff::detachWrapper() for an explaination what's happening here. + unsigned size = m_wrappers.size(); + ASSERT(size == m_values.size()); + for (unsigned i = 0; i < size; ++i) { + RefPtr<ListItemTearOff>& item = m_wrappers.at(i); + if (!item) + continue; + item->detachWrapper(); + } + + // Reinitialize the wrapper cache to be equal to the new values size, after the XML DOM changed the list. + if (newListSize) + m_wrappers.fill(0, newListSize); + else + m_wrappers.clear(); } + PropertyType& values() { return m_values; } + ListWrapperCache& wrappers() { return m_wrappers; } + private: friend class SVGAnimatedProperty; - static PassRefPtr<SVGAnimatedListPropertyTearOff<PropertyType> > create(SVGElement* contextElement, const QualifiedName& attributeName, PropertyType& property) + static PassRefPtr<SVGAnimatedListPropertyTearOff<PropertyType> > create(SVGElement* contextElement, const QualifiedName& attributeName, PropertyType& values) { ASSERT(contextElement); - return adoptRef(new SVGAnimatedListPropertyTearOff<PropertyType>(contextElement, attributeName, property)); + return adoptRef(new SVGAnimatedListPropertyTearOff<PropertyType>(contextElement, attributeName, values)); } - SVGAnimatedListPropertyTearOff(SVGElement* contextElement, const QualifiedName& attributeName, PropertyType& property) + SVGAnimatedListPropertyTearOff(SVGElement* contextElement, const QualifiedName& attributeName, PropertyType& values) : SVGAnimatedProperty(contextElement, attributeName) - , m_property(property) + , m_values(values) { + if (!values.isEmpty()) + m_wrappers.fill(0, values.size()); } private: - PropertyType& m_property; + PropertyType& m_values; + + // FIXME: The list wrapper cache is shared between baseVal/animVal. If we implement animVal, + // we need two seperated wrapper caches if the attribute gets animated. + ListWrapperCache m_wrappers; RefPtr<SVGProperty> m_baseVal; RefPtr<SVGProperty> m_animVal; diff --git a/WebCore/svg/properties/SVGAnimatedPropertyMacros.h b/WebCore/svg/properties/SVGAnimatedPropertyMacros.h index 12d0565..e1c75b9 100644 --- a/WebCore/svg/properties/SVGAnimatedPropertyMacros.h +++ b/WebCore/svg/properties/SVGAnimatedPropertyMacros.h @@ -32,6 +32,42 @@ namespace WebCore { +class SVGElement; + +// GetOwnerElementForType implementation +template<typename OwnerType, bool isDerivedFromSVGElement> +struct GetOwnerElementForType; + +template<typename OwnerType> +struct GetOwnerElementForType<OwnerType, true> { + static SVGElement* ownerElement(OwnerType* type) + { + return type; + } +}; + +template<typename OwnerType> +struct GetOwnerElementForType<OwnerType, false> { + static SVGElement* ownerElement(OwnerType* type) + { + SVGElement* context = type->contextElement(); + ASSERT(context); + return context; + } +}; + +// IsDerivedFromSVGElement implementation +template<typename OwnerType> +struct IsDerivedFromSVGElement { + static const bool value = true; +}; + +class SVGViewSpec; +template<> +struct IsDerivedFromSVGElement<SVGViewSpec> { + static const bool value = false; +}; + template<typename PropertyType> struct SVGSynchronizableAnimatedProperty { SVGSynchronizableAnimatedProperty() diff --git a/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h b/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h index 2b816ab..b97073d 100644 --- a/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h +++ b/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h @@ -23,42 +23,6 @@ #if ENABLE(SVG) namespace WebCore { -class SVGElement; - -// GetOwnerElementForType implementation -template<typename OwnerType, bool isDerivedFromSVGElement> -struct GetOwnerElementForType; - -template<typename OwnerType> -struct GetOwnerElementForType<OwnerType, true> : public Noncopyable { - static SVGElement* ownerElement(OwnerType* type) - { - return type; - } -}; - -template<typename OwnerType> -struct GetOwnerElementForType<OwnerType, false> : public Noncopyable { - static SVGElement* ownerElement(OwnerType* type) - { - SVGElement* context = type->contextElement(); - ASSERT(context); - return context; - } -}; - -// IsDerivedFromSVGElement implementation -template<typename OwnerType> -struct IsDerivedFromSVGElement : public Noncopyable { - static const bool value = true; -}; - -class SVGViewSpec; -template<> -struct IsDerivedFromSVGElement<SVGViewSpec> : public Noncopyable { - static const bool value = false; -}; - // Helper template used for synchronizing SVG <-> XML properties template<bool isDerivedFromSVGElement> struct SVGAnimatedPropertySynchronizer { diff --git a/WebCore/svg/properties/SVGListProperty.h b/WebCore/svg/properties/SVGListProperty.h new file mode 100644 index 0000000..7edc0f1 --- /dev/null +++ b/WebCore/svg/properties/SVGListProperty.h @@ -0,0 +1,412 @@ +/* + * Copyright (C) Research In Motion Limited 2010. 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. + * + * 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. + * + * 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. + */ + +#ifndef SVGListProperty_h +#define SVGListProperty_h + +#if ENABLE(SVG) +#include "ExceptionCode.h" +#include "SVGAnimatedProperty.h" +#include "SVGPropertyTearOff.h" +#include "SVGPropertyTraits.h" + +namespace WebCore { + +template<typename PropertyType> +class SVGAnimatedListPropertyTearOff; + +template<typename PropertyType> +class SVGListProperty : public SVGProperty { +public: + typedef SVGListProperty<PropertyType> Self; + + typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType; + typedef SVGPropertyTearOff<ListItemType> ListItemTearOff; + typedef PassRefPtr<ListItemTearOff> PassListItemTearOff; + typedef SVGAnimatedListPropertyTearOff<PropertyType> AnimatedListPropertyTearOff; + typedef typename SVGAnimatedListPropertyTearOff<PropertyType>::ListWrapperCache ListWrapperCache; + + bool canAlterList(ExceptionCode& ec) const + { + if (m_role == AnimValRole) { + ec = NO_MODIFICATION_ALLOWED_ERR; + return false; + } + + return true; + } + + // SVGList::clear() + void clearValues(PropertyType& values, ExceptionCode& ec) + { + if (!canAlterList(ec)) + return; + + values.clear(); + commitChange(); + } + + void clearValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, ExceptionCode& ec) + { + ASSERT(animatedList); + if (!canAlterList(ec)) + return; + + animatedList->detachListWrappers(0); + animatedList->values().clear(); + commitChange(); + } + + // SVGList::numberOfItems() + unsigned numberOfItemsValues(PropertyType& values) const + { + return values.size(); + } + + unsigned numberOfItemsValuesAndWrappers(AnimatedListPropertyTearOff* animatedList) const + { + ASSERT(animatedList); + return animatedList->values().size(); + } + + // SVGList::initialize() + ListItemType initializeValues(PropertyType& values, const ListItemType& newItem, ExceptionCode& ec) + { + if (!canAlterList(ec)) + return ListItemType(); + + // Spec: If the inserted item is already in a list, it is removed from its previous list before it is inserted into this list. + processIncomingListItemValue(newItem, 0); + + // Spec: Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter. + values.clear(); + values.append(newItem); + + commitChange(); + return newItem; + } + + PassListItemTearOff initializeValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, PassListItemTearOff passNewItem, ExceptionCode& ec) + { + ASSERT(animatedList); + if (!canAlterList(ec)) + return 0; + + // Not specified, but FF/Opera do it this way, and it's just sane. + if (!passNewItem) { + ec = TYPE_MISMATCH_ERR; + return 0; + } + + PropertyType& values = animatedList->values(); + ListWrapperCache& wrappers = animatedList->wrappers(); + + RefPtr<ListItemTearOff> newItem = passNewItem; + ASSERT(values.size() == wrappers.size()); + + // Spec: If the inserted item is already in a list, it is removed from its previous list before it is inserted into this list. + processIncomingListItemWrapper(newItem, 0); + + // Spec: Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter. + animatedList->detachListWrappers(0); + values.clear(); + + values.append(newItem->propertyReference()); + wrappers.append(newItem); + + commitChange(); + return newItem.release(); + } + + // SVGList::getItem() + bool canGetItem(PropertyType& values, unsigned index, ExceptionCode& ec) + { + if (index >= values.size()) { + ec = INDEX_SIZE_ERR; + return false; + } + + return true; + } + + ListItemType getItemValues(PropertyType& values, unsigned index, ExceptionCode& ec) + { + if (!canGetItem(values, index, ec)) + return ListItemType(); + + // Spec: Returns the specified item from the list. The returned item is the item itself and not a copy. + return values.at(index); + } + + PassListItemTearOff getItemValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, unsigned index, ExceptionCode& ec) + { + ASSERT(animatedList); + PropertyType& values = animatedList->values(); + if (!canGetItem(values, index, ec)) + return 0; + + ListWrapperCache& wrappers = animatedList->wrappers(); + + // Spec: Returns the specified item from the list. The returned item is the item itself and not a copy. + // Any changes made to the item are immediately reflected in the list. + ASSERT(values.size() == wrappers.size()); + RefPtr<ListItemTearOff> wrapper = wrappers.at(index); + if (!wrapper) { + // Create new wrapper, which is allowed to directly modify the item in the list, w/o copying and cache the wrapper in our map. + // It is also associated with our animated property, so it can notify the SVG Element which holds the SVGAnimated*List + // that it has been modified (and thus can call svgAttributeChanged(associatedAttributeName)). + wrapper = ListItemTearOff::create(animatedList, UndefinedRole, values.at(index)); + wrappers.at(index) = wrapper; + } + + return wrapper.release(); + } + + // SVGList::insertItemBefore() + ListItemType insertItemBeforeValues(PropertyType& values, const ListItemType& newItem, unsigned index, ExceptionCode& ec) + { + if (!canAlterList(ec)) + return ListItemType(); + + // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + if (index > values.size()) + index = values.size(); + + // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. + processIncomingListItemValue(newItem, &index); + + // Spec: Inserts a new item into the list at the specified position. The index of the item before which the new item is to be + // inserted. The first item is number 0. If the index is equal to 0, then the new item is inserted at the front of the list. + values.insert(index, newItem); + + commitChange(); + return newItem; + } + + PassListItemTearOff insertItemBeforeValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, PassListItemTearOff passNewItem, unsigned index, ExceptionCode& ec) + { + ASSERT(animatedList); + if (!canAlterList(ec)) + return 0; + + // Not specified, but FF/Opera do it this way, and it's just sane. + if (!passNewItem) { + ec = TYPE_MISMATCH_ERR; + return 0; + } + + PropertyType& values = animatedList->values(); + ListWrapperCache& wrappers = animatedList->wrappers(); + + // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + if (index > values.size()) + index = values.size(); + + RefPtr<ListItemTearOff> newItem = passNewItem; + ASSERT(values.size() == wrappers.size()); + + // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. + processIncomingListItemWrapper(newItem, &index); + + // Spec: Inserts a new item into the list at the specified position. The index of the item before which the new item is to be + // inserted. The first item is number 0. If the index is equal to 0, then the new item is inserted at the front of the list. + values.insert(index, newItem->propertyReference()); + + // Store new wrapper at position 'index', change its underlying value, so mutations of newItem, directly affect the item in the list. + wrappers.insert(index, newItem); + + commitChange(); + return newItem.release(); + } + + // SVGList::replaceItem() + bool canReplaceItem(PropertyType& values, unsigned index, ExceptionCode& ec) + { + if (!canAlterList(ec)) + return false; + + if (index >= values.size()) { + ec = INDEX_SIZE_ERR; + return false; + } + + return true; + } + + ListItemType replaceItemValues(PropertyType& values, const ListItemType& newItem, unsigned index, ExceptionCode& ec) + { + if (!canReplaceItem(values, index, ec)) + return ListItemType(); + + // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. + // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item. + processIncomingListItemValue(newItem, &index); + + // Update the value at the desired position 'index'. + values.at(index) = newItem; + + commitChange(); + return newItem; + } + + PassListItemTearOff replaceItemValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, PassListItemTearOff passNewItem, unsigned index, ExceptionCode& ec) + { + ASSERT(animatedList); + PropertyType& values = animatedList->values(); + if (!canReplaceItem(values, index, ec)) + return 0; + + // Not specified, but FF/Opera do it this way, and it's just sane. + if (!passNewItem) { + ec = TYPE_MISMATCH_ERR; + return 0; + } + + ListWrapperCache& wrappers = animatedList->wrappers(); + ASSERT(values.size() == wrappers.size()); + RefPtr<ListItemTearOff> newItem = passNewItem; + + // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. + // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item. + processIncomingListItemWrapper(newItem, &index); + + // Detach the existing wrapper. + RefPtr<ListItemTearOff>& oldItem = wrappers.at(index); + if (oldItem) + oldItem->detachWrapper(); + + // Update the value and the wrapper at the desired position 'index'. + values.at(index) = newItem->propertyReference(); + wrappers.at(index) = newItem; + + commitChange(); + return newItem.release(); + } + + // SVGList::removeItem() + bool canRemoveItem(PropertyType& values, unsigned index, ExceptionCode& ec) + { + if (!canAlterList(ec)) + return false; + + if (index >= values.size()) { + ec = INDEX_SIZE_ERR; + return false; + } + + return true; + } + + ListItemType removeItemValues(PropertyType& values, unsigned index, ExceptionCode& ec) + { + if (!canRemoveItem(values, index, ec)) + return ListItemType(); + + ListItemType oldItem = values.at(index); + values.remove(index); + + commitChange(); + return oldItem; + } + + PassListItemTearOff removeItemValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, unsigned index, ExceptionCode& ec) + { + ASSERT(animatedList); + PropertyType& values = animatedList->values(); + if (!canRemoveItem(values, index, ec)) + return 0; + + ListWrapperCache& wrappers = animatedList->wrappers(); + ASSERT(values.size() == wrappers.size()); + + // Detach the existing wrapper. + RefPtr<ListItemTearOff>& oldItem = wrappers.at(index); + if (oldItem) + oldItem->detachWrapper(); + + wrappers.remove(index); + values.remove(index); + + commitChange(); + return oldItem.release(); + } + + // SVGList::appendItem() + ListItemType appendItemValues(PropertyType& values, const ListItemType& newItem, ExceptionCode& ec) + { + if (!canAlterList(ec)) + return ListItemType(); + + // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. + processIncomingListItemValue(newItem, 0); + + // Append the value at the end of the list. + values.append(newItem); + + commitChange(); + return newItem; + } + + PassListItemTearOff appendItemValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, PassListItemTearOff passNewItem, ExceptionCode& ec) + { + ASSERT(animatedList); + if (!canAlterList(ec)) + return 0; + + // Not specified, but FF/Opera do it this way, and it's just sane. + if (!passNewItem) { + ec = TYPE_MISMATCH_ERR; + return 0; + } + + PropertyType& values = animatedList->values(); + ListWrapperCache& wrappers = animatedList->wrappers(); + + RefPtr<ListItemTearOff> newItem = passNewItem; + ASSERT(values.size() == wrappers.size()); + + // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. + processIncomingListItemWrapper(newItem, 0); + + // Append the value and wrapper at the end of the list. + values.append(newItem->propertyReference()); + wrappers.append(newItem); + + commitChange(); + return newItem.release(); + } + +protected: + SVGListProperty(SVGPropertyRole role) + : m_role(role) + { + } + + virtual void commitChange() = 0; + virtual void processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify) = 0; + virtual void processIncomingListItemWrapper(RefPtr<ListItemTearOff>& newItem, unsigned* indexToModify) = 0; + +private: + SVGPropertyRole m_role; +}; + +} + +#endif // ENABLE(SVG) +#endif // SVGListProperty_h diff --git a/WebCore/svg/properties/SVGListPropertyTearOff.h b/WebCore/svg/properties/SVGListPropertyTearOff.h index 2801168..56d626f 100644 --- a/WebCore/svg/properties/SVGListPropertyTearOff.h +++ b/WebCore/svg/properties/SVGListPropertyTearOff.h @@ -21,52 +21,43 @@ #define SVGListPropertyTearOff_h #if ENABLE(SVG) -#include "ExceptionCode.h" -#include "SVGAnimatedProperty.h" -#include "SVGPropertyTearOff.h" -#include "SVGPropertyTraits.h" +#include "SVGListProperty.h" namespace WebCore { template<typename PropertyType> -class SVGAnimatedListPropertyTearOff; - -template<typename PropertyType> -class SVGListPropertyTearOff : public SVGProperty { +class SVGListPropertyTearOff : public SVGListProperty<PropertyType> { public: - typedef SVGListPropertyTearOff<PropertyType> Self; + typedef SVGListProperty<PropertyType> Base; typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType; typedef SVGPropertyTearOff<ListItemType> ListItemTearOff; typedef PassRefPtr<ListItemTearOff> PassListItemTearOff; - typedef Vector<RefPtr<ListItemTearOff> > ListWrapperCache; + typedef SVGAnimatedListPropertyTearOff<PropertyType> AnimatedListPropertyTearOff; + typedef typename SVGAnimatedListPropertyTearOff<PropertyType>::ListWrapperCache ListWrapperCache; - // Used for [SVGAnimatedProperty] types (for example: SVGAnimatedLengthList::baseVal()) - static PassRefPtr<Self> create(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType& values) + static PassRefPtr<SVGListPropertyTearOff<PropertyType> > create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role) { ASSERT(animatedProperty); - return adoptRef(new Self(animatedProperty, role, values)); - } - - // Used for non-animated POD types (for example: SVGStringList). - static PassRefPtr<Self> create(const PropertyType& initialValue) - { - return adoptRef(new Self(initialValue)); + return adoptRef(new SVGListPropertyTearOff<PropertyType>(animatedProperty, role)); } int removeItemFromList(ListItemTearOff* removeItem, bool shouldSynchronizeWrappers) { + PropertyType& values = m_animatedProperty->values(); + ListWrapperCache& wrappers = m_animatedProperty->wrappers(); + // Lookup item in cache and remove its corresponding wrapper. - unsigned size = m_wrappers.size(); - ASSERT(size == m_values->size()); + unsigned size = wrappers.size(); + ASSERT(size == values.size()); for (unsigned i = 0; i < size; ++i) { - RefPtr<ListItemTearOff>& item = m_wrappers.at(i); + RefPtr<ListItemTearOff>& item = wrappers.at(i); if (item != removeItem) continue; item->detachWrapper(); - m_wrappers.remove(i); - m_values->remove(i); + wrappers.remove(i); + values.remove(i); if (shouldSynchronizeWrappers) commitChange(); @@ -77,275 +68,103 @@ public: return -1; } - void detachListWrappers(unsigned newListSize) - { - // See SVGPropertyTearOff::detachWrapper() for an explaination what's happening here. - unsigned size = m_wrappers.size(); - ASSERT(size == m_values->size()); - for (unsigned i = 0; i < size; ++i) { - RefPtr<ListItemTearOff>& item = m_wrappers.at(i); - if (!item) - continue; - item->detachWrapper(); - } - - // Reinitialize the wrapper cache to be equal to the new values size, after the XML DOM changed the list. - if (newListSize) - m_wrappers.fill(0, newListSize); - else - m_wrappers.clear(); - } - // SVGList API void clear(ExceptionCode& ec) { - if (m_role == AnimValRole) { - ec = NO_MODIFICATION_ALLOWED_ERR; - return; - } - - detachListWrappers(0); - m_values->clear(); + Base::clearValuesAndWrappers(m_animatedProperty.get(), ec); } unsigned numberOfItems() const { - return m_values->size(); + return Base::numberOfItemsValuesAndWrappers(m_animatedProperty.get()); } PassListItemTearOff initialize(PassListItemTearOff passNewItem, ExceptionCode& ec) { - if (m_role == AnimValRole) { - ec = NO_MODIFICATION_ALLOWED_ERR; - return 0; - } - - // Not specified, but FF/Opera do it this way, and it's just sane. - if (!passNewItem) { - ec = TYPE_MISMATCH_ERR; - return 0; - } - - RefPtr<ListItemTearOff> newItem = passNewItem; - ASSERT(m_values->size() == m_wrappers.size()); - - // Spec: If the inserted item is already in a list, it is removed from its previous list before it is inserted into this list. - removeItemFromListIfNeeded(newItem.get(), 0); - - // Spec: Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter. - detachListWrappers(0); - m_values->clear(); - - m_values->append(newItem->propertyReference()); - m_wrappers.append(newItem); - - commitChange(); - return newItem.release(); + return Base::initializeValuesAndWrappers(m_animatedProperty.get(), passNewItem, ec); } PassListItemTearOff getItem(unsigned index, ExceptionCode& ec) { - if (index >= m_values->size()) { - ec = INDEX_SIZE_ERR; - return 0; - } - - // Spec: Returns the specified item from the list. The returned item is the item itself and not a copy. - // Any changes made to the item are immediately reflected in the list. - ASSERT(m_values->size() == m_wrappers.size()); - RefPtr<ListItemTearOff> wrapper = m_wrappers.at(index); - if (!wrapper) { - // Create new wrapper, which is allowed to directly modify the item in the list, w/o copying and cache the wrapper in our map. - // It is also associated with our animated property, so it can notify the SVG Element which holds the SVGAnimated*List - // that it has been modified (and thus can call svgAttributeChanged(associatedAttributeName)). - wrapper = ListItemTearOff::create(m_animatedProperty.get(), UndefinedRole, m_values->at(index)); - m_wrappers.at(index) = wrapper; - } - - return wrapper.release(); + return Base::getItemValuesAndWrappers(m_animatedProperty.get(), index, ec); } PassListItemTearOff insertItemBefore(PassListItemTearOff passNewItem, unsigned index, ExceptionCode& ec) { - if (m_role == AnimValRole) { - ec = NO_MODIFICATION_ALLOWED_ERR; - return 0; - } - - // Not specified, but FF/Opera do it this way, and it's just sane. - if (!passNewItem) { - ec = TYPE_MISMATCH_ERR; - return 0; - } - - // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. - if (index > m_values->size()) - index = m_values->size(); - - RefPtr<ListItemTearOff> newItem = passNewItem; - ASSERT(m_values->size() == m_wrappers.size()); - - // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. - removeItemFromListIfNeeded(newItem.get(), &index); - - // Spec: Inserts a new item into the list at the specified position. The index of the item before which the new item is to be - // inserted. The first item is number 0. If the index is equal to 0, then the new item is inserted at the front of the list. - m_values->insert(index, newItem->propertyReference()); - - // Store new wrapper at position 'index', change its underlying value, so mutations of newItem, directly affect the item in the list. - m_wrappers.insert(index, newItem); - - commitChange(); - return newItem.release(); + return Base::insertItemBeforeValuesAndWrappers(m_animatedProperty.get(), passNewItem, index, ec); } PassListItemTearOff replaceItem(PassListItemTearOff passNewItem, unsigned index, ExceptionCode& ec) { - if (m_role == AnimValRole) { - ec = NO_MODIFICATION_ALLOWED_ERR; - return 0; - } - - if (index >= m_values->size()) { - ec = INDEX_SIZE_ERR; - return 0; - } - - // Not specified, but FF/Opera do it this way, and it's just sane. - if (!passNewItem) { - ec = TYPE_MISMATCH_ERR; - return 0; - } - - RefPtr<ListItemTearOff> newItem = passNewItem; - ASSERT(m_values->size() == m_wrappers.size()); - - // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. - // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item. - removeItemFromListIfNeeded(newItem.get(), &index); - - // Detach the existing wrapper. - RefPtr<ListItemTearOff>& oldItem = m_wrappers.at(index); - if (oldItem) - oldItem->detachWrapper(); - - // Update the value and the wrapper at the desired position 'index'. - m_values->at(index) = newItem->propertyReference(); - m_wrappers.at(index) = newItem; - - commitChange(); - return newItem.release(); + return Base::replaceItemValuesAndWrappers(m_animatedProperty.get(), passNewItem, index, ec); } PassListItemTearOff removeItem(unsigned index, ExceptionCode& ec) { - if (m_role == AnimValRole) { - ec = NO_MODIFICATION_ALLOWED_ERR; - return 0; - } - - if (index >= m_values->size()) { - ec = INDEX_SIZE_ERR; - return 0; - } - - ASSERT(m_values->size() == m_wrappers.size()); - - // Detach the existing wrapper. - RefPtr<ListItemTearOff>& oldItem = m_wrappers.at(index); - if (oldItem) { - oldItem->detachWrapper(); - m_wrappers.remove(index); - } - - m_values->remove(index); - - commitChange(); - return oldItem.release(); + return Base::removeItemValuesAndWrappers(m_animatedProperty.get(), index, ec); } PassListItemTearOff appendItem(PassListItemTearOff passNewItem, ExceptionCode& ec) { - if (m_role == AnimValRole) { - ec = NO_MODIFICATION_ALLOWED_ERR; - return 0; - } - - // Not specified, but FF/Opera do it this way, and it's just sane. - if (!passNewItem) { - ec = TYPE_MISMATCH_ERR; - return 0; - } - - RefPtr<ListItemTearOff> newItem = passNewItem; - ASSERT(m_values->size() == m_wrappers.size()); - - // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. - removeItemFromListIfNeeded(newItem.get(), 0); - - // Append the value and wrapper at the end of the list. - m_values->append(newItem->propertyReference()); - m_wrappers.append(newItem); - - commitChange(); - return newItem.release(); + return Base::appendItemValuesAndWrappers(m_animatedProperty.get(), passNewItem, ec); } private: - SVGListPropertyTearOff(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType& values) - : m_animatedProperty(animatedProperty) - , m_role(role) - , m_values(&values) - , m_valuesIsCopy(false) - { - // Using operator & is completly fine, as SVGAnimatedProperty owns this reference, - // and we're guaranteed to live as long as SVGAnimatedProperty does. - if (!values.isEmpty()) - m_wrappers.fill(0, values.size()); - } - - SVGListPropertyTearOff(const PropertyType& initialValue) - : m_animatedProperty(0) - , m_role(UndefinedRole) - , m_values(new PropertyType(initialValue)) - , m_valuesIsCopy(true) + SVGListPropertyTearOff(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role) + : SVGListProperty<PropertyType>(role) + , m_animatedProperty(animatedProperty) { } - virtual ~SVGListPropertyTearOff() + virtual void commitChange() { - if (m_valuesIsCopy) - delete m_values; - } + PropertyType& values = m_animatedProperty->values(); + ListWrapperCache& wrappers = m_animatedProperty->wrappers(); - void commitChange() - { - // Update existing wrappers, as the index in the m_values list has changed. - unsigned size = m_wrappers.size(); - ASSERT(size == m_values->size()); + // Update existing wrappers, as the index in the values list has changed. + unsigned size = wrappers.size(); + ASSERT(size == values.size()); for (unsigned i = 0; i < size; ++i) { - RefPtr<ListItemTearOff>& item = m_wrappers.at(i); + RefPtr<ListItemTearOff>& item = wrappers.at(i); if (!item) continue; item->setAnimatedProperty(m_animatedProperty.get()); - item->setValue(m_values->at(i)); + item->setValue(values.at(i)); } - ASSERT(!m_valuesIsCopy); - ASSERT(m_animatedProperty); m_animatedProperty->commitChange(); } - void removeItemFromListIfNeeded(ListItemTearOff* newItem, unsigned* indexToModify) + virtual void processIncomingListItemValue(const ListItemType&, unsigned*) + { + ASSERT_NOT_REACHED(); + } + + virtual void processIncomingListItemWrapper(RefPtr<ListItemTearOff>& newItem, unsigned* indexToModify) { - // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. SVGAnimatedProperty* animatedPropertyOfItem = newItem->animatedProperty(); - if (!animatedPropertyOfItem || !animatedPropertyOfItem->isAnimatedListTearOff()) + + // newItem has been created manually, it doesn't belong to any SVGElement. + // (for example: "textElement.x.baseVal.appendItem(svgsvgElement.createSVGLength())") + if (!animatedPropertyOfItem) + return; + + // newItem belongs to a SVGElement, but its associated SVGAnimatedProperty is not an animated list tear off. + // (for example: "textElement.x.baseVal.appendItem(rectElement.width.baseVal)") + if (!animatedPropertyOfItem->isAnimatedListTearOff()) { + // We have to copy the incoming newItem, as we're not allowed to insert this tear off as is into our wrapper cache. + // Otherwhise we'll end up having two SVGAnimatedPropertys that operate on the same SVGPropertyTearOff. Consider the example above: + // SVGRectElements SVGAnimatedLength 'width' property baseVal points to the same tear off object + // that's inserted into SVGTextElements SVGAnimatedLengthList 'x'. textElement.x.baseVal.getItem(0).value += 150 would + // mutate the rectElement width _and_ the textElement x list. That's obviously wrong, take care of that. + newItem = ListItemTearOff::create(newItem->propertyReference()); return; + } + // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. // 'newItem' is already living in another list. If it's not our list, synchronize the other lists wrappers after the removal. bool livesInOtherList = animatedPropertyOfItem != m_animatedProperty; - int removedIndex = static_cast<SVGAnimatedListPropertyTearOff<PropertyType>*>(animatedPropertyOfItem)->removeItemFromList(newItem, livesInOtherList); + int removedIndex = static_cast<AnimatedListPropertyTearOff*>(animatedPropertyOfItem)->removeItemFromList(newItem.get(), livesInOtherList); ASSERT(removedIndex != -1); if (!indexToModify) @@ -363,17 +182,7 @@ private: private: // Back pointer to the animated property that created us // For example (text.x.baseVal): m_animatedProperty points to the 'x' SVGAnimatedLengthList object - RefPtr<SVGAnimatedProperty> m_animatedProperty; - - // The role of this property (baseVal or animVal) - SVGPropertyRole m_role; - - // For the example above (text.x.baseVal): A reference to the SVGLengthList& stored in the SVGTextElement, which we can directly modify - PropertyType* m_values; - bool m_valuesIsCopy : 1; - - // A list of wrappers, which is always in sync between m_values. - ListWrapperCache m_wrappers; + RefPtr<AnimatedListPropertyTearOff> m_animatedProperty; }; } diff --git a/WebCore/svg/properties/SVGPropertyTearOff.h b/WebCore/svg/properties/SVGPropertyTearOff.h index 17588b4..2ffaede 100644 --- a/WebCore/svg/properties/SVGPropertyTearOff.h +++ b/WebCore/svg/properties/SVGPropertyTearOff.h @@ -32,7 +32,7 @@ class SVGPropertyTearOff : public SVGProperty { public: typedef SVGPropertyTearOff<PropertyType> Self; - // Used for [SVGAnimatedProperty] types (for example: SVGAnimatedLength::baseVal()). + // Used for child types (baseVal/animVal) of a SVGAnimated* property (for example: SVGAnimatedLength::baseVal()). // Also used for list tear offs (for example: text.x.baseVal.getItem(0)). static PassRefPtr<Self> create(SVGAnimatedProperty* animatedProperty, SVGPropertyRole, PropertyType& value) { @@ -40,7 +40,7 @@ public: return adoptRef(new Self(animatedProperty, value)); } - // Used for non-animated POD types (for example: SVGLength). + // Used for non-animated POD types (for example: SVGSVGElement::createSVGLength()). static PassRefPtr<Self> create(const PropertyType& initialValue) { return adoptRef(new Self(initialValue)); @@ -49,8 +49,6 @@ public: PropertyType& propertyReference() { return *m_value; } SVGAnimatedProperty* animatedProperty() const { return m_animatedProperty.get(); } - virtual int removeItemFromList(SVGAnimatedProperty*) { return -1; } - // Used only by the list tear offs! void setValue(PropertyType& value) { @@ -81,16 +79,17 @@ public: ASSERT(!m_valueIsCopy); m_value = new PropertyType(*m_value); m_valueIsCopy = true; + m_animatedProperty = 0; } - void commitChange() + virtual void commitChange() { if (!m_animatedProperty || m_valueIsCopy) return; m_animatedProperty->commitChange(); } -private: +protected: SVGPropertyTearOff(SVGAnimatedProperty* animatedProperty, PropertyType& value) : m_animatedProperty(animatedProperty) , m_value(&value) diff --git a/WebCore/svg/properties/SVGPropertyTraits.h b/WebCore/svg/properties/SVGPropertyTraits.h index 8d82a61..85bca7e 100644 --- a/WebCore/svg/properties/SVGPropertyTraits.h +++ b/WebCore/svg/properties/SVGPropertyTraits.h @@ -26,7 +26,10 @@ #include "SVGAngle.h" #include "SVGLength.h" #include "SVGLengthList.h" +#include "SVGNumberList.h" +#include "SVGPointList.h" #include "SVGPreserveAspectRatio.h" +#include "SVGStringList.h" #include <wtf/text/StringBuilder.h> namespace WebCore { @@ -79,6 +82,14 @@ struct SVGPropertyTraits<float> { }; template<> +struct SVGPropertyTraits<SVGNumberList> { + typedef float ListItemType; + + static SVGNumberList initialValue() { return SVGNumberList(); } + static String toString(const SVGNumberList& type) { return type.valueAsString(); } +}; + +template<> struct SVGPropertyTraits<SVGPreserveAspectRatio> { static SVGPreserveAspectRatio initialValue() { return SVGPreserveAspectRatio(); } static String toString(const SVGPreserveAspectRatio& type) { return type.valueAsString(); } @@ -108,6 +119,17 @@ struct SVGPropertyTraits<String> { static String toString(const String& type) { return type; } }; +template<> +struct SVGPropertyTraits<SVGStringList> { + typedef String ListItemType; +}; + +template<> +struct SVGPropertyTraits<SVGPointList> { + static SVGPointList initialValue() { return SVGPointList(); } + typedef FloatPoint ListItemType; +}; + } #endif diff --git a/WebCore/svg/properties/SVGStaticListPropertyTearOff.h b/WebCore/svg/properties/SVGStaticListPropertyTearOff.h new file mode 100644 index 0000000..a6f0f28 --- /dev/null +++ b/WebCore/svg/properties/SVGStaticListPropertyTearOff.h @@ -0,0 +1,114 @@ +/* + * Copyright (C) Research In Motion Limited 2010. 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. + * + * 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. + * + * 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. + */ + +#ifndef SVGStaticListPropertyTearOff_h +#define SVGStaticListPropertyTearOff_h + +#if ENABLE(SVG) +#include "SVGListProperty.h" + +namespace WebCore { + +template<typename PropertyType> +class SVGStaticListPropertyTearOff : public SVGListProperty<PropertyType> { +public: + typedef SVGListProperty<PropertyType> Base; + + typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType; + typedef SVGPropertyTearOff<ListItemType> ListItemTearOff; + + static PassRefPtr<SVGStaticListPropertyTearOff<PropertyType> > create(SVGElement* contextElement, PropertyType& values) + { + ASSERT(contextElement); + return adoptRef(new SVGStaticListPropertyTearOff<PropertyType>(contextElement, values)); + } + + // SVGList API + void clear(ExceptionCode& ec) + { + Base::clearValues(m_values, ec); + } + + unsigned numberOfItems() const + { + return Base::numberOfItemsValues(m_values); + } + + ListItemType initialize(const ListItemType& newItem, ExceptionCode& ec) + { + return Base::initializeValues(m_values, newItem, ec); + } + + ListItemType getItem(unsigned index, ExceptionCode& ec) + { + return Base::getItemValues(m_values, index, ec); + } + + ListItemType insertItemBefore(const ListItemType& newItem, unsigned index, ExceptionCode& ec) + { + return Base::insertItemBeforeValues(m_values, newItem, index, ec); + } + + ListItemType replaceItem(const ListItemType& newItem, unsigned index, ExceptionCode& ec) + { + return Base::replaceItemValues(m_values, newItem, index, ec); + } + + ListItemType removeItem(unsigned index, ExceptionCode& ec) + { + return Base::removeItemValues(m_values, index, ec); + } + + ListItemType appendItem(const ListItemType& newItem, ExceptionCode& ec) + { + return Base::appendItemValues(m_values, newItem, ec); + } + +private: + SVGStaticListPropertyTearOff(SVGElement* contextElement, PropertyType& values) + : SVGListProperty<PropertyType>(UndefinedRole) + , m_contextElement(contextElement) + , m_values(values) + { + } + + virtual void commitChange() + { + m_values.commitChange(m_contextElement.get()); + } + + virtual void processIncomingListItemValue(const ListItemType&, unsigned*) + { + // no-op for static lists + } + + virtual void processIncomingListItemWrapper(RefPtr<ListItemTearOff>&, unsigned*) + { + ASSERT_NOT_REACHED(); + } + +private: + RefPtr<SVGElement> m_contextElement; + PropertyType& m_values; +}; + +} + +#endif // ENABLE(SVG) +#endif // SVGStaticListPropertyTearOff_h diff --git a/WebCore/svg/properties/SVGStaticPropertyTearOff.h b/WebCore/svg/properties/SVGStaticPropertyTearOff.h new file mode 100644 index 0000000..8f31909 --- /dev/null +++ b/WebCore/svg/properties/SVGStaticPropertyTearOff.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) Research In Motion Limited 2010. 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. + * + * 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. + * + * 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. + */ + +#ifndef SVGStaticPropertyTearOff_h +#define SVGStaticPropertyTearOff_h + +#if ENABLE(SVG) +#include "SVGPropertyTearOff.h" + +namespace WebCore { + +#if COMPILER(MSVC) +// UpdateMethod is 12 bytes. We have to pack to a size greater than or equal to that to avoid an +// alignment warning (C4121). 16 is the next-largest size allowed for packing, so we use that. +#pragma pack(push, 16) +#endif +template<typename ContextElement, typename PropertyType> +class SVGStaticPropertyTearOff : public SVGPropertyTearOff<PropertyType> { +public: + typedef SVGStaticPropertyTearOff<ContextElement, PropertyType> Self; + typedef void (ContextElement::*UpdateMethod)(); + + // Used for non-animated POD types that are not associated with a SVGAnimatedProperty object, nor with a XML DOM attribute + // (for example: SVGSVGElement::currentTranslate). + static PassRefPtr<Self> create(ContextElement* contextElement, PropertyType& value, UpdateMethod update) + { + ASSERT(contextElement); + return adoptRef(new Self(contextElement, value, update)); + } + + virtual void commitChange() { (m_contextElement.get()->*m_update)(); } + +private: + SVGStaticPropertyTearOff(ContextElement* contextElement, PropertyType& value, UpdateMethod update) + : SVGPropertyTearOff<PropertyType>(0, value) + , m_update(update) + , m_contextElement(contextElement) + { + } + + UpdateMethod m_update; + RefPtr<ContextElement> m_contextElement; +}; +#if COMPILER(MSVC) +#pragma pack(pop) +#endif + +} + +#endif // ENABLE(SVG) +#endif // SVGStaticPropertyTearOff_h diff --git a/WebCore/svg/svgattrs.in b/WebCore/svg/svgattrs.in index fe48c8a..dbe7663 100644 --- a/WebCore/svg/svgattrs.in +++ b/WebCore/svg/svgattrs.in @@ -141,8 +141,6 @@ onzoom opacity operator order -orderX -orderY orient orientation origin |