diff options
Diffstat (limited to 'WebCore/svg')
206 files changed, 3010 insertions, 3097 deletions
diff --git a/WebCore/svg/DeprecatedSVGAnimatedProperty.h b/WebCore/svg/DeprecatedSVGAnimatedProperty.h deleted file mode 100644 index e2f2af7..0000000 --- a/WebCore/svg/DeprecatedSVGAnimatedProperty.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) Research In Motion Limited 2009-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 DeprecatedSVGAnimatedProperty_h -#define DeprecatedSVGAnimatedProperty_h - -#if ENABLE(SVG) -#include "SVGAnimatedPropertySynchronizer.h" -#include "DeprecatedSVGAnimatedPropertyTraits.h" -#include "DeprecatedSVGAnimatedTemplate.h" - -namespace WebCore { - -template<typename AnimatedType> -class DeprecatedSVGAnimatedProperty; - -template<typename AnimatedType> -class DeprecatedSVGAnimatedPropertyTearOff : public DeprecatedSVGAnimatedTemplate<AnimatedType> { -public: - typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::PassType PassType; - typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType ReturnType; - - typedef DeprecatedSVGAnimatedPropertyTearOff<AnimatedType> Self; - typedef DeprecatedSVGAnimatedProperty<AnimatedType> Creator; - - static PassRefPtr<Self> create(Creator& creator, SVGElement* contextElement) - { - return adoptRef(new Self(creator, contextElement)); - } - - virtual void setBaseVal(PassType type) - { - m_creator.setBaseValue(type); - m_contextElement->invalidateSVGAttributes(); - } - - virtual void setAnimVal(PassType type) - { - m_creator.setValue(type); - m_contextElement->invalidateSVGAttributes(); - } - - virtual ReturnType baseVal() const { return m_creator.baseValue(); } - virtual ReturnType animVal() const { return m_creator.value(); } - virtual const QualifiedName& associatedAttributeName() const { return m_creator.associatedAttributeName(); } - -private: - DeprecatedSVGAnimatedPropertyTearOff(Creator& creator, SVGElement* contextElement) - : m_creator(creator) - , m_contextElement(contextElement) - { - m_creator.setShouldSynchronize(true); - } - - virtual ~DeprecatedSVGAnimatedPropertyTearOff() - { - m_creator.setShouldSynchronize(false); - } - - Creator& m_creator; - RefPtr<SVGElement> m_contextElement; -}; - -template<typename AnimatedType> -class DeprecatedSVGAnimatedProperty { -public: - virtual ~DeprecatedSVGAnimatedProperty() { } - - typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::PassType PassType; - typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType ReturnType; - typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::StoredType StoredType; - - DeprecatedSVGAnimatedProperty() - : m_value(DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::null()) - , m_shouldSynchronize(false) - { - } - - template<typename ConstructorParameterOne> - DeprecatedSVGAnimatedProperty(const ConstructorParameterOne& value1) - : m_value(value1) - , m_shouldSynchronize(false) - { - } - - template<typename ConstructorParameterOne, typename ConstructorParameterTwo> - DeprecatedSVGAnimatedProperty(const ConstructorParameterOne& value1, const ConstructorParameterTwo& value2) - : m_value(value1, value2) - , m_shouldSynchronize(false) - { - } - - ReturnType value() const { return DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::toReturnType(m_value); } - ReturnType baseValue() const { return DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::toReturnType(m_value); } - - void setValue(PassType type) { m_value = type; } - void setBaseValue(PassType type) { m_value = type; } - - bool shouldSynchronize() const { return m_shouldSynchronize; } - void setShouldSynchronize(bool value) { m_shouldSynchronize = value; } - - virtual const QualifiedName& associatedAttributeName() const = 0; - -protected: - StoredType m_value; - bool m_shouldSynchronize; -}; - -}; - -// Helper macro used within DECLARE_ANIMATED_PROPERTY below -#define DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, AnimatedType, UpperProperty) \ -class DeprecatedSVGAnimatedProperty##UpperProperty : public DeprecatedSVGAnimatedProperty<AnimatedType> { \ -public: \ - DeprecatedSVGAnimatedProperty##UpperProperty() \ - : DeprecatedSVGAnimatedProperty<AnimatedType>() \ - { \ - } \ - \ - template<typename ConstructorParameterOne> \ - DeprecatedSVGAnimatedProperty##UpperProperty(const ConstructorParameterOne& value1) \ - : DeprecatedSVGAnimatedProperty<AnimatedType>(value1) \ - { \ - } \ - \ - template<typename ConstructorParameterOne, typename ConstructorParameterTwo> \ - DeprecatedSVGAnimatedProperty##UpperProperty(const ConstructorParameterOne& value1, const ConstructorParameterTwo& value2) \ - : DeprecatedSVGAnimatedProperty<AnimatedType>(value1, value2) \ - { \ - } \ - \ - void synchronize(SVGElement* contextElement) \ - { \ - ASSERT(m_shouldSynchronize); \ - AtomicString value(DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::toString(baseValue())); \ - SVGAnimatedPropertySynchronizer<IsDerivedFromSVGElement<OwnerType>::value>::synchronize(contextElement, DOMAttribute, value); \ - } \ - \ - virtual const QualifiedName& associatedAttributeName() const \ - { \ - return DOMAttribute; \ - } \ -} - -// Helper macro shared by DECLARE_ANIMATED_PROPERTY / DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS -#define DECLARE_ANIMATED_PROPERTY_SHARED(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, AnimatedType, UpperProperty, LowerProperty) \ -private: \ - typedef DeprecatedSVGAnimatedPropertyTearOff<AnimatedType> DeprecatedSVGAnimatedPropertyTearOff##UpperProperty; \ - DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, AnimatedType, UpperProperty); \ - DeprecatedSVGAnimatedProperty##UpperProperty m_##LowerProperty; \ - \ -public: \ - DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType LowerProperty() const \ - { \ - return m_##LowerProperty.value(); \ - } \ - \ - DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType LowerProperty##BaseValue() const \ - { \ - return m_##LowerProperty.baseValue(); \ - } \ - \ - void set##UpperProperty(DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::PassType type) \ - { \ - m_##LowerProperty.setValue(type); \ - SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ - contextElement->invalidateSVGAttributes(); \ - } \ - \ - void set##UpperProperty##BaseValue(DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::PassType type) \ - { \ - m_##LowerProperty.setBaseValue(type); \ - SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ - contextElement->invalidateSVGAttributes(); \ - } \ - \ - void synchronize##UpperProperty() \ - { \ - if (!m_##LowerProperty.shouldSynchronize()) \ - return; \ - SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ - m_##LowerProperty.synchronize(contextElement); \ - } \ - \ - PassRefPtr<DeprecatedSVGAnimatedPropertyTearOff##UpperProperty> LowerProperty##Animated() \ - { \ - SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ - return lookupOrCreateWrapper<AnimatedType, DeprecatedSVGAnimatedPropertyTearOff##UpperProperty>(contextElement, m_##LowerProperty, DOMAttribute); \ - } - -// Used for SVG DOM properties that map exactly to one XML DOM attribute -#define DECLARE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, AnimatedType, UpperProperty, LowerProperty) \ -DECLARE_ANIMATED_PROPERTY_SHARED(OwnerType, DOMAttribute, DOMAttribute.localName(), AnimatedType, UpperProperty, LowerProperty) - -// Used for the rare case multiple SVG DOM properties that map to the same XML dom attribute -#define DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, AnimatedType, UpperProperty, LowerProperty) \ -DECLARE_ANIMATED_PROPERTY_SHARED(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, AnimatedType, UpperProperty, LowerProperty) - -#endif -#endif diff --git a/WebCore/svg/DeprecatedSVGAnimatedTemplate.h b/WebCore/svg/DeprecatedSVGAnimatedTemplate.h deleted file mode 100644 index 7021d12..0000000 --- a/WebCore/svg/DeprecatedSVGAnimatedTemplate.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * - * 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 DeprecatedSVGAnimatedTemplate_h -#define DeprecatedSVGAnimatedTemplate_h - -#if ENABLE(SVG) -#include "DeprecatedSVGAnimatedPropertyTraits.h" -#include "QualifiedName.h" -#include <wtf/Forward.h> -#include <wtf/HashMap.h> - -// FIXME: Remove this file! -namespace WebCore { - - class SVGElement; - - struct DeprecatedSVGAnimatedTypeWrapperKey { - // Empty value - DeprecatedSVGAnimatedTypeWrapperKey() - : element(0) - , attributeName(0) - { } - - // Deleted value - DeprecatedSVGAnimatedTypeWrapperKey(WTF::HashTableDeletedValueType) - : element(reinterpret_cast<SVGElement*>(-1)) - { - } - - bool isHashTableDeletedValue() const - { - return element == reinterpret_cast<SVGElement*>(-1); - } - - DeprecatedSVGAnimatedTypeWrapperKey(const SVGElement* _element, const AtomicString& _attributeName) - : element(_element) - , attributeName(_attributeName.impl()) - { - ASSERT(element); - ASSERT(attributeName); - } - - bool operator==(const DeprecatedSVGAnimatedTypeWrapperKey& other) const - { - return element == other.element && attributeName == other.attributeName; - } - - const SVGElement* element; - AtomicStringImpl* attributeName; - }; - - struct DeprecatedSVGAnimatedTypeWrapperKeyHash { - static unsigned hash(const DeprecatedSVGAnimatedTypeWrapperKey& key) - { - return WTF::StringHasher::createBlobHash<sizeof(DeprecatedSVGAnimatedTypeWrapperKey)>(&key); - } - - static bool equal(const DeprecatedSVGAnimatedTypeWrapperKey& a, const DeprecatedSVGAnimatedTypeWrapperKey& b) - { - return a == b; - } - - static const bool safeToCompareToEmptyOrDeleted = true; - }; - - struct DeprecatedSVGAnimatedTypeWrapperKeyHashTraits : WTF::GenericHashTraits<DeprecatedSVGAnimatedTypeWrapperKey> { - static const bool emptyValueIsZero = true; - - static void constructDeletedValue(DeprecatedSVGAnimatedTypeWrapperKey& slot) - { - new (&slot) DeprecatedSVGAnimatedTypeWrapperKey(WTF::HashTableDeletedValue); - } - - static bool isDeletedValue(const DeprecatedSVGAnimatedTypeWrapperKey& value) - { - return value.isHashTableDeletedValue(); - } - }; - - template<typename AnimatedType> - class DeprecatedSVGAnimatedTemplate : public RefCounted<DeprecatedSVGAnimatedTemplate<AnimatedType> > { - public: - typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::PassType PassType; - typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType ReturnType; - - virtual ~DeprecatedSVGAnimatedTemplate() { forgetWrapper(this); } - - virtual ReturnType baseVal() const = 0; - virtual void setBaseVal(PassType) = 0; - - virtual ReturnType animVal() const = 0; - virtual void setAnimVal(PassType) = 0; - - virtual const QualifiedName& associatedAttributeName() const = 0; - - typedef HashMap<DeprecatedSVGAnimatedTypeWrapperKey, DeprecatedSVGAnimatedTemplate<AnimatedType>*, DeprecatedSVGAnimatedTypeWrapperKeyHash, DeprecatedSVGAnimatedTypeWrapperKeyHashTraits > ElementToWrapperMap; - typedef typename ElementToWrapperMap::const_iterator ElementToWrapperMapIterator; - - static ElementToWrapperMap* wrapperCache() - { - static ElementToWrapperMap* s_wrapperCache = new ElementToWrapperMap; - return s_wrapperCache; - } - - static void forgetWrapper(DeprecatedSVGAnimatedTemplate<AnimatedType>* wrapper) - { - ElementToWrapperMap* cache = wrapperCache(); - ElementToWrapperMapIterator itr = cache->begin(); - ElementToWrapperMapIterator end = cache->end(); - for (; itr != end; ++itr) { - if (itr->second == wrapper) { - cache->remove(itr->first); - break; - } - } - } - }; - - template<typename AnimatedType> - class DeprecatedSVGAnimatedProperty; - - template<typename AnimatedType, typename AnimatedTearOff> - PassRefPtr<AnimatedTearOff> lookupOrCreateWrapper(SVGElement* element, DeprecatedSVGAnimatedProperty<AnimatedType>& creator, const QualifiedName& attrName) - { - DeprecatedSVGAnimatedTypeWrapperKey key(element, attrName.localName()); - RefPtr<AnimatedTearOff> wrapper = static_cast<AnimatedTearOff*>(AnimatedTearOff::wrapperCache()->get(key)); - - if (!wrapper) { - wrapper = AnimatedTearOff::create(creator, element); - AnimatedTearOff::wrapperCache()->set(key, wrapper.get()); - } - - return wrapper.release(); - } - -} - -#endif -#endif diff --git a/WebCore/svg/SVGAElement.cpp b/WebCore/svg/SVGAElement.cpp index 8e0e56e..811d5f7 100644 --- a/WebCore/svg/SVGAElement.cpp +++ b/WebCore/svg/SVGAElement.cpp @@ -108,6 +108,7 @@ void SVGAElement::synchronizeProperty(const QualifiedName& attrName) synchronizeSVGTarget(); synchronizeHref(); synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -117,6 +118,8 @@ void SVGAElement::synchronizeProperty(const QualifiedName& attrName) synchronizeHref(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } RenderObject* SVGAElement::createRenderer(RenderArena* arena, RenderStyle*) diff --git a/WebCore/svg/SVGAllInOne.cpp b/WebCore/svg/SVGAllInOne.cpp index e01af2c..60d3071 100644 --- a/WebCore/svg/SVGAllInOne.cpp +++ b/WebCore/svg/SVGAllInOne.cpp @@ -30,7 +30,6 @@ #include "SVGAltGlyphElement.cpp" #include "SVGAngle.cpp" #include "SVGAnimateColorElement.cpp" -#include "SVGAnimatedPathData.cpp" #include "SVGAnimateElement.cpp" #include "SVGAnimateMotionElement.cpp" #include "SVGAnimateTransformElement.cpp" @@ -113,20 +112,9 @@ #include "SVGPathElement.cpp" #include "SVGPathParser.cpp" #include "SVGPathParserFactory.cpp" -#include "SVGPathSeg.cpp" -#include "SVGPathSegArc.cpp" -#include "SVGPathSegClosePath.cpp" -#include "SVGPathSegCurvetoCubic.cpp" -#include "SVGPathSegCurvetoCubicSmooth.cpp" -#include "SVGPathSegCurvetoQuadratic.cpp" -#include "SVGPathSegCurvetoQuadraticSmooth.cpp" -#include "SVGPathSegLineto.cpp" -#include "SVGPathSegLinetoHorizontal.cpp" -#include "SVGPathSegLinetoVertical.cpp" #include "SVGPathSegList.cpp" #include "SVGPathSegListBuilder.cpp" #include "SVGPathSegListSource.cpp" -#include "SVGPathSegMoveto.cpp" #include "SVGPathStringBuilder.cpp" #include "SVGPathStringSource.cpp" #include "SVGPathTraversalStateBuilder.cpp" diff --git a/WebCore/svg/SVGAngle.h b/WebCore/svg/SVGAngle.h index 4afaa4b..6fadabb 100644 --- a/WebCore/svg/SVGAngle.h +++ b/WebCore/svg/SVGAngle.h @@ -24,7 +24,7 @@ #if ENABLE(SVG) #include "ExceptionCode.h" -#include <wtf/text/WTFString.h> +#include "SVGPropertyTraits.h" namespace WebCore { @@ -59,6 +59,12 @@ private: float m_valueInSpecifiedUnits; }; +template<> +struct SVGPropertyTraits<SVGAngle> { + static SVGAngle initialValue() { return SVGAngle(); } + static String toString(const SVGAngle& type) { return type.valueAsString(); } +}; + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGAnimatedLength.h b/WebCore/svg/SVGAnimatedLength.h index 0504fd7..570b2a0 100644 --- a/WebCore/svg/SVGAnimatedLength.h +++ b/WebCore/svg/SVGAnimatedLength.h @@ -28,6 +28,13 @@ namespace WebCore { typedef SVGAnimatedPropertyTearOff<SVGLength> SVGAnimatedLength; +// Helper macros to declare/define a SVGAnimatedLength object +#define DECLARE_ANIMATED_LENGTH(UpperProperty, LowerProperty) \ +DECLARE_ANIMATED_PROPERTY(SVGAnimatedLength, SVGLength, UpperProperty, LowerProperty) + +#define DEFINE_ANIMATED_LENGTH(OwnerType, DOMAttribute, UpperProperty, LowerProperty) \ +DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedLength, SVGLength, UpperProperty, LowerProperty) + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGAnimatedLengthList.h b/WebCore/svg/SVGAnimatedLengthList.h index fcd8197..a0217fa 100644 --- a/WebCore/svg/SVGAnimatedLengthList.h +++ b/WebCore/svg/SVGAnimatedLengthList.h @@ -28,6 +28,13 @@ namespace WebCore { typedef SVGAnimatedListPropertyTearOff<SVGLengthList> SVGAnimatedLengthList; +// Helper macros to declare/define a SVGAnimatedLengthList object +#define DECLARE_ANIMATED_LENGTH_LIST(UpperProperty, LowerProperty) \ +DECLARE_ANIMATED_LIST_PROPERTY(SVGAnimatedLengthList, SVGLengthList, UpperProperty, LowerProperty) + +#define DEFINE_ANIMATED_LENGTH_LIST(OwnerType, DOMAttribute, UpperProperty, LowerProperty) \ +DEFINE_ANIMATED_LIST_PROPERTY(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedLengthList, SVGLengthList, UpperProperty, LowerProperty) + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGAnimatedNumber.h b/WebCore/svg/SVGAnimatedNumber.h index 6897aad..04410d7 100644 --- a/WebCore/svg/SVGAnimatedNumber.h +++ b/WebCore/svg/SVGAnimatedNumber.h @@ -22,11 +22,22 @@ #if ENABLE(SVG) #include "SVGAnimatedStaticPropertyTearOff.h" +#include "SVGAnimatedPropertyMacros.h" namespace WebCore { typedef SVGAnimatedStaticPropertyTearOff<float> SVGAnimatedNumber; +// Helper macros to declare/define a SVGAnimatedNumber object +#define DECLARE_ANIMATED_NUMBER(UpperProperty, LowerProperty) \ +DECLARE_ANIMATED_PROPERTY(SVGAnimatedNumber, float, UpperProperty, LowerProperty) + +#define DEFINE_ANIMATED_NUMBER(OwnerType, DOMAttribute, UpperProperty, LowerProperty) \ +DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedNumber, float, UpperProperty, LowerProperty) + +#define DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, UpperProperty, LowerProperty) \ +DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, SVGAnimatedNumber, float, UpperProperty, LowerProperty) + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGAnimatedNumberList.h b/WebCore/svg/SVGAnimatedNumberList.h index f86b3c2..8beabaa 100644 --- a/WebCore/svg/SVGAnimatedNumberList.h +++ b/WebCore/svg/SVGAnimatedNumberList.h @@ -28,6 +28,13 @@ namespace WebCore { typedef SVGAnimatedListPropertyTearOff<SVGNumberList> SVGAnimatedNumberList; +// Helper macros to declare/define a SVGAnimatedNumberList object +#define DECLARE_ANIMATED_NUMBER_LIST(UpperProperty, LowerProperty) \ +DECLARE_ANIMATED_LIST_PROPERTY(SVGAnimatedNumberList, SVGNumberList, UpperProperty, LowerProperty) + +#define DEFINE_ANIMATED_NUMBER_LIST(OwnerType, DOMAttribute, UpperProperty, LowerProperty) \ +DEFINE_ANIMATED_LIST_PROPERTY(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedNumberList, SVGNumberList, UpperProperty, LowerProperty) + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGAnimatedPathData.cpp b/WebCore/svg/SVGAnimatedPathData.cpp deleted file mode 100644 index 6f54888..0000000 --- a/WebCore/svg/SVGAnimatedPathData.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/SVGAnimatedPathData.h b/WebCore/svg/SVGAnimatedPathData.h deleted file mode 100644 index 5ff66d3..0000000 --- a/WebCore/svg/SVGAnimatedPathData.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 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 - * 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 SVGAnimatedPathData_h -#define SVGAnimatedPathData_h - -#if ENABLE(SVG) - -namespace WebCore { - - class SVGPathSegList; - - class SVGAnimatedPathData { - public: - virtual ~SVGAnimatedPathData() { } - - virtual SVGPathSegList* pathSegList() const = 0; - virtual SVGPathSegList* normalizedPathSegList() const = 0; - virtual SVGPathSegList* animatedPathSegList() const = 0; - virtual SVGPathSegList* animatedNormalizedPathSegList() const = 0; - }; - -} // namespace WebCore - -#endif // ENABLE(SVG) -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGAnimatedPathData.idl b/WebCore/svg/SVGAnimatedPathData.idl deleted file mode 100644 index eae1340..0000000 --- a/WebCore/svg/SVGAnimatedPathData.idl +++ /dev/null @@ -1,35 +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] SVGAnimatedPathData { - readonly attribute SVGPathSegList pathSegList; - readonly attribute SVGPathSegList normalizedPathSegList; - readonly attribute SVGPathSegList animatedPathSegList; - readonly attribute SVGPathSegList animatedNormalizedPathSegList; - }; - -} diff --git a/WebCore/svg/SVGAnimatedTransformList.h b/WebCore/svg/SVGAnimatedTransformList.h index dcf87dd..8caee3c 100644 --- a/WebCore/svg/SVGAnimatedTransformList.h +++ b/WebCore/svg/SVGAnimatedTransformList.h @@ -27,6 +27,13 @@ namespace WebCore { typedef SVGAnimatedTransformListPropertyTearOff SVGAnimatedTransformList; +// Helper macros to declare/define a SVGAnimatedTransformList object +#define DECLARE_ANIMATED_TRANSFORM_LIST(UpperProperty, LowerProperty) \ +DECLARE_ANIMATED_LIST_PROPERTY(SVGAnimatedTransformList, SVGTransformList, UpperProperty, LowerProperty) + +#define DEFINE_ANIMATED_TRANSFORM_LIST(OwnerType, DOMAttribute, UpperProperty, LowerProperty) \ +DEFINE_ANIMATED_LIST_PROPERTY(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedTransformList, SVGTransformList, UpperProperty, LowerProperty) + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGAnimationElement.cpp b/WebCore/svg/SVGAnimationElement.cpp index 25b319e..c3b6f0c 100644 --- a/WebCore/svg/SVGAnimationElement.cpp +++ b/WebCore/svg/SVGAnimationElement.cpp @@ -166,8 +166,16 @@ void SVGAnimationElement::synchronizeProperty(const QualifiedName& attrName) { SVGSMILElement::synchronizeProperty(attrName); - if (attrName == anyQName() || SVGExternalResourcesRequired::isKnownAttribute(attrName)) + if (attrName == anyQName()) { synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); + return; + } + + if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) + synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } float SVGAnimationElement::getStartTime() const diff --git a/WebCore/svg/SVGCircleElement.cpp b/WebCore/svg/SVGCircleElement.cpp index a2c6a8d..1e6af43 100644 --- a/WebCore/svg/SVGCircleElement.cpp +++ b/WebCore/svg/SVGCircleElement.cpp @@ -32,6 +32,11 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGCircleElement, SVGNames::cxAttr, Cx, cx) +DEFINE_ANIMATED_LENGTH(SVGCircleElement, SVGNames::cyAttr, Cy, cy) +DEFINE_ANIMATED_LENGTH(SVGCircleElement, SVGNames::rAttr, R, r) + inline SVGCircleElement::SVGCircleElement(const QualifiedName& tagName, Document* document) : SVGStyledTransformableElement(tagName, document) , m_cx(LengthModeWidth) @@ -110,6 +115,7 @@ void SVGCircleElement::synchronizeProperty(const QualifiedName& attrName) synchronizeCy(); synchronizeR(); synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -121,6 +127,8 @@ void SVGCircleElement::synchronizeProperty(const QualifiedName& attrName) synchronizeR(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGCircleElement::toPathData(Path& path) const diff --git a/WebCore/svg/SVGCircleElement.h b/WebCore/svg/SVGCircleElement.h index 5c3a62f..23d5e79 100644 --- a/WebCore/svg/SVGCircleElement.h +++ b/WebCore/svg/SVGCircleElement.h @@ -31,33 +31,34 @@ namespace WebCore { - class SVGCircleElement : public SVGStyledTransformableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired { - public: - static PassRefPtr<SVGCircleElement> create(const QualifiedName&, Document*); +class SVGCircleElement : public SVGStyledTransformableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired { +public: + static PassRefPtr<SVGCircleElement> create(const QualifiedName&, Document*); - private: - SVGCircleElement(const QualifiedName&, Document*); +private: + SVGCircleElement(const QualifiedName&, Document*); - virtual bool isValid() const { return SVGTests::isValid(); } + virtual bool isValid() const { return SVGTests::isValid(); } - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual void toPathData(Path&) const; + virtual void toPathData(Path&) const; - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - DECLARE_ANIMATED_PROPERTY_NEW(SVGCircleElement, SVGNames::cxAttr, SVGLength, Cx, cx) - DECLARE_ANIMATED_PROPERTY_NEW(SVGCircleElement, SVGNames::cyAttr, SVGLength, Cy, cy) - DECLARE_ANIMATED_PROPERTY_NEW(SVGCircleElement, SVGNames::rAttr, SVGLength, R, r) + // Animated property declarations + DECLARE_ANIMATED_LENGTH(Cx, cx) + DECLARE_ANIMATED_LENGTH(Cy, cy) + DECLARE_ANIMATED_LENGTH(R, r) - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGCircleElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - }; + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGCircleElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGClipPathElement.cpp b/WebCore/svg/SVGClipPathElement.cpp index 715a34e..bd4df19 100644 --- a/WebCore/svg/SVGClipPathElement.cpp +++ b/WebCore/svg/SVGClipPathElement.cpp @@ -86,6 +86,7 @@ void SVGClipPathElement::synchronizeProperty(const QualifiedName& attrName) if (attrName == anyQName()) { synchronizeClipPathUnits(); synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -93,6 +94,8 @@ void SVGClipPathElement::synchronizeProperty(const QualifiedName& attrName) synchronizeClipPathUnits(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGClipPathElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) diff --git a/WebCore/svg/SVGComponentTransferFunctionElement.cpp b/WebCore/svg/SVGComponentTransferFunctionElement.cpp index 078b30d..4e1e2dd 100644 --- a/WebCore/svg/SVGComponentTransferFunctionElement.cpp +++ b/WebCore/svg/SVGComponentTransferFunctionElement.cpp @@ -30,6 +30,14 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER_LIST(SVGComponentTransferFunctionElement, SVGNames::tableValuesAttr, TableValues, tableValues) +DEFINE_ANIMATED_NUMBER(SVGComponentTransferFunctionElement, SVGNames::slopeAttr, Slope, slope) +DEFINE_ANIMATED_NUMBER(SVGComponentTransferFunctionElement, SVGNames::interceptAttr, Intercept, intercept) +DEFINE_ANIMATED_NUMBER(SVGComponentTransferFunctionElement, SVGNames::amplitudeAttr, Amplitude, amplitude) +DEFINE_ANIMATED_NUMBER(SVGComponentTransferFunctionElement, SVGNames::exponentAttr, Exponent, exponent) +DEFINE_ANIMATED_NUMBER(SVGComponentTransferFunctionElement, SVGNames::offsetAttr, Offset, offset) + SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement(const QualifiedName& tagName, Document* document) : SVGElement(tagName, document) , m_type(FECOMPONENTTRANSFER_TYPE_UNKNOWN) @@ -57,7 +65,7 @@ void SVGComponentTransferFunctionElement::parseMappedAttribute(Attribute* attr) SVGNumberList newList; newList.parse(value); detachAnimatedTableValuesListWrappers(newList.size()); - tableValuesBaseValue() = newList; + setTableValuesBaseValue(newList); } else if (attr->name() == SVGNames::slopeAttr) setSlopeBaseValue(value.toFloat()); else if (attr->name() == SVGNames::interceptAttr) diff --git a/WebCore/svg/SVGComponentTransferFunctionElement.h b/WebCore/svg/SVGComponentTransferFunctionElement.h index e02fc16..7c56507 100644 --- a/WebCore/svg/SVGComponentTransferFunctionElement.h +++ b/WebCore/svg/SVGComponentTransferFunctionElement.h @@ -23,30 +23,31 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FEComponentTransfer.h" -#include "SVGAnimatedPropertyMacros.h" -#include "SVGNumberList.h" +#include "SVGAnimatedNumber.h" +#include "SVGAnimatedNumberList.h" namespace WebCore { - class SVGComponentTransferFunctionElement : public SVGElement { - public: - ComponentTransferFunction transferFunction() const; - - protected: - SVGComponentTransferFunctionElement(const QualifiedName&, Document*); - - virtual void parseMappedAttribute(Attribute*); - virtual void synchronizeProperty(const QualifiedName&); - - private: - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGComponentTransferFunctionElement, SVGNames::typeAttr, int, Type, type) - 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) - }; +class SVGComponentTransferFunctionElement : public SVGElement { +public: + ComponentTransferFunction transferFunction() const; + +protected: + SVGComponentTransferFunctionElement(const QualifiedName&, Document*); + + virtual void parseMappedAttribute(Attribute*); + virtual void synchronizeProperty(const QualifiedName&); + +private: + // Animated property declarations + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGComponentTransferFunctionElement, SVGNames::typeAttr, int, Type, type) + DECLARE_ANIMATED_NUMBER_LIST(TableValues, tableValues) + DECLARE_ANIMATED_NUMBER(Slope, slope) + DECLARE_ANIMATED_NUMBER(Intercept, intercept) + DECLARE_ANIMATED_NUMBER(Amplitude, amplitude) + DECLARE_ANIMATED_NUMBER(Exponent, exponent) + DECLARE_ANIMATED_NUMBER(Offset, offset) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGCursorElement.cpp b/WebCore/svg/SVGCursorElement.cpp index 9fb4140..175478d 100644 --- a/WebCore/svg/SVGCursorElement.cpp +++ b/WebCore/svg/SVGCursorElement.cpp @@ -30,6 +30,10 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGCursorElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGCursorElement, SVGNames::yAttr, Y, y) + inline SVGCursorElement::SVGCursorElement(const QualifiedName& tagName, Document* document) : SVGElement(tagName, document) , m_x(LengthModeWidth) @@ -104,6 +108,7 @@ void SVGCursorElement::synchronizeProperty(const QualifiedName& attrName) synchronizeY(); synchronizeExternalResourcesRequired(); synchronizeHref(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -115,6 +120,8 @@ void SVGCursorElement::synchronizeProperty(const QualifiedName& attrName) synchronizeExternalResourcesRequired(); else if (SVGURIReference::isKnownAttribute(attrName)) synchronizeHref(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGCursorElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const diff --git a/WebCore/svg/SVGCursorElement.h b/WebCore/svg/SVGCursorElement.h index d3bcb8b..d83fba5 100644 --- a/WebCore/svg/SVGCursorElement.h +++ b/WebCore/svg/SVGCursorElement.h @@ -31,40 +31,41 @@ namespace WebCore { - class SVGCursorElement : public SVGElement, - public SVGTests, - public SVGExternalResourcesRequired, - public SVGURIReference { - public: - static PassRefPtr<SVGCursorElement> create(const QualifiedName&, Document*); +class SVGCursorElement : public SVGElement, + public SVGTests, + public SVGExternalResourcesRequired, + public SVGURIReference { +public: + static PassRefPtr<SVGCursorElement> create(const QualifiedName&, Document*); - virtual ~SVGCursorElement(); + virtual ~SVGCursorElement(); - void addClient(SVGElement*); - void removeClient(SVGElement*); + void addClient(SVGElement*); + void removeClient(SVGElement*); - private: - SVGCursorElement(const QualifiedName&, Document*); +private: + SVGCursorElement(const QualifiedName&, Document*); - virtual bool isValid() const { return SVGTests::isValid(); } + virtual bool isValid() const { return SVGTests::isValid(); } - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; + virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; - DECLARE_ANIMATED_PROPERTY_NEW(SVGCursorElement, SVGNames::xAttr, SVGLength, X, x) - DECLARE_ANIMATED_PROPERTY_NEW(SVGCursorElement, SVGNames::yAttr, SVGLength, Y, y) + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) - // SVGURIReference - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGCursorElement, XLinkNames::hrefAttr, String, Href, href) + // SVGURIReference + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGCursorElement, XLinkNames::hrefAttr, String, Href, href) - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGCursorElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGCursorElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - HashSet<SVGElement*> m_clients; - }; + HashSet<SVGElement*> m_clients; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGDefsElement.cpp b/WebCore/svg/SVGDefsElement.cpp index 4f5a582..8525705 100644 --- a/WebCore/svg/SVGDefsElement.cpp +++ b/WebCore/svg/SVGDefsElement.cpp @@ -51,8 +51,16 @@ void SVGDefsElement::synchronizeProperty(const QualifiedName& attrName) { SVGStyledTransformableElement::synchronizeProperty(attrName); - if (attrName == anyQName() || SVGExternalResourcesRequired::isKnownAttribute(attrName)) + if (attrName == anyQName()) { synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); + return; + } + + if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) + synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } } diff --git a/WebCore/svg/SVGElement.h b/WebCore/svg/SVGElement.h index 96e7fd7..0af041f 100644 --- a/WebCore/svg/SVGElement.h +++ b/WebCore/svg/SVGElement.h @@ -110,8 +110,5 @@ namespace WebCore { } -// This file needs to be included after the SVGElement declaration -#include "DeprecatedSVGAnimatedProperty.h" // NOLINT - #endif #endif diff --git a/WebCore/svg/SVGEllipseElement.cpp b/WebCore/svg/SVGEllipseElement.cpp index 5726c53..b6ee3f2 100644 --- a/WebCore/svg/SVGEllipseElement.cpp +++ b/WebCore/svg/SVGEllipseElement.cpp @@ -32,6 +32,12 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::cxAttr, Cx, cx) +DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::cyAttr, Cy, cy) +DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::rxAttr, Rx, rx) +DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::ryAttr, Ry, ry) + inline SVGEllipseElement::SVGEllipseElement(const QualifiedName& tagName, Document* document) : SVGStyledTransformableElement(tagName, document) , m_cx(LengthModeWidth) @@ -117,6 +123,7 @@ void SVGEllipseElement::synchronizeProperty(const QualifiedName& attrName) synchronizeRx(); synchronizeRy(); synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -130,6 +137,8 @@ void SVGEllipseElement::synchronizeProperty(const QualifiedName& attrName) synchronizeRy(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGEllipseElement::toPathData(Path& path) const diff --git a/WebCore/svg/SVGEllipseElement.h b/WebCore/svg/SVGEllipseElement.h index 3bd7a50..17412af 100644 --- a/WebCore/svg/SVGEllipseElement.h +++ b/WebCore/svg/SVGEllipseElement.h @@ -31,34 +31,35 @@ namespace WebCore { - class SVGEllipseElement : public SVGStyledTransformableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired { - public: - static PassRefPtr<SVGEllipseElement> create(const QualifiedName&, Document*); +class SVGEllipseElement : public SVGStyledTransformableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired { +public: + static PassRefPtr<SVGEllipseElement> create(const QualifiedName&, Document*); - private: - SVGEllipseElement(const QualifiedName&, Document*); - - virtual bool isValid() const { return SVGTests::isValid(); } +private: + SVGEllipseElement(const QualifiedName&, Document*); + + virtual bool isValid() const { return SVGTests::isValid(); } - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual void toPathData(Path&) const; + virtual void toPathData(Path&) const; - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - DECLARE_ANIMATED_PROPERTY_NEW(SVGEllipseElement, SVGNames::cxAttr, SVGLength, Cx, cx) - DECLARE_ANIMATED_PROPERTY_NEW(SVGEllipseElement, SVGNames::cyAttr, SVGLength, Cy, cy) - DECLARE_ANIMATED_PROPERTY_NEW(SVGEllipseElement, SVGNames::rxAttr, SVGLength, Rx, rx) - DECLARE_ANIMATED_PROPERTY_NEW(SVGEllipseElement, SVGNames::ryAttr, SVGLength, Ry, ry) + // Animated property declarations + DECLARE_ANIMATED_LENGTH(Cx, cx) + DECLARE_ANIMATED_LENGTH(Cy, cy) + DECLARE_ANIMATED_LENGTH(Rx, rx) + DECLARE_ANIMATED_LENGTH(Ry, ry) - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGEllipseElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - }; + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGEllipseElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGFEBlendElement.cpp b/WebCore/svg/SVGFEBlendElement.cpp index 6c5952f..0e00627 100644 --- a/WebCore/svg/SVGFEBlendElement.cpp +++ b/WebCore/svg/SVGFEBlendElement.cpp @@ -89,7 +89,7 @@ void SVGFEBlendElement::synchronizeProperty(const QualifiedName& attrName) synchronizeIn2(); } -PassRefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); FilterEffect* input2 = filterBuilder->getEffectById(in2()); @@ -97,7 +97,7 @@ PassRefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder* filterBuilde if (!input1 || !input2) return 0; - RefPtr<FilterEffect> effect = FEBlend::create(static_cast<BlendModeType>(mode())); + RefPtr<FilterEffect> effect = FEBlend::create(filter, static_cast<BlendModeType>(mode())); FilterEffectVector& inputEffects = effect->inputEffects(); inputEffects.reserveCapacity(2); inputEffects.append(input1); diff --git a/WebCore/svg/SVGFEBlendElement.h b/WebCore/svg/SVGFEBlendElement.h index 44d45bf..e203cd0 100644 --- a/WebCore/svg/SVGFEBlendElement.h +++ b/WebCore/svg/SVGFEBlendElement.h @@ -36,7 +36,7 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEBlendElement, SVGNames::inAttr, String, In1, in1) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEBlendElement, SVGNames::in2Attr, String, In2, in2) diff --git a/WebCore/svg/SVGFEColorMatrixElement.cpp b/WebCore/svg/SVGFEColorMatrixElement.cpp index eed728d..4ab7700 100644 --- a/WebCore/svg/SVGFEColorMatrixElement.cpp +++ b/WebCore/svg/SVGFEColorMatrixElement.cpp @@ -29,6 +29,9 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER_LIST(SVGFEColorMatrixElement, SVGNames::valuesAttr, Values, values) + inline SVGFEColorMatrixElement::SVGFEColorMatrixElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m_type(FECOLORMATRIX_TYPE_UNKNOWN) @@ -59,7 +62,7 @@ void SVGFEColorMatrixElement::parseMappedAttribute(Attribute* attr) SVGNumberList newList; newList.parse(value); detachAnimatedValuesListWrappers(newList.size()); - valuesBaseValue() = newList; + setValuesBaseValue(newList); } else SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); } @@ -93,7 +96,7 @@ void SVGFEColorMatrixElement::synchronizeProperty(const QualifiedName& attrName) synchronizeValues(); } -PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); @@ -130,7 +133,7 @@ PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filter return 0; } - RefPtr<FilterEffect> effect = FEColorMatrix::create(filterType, filterValues); + RefPtr<FilterEffect> effect = FEColorMatrix::create(filter, filterType, filterValues); effect->inputEffects().append(input1); return effect.release(); } diff --git a/WebCore/svg/SVGFEColorMatrixElement.h b/WebCore/svg/SVGFEColorMatrixElement.h index dcdeb41..7d7f05d 100644 --- a/WebCore/svg/SVGFEColorMatrixElement.h +++ b/WebCore/svg/SVGFEColorMatrixElement.h @@ -23,8 +23,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FEColorMatrix.h" +#include "SVGAnimatedNumberList.h" #include "SVGFilterPrimitiveStandardAttributes.h" -#include "SVGNumberList.h" namespace WebCore { @@ -38,11 +38,12 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); + // Animated property declarations DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEColorMatrixElement, SVGNames::inAttr, String, In1, in1) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEColorMatrixElement, SVGNames::typeAttr, int, Type, type) - DECLARE_ANIMATED_LIST_PROPERTY_NEW(SVGFEColorMatrixElement, SVGNames::valuesAttr, SVGNumberList, Values, values) + DECLARE_ANIMATED_NUMBER_LIST(Values, values) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEComponentTransferElement.cpp b/WebCore/svg/SVGFEComponentTransferElement.cpp index f6b26f5..72cefac 100644 --- a/WebCore/svg/SVGFEComponentTransferElement.cpp +++ b/WebCore/svg/SVGFEComponentTransferElement.cpp @@ -60,7 +60,7 @@ void SVGFEComponentTransferElement::synchronizeProperty(const QualifiedName& att synchronizeIn1(); } -PassRefPtr<FilterEffect> SVGFEComponentTransferElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEComponentTransferElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); @@ -83,7 +83,7 @@ PassRefPtr<FilterEffect> SVGFEComponentTransferElement::build(SVGFilterBuilder* alpha = static_cast<SVGFEFuncAElement*>(n)->transferFunction(); } - RefPtr<FilterEffect> effect = FEComponentTransfer::create(red, green, blue, alpha); + RefPtr<FilterEffect> effect = FEComponentTransfer::create(filter, red, green, blue, alpha); effect->inputEffects().append(input1); return effect.release(); } diff --git a/WebCore/svg/SVGFEComponentTransferElement.h b/WebCore/svg/SVGFEComponentTransferElement.h index fe0e562..e0ad03a 100644 --- a/WebCore/svg/SVGFEComponentTransferElement.h +++ b/WebCore/svg/SVGFEComponentTransferElement.h @@ -36,7 +36,7 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEComponentTransferElement, SVGNames::inAttr, String, In1, in1) }; diff --git a/WebCore/svg/SVGFECompositeElement.cpp b/WebCore/svg/SVGFECompositeElement.cpp index 6d7e7b2..9d0dd56 100644 --- a/WebCore/svg/SVGFECompositeElement.cpp +++ b/WebCore/svg/SVGFECompositeElement.cpp @@ -28,6 +28,12 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER(SVGFECompositeElement, SVGNames::k1Attr, K1, k1) +DEFINE_ANIMATED_NUMBER(SVGFECompositeElement, SVGNames::k2Attr, K2, k2) +DEFINE_ANIMATED_NUMBER(SVGFECompositeElement, SVGNames::k3Attr, K3, k3) +DEFINE_ANIMATED_NUMBER(SVGFECompositeElement, SVGNames::k4Attr, K4, k4) + inline SVGFECompositeElement::SVGFECompositeElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m__operator(FECOMPOSITE_OPERATOR_OVER) @@ -116,7 +122,7 @@ void SVGFECompositeElement::synchronizeProperty(const QualifiedName& attrName) synchronizeK4(); } -PassRefPtr<FilterEffect> SVGFECompositeElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFECompositeElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); FilterEffect* input2 = filterBuilder->getEffectById(in2()); @@ -124,7 +130,7 @@ PassRefPtr<FilterEffect> SVGFECompositeElement::build(SVGFilterBuilder* filterBu if (!input1 || !input2) return 0; - RefPtr<FilterEffect> effect = FEComposite::create(static_cast<CompositeOperationType>(_operator()), + RefPtr<FilterEffect> effect = FEComposite::create(filter, static_cast<CompositeOperationType>(_operator()), k1(), k2(), k3(), k4()); FilterEffectVector& inputEffects = effect->inputEffects(); inputEffects.reserveCapacity(2); diff --git a/WebCore/svg/SVGFECompositeElement.h b/WebCore/svg/SVGFECompositeElement.h index 4870848..d41a4f9 100644 --- a/WebCore/svg/SVGFECompositeElement.h +++ b/WebCore/svg/SVGFECompositeElement.h @@ -23,6 +23,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FEComposite.h" +#include "SVGAnimatedNumber.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { @@ -37,15 +38,16 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); + // Animated property declarations 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_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) + DECLARE_ANIMATED_NUMBER(K1, k1) + DECLARE_ANIMATED_NUMBER(K2, k2) + DECLARE_ANIMATED_NUMBER(K3, k3) + DECLARE_ANIMATED_NUMBER(K4, k4) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEConvolveMatrixElement.cpp b/WebCore/svg/SVGFEConvolveMatrixElement.cpp index 1137543..dbdcc25 100644 --- a/WebCore/svg/SVGFEConvolveMatrixElement.cpp +++ b/WebCore/svg/SVGFEConvolveMatrixElement.cpp @@ -24,17 +24,20 @@ #include "Attr.h" #include "FloatPoint.h" -#include "FloatSize.h" #include "IntPoint.h" #include "IntSize.h" #include "SVGNames.h" -#include "SVGNumberList.h" #include "SVGParserUtilities.h" -#include <math.h> - namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER_LIST(SVGFEConvolveMatrixElement, SVGNames::kernelMatrixAttr, KernelMatrix, kernelMatrix) +DEFINE_ANIMATED_NUMBER(SVGFEConvolveMatrixElement, SVGNames::divisorAttr, Divisor, divisor) +DEFINE_ANIMATED_NUMBER(SVGFEConvolveMatrixElement, SVGNames::biasAttr, Bias, bias) +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEConvolveMatrixElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthXIdentifier(), KernelUnitLengthX, kernelUnitLengthX) +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEConvolveMatrixElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthYIdentifier(), KernelUnitLengthY, kernelUnitLengthY) + inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m_edgeMode(EDGEMODE_DUPLICATE) @@ -92,7 +95,7 @@ void SVGFEConvolveMatrixElement::parseMappedAttribute(Attribute* attr) SVGNumberList newList; newList.parse(value); detachAnimatedKernelMatrixListWrappers(newList.size()); - kernelMatrixBaseValue() = newList; + setKernelMatrixBaseValue(newList); } else if (attr->name() == SVGNames::divisorAttr) setDivisorBaseValue(value.toFloat()); else if (attr->name() == SVGNames::biasAttr) @@ -147,7 +150,7 @@ void SVGFEConvolveMatrixElement::svgAttributeChanged(const QualifiedName& attrNa invalidate(); } -PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); @@ -189,7 +192,7 @@ PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil divisorValue = 1; } - RefPtr<FilterEffect> effect = FEConvolveMatrix::create( + RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, IntSize(orderXValue, orderYValue), divisorValue, bias(), IntPoint(targetXValue, targetYValue), static_cast<EdgeModeType>(edgeMode()), FloatPoint(kernelUnitLengthX(), kernelUnitLengthX()), preserveAlpha(), kernelMatrix); diff --git a/WebCore/svg/SVGFEConvolveMatrixElement.h b/WebCore/svg/SVGFEConvolveMatrixElement.h index b36b7f1..efc6723 100644 --- a/WebCore/svg/SVGFEConvolveMatrixElement.h +++ b/WebCore/svg/SVGFEConvolveMatrixElement.h @@ -22,8 +22,9 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FEConvolveMatrix.h" +#include "SVGAnimatedNumber.h" +#include "SVGAnimatedNumberList.h" #include "SVGFilterPrimitiveStandardAttributes.h" -#include "SVGNumberList.h" namespace WebCore { @@ -39,24 +40,25 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); + static const AtomicString& orderXIdentifier(); static const AtomicString& orderYIdentifier(); - static const AtomicString& kernelUnitLengthXIdentifier(); static const AtomicString& kernelUnitLengthYIdentifier(); + // Animated property declarations 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_NUMBER_LIST(KernelMatrix, kernelMatrix) + DECLARE_ANIMATED_NUMBER(Divisor, divisor) + DECLARE_ANIMATED_NUMBER(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_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_NUMBER(KernelUnitLengthX, kernelUnitLengthX) + DECLARE_ANIMATED_NUMBER(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 6da804f..74a21e5 100644 --- a/WebCore/svg/SVGFEDiffuseLightingElement.cpp +++ b/WebCore/svg/SVGFEDiffuseLightingElement.cpp @@ -32,6 +32,12 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER(SVGFEDiffuseLightingElement, SVGNames::diffuseConstantAttr, DiffuseConstant, diffuseConstant) +DEFINE_ANIMATED_NUMBER(SVGFEDiffuseLightingElement, SVGNames::surfaceScaleAttr, SurfaceScale, surfaceScale) +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEDiffuseLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthXIdentifier(), KernelUnitLengthX, kernelUnitLengthX) +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEDiffuseLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthYIdentifier(), KernelUnitLengthY, kernelUnitLengthY) + inline SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m_diffuseConstant(1) @@ -112,7 +118,7 @@ void SVGFEDiffuseLightingElement::synchronizeProperty(const QualifiedName& attrN } } -PassRefPtr<FilterEffect> SVGFEDiffuseLightingElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEDiffuseLightingElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); @@ -122,7 +128,7 @@ PassRefPtr<FilterEffect> SVGFEDiffuseLightingElement::build(SVGFilterBuilder* fi RefPtr<RenderStyle> filterStyle = styleForRenderer(); Color color = filterStyle->svgStyle()->lightingColor(); - RefPtr<FilterEffect> effect = FEDiffuseLighting::create(color, surfaceScale(), diffuseConstant(), + RefPtr<FilterEffect> effect = FEDiffuseLighting::create(filter, color, surfaceScale(), diffuseConstant(), kernelUnitLengthX(), kernelUnitLengthY(), findLights()); effect->inputEffects().append(input1); return effect.release(); diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.h b/WebCore/svg/SVGFEDiffuseLightingElement.h index fa946e6..d31e7fe 100644 --- a/WebCore/svg/SVGFEDiffuseLightingElement.h +++ b/WebCore/svg/SVGFEDiffuseLightingElement.h @@ -41,16 +41,17 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); static const AtomicString& kernelUnitLengthXIdentifier(); static const AtomicString& kernelUnitLengthYIdentifier(); + // Animated property declarations 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) + DECLARE_ANIMATED_NUMBER(DiffuseConstant, diffuseConstant) + DECLARE_ANIMATED_NUMBER(SurfaceScale, surfaceScale) + DECLARE_ANIMATED_NUMBER(KernelUnitLengthX, kernelUnitLengthX) + DECLARE_ANIMATED_NUMBER(KernelUnitLengthY, kernelUnitLengthY) PassRefPtr<LightSource> findLights() const; }; diff --git a/WebCore/svg/SVGFEDisplacementMapElement.cpp b/WebCore/svg/SVGFEDisplacementMapElement.cpp index ba3311b..9829dad 100644 --- a/WebCore/svg/SVGFEDisplacementMapElement.cpp +++ b/WebCore/svg/SVGFEDisplacementMapElement.cpp @@ -26,6 +26,9 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER(SVGFEDisplacementMapElement, SVGNames::scaleAttr, Scale, scale) + inline SVGFEDisplacementMapElement::SVGFEDisplacementMapElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m_xChannelSelector(CHANNEL_A) @@ -106,7 +109,7 @@ void SVGFEDisplacementMapElement::synchronizeProperty(const QualifiedName& attrN synchronizeScale(); } -PassRefPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); FilterEffect* input2 = filterBuilder->getEffectById(in2()); @@ -114,7 +117,7 @@ PassRefPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilterBuilder* fi if (!input1 || !input2) return 0; - RefPtr<FilterEffect> effect = FEDisplacementMap::create(static_cast<ChannelSelectorType>(xChannelSelector()), + RefPtr<FilterEffect> effect = FEDisplacementMap::create(filter, static_cast<ChannelSelectorType>(xChannelSelector()), static_cast<ChannelSelectorType>(yChannelSelector()), scale()); FilterEffectVector& inputEffects = effect->inputEffects(); inputEffects.reserveCapacity(2); diff --git a/WebCore/svg/SVGFEDisplacementMapElement.h b/WebCore/svg/SVGFEDisplacementMapElement.h index 8131d82..a92fecd 100644 --- a/WebCore/svg/SVGFEDisplacementMapElement.h +++ b/WebCore/svg/SVGFEDisplacementMapElement.h @@ -22,6 +22,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FEDisplacementMap.h" +#include "SVGAnimatedNumber.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { @@ -38,13 +39,14 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); - + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); + + // Animated property declarations 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_STATIC_PROPERTY_NEW(SVGFEDisplacementMapElement, SVGNames::scaleAttr, float, Scale, scale) + DECLARE_ANIMATED_NUMBER(Scale, scale) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEFloodElement.cpp b/WebCore/svg/SVGFEFloodElement.cpp index 321eb8f..53ad910 100644 --- a/WebCore/svg/SVGFEFloodElement.cpp +++ b/WebCore/svg/SVGFEFloodElement.cpp @@ -39,14 +39,14 @@ PassRefPtr<SVGFEFloodElement> SVGFEFloodElement::create(const QualifiedName& tag return adoptRef(new SVGFEFloodElement(tagName, document)); } -PassRefPtr<FilterEffect> SVGFEFloodElement::build(SVGFilterBuilder*) +PassRefPtr<FilterEffect> SVGFEFloodElement::build(SVGFilterBuilder*, Filter* filter) { RefPtr<RenderStyle> filterStyle = styleForRenderer(); Color color = filterStyle->svgStyle()->floodColor(); float opacity = filterStyle->svgStyle()->floodOpacity(); - return FEFlood::create(color, opacity); + return FEFlood::create(filter, color, opacity); } } diff --git a/WebCore/svg/SVGFEFloodElement.h b/WebCore/svg/SVGFEFloodElement.h index 10a418f..1485ddd 100644 --- a/WebCore/svg/SVGFEFloodElement.h +++ b/WebCore/svg/SVGFEFloodElement.h @@ -34,7 +34,7 @@ public: private: SVGFEFloodElement(const QualifiedName&, Document*); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEGaussianBlurElement.cpp b/WebCore/svg/SVGFEGaussianBlurElement.cpp index c17c748..0981f8e 100644 --- a/WebCore/svg/SVGFEGaussianBlurElement.cpp +++ b/WebCore/svg/SVGFEGaussianBlurElement.cpp @@ -29,6 +29,10 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEGaussianBlurElement, SVGNames::stdDeviationAttr, stdDeviationXIdentifier(), StdDeviationX, stdDeviationX) +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEGaussianBlurElement, SVGNames::stdDeviationAttr, stdDeviationYIdentifier(), StdDeviationY, stdDeviationY) + inline SVGFEGaussianBlurElement::SVGFEGaussianBlurElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) { @@ -100,14 +104,14 @@ void SVGFEGaussianBlurElement::synchronizeProperty(const QualifiedName& attrName synchronizeIn1(); } -PassRefPtr<FilterEffect> SVGFEGaussianBlurElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEGaussianBlurElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); if (!input1) return 0; - RefPtr<FilterEffect> effect = FEGaussianBlur::create(stdDeviationX(), stdDeviationY()); + RefPtr<FilterEffect> effect = FEGaussianBlur::create(filter, stdDeviationX(), stdDeviationY()); effect->inputEffects().append(input1); return effect.release(); } diff --git a/WebCore/svg/SVGFEGaussianBlurElement.h b/WebCore/svg/SVGFEGaussianBlurElement.h index 3ddb437..a9ca799 100644 --- a/WebCore/svg/SVGFEGaussianBlurElement.h +++ b/WebCore/svg/SVGFEGaussianBlurElement.h @@ -23,6 +23,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FEGaussianBlur.h" +#include "SVGAnimatedNumber.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { @@ -39,14 +40,15 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); static const AtomicString& stdDeviationXIdentifier(); static const AtomicString& stdDeviationYIdentifier(); + // Animated property declarations 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) + DECLARE_ANIMATED_NUMBER(StdDeviationX, stdDeviationX) + DECLARE_ANIMATED_NUMBER(StdDeviationY, stdDeviationY) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp index 1db8edb..e0ba7a6 100644 --- a/WebCore/svg/SVGFEImageElement.cpp +++ b/WebCore/svg/SVGFEImageElement.cpp @@ -131,7 +131,7 @@ void SVGFEImageElement::notifyFinished(CachedResource*) RenderSVGResource::markForLayoutAndParentResourceInvalidation(parent->renderer()); } -PassRefPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder*) +PassRefPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder*, Filter* filter) { if (!m_cachedImage && !m_targetImage) { Element* hrefElement = document()->getElementById(SVGURIReference::getTarget(href())); @@ -149,7 +149,7 @@ PassRefPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder*) SVGImageBufferTools::renderSubtreeToImageBuffer(m_targetImage.get(), renderer, contentTransformation); } - return FEImage::create(m_targetImage ? m_targetImage->copyImage() : m_cachedImage->image(), preserveAspectRatio()); + return FEImage::create(filter, m_targetImage ? m_targetImage->copyImage() : m_cachedImage->image(), preserveAspectRatio()); } void SVGFEImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const diff --git a/WebCore/svg/SVGFEImageElement.h b/WebCore/svg/SVGFEImageElement.h index 0b9c5d8..78ba8e3 100644 --- a/WebCore/svg/SVGFEImageElement.h +++ b/WebCore/svg/SVGFEImageElement.h @@ -53,7 +53,7 @@ private: virtual void notifyFinished(CachedResource*); virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); void requestImageResource(); diff --git a/WebCore/svg/SVGFELightElement.cpp b/WebCore/svg/SVGFELightElement.cpp index 7fed774..1fbe958 100644 --- a/WebCore/svg/SVGFELightElement.cpp +++ b/WebCore/svg/SVGFELightElement.cpp @@ -31,6 +31,18 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::azimuthAttr, Azimuth, azimuth) +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::elevationAttr, Elevation, elevation) +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::zAttr, Z, z) +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::pointsAtXAttr, PointsAtX, pointsAtX) +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::pointsAtYAttr, PointsAtY, pointsAtY) +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::pointsAtZAttr, PointsAtZ, pointsAtZ) +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::specularExponentAttr, SpecularExponent, specularExponent) +DEFINE_ANIMATED_NUMBER(SVGFELightElement, SVGNames::limitingConeAngleAttr, LimitingConeAngle, limitingConeAngle) + SVGFELightElement::SVGFELightElement(const QualifiedName& tagName, Document* document) : SVGElement(tagName, document) , m_specularExponent(1) diff --git a/WebCore/svg/SVGFELightElement.h b/WebCore/svg/SVGFELightElement.h index 986a0dc..2f6e687 100644 --- a/WebCore/svg/SVGFELightElement.h +++ b/WebCore/svg/SVGFELightElement.h @@ -24,7 +24,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "LightSource.h" -#include "SVGAnimatedPropertyMacros.h" +#include "SVGAnimatedNumber.h" #include "SVGElement.h" namespace WebCore { @@ -42,16 +42,17 @@ private: virtual void synchronizeProperty(const QualifiedName&); virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); - 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) + // Animated property declarations + DECLARE_ANIMATED_NUMBER(Azimuth, azimuth) + DECLARE_ANIMATED_NUMBER(Elevation, elevation) + DECLARE_ANIMATED_NUMBER(X, x) + DECLARE_ANIMATED_NUMBER(Y, y) + DECLARE_ANIMATED_NUMBER(Z, z) + DECLARE_ANIMATED_NUMBER(PointsAtX, pointsAtX) + DECLARE_ANIMATED_NUMBER(PointsAtY, pointsAtY) + DECLARE_ANIMATED_NUMBER(PointsAtZ, pointsAtZ) + DECLARE_ANIMATED_NUMBER(SpecularExponent, specularExponent) + DECLARE_ANIMATED_NUMBER(LimitingConeAngle, limitingConeAngle) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEMergeElement.cpp b/WebCore/svg/SVGFEMergeElement.cpp index 49a052e..bc6bed5 100644 --- a/WebCore/svg/SVGFEMergeElement.cpp +++ b/WebCore/svg/SVGFEMergeElement.cpp @@ -37,9 +37,9 @@ PassRefPtr<SVGFEMergeElement> SVGFEMergeElement::create(const QualifiedName& tag return adoptRef(new SVGFEMergeElement(tagName, document)); } -PassRefPtr<FilterEffect> SVGFEMergeElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEMergeElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { - RefPtr<FilterEffect> effect = FEMerge::create(); + RefPtr<FilterEffect> effect = FEMerge::create(filter); FilterEffectVector& mergeInputs = effect->inputEffects(); for (Node* n = firstChild(); n != 0; n = n->nextSibling()) { if (n->hasTagName(SVGNames::feMergeNodeTag)) { diff --git a/WebCore/svg/SVGFEMergeElement.h b/WebCore/svg/SVGFEMergeElement.h index da94ac7..2495a56 100644 --- a/WebCore/svg/SVGFEMergeElement.h +++ b/WebCore/svg/SVGFEMergeElement.h @@ -34,7 +34,7 @@ public: private: SVGFEMergeElement(const QualifiedName&, Document*); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEMorphologyElement.cpp b/WebCore/svg/SVGFEMorphologyElement.cpp index c7954b2..49c9e99 100644 --- a/WebCore/svg/SVGFEMorphologyElement.cpp +++ b/WebCore/svg/SVGFEMorphologyElement.cpp @@ -28,6 +28,10 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEMorphologyElement, SVGNames::radiusAttr, radiusXIdentifier(), RadiusX, radiusX) +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFEMorphologyElement, SVGNames::radiusAttr, radiusYIdentifier(), RadiusY, radiusY) + inline SVGFEMorphologyElement::SVGFEMorphologyElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m__operator(FEMORPHOLOGY_OPERATOR_ERODE) @@ -110,7 +114,7 @@ void SVGFEMorphologyElement::synchronizeProperty(const QualifiedName& attrName) } } -PassRefPtr<FilterEffect> SVGFEMorphologyElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEMorphologyElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); float xRadius = radiusX(); @@ -122,7 +126,7 @@ PassRefPtr<FilterEffect> SVGFEMorphologyElement::build(SVGFilterBuilder* filterB if (xRadius < 0 || yRadius < 0) return 0; - RefPtr<FilterEffect> effect = FEMorphology::create(static_cast<MorphologyOperatorType>(_operator()), xRadius, yRadius); + RefPtr<FilterEffect> effect = FEMorphology::create(filter, static_cast<MorphologyOperatorType>(_operator()), xRadius, yRadius); effect->inputEffects().append(input1); return effect.release(); } diff --git a/WebCore/svg/SVGFEMorphologyElement.h b/WebCore/svg/SVGFEMorphologyElement.h index 845294b..6f05d11 100644 --- a/WebCore/svg/SVGFEMorphologyElement.h +++ b/WebCore/svg/SVGFEMorphologyElement.h @@ -22,6 +22,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FEMorphology.h" +#include "SVGAnimatedNumber.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { @@ -38,15 +39,16 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); static const AtomicString& radiusXIdentifier(); static const AtomicString& radiusYIdentifier(); + // Animated property declarations DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEMorphologyElement, SVGNames::inAttr, String, In1, in1) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFEMorphologyElement, SVGNames::operatorAttr, int, _operator, _operator) - 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) + DECLARE_ANIMATED_NUMBER(RadiusX, radiusX) + DECLARE_ANIMATED_NUMBER(RadiusY, radiusY) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEOffsetElement.cpp b/WebCore/svg/SVGFEOffsetElement.cpp index 65523a5..e6e4bed 100644 --- a/WebCore/svg/SVGFEOffsetElement.cpp +++ b/WebCore/svg/SVGFEOffsetElement.cpp @@ -27,6 +27,10 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER(SVGFEOffsetElement, SVGNames::dxAttr, Dx, dx) +DEFINE_ANIMATED_NUMBER(SVGFEOffsetElement, SVGNames::dyAttr, Dy, dy) + inline SVGFEOffsetElement::SVGFEOffsetElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) { @@ -79,14 +83,14 @@ void SVGFEOffsetElement::synchronizeProperty(const QualifiedName& attrName) synchronizeIn1(); } -PassRefPtr<FilterEffect> SVGFEOffsetElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFEOffsetElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); if (!input1) return 0; - RefPtr<FilterEffect> effect = FEOffset::create(dx(), dy()); + RefPtr<FilterEffect> effect = FEOffset::create(filter, dx(), dy()); effect->inputEffects().append(input1); return effect.release(); } diff --git a/WebCore/svg/SVGFEOffsetElement.h b/WebCore/svg/SVGFEOffsetElement.h index 6f5e843..af63f61 100644 --- a/WebCore/svg/SVGFEOffsetElement.h +++ b/WebCore/svg/SVGFEOffsetElement.h @@ -23,6 +23,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FEOffset.h" +#include "SVGAnimatedNumber.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { @@ -37,11 +38,12 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); + // Animated property declarations 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) + DECLARE_ANIMATED_NUMBER(Dx, dx) + DECLARE_ANIMATED_NUMBER(Dy, dy) }; } // namespace WebCore diff --git a/WebCore/svg/SVGFESpecularLightingElement.cpp b/WebCore/svg/SVGFESpecularLightingElement.cpp index 548eb15..54db0bd 100644 --- a/WebCore/svg/SVGFESpecularLightingElement.cpp +++ b/WebCore/svg/SVGFESpecularLightingElement.cpp @@ -32,6 +32,13 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER(SVGFESpecularLightingElement, SVGNames::specularConstantAttr, SpecularConstant, specularConstant) +DEFINE_ANIMATED_NUMBER(SVGFESpecularLightingElement, SVGNames::specularExponentAttr, SpecularExponent, specularExponent) +DEFINE_ANIMATED_NUMBER(SVGFESpecularLightingElement, SVGNames::surfaceScaleAttr, SurfaceScale, surfaceScale) +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFESpecularLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthXIdentifier(), KernelUnitLengthX, kernelUnitLengthX) +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFESpecularLightingElement, SVGNames::kernelUnitLengthAttr, kernelUnitLengthYIdentifier(), KernelUnitLengthY, kernelUnitLengthY) + inline SVGFESpecularLightingElement::SVGFESpecularLightingElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m_specularConstant(1) @@ -120,7 +127,7 @@ PassRefPtr<LightSource> SVGFESpecularLightingElement::findLights() const return 0; } -PassRefPtr<FilterEffect> SVGFESpecularLightingElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFESpecularLightingElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); @@ -131,7 +138,7 @@ PassRefPtr<FilterEffect> SVGFESpecularLightingElement::build(SVGFilterBuilder* f Color color = filterStyle->svgStyle()->lightingColor(); - RefPtr<FilterEffect> effect = FESpecularLighting::create(color, surfaceScale(), specularConstant(), + RefPtr<FilterEffect> effect = FESpecularLighting::create(filter, color, surfaceScale(), specularConstant(), specularExponent(), kernelUnitLengthX(), kernelUnitLengthY(), findLights()); effect->inputEffects().append(input1); return effect.release(); diff --git a/WebCore/svg/SVGFESpecularLightingElement.h b/WebCore/svg/SVGFESpecularLightingElement.h index c5d3ac4..c68168c 100644 --- a/WebCore/svg/SVGFESpecularLightingElement.h +++ b/WebCore/svg/SVGFESpecularLightingElement.h @@ -24,6 +24,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FESpecularLighting.h" +#include "SVGAnimatedNumber.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { @@ -37,17 +38,18 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); static const AtomicString& kernelUnitLengthXIdentifier(); static const AtomicString& kernelUnitLengthYIdentifier(); + // Animated property declarations 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) + DECLARE_ANIMATED_NUMBER(SpecularConstant, specularConstant) + DECLARE_ANIMATED_NUMBER(SpecularExponent, specularExponent) + DECLARE_ANIMATED_NUMBER(SurfaceScale, surfaceScale) + DECLARE_ANIMATED_NUMBER(KernelUnitLengthX, kernelUnitLengthX) + DECLARE_ANIMATED_NUMBER(KernelUnitLengthY, kernelUnitLengthY) PassRefPtr<LightSource> findLights() const; }; diff --git a/WebCore/svg/SVGFETileElement.cpp b/WebCore/svg/SVGFETileElement.cpp index 590b6b8..9d00a54 100644 --- a/WebCore/svg/SVGFETileElement.cpp +++ b/WebCore/svg/SVGFETileElement.cpp @@ -63,14 +63,14 @@ void SVGFETileElement::synchronizeProperty(const QualifiedName& attrName) synchronizeIn1(); } -PassRefPtr<FilterEffect> SVGFETileElement::build(SVGFilterBuilder* filterBuilder) +PassRefPtr<FilterEffect> SVGFETileElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); if (!input1) return 0; - RefPtr<FilterEffect> effect = FETile::create(); + RefPtr<FilterEffect> effect = FETile::create(filter); effect->inputEffects().append(input1); return effect.release(); } diff --git a/WebCore/svg/SVGFETileElement.h b/WebCore/svg/SVGFETileElement.h index b0c97d2..b4f3380 100644 --- a/WebCore/svg/SVGFETileElement.h +++ b/WebCore/svg/SVGFETileElement.h @@ -37,7 +37,7 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFETileElement, SVGNames::inAttr, String, In1, in1) }; diff --git a/WebCore/svg/SVGFETurbulenceElement.cpp b/WebCore/svg/SVGFETurbulenceElement.cpp index 53b8fb0..401929b 100644 --- a/WebCore/svg/SVGFETurbulenceElement.cpp +++ b/WebCore/svg/SVGFETurbulenceElement.cpp @@ -28,6 +28,11 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFETurbulenceElement, SVGNames::baseFrequencyAttr, baseFrequencyXIdentifier(), BaseFrequencyX, baseFrequencyX) +DEFINE_ANIMATED_NUMBER_MULTIPLE_WRAPPERS(SVGFETurbulenceElement, SVGNames::baseFrequencyAttr, baseFrequencyYIdentifier(), BaseFrequencyY, baseFrequencyY) +DEFINE_ANIMATED_NUMBER(SVGFETurbulenceElement, SVGNames::seedAttr, Seed, seed) + inline SVGFETurbulenceElement::SVGFETurbulenceElement(const QualifiedName& tagName, Document* document) : SVGFilterPrimitiveStandardAttributes(tagName, document) , m_numOctaves(1) @@ -119,12 +124,12 @@ void SVGFETurbulenceElement::synchronizeProperty(const QualifiedName& attrName) synchronizeNumOctaves(); } -PassRefPtr<FilterEffect> SVGFETurbulenceElement::build(SVGFilterBuilder*) +PassRefPtr<FilterEffect> SVGFETurbulenceElement::build(SVGFilterBuilder*, Filter* filter) { if (baseFrequencyX() < 0 || baseFrequencyY() < 0) return 0; - return FETurbulence::create(static_cast<TurbulanceType>(type()), baseFrequencyX(), + return FETurbulence::create(filter, static_cast<TurbulanceType>(type()), baseFrequencyX(), baseFrequencyY(), numOctaves(), seed(), stitchTiles() == SVG_STITCHTYPE_STITCH); } diff --git a/WebCore/svg/SVGFETurbulenceElement.h b/WebCore/svg/SVGFETurbulenceElement.h index 5c41fdd..6df01b1 100644 --- a/WebCore/svg/SVGFETurbulenceElement.h +++ b/WebCore/svg/SVGFETurbulenceElement.h @@ -23,6 +23,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "FETurbulence.h" +#include "SVGAnimatedNumber.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { @@ -43,15 +44,16 @@ private: virtual void parseMappedAttribute(Attribute*); virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); static const AtomicString& baseFrequencyXIdentifier(); static const AtomicString& baseFrequencyYIdentifier(); - 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) + // Animated property declarations + DECLARE_ANIMATED_NUMBER(BaseFrequencyX, baseFrequencyX) + DECLARE_ANIMATED_NUMBER(BaseFrequencyY, baseFrequencyY) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFETurbulenceElement, SVGNames::numOctavesAttr, long, NumOctaves, numOctaves) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFETurbulenceElement, SVGNames::seedAttr, float, Seed, seed) + DECLARE_ANIMATED_NUMBER(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 323dd4c..3e370e5 100644 --- a/WebCore/svg/SVGFilterElement.cpp +++ b/WebCore/svg/SVGFilterElement.cpp @@ -39,6 +39,12 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGFilterElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGFilterElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH(SVGFilterElement, SVGNames::widthAttr, Width, width) +DEFINE_ANIMATED_LENGTH(SVGFilterElement, SVGNames::heightAttr, Height, height) + inline SVGFilterElement::SVGFilterElement(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) , SVGURIReference() diff --git a/WebCore/svg/SVGFilterElement.h b/WebCore/svg/SVGFilterElement.h index 4efb958..deda48a 100644 --- a/WebCore/svg/SVGFilterElement.h +++ b/WebCore/svg/SVGFilterElement.h @@ -61,12 +61,13 @@ private: static const AtomicString& filterResXIdentifier(); static const AtomicString& filterResYIdentifier(); + // Animated property declarations DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFilterElement, SVGNames::filterUnitsAttr, int, FilterUnits, filterUnits) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFilterElement, SVGNames::primitiveUnitsAttr, int, PrimitiveUnits, primitiveUnits) - DECLARE_ANIMATED_PROPERTY_NEW(SVGFilterElement, SVGNames::xAttr, SVGLength, X, x) - DECLARE_ANIMATED_PROPERTY_NEW(SVGFilterElement, SVGNames::yAttr, SVGLength, Y, y) - DECLARE_ANIMATED_PROPERTY_NEW(SVGFilterElement, SVGNames::widthAttr, SVGLength, Width, width) - DECLARE_ANIMATED_PROPERTY_NEW(SVGFilterElement, SVGNames::heightAttr, SVGLength, Height, height) + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) + DECLARE_ANIMATED_LENGTH(Width, width) + DECLARE_ANIMATED_LENGTH(Height, height) DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFilterElement, SVGNames::filterResAttr, filterResXIdentifier(), long, FilterResX, filterResX) DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGFilterElement, SVGNames::filterResAttr, filterResYIdentifier(), long, FilterResY, filterResY) diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp index c2c443e..e612319 100644 --- a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp +++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp @@ -34,6 +34,12 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::widthAttr, Width, width) +DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::heightAttr, Height, height) + SVGFilterPrimitiveStandardAttributes::SVGFilterPrimitiveStandardAttributes(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) , m_x(LengthModeWidth, "0%") diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h index 6ac1962..2fb2dc1 100644 --- a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h +++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h @@ -40,7 +40,7 @@ class SVGFilterPrimitiveStandardAttributes : public SVGStyledElement { public: void setStandardAttributes(bool, FilterEffect*) const; - virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*) = 0; + virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter* filter) = 0; protected: SVGFilterPrimitiveStandardAttributes(const QualifiedName&, Document*); @@ -62,10 +62,11 @@ private: virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - DECLARE_ANIMATED_PROPERTY_NEW(SVGFilterPrimitiveStandardAttributes, SVGNames::xAttr, SVGLength, X, x) - 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) + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) + DECLARE_ANIMATED_LENGTH(Width, width) + DECLARE_ANIMATED_LENGTH(Height, height) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGFilterPrimitiveStandardAttributes, SVGNames::resultAttr, String, Result, result) }; diff --git a/WebCore/svg/SVGFont.cpp b/WebCore/svg/SVGFont.cpp index 898c259..ffa01f2 100644 --- a/WebCore/svg/SVGFont.cpp +++ b/WebCore/svg/SVGFont.cpp @@ -534,12 +534,9 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run, Path glyphPath = identifier.pathData; glyphPath.transform(glyphPathTransform); - context->beginPath(); - context->addPath(glyphPath); - RenderStyle* style = run.referencingRenderObject() ? run.referencingRenderObject()->style() : 0; if (activePaintingResource->applyResource(run.referencingRenderObject(), style, context, resourceMode)) - activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode); + activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode, &glyphPath); context->restore(); } diff --git a/WebCore/svg/SVGFontFaceElement.cpp b/WebCore/svg/SVGFontFaceElement.cpp index 0c74d08..515ce04 100644 --- a/WebCore/svg/SVGFontFaceElement.cpp +++ b/WebCore/svg/SVGFontFaceElement.cpp @@ -315,6 +315,7 @@ void SVGFontFaceElement::insertedIntoDocument() { SVGElement::insertedIntoDocument(); document()->mappedElementSheet()->append(m_fontFaceRule); + m_fontFaceRule->setParent(document()->mappedElementSheet()); rebuildFontFace(); } diff --git a/WebCore/svg/SVGForeignObjectElement.cpp b/WebCore/svg/SVGForeignObjectElement.cpp index d21172a..c620910 100644 --- a/WebCore/svg/SVGForeignObjectElement.cpp +++ b/WebCore/svg/SVGForeignObjectElement.cpp @@ -33,7 +33,13 @@ namespace WebCore { -SVGForeignObjectElement::SVGForeignObjectElement(const QualifiedName& tagName, Document* document) +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGForeignObjectElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGForeignObjectElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH(SVGForeignObjectElement, SVGNames::widthAttr, Width, width) +DEFINE_ANIMATED_LENGTH(SVGForeignObjectElement, SVGNames::heightAttr, Height, height) + +inline SVGForeignObjectElement::SVGForeignObjectElement(const QualifiedName& tagName, Document* document) : SVGStyledTransformableElement(tagName, document) , m_x(LengthModeWidth) , m_y(LengthModeHeight) @@ -111,6 +117,7 @@ void SVGForeignObjectElement::synchronizeProperty(const QualifiedName& attrName) synchronizeHeight(); synchronizeExternalResourcesRequired(); synchronizeHref(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -124,6 +131,8 @@ void SVGForeignObjectElement::synchronizeProperty(const QualifiedName& attrName) synchronizeHeight(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } RenderObject* SVGForeignObjectElement::createRenderer(RenderArena* arena, RenderStyle*) diff --git a/WebCore/svg/SVGForeignObjectElement.h b/WebCore/svg/SVGForeignObjectElement.h index ee17c19..925f181 100644 --- a/WebCore/svg/SVGForeignObjectElement.h +++ b/WebCore/svg/SVGForeignObjectElement.h @@ -30,39 +30,39 @@ #include "SVGExternalResourcesRequired.h" namespace WebCore { - class SVGLength; - class SVGForeignObjectElement : public SVGStyledTransformableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired { - public: - static PassRefPtr<SVGForeignObjectElement> create(const QualifiedName&, Document*); +class SVGForeignObjectElement : public SVGStyledTransformableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired { +public: + static PassRefPtr<SVGForeignObjectElement> create(const QualifiedName&, Document*); - private: - SVGForeignObjectElement(const QualifiedName&, Document*); +private: + SVGForeignObjectElement(const QualifiedName&, Document*); - virtual bool isValid() const { return SVGTests::isValid(); } - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual bool isValid() const { return SVGTests::isValid(); } + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual bool childShouldCreateRenderer(Node*) const; - virtual RenderObject* createRenderer(RenderArena* arena, RenderStyle* style); + virtual bool childShouldCreateRenderer(Node*) const; + virtual RenderObject* createRenderer(RenderArena* arena, RenderStyle* style); - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - DECLARE_ANIMATED_PROPERTY_NEW(SVGForeignObjectElement, SVGNames::xAttr, SVGLength, X, x) - DECLARE_ANIMATED_PROPERTY_NEW(SVGForeignObjectElement, SVGNames::yAttr, SVGLength, Y, y) - DECLARE_ANIMATED_PROPERTY_NEW(SVGForeignObjectElement, SVGNames::widthAttr, SVGLength, Width, width) - DECLARE_ANIMATED_PROPERTY_NEW(SVGForeignObjectElement, SVGNames::heightAttr, SVGLength, Height, height) + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) + DECLARE_ANIMATED_LENGTH(Width, width) + DECLARE_ANIMATED_LENGTH(Height, height) - // SVGURIReference - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGForeignObjectElement, XLinkNames::hrefAttr, String, Href, href) + // SVGURIReference + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGForeignObjectElement, XLinkNames::hrefAttr, String, Href, href) - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGForeignObjectElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - }; + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGForeignObjectElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGGElement.cpp b/WebCore/svg/SVGGElement.cpp index b6b4a70..c58eefa 100644 --- a/WebCore/svg/SVGGElement.cpp +++ b/WebCore/svg/SVGGElement.cpp @@ -77,8 +77,16 @@ void SVGGElement::synchronizeProperty(const QualifiedName& attrName) { SVGStyledTransformableElement::synchronizeProperty(attrName); - if (attrName == anyQName() || SVGExternalResourcesRequired::isKnownAttribute(attrName)) + if (attrName == anyQName()) { synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); + return; + } + + if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) + synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } RenderObject* SVGGElement::createRenderer(RenderArena* arena, RenderStyle* style) diff --git a/WebCore/svg/SVGGradientElement.cpp b/WebCore/svg/SVGGradientElement.cpp index 337944b..88c0fba 100644 --- a/WebCore/svg/SVGGradientElement.cpp +++ b/WebCore/svg/SVGGradientElement.cpp @@ -38,6 +38,9 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_TRANSFORM_LIST(SVGGradientElement, SVGNames::gradientTransformAttr, GradientTransform, gradientTransform) + SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) @@ -57,7 +60,7 @@ void SVGGradientElement::parseMappedAttribute(Attribute* attr) newList.clear(); detachAnimatedGradientTransformListWrappers(newList.size()); - gradientTransformBaseValue() = newList; + setGradientTransformBaseValue(newList); } else if (attr->name() == SVGNames::spreadMethodAttr) { if (attr->value() == "reflect") setSpreadMethodBaseValue(SpreadMethodReflect); diff --git a/WebCore/svg/SVGGradientElement.h b/WebCore/svg/SVGGradientElement.h index 1b28e22..606a983 100644 --- a/WebCore/svg/SVGGradientElement.h +++ b/WebCore/svg/SVGGradientElement.h @@ -27,39 +27,39 @@ #include "SVGAnimatedTransformList.h" #include "SVGExternalResourcesRequired.h" #include "SVGStyledElement.h" -#include "SVGTransformList.h" #include "SVGURIReference.h" namespace WebCore { - class SVGGradientElement : public SVGStyledElement, - public SVGURIReference, - public SVGExternalResourcesRequired { - public: - Vector<Gradient::ColorStop> buildStops(); +class SVGGradientElement : public SVGStyledElement, + public SVGURIReference, + public SVGExternalResourcesRequired { +public: + Vector<Gradient::ColorStop> buildStops(); - protected: - SVGGradientElement(const QualifiedName&, Document*); +protected: + SVGGradientElement(const QualifiedName&, Document*); - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - private: - virtual bool needsPendingResourceHandling() const { return false; } +private: + virtual bool needsPendingResourceHandling() const { return false; } - virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); + virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, SVGNames::spreadMethodAttr, int, SpreadMethod, spreadMethod) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, SVGNames::gradientUnitsAttr, int, GradientUnits, gradientUnits) - DECLARE_ANIMATED_TRANSFORM_LIST_PROPERTY_NEW(SVGGradientElement, SVGNames::gradientTransformAttr, SVGTransformList, GradientTransform, gradientTransform) + // Animated property declarations + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, SVGNames::spreadMethodAttr, int, SpreadMethod, spreadMethod) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, SVGNames::gradientUnitsAttr, int, GradientUnits, gradientUnits) + DECLARE_ANIMATED_TRANSFORM_LIST(GradientTransform, gradientTransform) - // SVGURIReference - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, XLinkNames::hrefAttr, String, Href, href) + // SVGURIReference + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, XLinkNames::hrefAttr, String, Href, href) - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - }; + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGGradientElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp index 3eb64db..f86e90c 100644 --- a/WebCore/svg/SVGImageElement.cpp +++ b/WebCore/svg/SVGImageElement.cpp @@ -37,6 +37,12 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::widthAttr, Width, width) +DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::heightAttr, Height, height) + inline SVGImageElement::SVGImageElement(const QualifiedName& tagName, Document* document) : SVGStyledTransformableElement(tagName, document) , m_x(LengthModeWidth) @@ -135,6 +141,7 @@ void SVGImageElement::synchronizeProperty(const QualifiedName& attrName) synchronizePreserveAspectRatio(); synchronizeExternalResourcesRequired(); synchronizeHref(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -152,6 +159,8 @@ void SVGImageElement::synchronizeProperty(const QualifiedName& attrName) synchronizeExternalResourcesRequired(); else if (SVGURIReference::isKnownAttribute(attrName)) synchronizeHref(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } bool SVGImageElement::selfHasRelativeLengths() const diff --git a/WebCore/svg/SVGImageElement.h b/WebCore/svg/SVGImageElement.h index b9f3865..af4d84e 100644 --- a/WebCore/svg/SVGImageElement.h +++ b/WebCore/svg/SVGImageElement.h @@ -34,52 +34,51 @@ namespace WebCore { - class SVGLength; - - class SVGImageElement : public SVGStyledTransformableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired, - public SVGURIReference { - public: - static PassRefPtr<SVGImageElement> create(const QualifiedName&, Document*); - - private: - SVGImageElement(const QualifiedName&, Document*); - - virtual bool isValid() const { return SVGTests::isValid(); } - - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); - - virtual void attach(); - virtual void insertedIntoDocument(); - - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); +class SVGImageElement : public SVGStyledTransformableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired, + public SVGURIReference { +public: + static PassRefPtr<SVGImageElement> create(const QualifiedName&, Document*); + +private: + SVGImageElement(const QualifiedName&, Document*); + + virtual bool isValid() const { return SVGTests::isValid(); } + + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); + + virtual void attach(); + virtual void insertedIntoDocument(); + + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - virtual const QualifiedName& imageSourceAttributeName() const; - virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; + virtual const QualifiedName& imageSourceAttributeName() const; + virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; - virtual bool haveLoadedRequiredResources(); + virtual bool haveLoadedRequiredResources(); - virtual bool selfHasRelativeLengths() const; - virtual void willMoveToNewOwnerDocument(); + virtual bool selfHasRelativeLengths() const; + virtual void willMoveToNewOwnerDocument(); - DECLARE_ANIMATED_PROPERTY_NEW(SVGImageElement, SVGNames::xAttr, SVGLength, X, x) - 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_NEW(SVGImageElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) + DECLARE_ANIMATED_LENGTH(Width, width) + DECLARE_ANIMATED_LENGTH(Height, height) + DECLARE_ANIMATED_PROPERTY_NEW(SVGImageElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) - // SVGURIReference - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGImageElement, XLinkNames::hrefAttr, String, Href, href) + // SVGURIReference + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGImageElement, XLinkNames::hrefAttr, String, Href, href) - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGImageElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGImageElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - SVGImageLoader m_imageLoader; - }; + SVGImageLoader m_imageLoader; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGLength.h b/WebCore/svg/SVGLength.h index ccd22ee..a256ed3 100644 --- a/WebCore/svg/SVGLength.h +++ b/WebCore/svg/SVGLength.h @@ -23,7 +23,7 @@ #if ENABLE(SVG) #include "ExceptionCode.h" -#include <wtf/text/WTFString.h> +#include "SVGPropertyTraits.h" namespace WebCore { @@ -118,6 +118,13 @@ private: unsigned int m_unit; }; +template<> +struct SVGPropertyTraits<SVGLength> { + static SVGLength initialValue() { return SVGLength(); } + static String toString(const SVGLength& type) { return type.valueAsString(); } +}; + + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGLengthList.cpp b/WebCore/svg/SVGLengthList.cpp index a05ea4b..d2e8fbb 100644 --- a/WebCore/svg/SVGLengthList.cpp +++ b/WebCore/svg/SVGLengthList.cpp @@ -61,7 +61,7 @@ String SVGLengthList::valueAsString() const unsigned size = this->size(); for (unsigned i = 0; i < size; ++i) { if (i > 0) - builder.append(", "); + builder.append(' '); builder.append(at(i).valueAsString()); } diff --git a/WebCore/svg/SVGLengthList.h b/WebCore/svg/SVGLengthList.h index 8b08557..865f7bc 100644 --- a/WebCore/svg/SVGLengthList.h +++ b/WebCore/svg/SVGLengthList.h @@ -35,6 +35,14 @@ public: String valueAsString() const; }; +template<> +struct SVGPropertyTraits<SVGLengthList> { + typedef SVGLength ListItemType; + + static SVGLengthList initialValue() { return SVGLengthList(); } + static String toString(const SVGLengthList& type) { return type.valueAsString(); } +}; + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGLengthList.idl b/WebCore/svg/SVGLengthList.idl index a5771d2..e23f8af 100644 --- a/WebCore/svg/SVGLengthList.idl +++ b/WebCore/svg/SVGLengthList.idl @@ -31,17 +31,17 @@ module svg { void clear() raises(DOMException); - SVGLength initialize(in SVGLength item) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGLength initialize(in SVGLength item) raises(DOMException, SVGException); - SVGLength getItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGLength getItem(in unsigned long index) raises(DOMException); - SVGLength insertItemBefore(in SVGLength item, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGLength insertItemBefore(in SVGLength item, in unsigned long index) raises(DOMException, SVGException); - SVGLength replaceItem(in SVGLength item, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGLength replaceItem(in SVGLength item, in unsigned long index) raises(DOMException, SVGException); - SVGLength removeItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGLength removeItem(in unsigned long index) raises(DOMException); - SVGLength appendItem(in SVGLength item) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGLength appendItem(in SVGLength item) raises(DOMException, SVGException); }; diff --git a/WebCore/svg/SVGLineElement.cpp b/WebCore/svg/SVGLineElement.cpp index ac461fe..2758b77 100644 --- a/WebCore/svg/SVGLineElement.cpp +++ b/WebCore/svg/SVGLineElement.cpp @@ -32,6 +32,12 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::x1Attr, X1, x1) +DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::y1Attr, Y1, y1) +DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::x2Attr, X2, x2) +DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::y2Attr, Y2, y2) + inline SVGLineElement::SVGLineElement(const QualifiedName& tagName, Document* document) : SVGStyledTransformableElement(tagName, document) , m_x1(LengthModeWidth) @@ -113,6 +119,7 @@ void SVGLineElement::synchronizeProperty(const QualifiedName& attrName) synchronizeX2(); synchronizeY2(); synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -126,6 +133,8 @@ void SVGLineElement::synchronizeProperty(const QualifiedName& attrName) synchronizeY2(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGLineElement::toPathData(Path& path) const diff --git a/WebCore/svg/SVGLineElement.h b/WebCore/svg/SVGLineElement.h index 4e876e1..614675f 100644 --- a/WebCore/svg/SVGLineElement.h +++ b/WebCore/svg/SVGLineElement.h @@ -31,38 +31,37 @@ namespace WebCore { - class SVGLength; +class SVGLineElement : public SVGStyledTransformableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired { +public: + static PassRefPtr<SVGLineElement> create(const QualifiedName&, Document*); - class SVGLineElement : public SVGStyledTransformableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired { - public: - static PassRefPtr<SVGLineElement> create(const QualifiedName&, Document*); +private: + SVGLineElement(const QualifiedName&, Document*); + + virtual bool isValid() const { return SVGTests::isValid(); } - private: - SVGLineElement(const QualifiedName&, Document*); - - virtual bool isValid() const { return SVGTests::isValid(); } + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void toPathData(Path&) const; - virtual void toPathData(Path&) const; + virtual bool supportsMarkers() const { return true; } - virtual bool supportsMarkers() const { return true; } + virtual bool selfHasRelativeLengths() const; - virtual bool selfHasRelativeLengths() const; + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X1, x1) + DECLARE_ANIMATED_LENGTH(Y1, y1) + DECLARE_ANIMATED_LENGTH(X2, x2) + DECLARE_ANIMATED_LENGTH(Y2, y2) - DECLARE_ANIMATED_PROPERTY_NEW(SVGLineElement, SVGNames::x1Attr, SVGLength, X1, x1) - DECLARE_ANIMATED_PROPERTY_NEW(SVGLineElement, SVGNames::y1Attr, SVGLength, Y1, y1) - DECLARE_ANIMATED_PROPERTY_NEW(SVGLineElement, SVGNames::x2Attr, SVGLength, X2, x2) - DECLARE_ANIMATED_PROPERTY_NEW(SVGLineElement, SVGNames::y2Attr, SVGLength, Y2, y2) - - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGLineElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - }; + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGLineElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGLinearGradientElement.cpp b/WebCore/svg/SVGLinearGradientElement.cpp index fa3e40c..5bece06 100644 --- a/WebCore/svg/SVGLinearGradientElement.cpp +++ b/WebCore/svg/SVGLinearGradientElement.cpp @@ -39,6 +39,12 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGLinearGradientElement, SVGNames::x1Attr, X1, x1) +DEFINE_ANIMATED_LENGTH(SVGLinearGradientElement, SVGNames::y1Attr, Y1, y1) +DEFINE_ANIMATED_LENGTH(SVGLinearGradientElement, SVGNames::x2Attr, X2, x2) +DEFINE_ANIMATED_LENGTH(SVGLinearGradientElement, SVGNames::y2Attr, Y2, y2) + inline SVGLinearGradientElement::SVGLinearGradientElement(const QualifiedName& tagName, Document* document) : SVGGradientElement(tagName, document) , m_x1(LengthModeWidth) diff --git a/WebCore/svg/SVGLinearGradientElement.h b/WebCore/svg/SVGLinearGradientElement.h index 4ebe9f6..6cf4e0c 100644 --- a/WebCore/svg/SVGLinearGradientElement.h +++ b/WebCore/svg/SVGLinearGradientElement.h @@ -28,32 +28,32 @@ namespace WebCore { - struct LinearGradientAttributes; - class SVGLength; +struct LinearGradientAttributes; - class SVGLinearGradientElement : public SVGGradientElement { - public: - static PassRefPtr<SVGLinearGradientElement> create(const QualifiedName&, Document*); +class SVGLinearGradientElement : public SVGGradientElement { +public: + static PassRefPtr<SVGLinearGradientElement> create(const QualifiedName&, Document*); - void collectGradientAttributes(LinearGradientAttributes&); - void calculateStartEndPoints(const LinearGradientAttributes&, FloatPoint& startPoint, FloatPoint& endPoint); + void collectGradientAttributes(LinearGradientAttributes&); + void calculateStartEndPoints(const LinearGradientAttributes&, FloatPoint& startPoint, FloatPoint& endPoint); - private: - SVGLinearGradientElement(const QualifiedName&, Document*); +private: + SVGLinearGradientElement(const QualifiedName&, Document*); - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - DECLARE_ANIMATED_PROPERTY_NEW(SVGLinearGradientElement, SVGNames::x1Attr, SVGLength, X1, x1) - DECLARE_ANIMATED_PROPERTY_NEW(SVGLinearGradientElement, SVGNames::y1Attr, SVGLength, Y1, y1) - DECLARE_ANIMATED_PROPERTY_NEW(SVGLinearGradientElement, SVGNames::x2Attr, SVGLength, X2, x2) - DECLARE_ANIMATED_PROPERTY_NEW(SVGLinearGradientElement, SVGNames::y2Attr, SVGLength, Y2, y2) - }; + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X1, x1) + DECLARE_ANIMATED_LENGTH(Y1, y1) + DECLARE_ANIMATED_LENGTH(X2, x2) + DECLARE_ANIMATED_LENGTH(Y2, y2) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGList.h b/WebCore/svg/SVGList.h deleted file mode 100644 index 6ae5191..0000000 --- a/WebCore/svg/SVGList.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * - * 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 SVGList_h -#define SVGList_h - -#if ENABLE(SVG) -#include "ExceptionCode.h" -#include "SVGListTraits.h" - -#include <wtf/RefCounted.h> -#include <wtf/PassRefPtr.h> -#include <wtf/Vector.h> - -namespace WebCore { - - class QualifiedName; - - template<typename Item> - struct SVGListTypeOperations { - static Item nullItem() - { - return SVGListTraits<UsesDefaultInitializer<Item>::value, Item>::nullItem(); - } - static bool isNull(const Item& it) - { - return SVGListTraits<UsesDefaultInitializer<Item>::value, Item>::isNull(it); - } - }; - - template<typename Item> - class SVGList : public RefCounted<SVGList<Item> > { - private: - typedef SVGListTypeOperations<Item> TypeOperations; - - public: - virtual ~SVGList() { } - - const QualifiedName& associatedAttributeName() const { return m_associatedAttributeName; } - - unsigned int numberOfItems() const { return m_vector.size(); } - void clear(ExceptionCode &) { m_vector.clear(); } - - Item initialize(Item newItem, ExceptionCode& ec) - { - if (TypeOperations::isNull(newItem)) { - ec = TYPE_MISMATCH_ERR; - return TypeOperations::nullItem(); - } - clear(ec); - return appendItem(newItem, ec); - } - - Item getFirst() const - { - ExceptionCode ec = 0; - return getItem(0, ec); - } - - Item getLast() const - { - ExceptionCode ec = 0; - return getItem(m_vector.size() - 1, ec); - } - - Item getItem(unsigned int index, ExceptionCode& ec) - { - if (index >= m_vector.size()) { - ec = INDEX_SIZE_ERR; - return TypeOperations::nullItem(); - } - - return m_vector.at(index); - } - - const Item getItem(unsigned int index, ExceptionCode& ec) const - { - if (index >= m_vector.size()) { - ec = INDEX_SIZE_ERR; - return TypeOperations::nullItem(); - } - - return m_vector[index]; - } - - Item insertItemBefore(Item newItem, unsigned int index, ExceptionCode& ec) - { - if (TypeOperations::isNull(newItem)) { - ec = TYPE_MISMATCH_ERR; - return TypeOperations::nullItem(); - } - - if (index < m_vector.size()) { - m_vector.insert(index, newItem); - } else { - m_vector.append(newItem); - } - return newItem; - } - - Item replaceItem(Item newItem, unsigned int index, ExceptionCode& ec) - { - if (index >= m_vector.size()) { - ec = INDEX_SIZE_ERR; - return TypeOperations::nullItem(); - } - - if (TypeOperations::isNull(newItem)) { - ec = TYPE_MISMATCH_ERR; - return TypeOperations::nullItem(); - } - - m_vector[index] = newItem; - return newItem; - } - - Item removeItem(unsigned int index, ExceptionCode& ec) - { - if (index >= m_vector.size()) { - ec = INDEX_SIZE_ERR; - return TypeOperations::nullItem(); - } - - Item item = m_vector[index]; - m_vector.remove(index); - return item; - } - - Item appendItem(Item newItem, ExceptionCode& ec) - { - if (TypeOperations::isNull(newItem)) { - ec = TYPE_MISMATCH_ERR; - return TypeOperations::nullItem(); - } - - m_vector.append(newItem); - return newItem; - } - - protected: - SVGList(const QualifiedName& attributeName) - : m_associatedAttributeName(attributeName) - { - } - - private: - Vector<Item> m_vector; - const QualifiedName& m_associatedAttributeName; - }; - - template<typename Item> - class SVGPODListItem : public RefCounted<SVGPODListItem<Item> > { - public: - static PassRefPtr<SVGPODListItem> create() { return adoptRef(new SVGPODListItem); } - static PassRefPtr<SVGPODListItem> copy(const Item& item) { return adoptRef(new SVGPODListItem(item)); } - - operator Item&() { return m_item; } - operator const Item&() const { return m_item; } - - // Updating facilities, used by JSSVGPODTypeWrapperCreatorForList - Item value() const { return m_item; } - void setValue(const Item& newItem) { m_item = newItem; } - - private: - SVGPODListItem() : m_item() { } - SVGPODListItem(const Item& item) : RefCounted<SVGPODListItem<Item> >(), m_item(item) { } - - Item m_item; - }; - - template<typename Item> - class SVGPODList : public SVGList<RefPtr<SVGPODListItem<Item> > > { - public: - Item initialize(Item newItem, ExceptionCode& ec) - { - SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::initialize(SVGPODListItem<Item>::copy(newItem), ec).get()); - if (!ptr) - return Item(); - - return static_cast<const Item&>(*ptr); - } - - Item getFirst() const - { - SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::getFirst().get()); - if (!ptr) - return Item(); - - return static_cast<const Item&>(*ptr); - } - - Item getLast() const - { - SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::getLast().get()); - if (!ptr) - return Item(); - - return static_cast<const Item&>(*ptr); - } - - Item getItem(unsigned int index, ExceptionCode& ec) - { - SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::getItem(index, ec).get()); - if (!ptr) - return Item(); - - return static_cast<const Item&>(*ptr); - } - - const Item getItem(unsigned int index, ExceptionCode& ec) const - { - SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::getItem(index, ec).get()); - if (!ptr) - return Item(); - - return static_cast<const Item&>(*ptr); - } - - Item insertItemBefore(Item newItem, unsigned int index, ExceptionCode& ec) - { - SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::insertItemBefore(SVGPODListItem<Item>::copy(newItem), index, ec).get()); - if (!ptr) - return Item(); - - return static_cast<const Item&>(*ptr); - } - - Item replaceItem(Item newItem, unsigned int index, ExceptionCode& ec) - { - SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::replaceItem(SVGPODListItem<Item>::copy(newItem), index, ec).get()); - if (!ptr) - return Item(); - - return static_cast<const Item&>(*ptr); - } - - Item removeItem(unsigned int index, ExceptionCode& ec) - { - SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::removeItem(index, ec).get()); - if (!ptr) - return Item(); - - return static_cast<const Item&>(*ptr); - } - - Item appendItem(Item newItem, ExceptionCode& ec) - { - SVGPODListItem<Item>* ptr(SVGList<RefPtr<SVGPODListItem<Item> > >::appendItem(SVGPODListItem<Item>::copy(newItem), ec).get()); - if (!ptr) - return Item(); - - return static_cast<const Item&>(*ptr); - } - - protected: - SVGPODList(const QualifiedName& attributeName) - : SVGList<RefPtr<SVGPODListItem<Item> > >(attributeName) { } - }; - -} // namespace WebCore - -#endif // ENABLE(SVG) -#endif // SVGList_h diff --git a/WebCore/svg/SVGListTraits.h b/WebCore/svg/SVGListTraits.h deleted file mode 100644 index 0f60c75..0000000 --- a/WebCore/svg/SVGListTraits.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2006 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * 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 SVGListTraits_h -#define SVGListTraits_h - -#if ENABLE(SVG) - -#include <wtf/RefPtr.h> - -namespace WebCore { - - template<typename Item> struct UsesDefaultInitializer { static const bool value = true; }; - template<> struct UsesDefaultInitializer<double> { static const bool value = false; }; - template<> struct UsesDefaultInitializer<float> { static const bool value = false; }; - - template<bool usesDefaultInitializer, typename Item> - struct SVGListTraits { }; - - template<typename ItemPtr> - struct SVGListTraits<true, ItemPtr*> { - static ItemPtr* nullItem() { return 0; } - static bool isNull(ItemPtr* it) { return !it; } - }; - - template<typename ItemPtr> - struct SVGListTraits<true, RefPtr<ItemPtr> > { - static RefPtr<ItemPtr> nullItem() { return 0; } - static bool isNull(const RefPtr<ItemPtr>& it) { return !it; } - }; - - template<typename Item> - struct SVGListTraits<true, Item> { - static Item nullItem() { return Item(); } - static bool isNull(Item it) { return !it; } - }; - - template<> - struct SVGListTraits<false, double> { - static double nullItem() { return 0.0; } - static bool isNull(double) { return false; } - }; - - template<> - struct SVGListTraits<false, float> { - static float nullItem() { return 0; } - static bool isNull(float) { return false; } - }; - - -} // namespace WebCore - -#endif // SVG_SUPPORT -#endif // SVGListTraits_h - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGMarkerElement.cpp b/WebCore/svg/SVGMarkerElement.cpp index 8b6d41c..169afec 100644 --- a/WebCore/svg/SVGMarkerElement.cpp +++ b/WebCore/svg/SVGMarkerElement.cpp @@ -35,7 +35,13 @@ namespace WebCore { -SVGMarkerElement::SVGMarkerElement(const QualifiedName& tagName, Document* document) +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGMarkerElement, SVGNames::refXAttr, RefX, refX) +DEFINE_ANIMATED_LENGTH(SVGMarkerElement, SVGNames::refYAttr, RefY, refY) +DEFINE_ANIMATED_LENGTH(SVGMarkerElement, SVGNames::markerWidthAttr, MarkerWidth, markerWidth) +DEFINE_ANIMATED_LENGTH(SVGMarkerElement, SVGNames::markerHeightAttr, MarkerHeight, markerHeight) + +inline SVGMarkerElement::SVGMarkerElement(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) , m_refX(LengthModeWidth) , m_refY(LengthModeHeight) diff --git a/WebCore/svg/SVGMarkerElement.h b/WebCore/svg/SVGMarkerElement.h index e84357e..9061083 100644 --- a/WebCore/svg/SVGMarkerElement.h +++ b/WebCore/svg/SVGMarkerElement.h @@ -29,6 +29,8 @@ #include "SVGExternalResourcesRequired.h" #include "SVGFitToViewBox.h" #include "SVGLangSpace.h" +#include "SVGPreserveAspectRatio.h" +#include "SVGRect.h" #include "SVGStyledElement.h" namespace WebCore { @@ -76,10 +78,11 @@ private: static const AtomicString& orientTypeIdentifier(); static const AtomicString& orientAngleIdentifier(); - DECLARE_ANIMATED_PROPERTY_NEW(SVGMarkerElement, SVGNames::refXAttr, SVGLength, RefX, refX) - DECLARE_ANIMATED_PROPERTY_NEW(SVGMarkerElement, SVGNames::refYAttr, SVGLength, RefY, refY) - DECLARE_ANIMATED_PROPERTY_NEW(SVGMarkerElement, SVGNames::markerWidthAttr, SVGLength, MarkerWidth, markerWidth) - DECLARE_ANIMATED_PROPERTY_NEW(SVGMarkerElement, SVGNames::markerHeightAttr, SVGLength, MarkerHeight, markerHeight) + // Animated property declarations + DECLARE_ANIMATED_LENGTH(RefX, refX) + DECLARE_ANIMATED_LENGTH(RefY, refY) + DECLARE_ANIMATED_LENGTH(MarkerWidth, markerWidth) + DECLARE_ANIMATED_LENGTH(MarkerHeight, markerHeight) DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGMarkerElement, SVGNames::markerUnitsAttr, int, MarkerUnits, markerUnits) DECLARE_ANIMATED_STATIC_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGMarkerElement, SVGNames::orientAttr, orientTypeIdentifier(), int, OrientType, orientType) DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS_NEW(SVGMarkerElement, SVGNames::orientAttr, orientAngleIdentifier(), SVGAngle, OrientAngle, orientAngle) diff --git a/WebCore/svg/SVGMaskElement.cpp b/WebCore/svg/SVGMaskElement.cpp index 78c3732..9bf38ce 100644 --- a/WebCore/svg/SVGMaskElement.cpp +++ b/WebCore/svg/SVGMaskElement.cpp @@ -29,15 +29,18 @@ #include "Attribute.h" #include "CSSStyleSelector.h" #include "RenderSVGResourceMasker.h" -#include "SVGLength.h" #include "SVGNames.h" #include "SVGRenderSupport.h" #include "SVGUnitTypes.h" -using namespace std; - namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGMaskElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGMaskElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH(SVGMaskElement, SVGNames::widthAttr, Width, width) +DEFINE_ANIMATED_LENGTH(SVGMaskElement, SVGNames::heightAttr, Height, height) + inline SVGMaskElement::SVGMaskElement(const QualifiedName& tagName, Document* document) : SVGStyledLocatableElement(tagName, document) , m_maskUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) @@ -124,6 +127,7 @@ void SVGMaskElement::synchronizeProperty(const QualifiedName& attrName) synchronizeX(); synchronizeY(); synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -137,6 +141,8 @@ void SVGMaskElement::synchronizeProperty(const QualifiedName& attrName) synchronizeY(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGMaskElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) diff --git a/WebCore/svg/SVGMaskElement.h b/WebCore/svg/SVGMaskElement.h index 599d184..f8c9727 100644 --- a/WebCore/svg/SVGMaskElement.h +++ b/WebCore/svg/SVGMaskElement.h @@ -31,42 +31,41 @@ namespace WebCore { - class SVGLength; +class SVGMaskElement : public SVGStyledLocatableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired { +public: + static PassRefPtr<SVGMaskElement> create(const QualifiedName&, Document*); - class SVGMaskElement : public SVGStyledLocatableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired { - public: - static PassRefPtr<SVGMaskElement> create(const QualifiedName&, Document*); + FloatRect maskBoundingBox(const FloatRect&) const; - FloatRect maskBoundingBox(const FloatRect&) const; +private: + SVGMaskElement(const QualifiedName&, Document*); - private: - SVGMaskElement(const QualifiedName&, Document*); + virtual bool isValid() const { return SVGTests::isValid(); } + virtual bool needsPendingResourceHandling() const { return false; } - virtual bool isValid() const { return SVGTests::isValid(); } - virtual bool needsPendingResourceHandling() const { return false; } + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); + virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); - virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + virtual bool selfHasRelativeLengths() const; - virtual bool selfHasRelativeLengths() const; + // Animated property declarations + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGMaskElement, SVGNames::maskUnitsAttr, int, MaskUnits, maskUnits) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGMaskElement, SVGNames::maskContentUnitsAttr, int, MaskContentUnits, maskContentUnits) + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) + DECLARE_ANIMATED_LENGTH(Width, width) + DECLARE_ANIMATED_LENGTH(Height, height) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGMaskElement, SVGNames::maskUnitsAttr, int, MaskUnits, maskUnits) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGMaskElement, SVGNames::maskContentUnitsAttr, int, MaskContentUnits, maskContentUnits) - DECLARE_ANIMATED_PROPERTY_NEW(SVGMaskElement, SVGNames::xAttr, SVGLength, X, x) - DECLARE_ANIMATED_PROPERTY_NEW(SVGMaskElement, SVGNames::yAttr, SVGLength, Y, y) - DECLARE_ANIMATED_PROPERTY_NEW(SVGMaskElement, SVGNames::widthAttr, SVGLength, Width, width) - DECLARE_ANIMATED_PROPERTY_NEW(SVGMaskElement, SVGNames::heightAttr, SVGLength, Height, height) - - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGMaskElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - }; + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGMaskElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) +}; } diff --git a/WebCore/svg/SVGNumberList.cpp b/WebCore/svg/SVGNumberList.cpp index a1dc430..7c0149c 100644 --- a/WebCore/svg/SVGNumberList.cpp +++ b/WebCore/svg/SVGNumberList.cpp @@ -51,7 +51,7 @@ String SVGNumberList::valueAsString() const unsigned size = this->size(); for (unsigned i = 0; i < size; ++i) { if (i > 0) - builder.append(", "); + builder.append(' '); builder.append(String::number(at(i))); } diff --git a/WebCore/svg/SVGNumberList.h b/WebCore/svg/SVGNumberList.h index abc82da..f42d937 100644 --- a/WebCore/svg/SVGNumberList.h +++ b/WebCore/svg/SVGNumberList.h @@ -22,8 +22,8 @@ #define SVGNumberList_h #if ENABLE(SVG) +#include "SVGPropertyTraits.h" #include <wtf/Vector.h> -#include <wtf/text/WTFString.h> namespace WebCore { @@ -35,6 +35,14 @@ public: String valueAsString() const; }; +template<> +struct SVGPropertyTraits<SVGNumberList> { + typedef float ListItemType; + + static SVGNumberList initialValue() { return SVGNumberList(); } + static String toString(const SVGNumberList& type) { return type.valueAsString(); } +}; + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGNumberList.idl b/WebCore/svg/SVGNumberList.idl index 58bbcf4..01ecf31 100644 --- a/WebCore/svg/SVGNumberList.idl +++ b/WebCore/svg/SVGNumberList.idl @@ -31,17 +31,17 @@ module svg { void clear() raises(DOMException); - SVGNumber initialize(in SVGNumber item) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGNumber initialize(in SVGNumber item) raises(DOMException, SVGException); - SVGNumber getItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGNumber getItem(in unsigned long index) raises(DOMException); - SVGNumber insertItemBefore(in SVGNumber item, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGNumber insertItemBefore(in SVGNumber item, in unsigned long index) raises(DOMException, SVGException); - SVGNumber replaceItem(in SVGNumber item, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGNumber replaceItem(in SVGNumber item, in unsigned long index) raises(DOMException, SVGException); - SVGNumber removeItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGNumber removeItem(in unsigned long index) raises(DOMException); - SVGNumber appendItem(in SVGNumber item) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGNumber appendItem(in SVGNumber item) raises(DOMException, SVGException); }; diff --git a/WebCore/svg/SVGParserUtilities.cpp b/WebCore/svg/SVGParserUtilities.cpp index 5a77ce2..63bc5bb 100644 --- a/WebCore/svg/SVGParserUtilities.cpp +++ b/WebCore/svg/SVGParserUtilities.cpp @@ -27,18 +27,24 @@ #include "Document.h" #include "FloatPoint.h" +#include <limits> #include "SVGPointList.h" #include <wtf/ASCIICType.h> namespace WebCore { +template <typename FloatType> static inline bool isValidRange(const FloatType& x) +{ + static const FloatType max = std::numeric_limits<FloatType>::max(); + return x >= -max && x <= max; +} + // We use this generic parseNumber function to allow the Path parsing code to work // at a higher precision internally, without any unnecessary runtime cost or code // complexity. template <typename FloatType> static bool genericParseNumber(const UChar*& ptr, const UChar* end, FloatType& number, bool skip) { - int exponent; - FloatType integer, decimal, frac; + FloatType integer, decimal, frac, exponent; int sign, expsign; const UChar* start = ptr; @@ -73,6 +79,9 @@ template <typename FloatType> static bool genericParseNumber(const UChar*& ptr, integer += multiplier * static_cast<FloatType>(*(ptrScanIntPart--) - '0'); multiplier *= 10; } + // Bail out early if this overflows. + if (!isValidRange(integer)) + return false; } if (ptr < end && *ptr == '.') { // read the decimals @@ -104,17 +113,24 @@ template <typename FloatType> static bool genericParseNumber(const UChar*& ptr, return false; while (ptr < end && *ptr >= '0' && *ptr <= '9') { - exponent *= 10; + exponent *= static_cast<FloatType>(10); exponent += *ptr - '0'; ptr++; } + // Make sure exponent is valid. + if (!isValidRange(exponent) || exponent > std::numeric_limits<FloatType>::max_exponent) + return false; } number = integer + decimal; number *= sign; if (exponent) - number *= static_cast<FloatType>(pow(10.0, expsign * exponent)); + number *= static_cast<FloatType>(pow(10.0, expsign * static_cast<int>(exponent))); + + // Don't return Infinity() or NaN(). + if (!isValidRange(number)) + return false; if (start == ptr) return false; diff --git a/WebCore/svg/SVGPathElement.cpp b/WebCore/svg/SVGPathElement.cpp index 8f8bef9..7ecd9d1 100644 --- a/WebCore/svg/SVGPathElement.cpp +++ b/WebCore/svg/SVGPathElement.cpp @@ -26,7 +26,6 @@ #include "Attribute.h" #include "RenderSVGPath.h" #include "RenderSVGResource.h" -#include "SVGNames.h" #include "SVGPathParserFactory.h" #include "SVGPathSegArc.h" #include "SVGPathSegClosePath.h" @@ -38,14 +37,20 @@ #include "SVGPathSegLinetoHorizontal.h" #include "SVGPathSegLinetoVertical.h" #include "SVGPathSegList.h" +#include "SVGPathSegListPropertyTearOff.h" #include "SVGPathSegListBuilder.h" #include "SVGPathSegMoveto.h" #include "SVGSVGElement.h" namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER(SVGPathElement, SVGNames::pathLengthAttr, PathLength, pathLength) + inline SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document* document) : SVGStyledTransformableElement(tagName, document) + , m_pathByteStream(SVGPathByteStream::create()) + , m_pathSegList(PathSegUnalteredRole) { } @@ -75,112 +80,110 @@ unsigned long SVGPathElement::getPathSegAtLength(float length) { SVGPathParserFactory* factory = SVGPathParserFactory::self(); unsigned long pathSeg = 0; - factory->getSVGPathSegAtLengthFromSVGPathSegList(pathSegList(), length, pathSeg); + factory->getSVGPathSegAtLengthFromSVGPathByteStream(m_pathByteStream.get(), length, pathSeg); return pathSeg; } -PassRefPtr<SVGPathSegClosePath> SVGPathElement::createSVGPathSegClosePath() +PassRefPtr<SVGPathSegClosePath> SVGPathElement::createSVGPathSegClosePath(SVGPathSegRole role) { - return SVGPathSegClosePath::create(); + return SVGPathSegClosePath::create(this, role); } -PassRefPtr<SVGPathSegMovetoAbs> SVGPathElement::createSVGPathSegMovetoAbs(float x, float y) +PassRefPtr<SVGPathSegMovetoAbs> SVGPathElement::createSVGPathSegMovetoAbs(float x, float y, SVGPathSegRole role) { - return SVGPathSegMovetoAbs::create(x, y); + return SVGPathSegMovetoAbs::create(this, role, x, y); } -PassRefPtr<SVGPathSegMovetoRel> SVGPathElement::createSVGPathSegMovetoRel(float x, float y) +PassRefPtr<SVGPathSegMovetoRel> SVGPathElement::createSVGPathSegMovetoRel(float x, float y, SVGPathSegRole role) { - return SVGPathSegMovetoRel::create(x, y); + return SVGPathSegMovetoRel::create(this, role, x, y); } -PassRefPtr<SVGPathSegLinetoAbs> SVGPathElement::createSVGPathSegLinetoAbs(float x, float y) +PassRefPtr<SVGPathSegLinetoAbs> SVGPathElement::createSVGPathSegLinetoAbs(float x, float y, SVGPathSegRole role) { - return SVGPathSegLinetoAbs::create(x, y); + return SVGPathSegLinetoAbs::create(this, role, x, y); } -PassRefPtr<SVGPathSegLinetoRel> SVGPathElement::createSVGPathSegLinetoRel(float x, float y) +PassRefPtr<SVGPathSegLinetoRel> SVGPathElement::createSVGPathSegLinetoRel(float x, float y, SVGPathSegRole role) { - return SVGPathSegLinetoRel::create(x, y); + return SVGPathSegLinetoRel::create(this, role, x, y); } -PassRefPtr<SVGPathSegCurvetoCubicAbs> SVGPathElement::createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2) +PassRefPtr<SVGPathSegCurvetoCubicAbs> SVGPathElement::createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role) { - return SVGPathSegCurvetoCubicAbs::create(x, y, x1, y1, x2, y2); + return SVGPathSegCurvetoCubicAbs::create(this, role, x, y, x1, y1, x2, y2); } -PassRefPtr<SVGPathSegCurvetoCubicRel> SVGPathElement::createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2) +PassRefPtr<SVGPathSegCurvetoCubicRel> SVGPathElement::createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role) { - return SVGPathSegCurvetoCubicRel::create(x, y, x1, y1, x2, y2); + return SVGPathSegCurvetoCubicRel::create(this, role, x, y, x1, y1, x2, y2); } -PassRefPtr<SVGPathSegCurvetoQuadraticAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1) +PassRefPtr<SVGPathSegCurvetoQuadraticAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1, SVGPathSegRole role) { - return SVGPathSegCurvetoQuadraticAbs::create(x, y, x1, y1); + return SVGPathSegCurvetoQuadraticAbs::create(this, role, x, y, x1, y1); } -PassRefPtr<SVGPathSegCurvetoQuadraticRel> SVGPathElement::createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1) +PassRefPtr<SVGPathSegCurvetoQuadraticRel> SVGPathElement::createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1, SVGPathSegRole role) { - return SVGPathSegCurvetoQuadraticRel::create(x, y, x1, y1); + return SVGPathSegCurvetoQuadraticRel::create(this, role, x, y, x1, y1); } -PassRefPtr<SVGPathSegArcAbs> SVGPathElement::createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) +PassRefPtr<SVGPathSegArcAbs> SVGPathElement::createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role) { - return SVGPathSegArcAbs::create(x, y, r1, r2, angle, largeArcFlag, sweepFlag); + return SVGPathSegArcAbs::create(this, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag); } -PassRefPtr<SVGPathSegArcRel> SVGPathElement::createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) +PassRefPtr<SVGPathSegArcRel> SVGPathElement::createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role) { - return SVGPathSegArcRel::create(x, y, r1, r2, angle, largeArcFlag, sweepFlag); + return SVGPathSegArcRel::create(this, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag); } -PassRefPtr<SVGPathSegLinetoHorizontalAbs> SVGPathElement::createSVGPathSegLinetoHorizontalAbs(float x) +PassRefPtr<SVGPathSegLinetoHorizontalAbs> SVGPathElement::createSVGPathSegLinetoHorizontalAbs(float x, SVGPathSegRole role) { - return SVGPathSegLinetoHorizontalAbs::create(x); + return SVGPathSegLinetoHorizontalAbs::create(this, role, x); } -PassRefPtr<SVGPathSegLinetoHorizontalRel> SVGPathElement::createSVGPathSegLinetoHorizontalRel(float x) +PassRefPtr<SVGPathSegLinetoHorizontalRel> SVGPathElement::createSVGPathSegLinetoHorizontalRel(float x, SVGPathSegRole role) { - return SVGPathSegLinetoHorizontalRel::create(x); + return SVGPathSegLinetoHorizontalRel::create(this, role, x); } -PassRefPtr<SVGPathSegLinetoVerticalAbs> SVGPathElement::createSVGPathSegLinetoVerticalAbs(float y) +PassRefPtr<SVGPathSegLinetoVerticalAbs> SVGPathElement::createSVGPathSegLinetoVerticalAbs(float y, SVGPathSegRole role) { - return SVGPathSegLinetoVerticalAbs::create(y); + return SVGPathSegLinetoVerticalAbs::create(this, role, y); } -PassRefPtr<SVGPathSegLinetoVerticalRel> SVGPathElement::createSVGPathSegLinetoVerticalRel(float y) +PassRefPtr<SVGPathSegLinetoVerticalRel> SVGPathElement::createSVGPathSegLinetoVerticalRel(float y, SVGPathSegRole role) { - return SVGPathSegLinetoVerticalRel::create(y); + return SVGPathSegLinetoVerticalRel::create(this, role, y); } -PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2) +PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2, SVGPathSegRole role) { - return SVGPathSegCurvetoCubicSmoothAbs::create(x, y, x2, y2); + return SVGPathSegCurvetoCubicSmoothAbs::create(this, role, x, y, x2, y2); } -PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2) +PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2, SVGPathSegRole role) { - return SVGPathSegCurvetoCubicSmoothRel::create(x, y, x2, y2); + return SVGPathSegCurvetoCubicSmoothRel::create(this, role, x, y, x2, y2); } -PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y) +PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y, SVGPathSegRole role) { - return SVGPathSegCurvetoQuadraticSmoothAbs::create(x, y); + return SVGPathSegCurvetoQuadraticSmoothAbs::create(this, role, x, y); } -PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y) +PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y, SVGPathSegRole role) { - return SVGPathSegCurvetoQuadraticSmoothRel::create(x, y); + return SVGPathSegCurvetoQuadraticSmoothRel::create(this, role, x, y); } void SVGPathElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::dAttr) { - ExceptionCode ec; - pathSegList()->clear(ec); SVGPathParserFactory* factory = SVGPathParserFactory::self(); - if (!factory->buildSVGPathSegListFromString(attr->value(), pathSegList(), NormalizedParsing)) + if (!factory->buildSVGPathByteStreamFromString(attr->value(), m_pathByteStream, UnalteredParsing)) document()->accessSVGExtensions()->reportError("Problem parsing d=\"" + attr->value() + "\""); } else if (attr->name() == SVGNames::pathLengthAttr) { setPathLengthBaseValue(attr->value().toFloat()); @@ -205,15 +208,26 @@ void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) return; RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer()); - if (!renderer) - return; if (attrName == SVGNames::dAttr) { + if (m_animatablePathSegList) { + SVGPathSegList newList(PathSegUnalteredRole); + SVGPathParserFactory* factory = SVGPathParserFactory::self(); + factory->buildSVGPathSegListFromByteStream(m_pathByteStream.get(), this, newList, UnalteredParsing); + m_pathSegList.value = newList; + } + + if (!renderer) + return; + renderer->setNeedsPathUpdate(); RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); return; } + if (!renderer) + return; + if (SVGStyledTransformableElement::isKnownAttribute(attrName)) { renderer->setNeedsTransformUpdate(); RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); @@ -231,40 +245,70 @@ void SVGPathElement::synchronizeProperty(const QualifiedName& attrName) SVGStyledTransformableElement::synchronizeProperty(attrName); if (attrName == anyQName()) { + synchronizeD(); synchronizePathLength(); synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); return; } - if (attrName == SVGNames::pathLengthAttr) + if (attrName == SVGNames::dAttr) + synchronizeD(); + else if (attrName == SVGNames::pathLengthAttr) synchronizePathLength(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); +} + +void SVGPathElement::synchronizeD() +{ + if (!m_pathSegList.shouldSynchronize) + return; + + SVGAnimatedPropertySynchronizer<true>::synchronize(this, SVGNames::dAttr, m_pathSegList.value.valueAsString()); } -SVGPathSegList* SVGPathElement::pathSegList() const +SVGPathSegListPropertyTearOff* SVGPathElement::pathSegList() { - if (!m_pathSegList) - m_pathSegList = SVGPathSegList::create(SVGNames::dAttr); + if (!m_animatablePathSegList) { + m_pathSegList.shouldSynchronize = true; - return m_pathSegList.get(); + SVGPathParserFactory* factory = SVGPathParserFactory::self(); + factory->buildSVGPathSegListFromByteStream(m_pathByteStream.get(), this, m_pathSegList.value, UnalteredParsing); + + m_animatablePathSegList = SVGAnimatedProperty::lookupOrCreateWrapper<SVGAnimatedPathSegListPropertyTearOff, SVGPathSegList> + (this, SVGNames::dAttr, SVGNames::dAttr.localName(), m_pathSegList.value); + } + + return static_cast<SVGPathSegListPropertyTearOff*>(m_animatablePathSegList->baseVal(PathSegUnalteredRole)); } -SVGPathSegList* SVGPathElement::normalizedPathSegList() const +SVGPathSegListPropertyTearOff* SVGPathElement::normalizedPathSegList() { - // TODO + // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists! return 0; } -SVGPathSegList* SVGPathElement::animatedPathSegList() const +SVGPathSegListPropertyTearOff* SVGPathElement::animatedPathSegList() { - // TODO - return 0; + if (!m_animatablePathSegList) { + m_pathSegList.shouldSynchronize = true; + + SVGPathParserFactory* factory = SVGPathParserFactory::self(); + factory->buildSVGPathSegListFromByteStream(m_pathByteStream.get(), this, m_pathSegList.value, UnalteredParsing); + + m_animatablePathSegList = SVGAnimatedProperty::lookupOrCreateWrapper<SVGAnimatedPathSegListPropertyTearOff, SVGPathSegList> + (this, SVGNames::dAttr, SVGNames::dAttr.localName(), m_pathSegList.value); + } + + return static_cast<SVGPathSegListPropertyTearOff*>(m_animatablePathSegList->animVal(PathSegUnalteredRole)); } -SVGPathSegList* SVGPathElement::animatedNormalizedPathSegList() const +SVGPathSegListPropertyTearOff* SVGPathElement::animatedNormalizedPathSegList() { - // TODO + // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists! return 0; } @@ -273,7 +317,33 @@ void SVGPathElement::toPathData(Path& path) const ASSERT(path.isEmpty()); SVGPathParserFactory* factory = SVGPathParserFactory::self(); - factory->buildPathFromSVGPathSegList(pathSegList(), path); + factory->buildPathFromByteStream(m_pathByteStream.get(), path); +} + +void SVGPathElement::pathSegListChanged(SVGPathSegRole role) +{ + SVGPathParserFactory* factory = SVGPathParserFactory::self(); + + switch (role) { + case PathSegNormalizedRole: + // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists! + break; + case PathSegUnalteredRole: + m_pathByteStream->clear(); + factory->buildSVGPathByteStreamFromSVGPathSegList(m_pathSegList.value, m_pathByteStream, UnalteredParsing); + break; + case PathSegUndefinedRole: + return; + } + + invalidateSVGAttributes(); + + RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer()); + if (!renderer) + return; + + renderer->setNeedsPathUpdate(); + RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); } } diff --git a/WebCore/svg/SVGPathElement.h b/WebCore/svg/SVGPathElement.h index 91d55b1..ffdd32e 100644 --- a/WebCore/svg/SVGPathElement.h +++ b/WebCore/svg/SVGPathElement.h @@ -22,94 +22,102 @@ #define SVGPathElement_h #if ENABLE(SVG) -#include "SVGAnimatedPathData.h" -#include "SVGAnimatedPropertyMacros.h" +#include "SVGAnimatedNumber.h" +#include "SVGAnimatedPathSegListPropertyTearOff.h" #include "SVGExternalResourcesRequired.h" #include "SVGLangSpace.h" +#include "SVGPathByteStream.h" #include "SVGStyledTransformableElement.h" #include "SVGTests.h" namespace WebCore { - class SVGPathSeg; - class SVGPathSegArcAbs; - class SVGPathSegArcRel; - class SVGPathSegClosePath; - class SVGPathSegLinetoAbs; - class SVGPathSegLinetoRel; - class SVGPathSegMovetoAbs; - class SVGPathSegMovetoRel; - class SVGPathSegCurvetoCubicAbs; - class SVGPathSegCurvetoCubicRel; - class SVGPathSegLinetoVerticalAbs; - class SVGPathSegLinetoVerticalRel; - class SVGPathSegLinetoHorizontalAbs; - class SVGPathSegLinetoHorizontalRel; - class SVGPathSegCurvetoQuadraticAbs; - class SVGPathSegCurvetoQuadraticRel; - class SVGPathSegCurvetoCubicSmoothAbs; - class SVGPathSegCurvetoCubicSmoothRel; - class SVGPathSegCurvetoQuadraticSmoothAbs; - class SVGPathSegCurvetoQuadraticSmoothRel; - - class SVGPathElement : public SVGStyledTransformableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired, - public SVGAnimatedPathData { - public: - static PassRefPtr<SVGPathElement> create(const QualifiedName&, Document*); - - float getTotalLength(); - FloatPoint getPointAtLength(float distance); - unsigned long getPathSegAtLength(float distance); - - static PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath(); - static PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y); - static PassRefPtr<SVGPathSegMovetoRel> createSVGPathSegMovetoRel(float x, float y); - static PassRefPtr<SVGPathSegLinetoAbs> createSVGPathSegLinetoAbs(float x, float y); - static PassRefPtr<SVGPathSegLinetoRel> createSVGPathSegLinetoRel(float x, float y); - static PassRefPtr<SVGPathSegCurvetoCubicAbs> createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2); - static PassRefPtr<SVGPathSegCurvetoCubicRel> createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2); - static PassRefPtr<SVGPathSegCurvetoQuadraticAbs> createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1); - static PassRefPtr<SVGPathSegCurvetoQuadraticRel> createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1); - static PassRefPtr<SVGPathSegArcAbs> createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag); - static PassRefPtr<SVGPathSegArcRel> createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag); - static PassRefPtr<SVGPathSegLinetoHorizontalAbs> createSVGPathSegLinetoHorizontalAbs(float x); - static PassRefPtr<SVGPathSegLinetoHorizontalRel> createSVGPathSegLinetoHorizontalRel(float x); - static PassRefPtr<SVGPathSegLinetoVerticalAbs> createSVGPathSegLinetoVerticalAbs(float y); - static PassRefPtr<SVGPathSegLinetoVerticalRel> createSVGPathSegLinetoVerticalRel(float y); - static PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2); - static PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2); - static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y); - static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y); - - // Derived from: 'SVGAnimatedPathData' - virtual SVGPathSegList* pathSegList() const; - virtual SVGPathSegList* normalizedPathSegList() const; - virtual SVGPathSegList* animatedPathSegList() const; - virtual SVGPathSegList* animatedNormalizedPathSegList() const; - - virtual void toPathData(Path&) const; - - private: - SVGPathElement(const QualifiedName&, Document*); - - virtual bool isValid() const { return SVGTests::isValid(); } - - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); - - virtual bool supportsMarkers() const { return true; } - - mutable RefPtr<SVGPathSegList> m_pathSegList; - - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPathElement, SVGNames::pathLengthAttr, float, PathLength, pathLength) - - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPathElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - }; +class SVGPathSegArcAbs; +class SVGPathSegArcRel; +class SVGPathSegClosePath; +class SVGPathSegLinetoAbs; +class SVGPathSegLinetoRel; +class SVGPathSegMovetoAbs; +class SVGPathSegMovetoRel; +class SVGPathSegCurvetoCubicAbs; +class SVGPathSegCurvetoCubicRel; +class SVGPathSegLinetoVerticalAbs; +class SVGPathSegLinetoVerticalRel; +class SVGPathSegLinetoHorizontalAbs; +class SVGPathSegLinetoHorizontalRel; +class SVGPathSegCurvetoQuadraticAbs; +class SVGPathSegCurvetoQuadraticRel; +class SVGPathSegCurvetoCubicSmoothAbs; +class SVGPathSegCurvetoCubicSmoothRel; +class SVGPathSegCurvetoQuadraticSmoothAbs; +class SVGPathSegCurvetoQuadraticSmoothRel; + +class SVGPathElement : public SVGStyledTransformableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired { +public: + static PassRefPtr<SVGPathElement> create(const QualifiedName&, Document*); + + float getTotalLength(); + FloatPoint getPointAtLength(float distance); + unsigned long getPathSegAtLength(float distance); + + PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath(SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegMovetoRel> createSVGPathSegMovetoRel(float x, float y, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegLinetoAbs> createSVGPathSegLinetoAbs(float x, float y, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegLinetoRel> createSVGPathSegLinetoRel(float x, float y, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegCurvetoCubicAbs> createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegCurvetoCubicRel> createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegCurvetoQuadraticAbs> createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegCurvetoQuadraticRel> createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegArcAbs> createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegArcRel> createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegLinetoHorizontalAbs> createSVGPathSegLinetoHorizontalAbs(float x, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegLinetoHorizontalRel> createSVGPathSegLinetoHorizontalRel(float x, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegLinetoVerticalAbs> createSVGPathSegLinetoVerticalAbs(float y, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegLinetoVerticalRel> createSVGPathSegLinetoVerticalRel(float y, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y, SVGPathSegRole role = PathSegUndefinedRole); + PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y, SVGPathSegRole role = PathSegUndefinedRole); + + // Used in the bindings only. + SVGPathSegListPropertyTearOff* pathSegList(); + SVGPathSegListPropertyTearOff* animatedPathSegList(); + SVGPathSegListPropertyTearOff* normalizedPathSegList(); + SVGPathSegListPropertyTearOff* animatedNormalizedPathSegList(); + + SVGPathByteStream* pathByteStream() const { return m_pathByteStream.get(); } + SVGAnimatedProperty* animatablePathSegList() const { return m_animatablePathSegList.get(); } + + virtual void toPathData(Path&) const; + void pathSegListChanged(SVGPathSegRole); + +private: + SVGPathElement(const QualifiedName&, Document*); + + virtual bool isValid() const { return SVGTests::isValid(); } + + virtual void parseMappedAttribute(Attribute*); + virtual void synchronizeProperty(const QualifiedName&); + virtual void svgAttributeChanged(const QualifiedName&); + virtual bool supportsMarkers() const { return true; } + + // Animated property declarations + DECLARE_ANIMATED_NUMBER(PathLength, pathLength) + + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPathElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) + + void synchronizeD(); + +protected: + OwnPtr<SVGPathByteStream> m_pathByteStream; + mutable SVGSynchronizableAnimatedProperty<SVGPathSegList> m_pathSegList; + RefPtr<SVGAnimatedPathSegListPropertyTearOff> m_animatablePathSegList; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGPathElement.idl b/WebCore/svg/SVGPathElement.idl index 1c1dca7..00a9d85 100644 --- a/WebCore/svg/SVGPathElement.idl +++ b/WebCore/svg/SVGPathElement.idl @@ -31,8 +31,7 @@ module svg { SVGLangSpace, SVGExternalResourcesRequired, SVGStylable, - SVGTransformable, - SVGAnimatedPathData { + SVGTransformable { readonly attribute SVGAnimatedNumber pathLength; float getTotalLength(); @@ -107,6 +106,11 @@ module svg { in float y); SVGPathSegCurvetoQuadraticSmoothRel createSVGPathSegCurvetoQuadraticSmoothRel(in float x, in float y); + + readonly attribute SVGPathSegList pathSegList; + readonly attribute SVGPathSegList normalizedPathSegList; + readonly attribute SVGPathSegList animatedPathSegList; + readonly attribute SVGPathSegList animatedNormalizedPathSegList; }; } diff --git a/WebCore/svg/SVGPathParserFactory.cpp b/WebCore/svg/SVGPathParserFactory.cpp index e707c20..deb0307 100644 --- a/WebCore/svg/SVGPathParserFactory.cpp +++ b/WebCore/svg/SVGPathParserFactory.cpp @@ -27,6 +27,7 @@ #include "SVGPathBuilder.h" #include "SVGPathByteStreamBuilder.h" #include "SVGPathByteStreamSource.h" +#include "SVGPathElement.h" #include "SVGPathParser.h" #include "SVGPathSegListBuilder.h" #include "SVGPathSegListSource.h" @@ -46,13 +47,15 @@ static SVGPathBuilder* globalSVGPathBuilder(Path& result) return s_builder; } -static SVGPathSegListBuilder* globalSVGPathSegListBuilder(SVGPathSegList* result) +static SVGPathSegListBuilder* globalSVGPathSegListBuilder(SVGPathElement* element, SVGPathSegRole role, SVGPathSegList& result) { static SVGPathSegListBuilder* s_builder = 0; if (!s_builder) s_builder = new SVGPathSegListBuilder; + s_builder->setCurrentSVGPathElement(element); s_builder->setCurrentSVGPathSegList(result); + s_builder->setCurrentSVGPathSegRole(role); return s_builder; } @@ -137,59 +140,43 @@ bool SVGPathParserFactory::buildPathFromString(const String& d, Path& result) return ok; } -bool SVGPathParserFactory::buildPathFromByteStream(SVGPathByteStream* stream, Path& result) +bool SVGPathParserFactory::buildSVGPathByteStreamFromSVGPathSegList(const SVGPathSegList& list, OwnPtr<SVGPathByteStream>& result, PathParsingMode parsingMode) { - ASSERT(stream); - if (stream->isEmpty()) + result = SVGPathByteStream::create(); + if (list.isEmpty()) return false; - SVGPathBuilder* builder = globalSVGPathBuilder(result); + SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result.get()); - OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); + OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(list); SVGPathParser* parser = globalSVGPathParser(source.get(), builder); - bool ok = parser->parsePathDataFromSource(NormalizedParsing); + bool ok = parser->parsePathDataFromSource(parsingMode); parser->cleanup(); return ok; } -bool SVGPathParserFactory::buildPathFromSVGPathSegList(SVGPathSegList* pathSegList, Path& result) +bool SVGPathParserFactory::buildPathFromByteStream(SVGPathByteStream* stream, Path& result) { - ASSERT(pathSegList); - if (!pathSegList->numberOfItems()) + ASSERT(stream); + if (stream->isEmpty()) return false; SVGPathBuilder* builder = globalSVGPathBuilder(result); - OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList); + OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); SVGPathParser* parser = globalSVGPathParser(source.get(), builder); bool ok = parser->parsePathDataFromSource(NormalizedParsing); parser->cleanup(); return ok; } -bool SVGPathParserFactory::buildSVGPathSegListFromString(const String& d, SVGPathSegList* result, PathParsingMode parsingMode) -{ - ASSERT(result); - if (d.isEmpty()) - return false; - - SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder(result); - - OwnPtr<SVGPathStringSource> source = SVGPathStringSource::create(d); - SVGPathParser* parser = globalSVGPathParser(source.get(), builder); - bool ok = parser->parsePathDataFromSource(parsingMode); - parser->cleanup(); - return ok; -} - -bool SVGPathParserFactory::buildSVGPathSegListFromByteStream(SVGPathByteStream* stream, SVGPathSegList* result, PathParsingMode parsingMode) +bool SVGPathParserFactory::buildSVGPathSegListFromByteStream(SVGPathByteStream* stream, SVGPathElement* element, SVGPathSegList& result, PathParsingMode parsingMode) { ASSERT(stream); - ASSERT(result); if (stream->isEmpty()) return false; - SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder(result); + SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder(element, parsingMode == NormalizedParsing ? PathSegNormalizedRole : PathSegUnalteredRole, result); OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); SVGPathParser* parser = globalSVGPathParser(source.get(), builder); @@ -214,15 +201,15 @@ bool SVGPathParserFactory::buildStringFromByteStream(SVGPathByteStream* stream, return ok; } -bool SVGPathParserFactory::buildStringFromSVGPathSegList(SVGPathSegList* pathSegList, String& result, PathParsingMode parsingMode) +bool SVGPathParserFactory::buildStringFromSVGPathSegList(const SVGPathSegList& list, String& result, PathParsingMode parsingMode) { - ASSERT(pathSegList); - if (!pathSegList->numberOfItems()) - return false; + result = String(); + if (list.isEmpty()) + return false; SVGPathStringBuilder* builder = globalSVGPathStringBuilder(); - OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList); + OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(list); SVGPathParser* parser = globalSVGPathParser(source.get(), builder); bool ok = parser->parsePathDataFromSource(parsingMode); result = builder->result(); @@ -232,16 +219,15 @@ bool SVGPathParserFactory::buildStringFromSVGPathSegList(SVGPathSegList* pathSeg bool SVGPathParserFactory::buildSVGPathByteStreamFromString(const String& d, OwnPtr<SVGPathByteStream>& result, PathParsingMode parsingMode) { + result = SVGPathByteStream::create(); if (d.isEmpty()) return false; - OwnPtr<SVGPathByteStream> stream = SVGPathByteStream::create(); - SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(stream.get()); + SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result.get()); OwnPtr<SVGPathStringSource> source = SVGPathStringSource::create(d); SVGPathParser* parser = globalSVGPathParser(source.get(), builder); bool ok = parser->parsePathDataFromSource(parsingMode); - result = stream.release(); parser->cleanup(); return ok; } @@ -250,31 +236,30 @@ bool SVGPathParserFactory::buildAnimatedSVGPathByteStream(SVGPathByteStream* fro { ASSERT(fromStream); ASSERT(toStream); + result = SVGPathByteStream::create(); if (fromStream->isEmpty() || toStream->isEmpty()) return false; - OwnPtr<SVGPathByteStream> stream = SVGPathByteStream::create(); - SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(stream.get()); + SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result.get()); OwnPtr<SVGPathByteStreamSource> fromSource = SVGPathByteStreamSource::create(fromStream); OwnPtr<SVGPathByteStreamSource> toSource = SVGPathByteStreamSource::create(toStream); SVGPathBlender* blender = globalSVGPathBlender(); bool ok = blender->blendAnimatedPath(progress, fromSource.get(), toSource.get(), builder); - result = stream.release(); blender->cleanup(); return ok; } -bool SVGPathParserFactory::getSVGPathSegAtLengthFromSVGPathSegList(SVGPathSegList* pathSegList, float length, unsigned long& pathSeg) +bool SVGPathParserFactory::getSVGPathSegAtLengthFromSVGPathByteStream(SVGPathByteStream* stream, float length, unsigned long& pathSeg) { - ASSERT(pathSegList); - if (!pathSegList->numberOfItems()) - return false; + ASSERT(stream); + if (stream->isEmpty()) + return false; PathTraversalState traversalState(PathTraversalState::TraversalSegmentAtLength); SVGPathTraversalStateBuilder* builder = globalSVGPathTraversalStateBuilder(traversalState, length); - OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList); + OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); SVGPathParser* parser = globalSVGPathParser(source.get(), builder); bool ok = parser->parsePathDataFromSource(NormalizedParsing); pathSeg = builder->pathSegmentIndex(); diff --git a/WebCore/svg/SVGPathParserFactory.h b/WebCore/svg/SVGPathParserFactory.h index b8a2dd5..5ae5e8a 100644 --- a/WebCore/svg/SVGPathParserFactory.h +++ b/WebCore/svg/SVGPathParserFactory.h @@ -30,25 +30,29 @@ namespace WebCore { +class SVGPathElement; + class SVGPathParserFactory { public: static SVGPathParserFactory* self(); + // String/SVGPathByteStream -> Path bool buildPathFromString(const String&, Path&); bool buildPathFromByteStream(SVGPathByteStream*, Path&); - bool buildPathFromSVGPathSegList(SVGPathSegList*, Path&); - bool buildSVGPathSegListFromString(const String&, SVGPathSegList*, PathParsingMode); - bool buildSVGPathSegListFromByteStream(SVGPathByteStream*, SVGPathSegList*, PathParsingMode); + // SVGPathSegList/String -> SVGPathByteStream + bool buildSVGPathByteStreamFromSVGPathSegList(const SVGPathSegList&, OwnPtr<SVGPathByteStream>&, PathParsingMode); + bool buildSVGPathByteStreamFromString(const String&, OwnPtr<SVGPathByteStream>&, PathParsingMode); + // SVGPathByteStream/SVGPathSegList -> String bool buildStringFromByteStream(SVGPathByteStream*, String&, PathParsingMode); - bool buildStringFromSVGPathSegList(SVGPathSegList*, String&, PathParsingMode); + bool buildStringFromSVGPathSegList(const SVGPathSegList&, String&, PathParsingMode); - bool buildSVGPathByteStreamFromString(const String&, OwnPtr<SVGPathByteStream>&, PathParsingMode); + // SVGPathByteStream -> SVGPathSegList + bool buildSVGPathSegListFromByteStream(SVGPathByteStream*, SVGPathElement*, SVGPathSegList&, PathParsingMode); bool buildAnimatedSVGPathByteStream(SVGPathByteStream*, SVGPathByteStream*, OwnPtr<SVGPathByteStream>&, float); - - bool getSVGPathSegAtLengthFromSVGPathSegList(SVGPathSegList*, float, unsigned long&); + bool getSVGPathSegAtLengthFromSVGPathByteStream(SVGPathByteStream*, float length, unsigned long& pathSeg); private: SVGPathParserFactory(); diff --git a/WebCore/svg/SVGPathSeg.cpp b/WebCore/svg/SVGPathSeg.cpp deleted file mode 100644 index 5939976..0000000 --- a/WebCore/svg/SVGPathSeg.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2010 Google, 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. - */ - -#include "config.h" -#if ENABLE(SVG) -#include "SVGPathSeg.h" - -#include "SVGNames.h" - -namespace WebCore { - -const QualifiedName& SVGPathSeg::associatedAttributeName() const -{ - return SVGNames::dAttr; -} - -} // namespace WebCore -#endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGPathSeg.h b/WebCore/svg/SVGPathSeg.h index a2cf261..4fce0c3 100644 --- a/WebCore/svg/SVGPathSeg.h +++ b/WebCore/svg/SVGPathSeg.h @@ -22,8 +22,7 @@ #define SVGPathSeg_h #if ENABLE(SVG) -#include <wtf/Forward.h> -#include <wtf/RefCounted.h> +#include <wtf/text/WTFString.h> namespace WebCore { @@ -50,10 +49,15 @@ enum SVGPathSegType { PathSegCurveToQuadraticSmoothRel = 19 }; -class QualifiedName; +enum SVGPathSegRole { + PathSegUnalteredRole = 0, + PathSegNormalizedRole = 1, + PathSegUndefinedRole = 2 +}; class SVGPathSeg : public RefCounted<SVGPathSeg> { public: + SVGPathSeg() { } virtual ~SVGPathSeg() { } // Forward declare these enums in the w3c naming scheme, for IDL generation @@ -80,31 +84,8 @@ public: PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = PathSegCurveToQuadraticSmoothRel }; - virtual unsigned short pathSegType() const = 0; virtual String pathSegTypeAsLetter() const = 0; - - const QualifiedName& associatedAttributeName() const; -}; - -class SVGPathSegSingleCoord : public SVGPathSeg { -public: - void setX(float x) { m_x = x; } - float x() const { return m_x; } - - void setY(float y) { m_y = y; } - float y() const { return m_y; } - -protected: - SVGPathSegSingleCoord(float x, float y) - : m_x(x) - , m_y(y) - { - } - -private: - float m_x; - float m_y; }; } // namespace WebCore diff --git a/WebCore/svg/SVGPathSeg.idl b/WebCore/svg/SVGPathSeg.idl index 8641a48..f46518c 100644 --- a/WebCore/svg/SVGPathSeg.idl +++ b/WebCore/svg/SVGPathSeg.idl @@ -28,29 +28,29 @@ module svg { interface [Conditional=SVG, CustomToJS, Polymorphic] SVGPathSeg { // Path Segment Types - const unsigned short PATHSEG_UNKNOWN = 0; - const unsigned short PATHSEG_CLOSEPATH = 1; - const unsigned short PATHSEG_MOVETO_ABS = 2; - const unsigned short PATHSEG_MOVETO_REL = 3; - const unsigned short PATHSEG_LINETO_ABS = 4; - const unsigned short PATHSEG_LINETO_REL = 5; - const unsigned short PATHSEG_CURVETO_CUBIC_ABS = 6; - const unsigned short PATHSEG_CURVETO_CUBIC_REL = 7; - const unsigned short PATHSEG_CURVETO_QUADRATIC_ABS = 8; - const unsigned short PATHSEG_CURVETO_QUADRATIC_REL = 9; - const unsigned short PATHSEG_ARC_ABS = 10; - const unsigned short PATHSEG_ARC_REL = 11; - const unsigned short PATHSEG_LINETO_HORIZONTAL_ABS = 12; - const unsigned short PATHSEG_LINETO_HORIZONTAL_REL = 13; - const unsigned short PATHSEG_LINETO_VERTICAL_ABS = 14; - const unsigned short PATHSEG_LINETO_VERTICAL_REL = 15; - const unsigned short PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; - const unsigned short PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; + const unsigned short PATHSEG_UNKNOWN = 0; + const unsigned short PATHSEG_CLOSEPATH = 1; + const unsigned short PATHSEG_MOVETO_ABS = 2; + const unsigned short PATHSEG_MOVETO_REL = 3; + const unsigned short PATHSEG_LINETO_ABS = 4; + const unsigned short PATHSEG_LINETO_REL = 5; + const unsigned short PATHSEG_CURVETO_CUBIC_ABS = 6; + const unsigned short PATHSEG_CURVETO_CUBIC_REL = 7; + const unsigned short PATHSEG_CURVETO_QUADRATIC_ABS = 8; + const unsigned short PATHSEG_CURVETO_QUADRATIC_REL = 9; + const unsigned short PATHSEG_ARC_ABS = 10; + const unsigned short PATHSEG_ARC_REL = 11; + const unsigned short PATHSEG_LINETO_HORIZONTAL_ABS = 12; + const unsigned short PATHSEG_LINETO_HORIZONTAL_REL = 13; + const unsigned short PATHSEG_LINETO_VERTICAL_ABS = 14; + const unsigned short PATHSEG_LINETO_VERTICAL_REL = 15; + const unsigned short PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; + const unsigned short PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; const unsigned short PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; const unsigned short PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; - readonly attribute unsigned short pathSegType; - readonly attribute DOMString pathSegTypeAsLetter; + readonly attribute unsigned short pathSegType; + readonly attribute DOMString pathSegTypeAsLetter; }; } diff --git a/WebCore/svg/SVGPathSegArc.cpp b/WebCore/svg/SVGPathSegArc.cpp deleted file mode 100644 index f606905..0000000 --- a/WebCore/svg/SVGPathSegArc.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - * - * 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. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPathSegArc.h" - -namespace WebCore { - -SVGPathSegArcAbs::SVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) - : SVGPathSegArc(x, y, r1, r2, angle, largeArcFlag, sweepFlag) -{ -} - -SVGPathSegArcRel::SVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) - : SVGPathSegArc(x, y, r1, r2, angle, largeArcFlag, sweepFlag) -{ -} - -} - -#endif // ENABLE(SVG) - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegArc.h b/WebCore/svg/SVGPathSegArc.h index 5d5c332..e835bc3 100644 --- a/WebCore/svg/SVGPathSegArc.h +++ b/WebCore/svg/SVGPathSegArc.h @@ -22,88 +22,119 @@ #define SVGPathSegArc_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { - class SVGPathSegArc : public SVGPathSeg { - public: - SVGPathSegArc(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) - : m_x(x) - , m_y(y) - , m_r1(r1) - , m_r2(r2) - , m_angle(angle) - , m_largeArcFlag(largeArcFlag) - , m_sweepFlag(sweepFlag) - { - } - - void setX(float x) { m_x = x; } - float x() const { return m_x; } - - void setY(float y) { m_y = y; } - float y() const { return m_y; } - - void setR1(float r1) { m_r1 = r1; } - float r1() const { return m_r1; } - - void setR2(float r2) { m_r2 = r2; } - float r2() const { return m_r2; } - - void setAngle(float angle) { m_angle = angle; } - float angle() const { return m_angle; } - - void setLargeArcFlag(bool largeArcFlag) { m_largeArcFlag = largeArcFlag; } - bool largeArcFlag() const { return m_largeArcFlag; } - - void setSweepFlag(bool sweepFlag) { m_sweepFlag = sweepFlag; } - bool sweepFlag() const { return m_sweepFlag; } - - private: - float m_x; - float m_y; - float m_r1; - float m_r2; - float m_angle; - - bool m_largeArcFlag : 1; - bool m_sweepFlag : 1; - }; - - class SVGPathSegArcAbs : public SVGPathSegArc { - public: - static PassRefPtr<SVGPathSegArcAbs> create(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) - { - return adoptRef(new SVGPathSegArcAbs(x, y, r1, r2, angle, largeArcFlag, sweepFlag)); - } - - private: - SVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag); - - virtual unsigned short pathSegType() const { return PATHSEG_ARC_ABS; } - virtual String pathSegTypeAsLetter() const { return "A"; } - }; - - class SVGPathSegArcRel : public SVGPathSegArc { - public: - static PassRefPtr<SVGPathSegArcRel> create(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) - { - return adoptRef(new SVGPathSegArcRel(x, y, r1, r2, angle, largeArcFlag, sweepFlag)); - } - - private: - SVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag); - - virtual unsigned short pathSegType() const { return PATHSEG_ARC_REL; } - virtual String pathSegTypeAsLetter() const { return "a"; } - }; +class SVGPathSegArc : public SVGPathSegWithContext { +public: + SVGPathSegArc(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) + : SVGPathSegWithContext(element, role) + , m_x(x) + , m_y(y) + , m_r1(r1) + , m_r2(r2) + , m_angle(angle) + , m_largeArcFlag(largeArcFlag) + , m_sweepFlag(sweepFlag) + { + } + + float x() const { return m_x; } + void setX(float x) + { + m_x = x; + commitChange(); + } + + float y() const { return m_y; } + void setY(float y) + { + m_y = y; + commitChange(); + } + + float r1() const { return m_r1; } + void setR1(float r1) + { + m_r1 = r1; + commitChange(); + } + + float r2() const { return m_r2; } + void setR2(float r2) + { + m_r2 = r2; + commitChange(); + } + + float angle() const { return m_angle; } + void setAngle(float angle) + { + m_angle = angle; + commitChange(); + } + + bool largeArcFlag() const { return m_largeArcFlag; } + void setLargeArcFlag(bool largeArcFlag) + { + m_largeArcFlag = largeArcFlag; + commitChange(); + } + + bool sweepFlag() const { return m_sweepFlag; } + void setSweepFlag(bool sweepFlag) + { + m_sweepFlag = sweepFlag; + commitChange(); + } + +private: + float m_x; + float m_y; + float m_r1; + float m_r2; + float m_angle; + + bool m_largeArcFlag : 1; + bool m_sweepFlag : 1; +}; + +class SVGPathSegArcAbs : public SVGPathSegArc { +public: + static PassRefPtr<SVGPathSegArcAbs> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) + { + return adoptRef(new SVGPathSegArcAbs(element, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag)); + } + +private: + SVGPathSegArcAbs(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) + : SVGPathSegArc(element, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_ARC_ABS; } + virtual String pathSegTypeAsLetter() const { return "A"; } +}; + +class SVGPathSegArcRel : public SVGPathSegArc { +public: + static PassRefPtr<SVGPathSegArcRel> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) + { + return adoptRef(new SVGPathSegArcRel(element, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag)); + } + +private: + SVGPathSegArcRel(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) + : SVGPathSegArc(element, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_ARC_REL; } + virtual String pathSegTypeAsLetter() const { return "a"; } +}; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegArcAbs.idl b/WebCore/svg/SVGPathSegArcAbs.idl index bdc45a7..7568155 100644 --- a/WebCore/svg/SVGPathSegArcAbs.idl +++ b/WebCore/svg/SVGPathSegArcAbs.idl @@ -27,20 +27,13 @@ module svg { interface [Conditional=SVG] SVGPathSegArcAbs : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; - attribute float r1 - /*setter raises(DOMException)*/; - attribute float r2 - /*setter raises(DOMException)*/; - attribute float angle - /*setter raises(DOMException)*/; - attribute boolean largeArcFlag - /*setter raises(DOMException)*/; - attribute boolean sweepFlag - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; + attribute [StrictTypeChecking] float r1; + attribute [StrictTypeChecking] float r2; + attribute [StrictTypeChecking] float angle; + attribute [StrictTypeChecking] boolean largeArcFlag; + attribute [StrictTypeChecking] boolean sweepFlag; }; } diff --git a/WebCore/svg/SVGPathSegArcRel.idl b/WebCore/svg/SVGPathSegArcRel.idl index 8b08d68..78852d8 100644 --- a/WebCore/svg/SVGPathSegArcRel.idl +++ b/WebCore/svg/SVGPathSegArcRel.idl @@ -27,20 +27,13 @@ module svg { interface [Conditional=SVG] SVGPathSegArcRel : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; - attribute float r1 - /*setter raises(DOMException)*/; - attribute float r2 - /*setter raises(DOMException)*/; - attribute float angle - /*setter raises(DOMException)*/; - attribute boolean largeArcFlag - /*setter raises(DOMException)*/; - attribute boolean sweepFlag - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; + attribute [StrictTypeChecking] float r1; + attribute [StrictTypeChecking] float r2; + attribute [StrictTypeChecking] float angle; + attribute [StrictTypeChecking] boolean largeArcFlag; + attribute [StrictTypeChecking] boolean sweepFlag; }; } diff --git a/WebCore/svg/SVGPathSegClosePath.cpp b/WebCore/svg/SVGPathSegClosePath.cpp deleted file mode 100644 index 6f54888..0000000 --- a/WebCore/svg/SVGPathSegClosePath.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/SVGPathSegClosePath.h b/WebCore/svg/SVGPathSegClosePath.h index 8f074ed..c3b2c14 100644 --- a/WebCore/svg/SVGPathSegClosePath.h +++ b/WebCore/svg/SVGPathSegClosePath.h @@ -22,18 +22,22 @@ #define SVGPathSegClosePath_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { -class SVGPathSegClosePath : public SVGPathSeg { +class SVGPathSegClosePath : public SVGPathSegWithContext { public: - static PassRefPtr<SVGPathSegClosePath> create() { return adoptRef(new SVGPathSegClosePath); } + static PassRefPtr<SVGPathSegClosePath> create(SVGPathElement* element, SVGPathSegRole role) + { + return adoptRef(new SVGPathSegClosePath(element, role)); + } private: - SVGPathSegClosePath() { } + SVGPathSegClosePath(SVGPathElement* element, SVGPathSegRole role) + : SVGPathSegWithContext(element, role) + { + } virtual unsigned short pathSegType() const { return PATHSEG_CLOSEPATH; } virtual String pathSegTypeAsLetter() const { return "Z"; } diff --git a/WebCore/svg/SVGPathSegCurvetoCubic.cpp b/WebCore/svg/SVGPathSegCurvetoCubic.cpp deleted file mode 100644 index 33f2d96..0000000 --- a/WebCore/svg/SVGPathSegCurvetoCubic.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - * - * 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. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPathSegCurvetoCubic.h" - -namespace WebCore { - -SVGPathSegCurvetoCubicAbs::SVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2) - : SVGPathSegCurvetoCubic(x, y, x1, y1, x2, y2) -{ -} - -SVGPathSegCurvetoCubicRel::SVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2) - : SVGPathSegCurvetoCubic(x, y, x1, y1, x2, y2) -{ -} - -} - -#endif // ENABLE(SVG) - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegCurvetoCubic.h b/WebCore/svg/SVGPathSegCurvetoCubic.h index ae4a21d..169d8f8 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubic.h +++ b/WebCore/svg/SVGPathSegCurvetoCubic.h @@ -22,74 +22,109 @@ #define SVGPathSegCurvetoCubic_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { - class SVGPathSegCurvetoCubic : public SVGPathSeg { - public: - SVGPathSegCurvetoCubic(float x, float y, float x1, float y1, float x2, float y2) : m_x(x), m_y(y), m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2) { } - - void setX(float x) { m_x = x; } - float x() const { return m_x; } - - void setY(float y) { m_y = y; } - float y() const { return m_y; } - - void setX1(float x1) { m_x1 = x1; } - float x1() const { return m_x1; } - - void setY1(float y1) { m_y1 = y1; } - float y1() const { return m_y1; } - - void setX2(float x2) { m_x2 = x2; } - float x2() const { return m_x2; } - - void setY2(float y2) { m_y2 = y2; } - float y2() const { return m_y2; } - - private: - float m_x; - float m_y; - float m_x1; - float m_y1; - float m_x2; - float m_y2; - }; - - class SVGPathSegCurvetoCubicAbs : public SVGPathSegCurvetoCubic { - public: - static PassRefPtr<SVGPathSegCurvetoCubicAbs> create(float x, float y, float x1, float y1, float x2, float y2) - { - return adoptRef(new SVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2)); - } - - private: - SVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2); - - virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_ABS; } - virtual String pathSegTypeAsLetter() const { return "C"; } - }; - - class SVGPathSegCurvetoCubicRel : public SVGPathSegCurvetoCubic { - public: - static PassRefPtr<SVGPathSegCurvetoCubicRel> create(float x, float y, float x1, float y1, float x2, float y2) - { - return adoptRef(new SVGPathSegCurvetoCubicRel(x, y, x1, y1, x2, y2)); - } - - private: - SVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2); - - virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_REL; } - virtual String pathSegTypeAsLetter() const { return "c"; } - }; +class SVGPathSegCurvetoCubic : public SVGPathSegWithContext { +public: + SVGPathSegCurvetoCubic(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2) + : SVGPathSegWithContext(element, role) + , m_x(x) + , m_y(y) + , m_x1(x1) + , m_y1(y1) + , m_x2(x2) + , m_y2(y2) + { + } + + float x() const { return m_x; } + void setX(float x) + { + m_x = x; + commitChange(); + } + + float y() const { return m_y; } + void setY(float y) + { + m_y = y; + commitChange(); + } + + float x1() const { return m_x1; } + void setX1(float x1) + { + m_x1 = x1; + commitChange(); + } + + float y1() const { return m_y1; } + void setY1(float y1) + { + m_y1 = y1; + commitChange(); + } + + float x2() const { return m_x2; } + void setX2(float x2) + { + m_x2 = x2; + commitChange(); + } + + float y2() const { return m_y2; } + void setY2(float y2) + { + m_y2 = y2; + commitChange(); + } + +private: + float m_x; + float m_y; + float m_x1; + float m_y1; + float m_x2; + float m_y2; +}; + +class SVGPathSegCurvetoCubicAbs : public SVGPathSegCurvetoCubic { +public: + static PassRefPtr<SVGPathSegCurvetoCubicAbs> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2) + { + return adoptRef(new SVGPathSegCurvetoCubicAbs(element, role, x, y, x1, y1, x2, y2)); + } + +private: + SVGPathSegCurvetoCubicAbs(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2) + : SVGPathSegCurvetoCubic(element, role, x, y, x1, y1, x2, y2) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_ABS; } + virtual String pathSegTypeAsLetter() const { return "C"; } +}; + +class SVGPathSegCurvetoCubicRel : public SVGPathSegCurvetoCubic { +public: + static PassRefPtr<SVGPathSegCurvetoCubicRel> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2) + { + return adoptRef(new SVGPathSegCurvetoCubicRel(element, role, x, y, x1, y1, x2, y2)); + } + +private: + SVGPathSegCurvetoCubicRel(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2) + : SVGPathSegCurvetoCubic(element, role, x, y, x1, y1, x2, y2) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_REL; } + virtual String pathSegTypeAsLetter() const { return "c"; } +}; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegCurvetoCubicAbs.idl b/WebCore/svg/SVGPathSegCurvetoCubicAbs.idl index 6b16809..4baf113 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubicAbs.idl +++ b/WebCore/svg/SVGPathSegCurvetoCubicAbs.idl @@ -22,23 +22,17 @@ * 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] SVGPathSegCurvetoCubicAbs : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; - attribute float x1 - /*setter raises(DOMException)*/; - attribute float y1 - /*setter raises(DOMException)*/; - attribute float x2 - /*setter raises(DOMException)*/; - attribute float y2 - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; + attribute [StrictTypeChecking] float x1; + attribute [StrictTypeChecking] float y1; + attribute [StrictTypeChecking] float x2; + attribute [StrictTypeChecking] float y2; }; } diff --git a/WebCore/svg/SVGPathSegCurvetoCubicRel.idl b/WebCore/svg/SVGPathSegCurvetoCubicRel.idl index be6606d..7e9fb7f 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubicRel.idl +++ b/WebCore/svg/SVGPathSegCurvetoCubicRel.idl @@ -22,23 +22,17 @@ * 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] SVGPathSegCurvetoCubicRel : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; - attribute float x1 - /*setter raises(DOMException)*/; - attribute float y1 - /*setter raises(DOMException)*/; - attribute float x2 - /*setter raises(DOMException)*/; - attribute float y2 - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; + attribute [StrictTypeChecking] float x1; + attribute [StrictTypeChecking] float y1; + attribute [StrictTypeChecking] float x2; + attribute [StrictTypeChecking] float y2; }; } diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp deleted file mode 100644 index a7625e3..0000000 --- a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - * - * 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. - */ - -#include "config.h" -#if ENABLE(SVG) -#include "SVGPathSegCurvetoCubicSmooth.h" - -namespace WebCore { - -SVGPathSegCurvetoCubicSmoothAbs::SVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2) - : SVGPathSegCurvetoCubicSmooth(x, y, x2, y2) -{ -} - -SVGPathSegCurvetoCubicSmoothRel::SVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2) - : SVGPathSegCurvetoCubicSmooth(x, y, x2, y2) -{ -} - -} - -#endif // ENABLE(SVG) - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h index 2227951..a654297 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h +++ b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h @@ -22,62 +22,89 @@ #define SVGPathSegCurvetoCubicSmooth_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { - class SVGPathSegCurvetoCubicSmooth : public SVGPathSeg { - public: - SVGPathSegCurvetoCubicSmooth(float x, float y, float x2, float y2) - : m_x(x) - , m_y(y) - , m_x2(x2) - , m_y2(y2) - { - } - - void setX(float x) { m_x = x; } - float x() const { return m_x; } - - void setY(float y) { m_y = y; } - float y() const { return m_y; } - - void setX2(float x2) { m_x2 = x2; } - float x2() const { return m_x2; } - - void setY2(float y2) { m_y2 = y2; } - float y2() const { return m_y2; } - - private: - float m_x; - float m_y; - float m_x2; - float m_y2; - }; - - class SVGPathSegCurvetoCubicSmoothAbs : public SVGPathSegCurvetoCubicSmooth { - public: - static PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> create(float x, float y, float x2, float y2) { return adoptRef(new SVGPathSegCurvetoCubicSmoothAbs(x, y, x2, y2)); } - - private: - SVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2); - - virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; } - virtual String pathSegTypeAsLetter() const { return "S"; } - }; - - class SVGPathSegCurvetoCubicSmoothRel : public SVGPathSegCurvetoCubicSmooth { - public: - static PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> create(float x, float y, float x2, float y2) { return adoptRef(new SVGPathSegCurvetoCubicSmoothRel(x, y, x2, y2)); } - - private: - SVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2); - - virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_REL; } - virtual String pathSegTypeAsLetter() const { return "s"; } - }; +class SVGPathSegCurvetoCubicSmooth : public SVGPathSegWithContext { +public: + SVGPathSegCurvetoCubicSmooth(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x2, float y2) + : SVGPathSegWithContext(element, role) + , m_x(x) + , m_y(y) + , m_x2(x2) + , m_y2(y2) + { + } + + float x() const { return m_x; } + void setX(float x) + { + m_x = x; + commitChange(); + } + + float y() const { return m_y; } + void setY(float y) + { + m_y = y; + commitChange(); + } + + float x2() const { return m_x2; } + void setX2(float x2) + { + m_x2 = x2; + commitChange(); + } + + float y2() const { return m_y2; } + void setY2(float y2) + { + m_y2 = y2; + commitChange(); + } + +private: + float m_x; + float m_y; + float m_x2; + float m_y2; +}; + +class SVGPathSegCurvetoCubicSmoothAbs : public SVGPathSegCurvetoCubicSmooth { +public: + static PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x2, float y2) + { + return adoptRef(new SVGPathSegCurvetoCubicSmoothAbs(element, role, x, y, x2, y2)); + } + +private: + SVGPathSegCurvetoCubicSmoothAbs(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x2, float y2) + : SVGPathSegCurvetoCubicSmooth(element, role, x, y, x2, y2) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; } + virtual String pathSegTypeAsLetter() const { return "S"; } +}; + +class SVGPathSegCurvetoCubicSmoothRel : public SVGPathSegCurvetoCubicSmooth { +public: + static PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x2, float y2) + { + return adoptRef(new SVGPathSegCurvetoCubicSmoothRel(element, role, x, y, x2, y2)); + } + +private: + SVGPathSegCurvetoCubicSmoothRel(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x2, float y2) + : SVGPathSegCurvetoCubicSmooth(element, role, x, y, x2, y2) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_REL; } + virtual String pathSegTypeAsLetter() const { return "s"; } +}; } // namespace WebCore diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmoothAbs.idl b/WebCore/svg/SVGPathSegCurvetoCubicSmoothAbs.idl index d31582e..0779c9f 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubicSmoothAbs.idl +++ b/WebCore/svg/SVGPathSegCurvetoCubicSmoothAbs.idl @@ -22,19 +22,15 @@ * 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] SVGPathSegCurvetoCubicSmoothAbs : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; - attribute float x2 - /*setter raises(DOMException)*/; - attribute float y2 - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; + attribute [StrictTypeChecking] float x2; + attribute [StrictTypeChecking] float y2; }; } diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmoothRel.idl b/WebCore/svg/SVGPathSegCurvetoCubicSmoothRel.idl index 2dd71f0..d4f71e4 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubicSmoothRel.idl +++ b/WebCore/svg/SVGPathSegCurvetoCubicSmoothRel.idl @@ -22,19 +22,15 @@ * 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] SVGPathSegCurvetoCubicSmoothRel : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; - attribute float x2 - /*setter raises(DOMException)*/; - attribute float y2 - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; + attribute [StrictTypeChecking] float x2; + attribute [StrictTypeChecking] float y2; }; } diff --git a/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp b/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp deleted file mode 100644 index bf2bb4d..0000000 --- a/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - * - * 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. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPathSegCurvetoQuadratic.h" - -namespace WebCore { - -SVGPathSegCurvetoQuadraticAbs::SVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1) - : SVGPathSegCurvetoQuadratic(x, y, x1, y1) -{ -} - -SVGPathSegCurvetoQuadraticRel::SVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1) - : SVGPathSegCurvetoQuadratic(x, y, x1, y1) -{ -} - -} - -#endif // ENABLE(SVG) - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegCurvetoQuadratic.h b/WebCore/svg/SVGPathSegCurvetoQuadratic.h index f84cfaa..894f787 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadratic.h +++ b/WebCore/svg/SVGPathSegCurvetoQuadratic.h @@ -22,66 +22,91 @@ #define SVGPathSegCurvetoQuadratic_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { - class SVGPathSegCurvetoQuadratic : public SVGPathSeg { - public: - SVGPathSegCurvetoQuadratic(float x, float y, float x1, float y1) - : m_x(x) - , m_y(y) - , m_x1(x1) - , m_y1(y1) - { - } - - void setX(float x) { m_x = x; } - float x() const { return m_x; } - - void setY(float y) { m_y = y; } - float y() const { return m_y; } - - void setX1(float x1) { m_x1 = x1; } - float x1() const { return m_x1; } - - void setY1(float y1) { m_y1 = y1; } - float y1() const { return m_y1; } - - private: - float m_x; - float m_y; - float m_x1; - float m_y1; - }; - - class SVGPathSegCurvetoQuadraticAbs : public SVGPathSegCurvetoQuadratic { - public: - static PassRefPtr<SVGPathSegCurvetoQuadraticAbs> create(float x, float y, float x1, float y1) { return adoptRef(new SVGPathSegCurvetoQuadraticAbs(x, y, x1, y1)); } - - private: - SVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1); - - virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_ABS; } - virtual String pathSegTypeAsLetter() const { return "Q"; } - }; - - class SVGPathSegCurvetoQuadraticRel : public SVGPathSegCurvetoQuadratic { - public: - static PassRefPtr<SVGPathSegCurvetoQuadraticRel> create(float x, float y, float x1, float y1) { return adoptRef(new SVGPathSegCurvetoQuadraticRel(x, y, x1, y1)); } - - private: - SVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1); - - virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_REL; } - virtual String pathSegTypeAsLetter() const { return "q"; } - }; +class SVGPathSegCurvetoQuadratic : public SVGPathSegWithContext { +public: + SVGPathSegCurvetoQuadratic(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1) + : SVGPathSegWithContext(element, role) + , m_x(x) + , m_y(y) + , m_x1(x1) + , m_y1(y1) + { + } + + float x() const { return m_x; } + void setX(float x) + { + m_x = x; + commitChange(); + } + + float y() const { return m_y; } + void setY(float y) + { + m_y = y; + commitChange(); + } + + float x1() const { return m_x1; } + void setX1(float x1) + { + m_x1 = x1; + commitChange(); + } + + float y1() const { return m_y1; } + void setY1(float y1) + { + m_y1 = y1; + commitChange(); + } + +private: + float m_x; + float m_y; + float m_x1; + float m_y1; +}; + +class SVGPathSegCurvetoQuadraticAbs : public SVGPathSegCurvetoQuadratic { +public: + static PassRefPtr<SVGPathSegCurvetoQuadraticAbs> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1) + { + return adoptRef(new SVGPathSegCurvetoQuadraticAbs(element, role, x, y, x1, y1)); + } + +private: + SVGPathSegCurvetoQuadraticAbs(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1) + : SVGPathSegCurvetoQuadratic(element, role, x, y, x1, y1) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_ABS; } + virtual String pathSegTypeAsLetter() const { return "Q"; } +}; + +class SVGPathSegCurvetoQuadraticRel : public SVGPathSegCurvetoQuadratic { +public: + static PassRefPtr<SVGPathSegCurvetoQuadraticRel> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1) + { + return adoptRef(new SVGPathSegCurvetoQuadraticRel(element, role, x, y, x1, y1)); + } + +private: + SVGPathSegCurvetoQuadraticRel(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1) + : SVGPathSegCurvetoQuadratic(element, role, x, y, x1, y1) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_REL; } + virtual String pathSegTypeAsLetter() const { return "q"; } +}; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticAbs.idl b/WebCore/svg/SVGPathSegCurvetoQuadraticAbs.idl index 9b09222..1fbb461 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadraticAbs.idl +++ b/WebCore/svg/SVGPathSegCurvetoQuadraticAbs.idl @@ -27,14 +27,10 @@ module svg { interface [Conditional=SVG] SVGPathSegCurvetoQuadraticAbs : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; - attribute float x1 - /*setter raises(DOMException)*/; - attribute float y1 - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; + attribute [StrictTypeChecking] float x1; + attribute [StrictTypeChecking] float y1; }; } diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticRel.idl b/WebCore/svg/SVGPathSegCurvetoQuadraticRel.idl index 01e1e6d..48a39fb 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadraticRel.idl +++ b/WebCore/svg/SVGPathSegCurvetoQuadraticRel.idl @@ -27,14 +27,10 @@ module svg { interface [Conditional=SVG] SVGPathSegCurvetoQuadraticRel : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; - attribute float x1 - /*setter raises(DOMException)*/; - attribute float y1 - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; + attribute [StrictTypeChecking] float x1; + attribute [StrictTypeChecking] float y1; }; } diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp deleted file mode 100644 index 6a7e9f7..0000000 --- a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - * - * 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. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPathSegCurvetoQuadraticSmooth.h" - -namespace WebCore { - -SVGPathSegCurvetoQuadraticSmoothAbs::SVGPathSegCurvetoQuadraticSmoothAbs(float x, float y) - : SVGPathSegSingleCoord(x, y) -{ -} - -SVGPathSegCurvetoQuadraticSmoothRel::SVGPathSegCurvetoQuadraticSmoothRel(float x, float y) - : SVGPathSegSingleCoord(x, y) -{ -} - -} - -#endif // ENABLE(SVG) - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h index 109799e..b66062a 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h +++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h @@ -22,37 +22,45 @@ #define SVGPathSegCurvetoQuadraticSmooth_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { - class SVGPathSegCurvetoQuadraticSmoothAbs : public SVGPathSegSingleCoord { - public: - static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> create(float x, float y) { return adoptRef(new SVGPathSegCurvetoQuadraticSmoothAbs(x, y)); } +class SVGPathSegCurvetoQuadraticSmoothAbs : public SVGPathSegSingleCoordinate { +public: + static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> create(SVGPathElement* element, SVGPathSegRole role, float x, float y) + { + return adoptRef(new SVGPathSegCurvetoQuadraticSmoothAbs(element, role, x, y)); + } - private: - SVGPathSegCurvetoQuadraticSmoothAbs(float x, float y); +private: + SVGPathSegCurvetoQuadraticSmoothAbs(SVGPathElement* element, SVGPathSegRole role, float x, float y) + : SVGPathSegSingleCoordinate(element, role, x, y) + { + } - virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; } - virtual String pathSegTypeAsLetter() const { return "T"; } - }; + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; } + virtual String pathSegTypeAsLetter() const { return "T"; } +}; - class SVGPathSegCurvetoQuadraticSmoothRel : public SVGPathSegSingleCoord { - public: - static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> create(float x, float y) { return adoptRef(new SVGPathSegCurvetoQuadraticSmoothRel(x, y)); } +class SVGPathSegCurvetoQuadraticSmoothRel : public SVGPathSegSingleCoordinate { +public: + static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> create(SVGPathElement* element, SVGPathSegRole role, float x, float y) + { + return adoptRef(new SVGPathSegCurvetoQuadraticSmoothRel(element, role, x, y)); + } - private: - SVGPathSegCurvetoQuadraticSmoothRel(float x, float y); +private: + SVGPathSegCurvetoQuadraticSmoothRel(SVGPathElement* element, SVGPathSegRole role, float x, float y) + : SVGPathSegSingleCoordinate(element, role, x, y) + { + } - virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; } - virtual String pathSegTypeAsLetter() const { return "t"; } - }; + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; } + virtual String pathSegTypeAsLetter() const { return "t"; } +}; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl b/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl index 4568538..ad02534 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl +++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl @@ -27,10 +27,8 @@ module svg { interface [Conditional=SVG] SVGPathSegCurvetoQuadraticSmoothAbs : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; }; } diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothRel.idl b/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothRel.idl index 5ffde79..6d58b8f 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothRel.idl +++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmoothRel.idl @@ -27,10 +27,8 @@ module svg { interface [Conditional=SVG] SVGPathSegCurvetoQuadraticSmoothRel : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; }; } diff --git a/WebCore/svg/SVGPathSegLineto.cpp b/WebCore/svg/SVGPathSegLineto.cpp deleted file mode 100644 index 746f2c1..0000000 --- a/WebCore/svg/SVGPathSegLineto.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> - * - * 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. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPathSegLineto.h" - -namespace WebCore { - -SVGPathSegLinetoAbs::SVGPathSegLinetoAbs(float x, float y) - : SVGPathSegSingleCoord(x, y) -{ -} - -SVGPathSegLinetoRel::SVGPathSegLinetoRel(float x, float y) - : SVGPathSegSingleCoord(x, y) -{ -} - -} - -#endif // ENABLE(SVG) - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegLineto.h b/WebCore/svg/SVGPathSegLineto.h index 3cd3b7f..c995c98 100644 --- a/WebCore/svg/SVGPathSegLineto.h +++ b/WebCore/svg/SVGPathSegLineto.h @@ -22,37 +22,45 @@ #define SVGPathSegLineto_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { - class SVGPathSegLinetoAbs : public SVGPathSegSingleCoord { - public: - static PassRefPtr<SVGPathSegLinetoAbs> create(float x, float y) { return adoptRef(new SVGPathSegLinetoAbs(x, y)); } +class SVGPathSegLinetoAbs : public SVGPathSegSingleCoordinate { +public: + static PassRefPtr<SVGPathSegLinetoAbs> create(SVGPathElement* element, SVGPathSegRole role, float x, float y) + { + return adoptRef(new SVGPathSegLinetoAbs(element, role, x, y)); + } - private: - SVGPathSegLinetoAbs(float x, float y); +private: + SVGPathSegLinetoAbs(SVGPathElement* element, SVGPathSegRole role, float x, float y) + : SVGPathSegSingleCoordinate(element, role, x, y) + { + } - virtual unsigned short pathSegType() const { return PATHSEG_LINETO_ABS; } - virtual String pathSegTypeAsLetter() const { return "L"; } - }; + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_ABS; } + virtual String pathSegTypeAsLetter() const { return "L"; } +}; - class SVGPathSegLinetoRel : public SVGPathSegSingleCoord { - public: - static PassRefPtr<SVGPathSegLinetoRel> create(float x, float y) { return adoptRef(new SVGPathSegLinetoRel(x, y)); } +class SVGPathSegLinetoRel : public SVGPathSegSingleCoordinate { +public: + static PassRefPtr<SVGPathSegLinetoRel> create(SVGPathElement* element, SVGPathSegRole role, float x, float y) + { + return adoptRef(new SVGPathSegLinetoRel(element, role, x, y)); + } - private: - SVGPathSegLinetoRel(float x, float y); +private: + SVGPathSegLinetoRel(SVGPathElement* element, SVGPathSegRole role, float x, float y) + : SVGPathSegSingleCoordinate(element, role, x, y) + { + } - virtual unsigned short pathSegType() const { return PATHSEG_LINETO_REL; } - virtual String pathSegTypeAsLetter() const { return "l"; } - }; + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_REL; } + virtual String pathSegTypeAsLetter() const { return "l"; } +}; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegLinetoAbs.idl b/WebCore/svg/SVGPathSegLinetoAbs.idl index 85dfca5..c428a2b 100644 --- a/WebCore/svg/SVGPathSegLinetoAbs.idl +++ b/WebCore/svg/SVGPathSegLinetoAbs.idl @@ -27,10 +27,8 @@ module svg { interface [Conditional=SVG] SVGPathSegLinetoAbs : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; }; } diff --git a/WebCore/svg/SVGPathSegLinetoHorizontal.cpp b/WebCore/svg/SVGPathSegLinetoHorizontal.cpp deleted file mode 100644 index 85f2896..0000000 --- a/WebCore/svg/SVGPathSegLinetoHorizontal.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> - * - * 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. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPathSegLinetoHorizontal.h" - -namespace WebCore { - -SVGPathSegLinetoHorizontalAbs::SVGPathSegLinetoHorizontalAbs(float x) - : SVGPathSegLinetoHorizontal(x) -{ -} - -SVGPathSegLinetoHorizontalRel::SVGPathSegLinetoHorizontalRel(float x) - : SVGPathSegLinetoHorizontal(x) -{ -} - -} - -#endif // ENABLE(SVG) - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegLinetoHorizontal.h b/WebCore/svg/SVGPathSegLinetoHorizontal.h index da59f05..d175cdd 100644 --- a/WebCore/svg/SVGPathSegLinetoHorizontal.h +++ b/WebCore/svg/SVGPathSegLinetoHorizontal.h @@ -22,48 +22,64 @@ #define SVGPathSegLinetoHorizontal_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { - class SVGPathSegLinetoHorizontal : public SVGPathSeg { - public: - SVGPathSegLinetoHorizontal(float x) : SVGPathSeg(), m_x(x) {} - - void setX(float x) { m_x = x; } - float x() const { return m_x; } - - private: - float m_x; - }; - - class SVGPathSegLinetoHorizontalAbs : public SVGPathSegLinetoHorizontal { - public: - static PassRefPtr<SVGPathSegLinetoHorizontalAbs> create(float x) { return adoptRef(new SVGPathSegLinetoHorizontalAbs(x)); } - - private: - SVGPathSegLinetoHorizontalAbs(float x); - - virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_ABS; } - virtual String pathSegTypeAsLetter() const { return "H"; } - }; - - class SVGPathSegLinetoHorizontalRel : public SVGPathSegLinetoHorizontal { - public: - static PassRefPtr<SVGPathSegLinetoHorizontalRel> create(float x) { return adoptRef(new SVGPathSegLinetoHorizontalRel(x)); } - - private: - SVGPathSegLinetoHorizontalRel(float x); - - virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_REL; } - virtual String pathSegTypeAsLetter() const { return "h"; } - }; +class SVGPathSegLinetoHorizontal : public SVGPathSegWithContext { +public: + SVGPathSegLinetoHorizontal(SVGPathElement* element, SVGPathSegRole role, float x) + : SVGPathSegWithContext(element, role) + , m_x(x) + { + } + + float x() const { return m_x; } + void setX(float x) + { + m_x = x; + commitChange(); + } + +private: + float m_x; +}; + +class SVGPathSegLinetoHorizontalAbs : public SVGPathSegLinetoHorizontal { +public: + static PassRefPtr<SVGPathSegLinetoHorizontalAbs> create(SVGPathElement* element, SVGPathSegRole role, float x) + { + return adoptRef(new SVGPathSegLinetoHorizontalAbs(element, role, x)); + } + +private: + SVGPathSegLinetoHorizontalAbs(SVGPathElement* element, SVGPathSegRole role, float x) + : SVGPathSegLinetoHorizontal(element, role, x) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_ABS; } + virtual String pathSegTypeAsLetter() const { return "H"; } +}; + +class SVGPathSegLinetoHorizontalRel : public SVGPathSegLinetoHorizontal { +public: + static PassRefPtr<SVGPathSegLinetoHorizontalRel> create(SVGPathElement* element, SVGPathSegRole role, float x) + { + return adoptRef(new SVGPathSegLinetoHorizontalRel(element, role, x)); + } + +private: + SVGPathSegLinetoHorizontalRel(SVGPathElement* element, SVGPathSegRole role, float x) + : SVGPathSegLinetoHorizontal(element, role, x) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_REL; } + virtual String pathSegTypeAsLetter() const { return "h"; } +}; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegLinetoHorizontalAbs.idl b/WebCore/svg/SVGPathSegLinetoHorizontalAbs.idl index eadb612..522f997 100644 --- a/WebCore/svg/SVGPathSegLinetoHorizontalAbs.idl +++ b/WebCore/svg/SVGPathSegLinetoHorizontalAbs.idl @@ -27,8 +27,7 @@ module svg { interface [Conditional=SVG] SVGPathSegLinetoHorizontalAbs : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; }; } diff --git a/WebCore/svg/SVGPathSegLinetoHorizontalRel.idl b/WebCore/svg/SVGPathSegLinetoHorizontalRel.idl index 91f537c..3f9a22a 100644 --- a/WebCore/svg/SVGPathSegLinetoHorizontalRel.idl +++ b/WebCore/svg/SVGPathSegLinetoHorizontalRel.idl @@ -27,8 +27,7 @@ module svg { interface [Conditional=SVG] SVGPathSegLinetoHorizontalRel : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; }; } diff --git a/WebCore/svg/SVGPathSegLinetoRel.idl b/WebCore/svg/SVGPathSegLinetoRel.idl index 51a8b5d..d92cdc4 100644 --- a/WebCore/svg/SVGPathSegLinetoRel.idl +++ b/WebCore/svg/SVGPathSegLinetoRel.idl @@ -27,10 +27,8 @@ module svg { interface [Conditional=SVG] SVGPathSegLinetoRel : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; }; } diff --git a/WebCore/svg/SVGPathSegLinetoVertical.cpp b/WebCore/svg/SVGPathSegLinetoVertical.cpp deleted file mode 100644 index ba02c9e..0000000 --- a/WebCore/svg/SVGPathSegLinetoVertical.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - * - * 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. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPathSegLinetoVertical.h" - -namespace WebCore { - -SVGPathSegLinetoVerticalAbs::SVGPathSegLinetoVerticalAbs(float y) - : SVGPathSegLinetoVertical(y) -{ -} - -SVGPathSegLinetoVerticalRel::SVGPathSegLinetoVerticalRel(float y) - : SVGPathSegLinetoVertical(y) -{ -} -} - -#endif // ENABLE(SVG) - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegLinetoVertical.h b/WebCore/svg/SVGPathSegLinetoVertical.h index b13b9f4..fec7fb6 100644 --- a/WebCore/svg/SVGPathSegLinetoVertical.h +++ b/WebCore/svg/SVGPathSegLinetoVertical.h @@ -22,48 +22,64 @@ #define SVGPathSegLinetoVertical_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { - class SVGPathSegLinetoVertical : public SVGPathSeg { - public: - SVGPathSegLinetoVertical(float y) : SVGPathSeg(), m_y(y) {} - - void setY(float y) { m_y = y; } - float y() const { return m_y; } - - private: - float m_y; - }; - - class SVGPathSegLinetoVerticalAbs : public SVGPathSegLinetoVertical { - public: - static PassRefPtr<SVGPathSegLinetoVerticalAbs> create(float y) { return adoptRef(new SVGPathSegLinetoVerticalAbs(y)); } - - private: - SVGPathSegLinetoVerticalAbs(float y); - - virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_ABS; } - virtual String pathSegTypeAsLetter() const { return "V"; } - }; - - class SVGPathSegLinetoVerticalRel : public SVGPathSegLinetoVertical { - public: - static PassRefPtr<SVGPathSegLinetoVerticalRel> create(float y) { return adoptRef(new SVGPathSegLinetoVerticalRel(y)); } - - private: - SVGPathSegLinetoVerticalRel(float y); - - virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_REL; } - virtual String pathSegTypeAsLetter() const { return "v"; } - }; +class SVGPathSegLinetoVertical : public SVGPathSegWithContext { +public: + SVGPathSegLinetoVertical(SVGPathElement* element, SVGPathSegRole role, float y) + : SVGPathSegWithContext(element, role) + , m_y(y) + { + } + + float y() const { return m_y; } + void setY(float y) + { + m_y = y; + commitChange(); + } + +private: + float m_y; +}; + +class SVGPathSegLinetoVerticalAbs : public SVGPathSegLinetoVertical { +public: + static PassRefPtr<SVGPathSegLinetoVerticalAbs> create(SVGPathElement* element, SVGPathSegRole role, float y) + { + return adoptRef(new SVGPathSegLinetoVerticalAbs(element, role, y)); + } + +private: + SVGPathSegLinetoVerticalAbs(SVGPathElement* element, SVGPathSegRole role, float y) + : SVGPathSegLinetoVertical(element, role, y) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_ABS; } + virtual String pathSegTypeAsLetter() const { return "V"; } +}; + +class SVGPathSegLinetoVerticalRel : public SVGPathSegLinetoVertical { +public: + static PassRefPtr<SVGPathSegLinetoVerticalRel> create(SVGPathElement* element, SVGPathSegRole role, float y) + { + return adoptRef(new SVGPathSegLinetoVerticalRel(element, role, y)); + } + +private: + SVGPathSegLinetoVerticalRel(SVGPathElement* element, SVGPathSegRole role, float y) + : SVGPathSegLinetoVertical(element, role, y) + { + } + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_REL; } + virtual String pathSegTypeAsLetter() const { return "v"; } +}; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegLinetoVerticalAbs.idl b/WebCore/svg/SVGPathSegLinetoVerticalAbs.idl index b6ba7f1..a9af261 100644 --- a/WebCore/svg/SVGPathSegLinetoVerticalAbs.idl +++ b/WebCore/svg/SVGPathSegLinetoVerticalAbs.idl @@ -27,8 +27,7 @@ module svg { interface [Conditional=SVG] SVGPathSegLinetoVerticalAbs : SVGPathSeg { - attribute float y - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float y; }; } diff --git a/WebCore/svg/SVGPathSegLinetoVerticalRel.idl b/WebCore/svg/SVGPathSegLinetoVerticalRel.idl index 7246c7d..a9b9b36 100644 --- a/WebCore/svg/SVGPathSegLinetoVerticalRel.idl +++ b/WebCore/svg/SVGPathSegLinetoVerticalRel.idl @@ -27,8 +27,7 @@ module svg { interface [Conditional=SVG] SVGPathSegLinetoVerticalRel : SVGPathSeg { - attribute float y - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float y; }; } diff --git a/WebCore/svg/SVGPathSegList.cpp b/WebCore/svg/SVGPathSegList.cpp index 5a40c64..09a3c0d 100644 --- a/WebCore/svg/SVGPathSegList.cpp +++ b/WebCore/svg/SVGPathSegList.cpp @@ -25,11 +25,23 @@ #if ENABLE(SVG) #include "SVGPathSegList.h" +#include "SVGPathElement.h" +#include "SVGPathParserFactory.h" + namespace WebCore { -SVGPathSegList::SVGPathSegList(const QualifiedName& attributeName) - : SVGList<RefPtr<SVGPathSeg> >(attributeName) +String SVGPathSegList::valueAsString() const +{ + String pathString; + SVGPathParserFactory::self()->buildStringFromSVGPathSegList(*this, pathString, UnalteredParsing); + return pathString; +} + +void SVGPathSegList::commitChange(SVGElement* contextElement) { + ASSERT(contextElement); + ASSERT(contextElement->hasTagName(SVGNames::pathTag)); + static_cast<SVGPathElement*>(contextElement)->pathSegListChanged(m_role); } } diff --git a/WebCore/svg/SVGPathSegList.h b/WebCore/svg/SVGPathSegList.h index 6e61c06..48a1845 100644 --- a/WebCore/svg/SVGPathSegList.h +++ b/WebCore/svg/SVGPathSegList.h @@ -21,19 +21,36 @@ #define SVGPathSegList_h #if ENABLE(SVG) -#include "SVGList.h" +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> + #include "SVGPathSeg.h" +#include "SVGPropertyTraits.h" namespace WebCore { class SVGElement; -class SVGPathSegList : public SVGList<RefPtr<SVGPathSeg> > { +class SVGPathSegList : public Vector<RefPtr<SVGPathSeg> > { public: - static PassRefPtr<SVGPathSegList> create(const QualifiedName& attributeName) { return adoptRef(new SVGPathSegList(attributeName)); } + SVGPathSegList(SVGPathSegRole role) + : m_role(role) + { + } + + String valueAsString() const; + + // Only used by SVGPathSegListPropertyTearOff. + void commitChange(SVGElement* contextElement); private: - SVGPathSegList(const QualifiedName&); + SVGPathSegRole m_role; +}; + +template<> +struct SVGPropertyTraits<SVGPathSegList> { + static SVGPathSegList initialValue() { return SVGPathSegList(PathSegUndefinedRole); } + typedef RefPtr<SVGPathSeg> ListItemType; }; } // namespace WebCore diff --git a/WebCore/svg/SVGPathSegList.idl b/WebCore/svg/SVGPathSegList.idl index 1407b33..e77a997 100644 --- a/WebCore/svg/SVGPathSegList.idl +++ b/WebCore/svg/SVGPathSegList.idl @@ -29,19 +29,19 @@ module svg { interface [Conditional=SVG] SVGPathSegList { readonly attribute unsigned long numberOfItems; - [JSCCustom] void clear() + void clear() raises(DOMException); - [JSCCustom] SVGPathSeg initialize(in SVGPathSeg newItem) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPathSeg initialize(in SVGPathSeg newItem) raises(DOMException, SVGException); - [JSCCustom] SVGPathSeg getItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPathSeg getItem(in unsigned long index) raises(DOMException); - [JSCCustom] SVGPathSeg insertItemBefore(in SVGPathSeg newItem, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPathSeg insertItemBefore(in SVGPathSeg newItem, in unsigned long index) raises(DOMException, SVGException); - [JSCCustom] SVGPathSeg replaceItem(in SVGPathSeg newItem, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPathSeg replaceItem(in SVGPathSeg newItem, in unsigned long index) raises(DOMException, SVGException); - [JSCCustom] SVGPathSeg removeItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPathSeg removeItem(in unsigned long index) raises(DOMException); - [JSCCustom] SVGPathSeg appendItem(in SVGPathSeg newItem) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPathSeg appendItem(in SVGPathSeg newItem) raises(DOMException, SVGException); }; diff --git a/WebCore/svg/SVGPathSegListBuilder.cpp b/WebCore/svg/SVGPathSegListBuilder.cpp index 342de88..bd657c3 100644 --- a/WebCore/svg/SVGPathSegListBuilder.cpp +++ b/WebCore/svg/SVGPathSegListBuilder.cpp @@ -43,115 +43,107 @@ namespace WebCore { SVGPathSegListBuilder::SVGPathSegListBuilder() - : m_pathSegList(0) + : m_pathElement(0) + , m_pathSegList(0) + , m_pathSegRole(PathSegUndefinedRole) { } void SVGPathSegListBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoordinateMode mode) { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; if (mode == AbsoluteCoordinates) - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegMovetoAbs(targetPoint.x(), targetPoint.y()), ec); + m_pathSegList->append(m_pathElement->createSVGPathSegMovetoAbs(targetPoint.x(), targetPoint.y(), m_pathSegRole)); else - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegMovetoRel(targetPoint.x(), targetPoint.y()), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegMovetoRel(targetPoint.x(), targetPoint.y(), m_pathSegRole)); } void SVGPathSegListBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode mode) { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; if (mode == AbsoluteCoordinates) - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoAbs(targetPoint.x(), targetPoint.y()), ec); + m_pathSegList->append(m_pathElement->createSVGPathSegLinetoAbs(targetPoint.x(), targetPoint.y(), m_pathSegRole)); else - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoRel(targetPoint.x(), targetPoint.y()), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegLinetoRel(targetPoint.x(), targetPoint.y(), m_pathSegRole)); } void SVGPathSegListBuilder::lineToHorizontal(float x, PathCoordinateMode mode) { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; if (mode == AbsoluteCoordinates) - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoHorizontalAbs(x), ec); + m_pathSegList->append(m_pathElement->createSVGPathSegLinetoHorizontalAbs(x, m_pathSegRole)); else - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoHorizontalRel(x), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegLinetoHorizontalRel(x, m_pathSegRole)); } void SVGPathSegListBuilder::lineToVertical(float y, PathCoordinateMode mode) { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; if (mode == AbsoluteCoordinates) - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoVerticalAbs(y), ec); + m_pathSegList->append(m_pathElement->createSVGPathSegLinetoVerticalAbs(y, m_pathSegRole)); else - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegLinetoVerticalRel(y), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegLinetoVerticalRel(y, m_pathSegRole)); } void SVGPathSegListBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode) { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; if (mode == AbsoluteCoordinates) - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicAbs(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), point2.x(), point2.y()), ec); + m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoCubicAbs(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), point2.x(), point2.y(), m_pathSegRole)); else - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicRel(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), point2.x(), point2.y()), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoCubicRel(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), point2.x(), point2.y(), m_pathSegRole)); } void SVGPathSegListBuilder::curveToCubicSmooth(const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode) { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; if (mode == AbsoluteCoordinates) - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs(targetPoint.x(), targetPoint.y(), point2.x(), point2.y()), ec); + m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoCubicSmoothAbs(targetPoint.x(), targetPoint.y(), point2.x(), point2.y(), m_pathSegRole)); else - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(targetPoint.x(), targetPoint.y(), point2.x(), point2.y()), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoCubicSmoothRel(targetPoint.x(), targetPoint.y(), point2.x(), point2.y(), m_pathSegRole)); } void SVGPathSegListBuilder::curveToQuadratic(const FloatPoint& point1, const FloatPoint& targetPoint, PathCoordinateMode mode) { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; if (mode == AbsoluteCoordinates) - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticAbs(targetPoint.x(), targetPoint.y(), point1.x(), point1.y()), ec); + m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoQuadraticAbs(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), m_pathSegRole)); else - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticRel(targetPoint.x(), targetPoint.y(), point1.x(), point1.y()), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoQuadraticRel(targetPoint.x(), targetPoint.y(), point1.x(), point1.y(), m_pathSegRole)); } void SVGPathSegListBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint, PathCoordinateMode mode) { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; if (mode == AbsoluteCoordinates) - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(targetPoint.x(), targetPoint.y()), ec); + m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoQuadraticSmoothAbs(targetPoint.x(), targetPoint.y(), m_pathSegRole)); else - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(targetPoint.x(), targetPoint.y()), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegCurvetoQuadraticSmoothRel(targetPoint.x(), targetPoint.y(), m_pathSegRole)); } void SVGPathSegListBuilder::arcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode) { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; if (mode == AbsoluteCoordinates) - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegArcAbs(targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepFlag), ec); + m_pathSegList->append(m_pathElement->createSVGPathSegArcAbs(targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepFlag, m_pathSegRole)); else - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegArcRel(targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepFlag), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegArcRel(targetPoint.x(), targetPoint.y(), r1, r2, angle, largeArcFlag, sweepFlag, m_pathSegRole)); } void SVGPathSegListBuilder::closePath() { + ASSERT(m_pathElement); ASSERT(m_pathSegList); - ExceptionCode ec = 0; - m_pathSegList->appendItem(SVGPathElement::createSVGPathSegClosePath(), ec); - ASSERT(!ec); + m_pathSegList->append(m_pathElement->createSVGPathSegClosePath(m_pathSegRole)); } } diff --git a/WebCore/svg/SVGPathSegListBuilder.h b/WebCore/svg/SVGPathSegListBuilder.h index f376706..8f75b26 100644 --- a/WebCore/svg/SVGPathSegListBuilder.h +++ b/WebCore/svg/SVGPathSegListBuilder.h @@ -27,6 +27,7 @@ #if ENABLE(SVG) #include "FloatPoint.h" #include "SVGPathConsumer.h" +#include "SVGPathElement.h" #include "SVGPathSegList.h" namespace WebCore { @@ -35,12 +36,19 @@ class SVGPathSegListBuilder : public SVGPathConsumer { public: SVGPathSegListBuilder(); - void setCurrentSVGPathSegList(SVGPathSegList* pathSegList) { m_pathSegList = pathSegList; } + void setCurrentSVGPathElement(SVGPathElement* pathElement) { m_pathElement = pathElement; } + void setCurrentSVGPathSegList(SVGPathSegList& pathSegList) { m_pathSegList = &pathSegList; } + void setCurrentSVGPathSegRole(SVGPathSegRole pathSegRole) { m_pathSegRole = pathSegRole; } private: virtual void incrementPathSegmentCount() { } virtual bool continueConsuming() { return true; } - virtual void cleanup() { m_pathSegList = 0; } + virtual void cleanup() + { + m_pathElement = 0; + m_pathSegList = 0; + m_pathSegRole = PathSegUndefinedRole; + } // Used in UnalteredParisng/NormalizedParsing modes. virtual void moveTo(const FloatPoint&, bool closed, PathCoordinateMode); @@ -56,7 +64,9 @@ private: virtual void curveToQuadraticSmooth(const FloatPoint&, PathCoordinateMode); virtual void arcTo(float, float, float, bool largeArcFlag, bool sweepFlag, const FloatPoint&, PathCoordinateMode); + SVGPathElement* m_pathElement; SVGPathSegList* m_pathSegList; + SVGPathSegRole m_pathSegRole; }; } // namespace WebCore diff --git a/WebCore/svg/SVGPathSegListSource.cpp b/WebCore/svg/SVGPathSegListSource.cpp index 2378743..5526cd6 100644 --- a/WebCore/svg/SVGPathSegListSource.cpp +++ b/WebCore/svg/SVGPathSegListSource.cpp @@ -31,12 +31,11 @@ namespace WebCore { -SVGPathSegListSource::SVGPathSegListSource(SVGPathSegList* pathSegList) +SVGPathSegListSource::SVGPathSegListSource(const SVGPathSegList& pathSegList) : m_pathSegList(pathSegList) { - ASSERT(m_pathSegList); m_itemCurrent = 0; - m_itemEnd = m_pathSegList->numberOfItems(); + m_itemEnd = m_pathSegList.size(); } bool SVGPathSegListSource::hasMoreData() const @@ -46,11 +45,7 @@ bool SVGPathSegListSource::hasMoreData() const bool SVGPathSegListSource::parseSVGSegmentType(SVGPathSegType& pathSegType) { - ASSERT(m_pathSegList); - ExceptionCode ec = 0; - m_segment = m_pathSegList->getItem(m_itemCurrent, ec); - if (ec) - return false; + m_segment = m_pathSegList.at(m_itemCurrent); pathSegType = static_cast<SVGPathSegType>(m_segment->pathSegType()); ++m_itemCurrent; return true; @@ -58,11 +53,7 @@ bool SVGPathSegListSource::parseSVGSegmentType(SVGPathSegType& pathSegType) SVGPathSegType SVGPathSegListSource::nextCommand(SVGPathSegType) { - ASSERT(m_pathSegList); - ExceptionCode ec = 0; - m_segment = m_pathSegList->getItem(m_itemCurrent, ec); - if (ec) - return PathSegUnknown; + m_segment = m_pathSegList.at(m_itemCurrent); SVGPathSegType pathSegType = static_cast<SVGPathSegType>(m_segment->pathSegType()); ++m_itemCurrent; return pathSegType; @@ -72,7 +63,7 @@ bool SVGPathSegListSource::parseMoveToSegment(FloatPoint& targetPoint) { ASSERT(m_segment); ASSERT(m_segment->pathSegType() == PathSegMoveToAbs || m_segment->pathSegType() == PathSegMoveToRel); - SVGPathSegSingleCoord* moveTo = static_cast<SVGPathSegSingleCoord*>(m_segment.get()); + SVGPathSegSingleCoordinate* moveTo = static_cast<SVGPathSegSingleCoordinate*>(m_segment.get()); targetPoint = FloatPoint(moveTo->x(), moveTo->y()); return true; } @@ -81,7 +72,7 @@ bool SVGPathSegListSource::parseLineToSegment(FloatPoint& targetPoint) { ASSERT(m_segment); ASSERT(m_segment->pathSegType() == PathSegLineToAbs || m_segment->pathSegType() == PathSegLineToRel); - SVGPathSegSingleCoord* lineTo = static_cast<SVGPathSegSingleCoord*>(m_segment.get()); + SVGPathSegSingleCoordinate* lineTo = static_cast<SVGPathSegSingleCoordinate*>(m_segment.get()); targetPoint = FloatPoint(lineTo->x(), lineTo->y()); return true; } @@ -139,7 +130,7 @@ bool SVGPathSegListSource::parseCurveToQuadraticSmoothSegment(FloatPoint& target { ASSERT(m_segment); ASSERT(m_segment->pathSegType() == PathSegCurveToQuadraticSmoothAbs || m_segment->pathSegType() == PathSegCurveToQuadraticSmoothRel); - SVGPathSegSingleCoord* quadraticSmooth = static_cast<SVGPathSegSingleCoord*>(m_segment.get()); + SVGPathSegSingleCoordinate* quadraticSmooth = static_cast<SVGPathSegSingleCoordinate*>(m_segment.get()); targetPoint = FloatPoint(quadraticSmooth->x(), quadraticSmooth->y()); return true; } diff --git a/WebCore/svg/SVGPathSegListSource.h b/WebCore/svg/SVGPathSegListSource.h index 4f93be1..357248f 100644 --- a/WebCore/svg/SVGPathSegListSource.h +++ b/WebCore/svg/SVGPathSegListSource.h @@ -32,13 +32,13 @@ namespace WebCore { class SVGPathSegListSource : public SVGPathSource { public: - static PassOwnPtr<SVGPathSegListSource> create(SVGPathSegList* pathSegList) + static PassOwnPtr<SVGPathSegListSource> create(const SVGPathSegList& pathSegList) { return adoptPtr(new SVGPathSegListSource(pathSegList)); } private: - SVGPathSegListSource(SVGPathSegList*); + SVGPathSegListSource(const SVGPathSegList&); virtual bool hasMoreData() const; virtual bool moveToNextToken() { return true; } @@ -55,7 +55,7 @@ private: virtual bool parseCurveToQuadraticSmoothSegment(FloatPoint&); virtual bool parseArcToSegment(float&, float&, float&, bool&, bool&, FloatPoint&); - SVGPathSegList* m_pathSegList; + const SVGPathSegList& m_pathSegList; RefPtr<SVGPathSeg> m_segment; int m_itemCurrent; int m_itemEnd; diff --git a/WebCore/svg/SVGPathSegMoveto.cpp b/WebCore/svg/SVGPathSegMoveto.cpp deleted file mode 100644 index f87077f..0000000 --- a/WebCore/svg/SVGPathSegMoveto.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - * - * 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. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPathSegMoveto.h" - -namespace WebCore { - -SVGPathSegMovetoAbs::SVGPathSegMovetoAbs(float x, float y) - : SVGPathSegSingleCoord(x, y) -{ -} - -SVGPathSegMovetoRel::SVGPathSegMovetoRel(float x, float y) - : SVGPathSegSingleCoord(x, y) -{ -} -} - -#endif // ENABLE(SVG) - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegMoveto.h b/WebCore/svg/SVGPathSegMoveto.h index edaff4b..87fcd7d 100644 --- a/WebCore/svg/SVGPathSegMoveto.h +++ b/WebCore/svg/SVGPathSegMoveto.h @@ -22,36 +22,45 @@ #define SVGPathSegMoveto_h #if ENABLE(SVG) - -#include "PlatformString.h" -#include "SVGPathSeg.h" +#include "SVGPathSegWithContext.h" namespace WebCore { - class SVGPathSegMovetoAbs : public SVGPathSegSingleCoord { - public: - static PassRefPtr<SVGPathSegMovetoAbs> create(float x, float y) { return adoptRef(new SVGPathSegMovetoAbs(x, y)); } - private: - SVGPathSegMovetoAbs(float x, float y); +class SVGPathSegMovetoAbs : public SVGPathSegSingleCoordinate { +public: + static PassRefPtr<SVGPathSegMovetoAbs> create(SVGPathElement* element, SVGPathSegRole role, float x, float y) + { + return adoptRef(new SVGPathSegMovetoAbs(element, role, x, y)); + } + +private: + SVGPathSegMovetoAbs(SVGPathElement* element, SVGPathSegRole role, float x, float y) + : SVGPathSegSingleCoordinate(element, role, x, y) + { + } - virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_ABS; } - virtual String pathSegTypeAsLetter() const { return "M"; } - }; + virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_ABS; } + virtual String pathSegTypeAsLetter() const { return "M"; } +}; - class SVGPathSegMovetoRel : public SVGPathSegSingleCoord { - public: - static PassRefPtr<SVGPathSegMovetoRel> create(float x, float y) { return adoptRef(new SVGPathSegMovetoRel(x, y)); } +class SVGPathSegMovetoRel : public SVGPathSegSingleCoordinate { +public: + static PassRefPtr<SVGPathSegMovetoRel> create(SVGPathElement* element, SVGPathSegRole role, float x, float y) + { + return adoptRef(new SVGPathSegMovetoRel(element, role, x, y)); + } - private: - SVGPathSegMovetoRel(float x, float y); +private: + SVGPathSegMovetoRel(SVGPathElement* element, SVGPathSegRole role, float x, float y) + : SVGPathSegSingleCoordinate(element, role, x, y) + { + } - virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_REL; } - virtual String pathSegTypeAsLetter() const { return "m"; } - }; + virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_REL; } + virtual String pathSegTypeAsLetter() const { return "m"; } +}; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGPathSegMovetoAbs.idl b/WebCore/svg/SVGPathSegMovetoAbs.idl index e10163e..bf371a2 100644 --- a/WebCore/svg/SVGPathSegMovetoAbs.idl +++ b/WebCore/svg/SVGPathSegMovetoAbs.idl @@ -27,10 +27,8 @@ module svg { interface [Conditional=SVG] SVGPathSegMovetoAbs : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; }; } diff --git a/WebCore/svg/SVGPathSegMovetoRel.idl b/WebCore/svg/SVGPathSegMovetoRel.idl index 78ba078..a8763a1 100644 --- a/WebCore/svg/SVGPathSegMovetoRel.idl +++ b/WebCore/svg/SVGPathSegMovetoRel.idl @@ -27,10 +27,8 @@ module svg { interface [Conditional=SVG] SVGPathSegMovetoRel : SVGPathSeg { - attribute float x - /*setter raises(DOMException)*/; - attribute float y - /*setter raises(DOMException)*/; + attribute [StrictTypeChecking] float x; + attribute [StrictTypeChecking] float y; }; } diff --git a/WebCore/svg/SVGPathSegWithContext.h b/WebCore/svg/SVGPathSegWithContext.h new file mode 100644 index 0000000..97d8df1 --- /dev/null +++ b/WebCore/svg/SVGPathSegWithContext.h @@ -0,0 +1,109 @@ +/* + * 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 SVGPathSegWithContext_h +#define SVGPathSegWithContext_h + +#if ENABLE(SVG) +#include "SVGPathElement.h" + +namespace WebCore { + +class SVGPathSegWithContext : public SVGPathSeg { +public: + SVGPathSegWithContext(SVGPathElement* element, SVGPathSegRole role) + : m_role(role) + , m_element(element) + { + } + + SVGAnimatedProperty* animatedProperty() const + { + switch (m_role) { + case PathSegUndefinedRole: + return 0; + case PathSegUnalteredRole: + return m_element->animatablePathSegList(); + case PathSegNormalizedRole: + // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists! + return 0; + }; + + return 0; + } + + SVGPathElement* contextElement() const { return m_element.get(); } + SVGPathSegRole role() const { return m_role; } + + void setContextAndRole(SVGPathElement* element, SVGPathSegRole role) + { + m_role = role; + m_element = element; + } + +protected: + void commitChange() + { + if (!m_element) { + ASSERT(m_role == PathSegUndefinedRole); + return; + } + + ASSERT(m_role != PathSegUndefinedRole); + m_element->pathSegListChanged(m_role); + } + +private: + SVGPathSegRole m_role; + RefPtr<SVGPathElement> m_element; +}; + +class SVGPathSegSingleCoordinate : public SVGPathSegWithContext { +public: + float x() const { return m_x; } + void setX(float x) + { + m_x = x; + commitChange(); + } + + float y() const { return m_y; } + void setY(float y) + { + m_y = y; + commitChange(); + } + +protected: + SVGPathSegSingleCoordinate(SVGPathElement* element, SVGPathSegRole role, float x, float y) + : SVGPathSegWithContext(element, role) + , m_x(x) + , m_y(y) + { + } + +private: + float m_x; + float m_y; +}; + +} // namespace WebCore + +#endif // ENABLE(SVG) +#endif diff --git a/WebCore/svg/SVGPatternElement.cpp b/WebCore/svg/SVGPatternElement.cpp index 229e1db..11f04d2 100644 --- a/WebCore/svg/SVGPatternElement.cpp +++ b/WebCore/svg/SVGPatternElement.cpp @@ -33,22 +33,22 @@ #include "PatternAttributes.h" #include "RenderSVGContainer.h" #include "RenderSVGResourcePattern.h" -#include "SVGLength.h" #include "SVGNames.h" #include "SVGRenderSupport.h" #include "SVGSVGElement.h" #include "SVGStyledTransformableElement.h" -#include "SVGTransformList.h" #include "SVGTransformable.h" #include "SVGUnitTypes.h" -#include <math.h> -#include <wtf/MathExtras.h> -#include <wtf/OwnPtr.h> - -using namespace std; namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::widthAttr, Width, width) +DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::heightAttr, Height, height) +DEFINE_ANIMATED_TRANSFORM_LIST(SVGPatternElement, SVGNames::patternTransformAttr, PatternTransform, patternTransform) + inline SVGPatternElement::SVGPatternElement(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) , m_x(LengthModeWidth) @@ -83,7 +83,7 @@ void SVGPatternElement::parseMappedAttribute(Attribute* attr) newList.clear(); detachAnimatedPatternTransformListWrappers(newList.size()); - patternTransformBaseValue() = newList; + setPatternTransformBaseValue(newList); } else if (attr->name() == SVGNames::xAttr) setXBaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::yAttr) @@ -158,6 +158,7 @@ void SVGPatternElement::synchronizeProperty(const QualifiedName& attrName) synchronizeViewBox(); synchronizePreserveAspectRatio(); synchronizeHref(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -177,11 +178,14 @@ void SVGPatternElement::synchronizeProperty(const QualifiedName& attrName) synchronizeHeight(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); - else if (SVGFitToViewBox::isKnownAttribute(attrName)) { + else if (attrName == SVGNames::viewBoxAttr) synchronizeViewBox(); + else if (attrName == SVGNames::preserveAspectRatioAttr) synchronizePreserveAspectRatio(); - } else if (SVGURIReference::isKnownAttribute(attrName)) + else if (SVGURIReference::isKnownAttribute(attrName)) synchronizeHref(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGPatternElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) diff --git a/WebCore/svg/SVGPatternElement.h b/WebCore/svg/SVGPatternElement.h index 37f91ca..b0c4446 100644 --- a/WebCore/svg/SVGPatternElement.h +++ b/WebCore/svg/SVGPatternElement.h @@ -28,61 +28,61 @@ #include "SVGExternalResourcesRequired.h" #include "SVGFitToViewBox.h" #include "SVGLangSpace.h" +#include "SVGPreserveAspectRatio.h" +#include "SVGRect.h" #include "SVGStyledElement.h" #include "SVGTests.h" -#include "SVGTransformList.h" #include "SVGURIReference.h" namespace WebCore { - struct PatternAttributes; +struct PatternAttributes; - class SVGLength; - - class SVGPatternElement : public SVGStyledElement, - public SVGURIReference, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired, - public SVGFitToViewBox { - public: - static PassRefPtr<SVGPatternElement> create(const QualifiedName&, Document*); - - void collectPatternAttributes(PatternAttributes&) const; - - private: - SVGPatternElement(const QualifiedName&, Document*); - - virtual bool isValid() const { return SVGTests::isValid(); } - virtual bool needsPendingResourceHandling() const { return false; } - - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); - virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); - - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - - virtual bool selfHasRelativeLengths() const; - - DECLARE_ANIMATED_PROPERTY_NEW(SVGPatternElement, SVGNames::xAttr, SVGLength, X, x) - DECLARE_ANIMATED_PROPERTY_NEW(SVGPatternElement, SVGNames::yAttr, SVGLength, Y, y) - DECLARE_ANIMATED_PROPERTY_NEW(SVGPatternElement, SVGNames::widthAttr, SVGLength, Width, width) - DECLARE_ANIMATED_PROPERTY_NEW(SVGPatternElement, SVGNames::heightAttr, SVGLength, Height, height) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPatternElement, SVGNames::patternUnitsAttr, int, PatternUnits, patternUnits) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPatternElement, SVGNames::patternContentUnitsAttr, int, PatternContentUnits, patternContentUnits) - DECLARE_ANIMATED_TRANSFORM_LIST_PROPERTY_NEW(SVGPatternElement, SVGNames::patternTransformAttr, SVGTransformList, PatternTransform, patternTransform) - - // SVGURIReference - 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_NEW(SVGPatternElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) - }; +class SVGPatternElement : public SVGStyledElement, + public SVGURIReference, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired, + public SVGFitToViewBox { +public: + static PassRefPtr<SVGPatternElement> create(const QualifiedName&, Document*); + + void collectPatternAttributes(PatternAttributes&) const; + +private: + SVGPatternElement(const QualifiedName&, Document*); + + virtual bool isValid() const { return SVGTests::isValid(); } + virtual bool needsPendingResourceHandling() const { return false; } + + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); + virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); + + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + + virtual bool selfHasRelativeLengths() const; + + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) + DECLARE_ANIMATED_LENGTH(Width, width) + DECLARE_ANIMATED_LENGTH(Height, height) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPatternElement, SVGNames::patternUnitsAttr, int, PatternUnits, patternUnits) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPatternElement, SVGNames::patternContentUnitsAttr, int, PatternContentUnits, patternContentUnits) + DECLARE_ANIMATED_TRANSFORM_LIST(PatternTransform, patternTransform) + + // SVGURIReference + 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_NEW(SVGPatternElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGPointList.h b/WebCore/svg/SVGPointList.h index 9f2efc9..4918936 100644 --- a/WebCore/svg/SVGPointList.h +++ b/WebCore/svg/SVGPointList.h @@ -23,8 +23,8 @@ #if ENABLE(SVG) #include "QualifiedName.h" +#include "SVGPropertyTraits.h" #include <wtf/Vector.h> -#include <wtf/text/WTFString.h> namespace WebCore { @@ -39,6 +39,12 @@ public: static bool createAnimated(const SVGPointList& fromList, const SVGPointList& toList, SVGPointList& resultList, float progress); }; +template<> +struct SVGPropertyTraits<SVGPointList> { + static SVGPointList initialValue() { return SVGPointList(); } + typedef FloatPoint ListItemType; +}; + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGPointList.idl b/WebCore/svg/SVGPointList.idl index 647ae69..080d114 100644 --- a/WebCore/svg/SVGPointList.idl +++ b/WebCore/svg/SVGPointList.idl @@ -30,17 +30,17 @@ module svg { void clear() raises(DOMException); - SVGPoint initialize(in SVGPoint item) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPoint initialize(in SVGPoint item) raises(DOMException, SVGException); - SVGPoint getItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPoint getItem(in unsigned long index) raises(DOMException); - SVGPoint insertItemBefore(in SVGPoint item, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPoint insertItemBefore(in SVGPoint item, in unsigned long index) raises(DOMException, SVGException); - SVGPoint replaceItem(in SVGPoint item, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPoint replaceItem(in SVGPoint item, in unsigned long index) raises(DOMException, SVGException); - SVGPoint removeItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPoint removeItem(in unsigned long index) raises(DOMException); - SVGPoint appendItem(in SVGPoint item) + [StrictTypeChecking, RequiresAllArguments=Raise] SVGPoint appendItem(in SVGPoint item) raises(DOMException, SVGException); }; diff --git a/WebCore/svg/SVGPolyElement.cpp b/WebCore/svg/SVGPolyElement.cpp index 211dd58..beef21f 100644 --- a/WebCore/svg/SVGPolyElement.cpp +++ b/WebCore/svg/SVGPolyElement.cpp @@ -97,6 +97,7 @@ void SVGPolyElement::synchronizeProperty(const QualifiedName& attrName) if (attrName == anyQName()) { synchronizeExternalResourcesRequired(); synchronizePoints(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -104,6 +105,8 @@ void SVGPolyElement::synchronizeProperty(const QualifiedName& attrName) synchronizeExternalResourcesRequired(); else if (attrName == SVGNames::pointsAttr) synchronizePoints(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGPolyElement::synchronizePoints() diff --git a/WebCore/svg/SVGPolygonElement.cpp b/WebCore/svg/SVGPolygonElement.cpp index 3439a78..f0bca35 100644 --- a/WebCore/svg/SVGPolygonElement.cpp +++ b/WebCore/svg/SVGPolygonElement.cpp @@ -23,6 +23,8 @@ #if ENABLE(SVG) #include "SVGPolygonElement.h" +#include "Path.h" + namespace WebCore { inline SVGPolygonElement::SVGPolygonElement(const QualifiedName& tagName, Document* document) diff --git a/WebCore/svg/SVGPolylineElement.cpp b/WebCore/svg/SVGPolylineElement.cpp index 8bd6d7b..e72173b 100644 --- a/WebCore/svg/SVGPolylineElement.cpp +++ b/WebCore/svg/SVGPolylineElement.cpp @@ -23,6 +23,8 @@ #if ENABLE(SVG) #include "SVGPolylineElement.h" +#include "Path.h" + namespace WebCore { inline SVGPolylineElement::SVGPolylineElement(const QualifiedName& tagName, Document* document) diff --git a/WebCore/svg/SVGPreserveAspectRatio.h b/WebCore/svg/SVGPreserveAspectRatio.h index eda82d4..bf00ee4 100644 --- a/WebCore/svg/SVGPreserveAspectRatio.h +++ b/WebCore/svg/SVGPreserveAspectRatio.h @@ -23,7 +23,7 @@ #if ENABLE(SVG) #include "ExceptionCode.h" -#include <wtf/text/WTFString.h> +#include "SVGPropertyTraits.h" namespace WebCore { @@ -86,6 +86,12 @@ private: SVGMeetOrSliceType m_meetOrSlice; }; +template<> +struct SVGPropertyTraits<SVGPreserveAspectRatio> { + static SVGPreserveAspectRatio initialValue() { return SVGPreserveAspectRatio(); } + static String toString(const SVGPreserveAspectRatio& type) { return type.valueAsString(); } +}; + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGRadialGradientElement.cpp b/WebCore/svg/SVGRadialGradientElement.cpp index aaf32bc..d525531 100644 --- a/WebCore/svg/SVGRadialGradientElement.cpp +++ b/WebCore/svg/SVGRadialGradientElement.cpp @@ -31,7 +31,6 @@ #include "FloatPoint.h" #include "RadialGradientAttributes.h" #include "RenderSVGResourceRadialGradient.h" -#include "SVGLength.h" #include "SVGNames.h" #include "SVGStopElement.h" #include "SVGTransform.h" @@ -40,6 +39,13 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::cxAttr, Cx, cx) +DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::cyAttr, Cy, cy) +DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::rAttr, R, r) +DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::fxAttr, Fx, fx) +DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::fyAttr, Fy, fy) + inline SVGRadialGradientElement::SVGRadialGradientElement(const QualifiedName& tagName, Document* document) : SVGGradientElement(tagName, document) , m_cx(LengthModeWidth, "50%") diff --git a/WebCore/svg/SVGRadialGradientElement.h b/WebCore/svg/SVGRadialGradientElement.h index f223514..52f5498 100644 --- a/WebCore/svg/SVGRadialGradientElement.h +++ b/WebCore/svg/SVGRadialGradientElement.h @@ -28,33 +28,33 @@ namespace WebCore { - struct RadialGradientAttributes; - class SVGLength; +struct RadialGradientAttributes; - class SVGRadialGradientElement : public SVGGradientElement { - public: - static PassRefPtr<SVGRadialGradientElement> create(const QualifiedName&, Document*); +class SVGRadialGradientElement : public SVGGradientElement { +public: + static PassRefPtr<SVGRadialGradientElement> create(const QualifiedName&, Document*); - void collectGradientAttributes(RadialGradientAttributes&); - void calculateFocalCenterPointsAndRadius(const RadialGradientAttributes&, FloatPoint& focalPoint, FloatPoint& centerPoint, float& radius); + void collectGradientAttributes(RadialGradientAttributes&); + void calculateFocalCenterPointsAndRadius(const RadialGradientAttributes&, FloatPoint& focalPoint, FloatPoint& centerPoint, float& radius); - private: - SVGRadialGradientElement(const QualifiedName&, Document*); +private: + SVGRadialGradientElement(const QualifiedName&, Document*); - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - DECLARE_ANIMATED_PROPERTY_NEW(SVGRadialGradientElement, SVGNames::cxAttr, SVGLength, Cx, cx) - DECLARE_ANIMATED_PROPERTY_NEW(SVGRadialGradientElement, SVGNames::cyAttr, SVGLength, Cy, cy) - DECLARE_ANIMATED_PROPERTY_NEW(SVGRadialGradientElement, SVGNames::rAttr, SVGLength, R, r) - DECLARE_ANIMATED_PROPERTY_NEW(SVGRadialGradientElement, SVGNames::fxAttr, SVGLength, Fx, fx) - DECLARE_ANIMATED_PROPERTY_NEW(SVGRadialGradientElement, SVGNames::fyAttr, SVGLength, Fy, fy) - }; + // Animated property declarations + DECLARE_ANIMATED_LENGTH(Cx, cx) + DECLARE_ANIMATED_LENGTH(Cy, cy) + DECLARE_ANIMATED_LENGTH(R, r) + DECLARE_ANIMATED_LENGTH(Fx, fx) + DECLARE_ANIMATED_LENGTH(Fy, fy) +}; } // namespace WebCore diff --git a/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h b/WebCore/svg/SVGRect.h index 3e31095..379a5bf 100644 --- a/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h +++ b/WebCore/svg/SVGRect.h @@ -1,6 +1,5 @@ /* * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -18,18 +17,35 @@ * Boston, MA 02110-1301, USA. */ -#ifndef DeprecatedSVGAnimatedPropertyTraits_h -#define DeprecatedSVGAnimatedPropertyTraits_h +#ifndef SVGRect_h +#define SVGRect_h #if ENABLE(SVG) +#include "FloatRect.h" +#include "SVGPropertyTraits.h" +#include <wtf/text/StringBuilder.h> -// FIXME: Remove this file! namespace WebCore { -template<typename Type> -struct DeprecatedSVGAnimatedPropertyTraits : public Noncopyable { }; +template<> +struct SVGPropertyTraits<FloatRect> { + static FloatRect initialValue() { return FloatRect(); } + static String toString(const FloatRect& type) + { + StringBuilder builder; + builder.append(String::number(type.x())); + builder.append(' '); + builder.append(String::number(type.y())); + builder.append(' '); + builder.append(String::number(type.width())); + builder.append(' '); + builder.append(String::number(type.height())); + builder.append(' '); + return builder.toString(); + } +}; -} +} // namespace WebCore -#endif -#endif +#endif // ENABLE(SVG) +#endif // SVGRect_h diff --git a/WebCore/svg/SVGRectElement.cpp b/WebCore/svg/SVGRectElement.cpp index c3ff3cb..04fba95 100644 --- a/WebCore/svg/SVGRectElement.cpp +++ b/WebCore/svg/SVGRectElement.cpp @@ -31,6 +31,14 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::widthAttr, Width, width) +DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::heightAttr, Height, height) +DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::rxAttr, Rx, rx) +DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::ryAttr, Ry, ry) + inline SVGRectElement::SVGRectElement(const QualifiedName& tagName, Document* document) : SVGStyledTransformableElement(tagName, document) , m_x(LengthModeWidth) @@ -130,6 +138,7 @@ void SVGRectElement::synchronizeProperty(const QualifiedName& attrName) synchronizeRx(); synchronizeRy(); synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -147,6 +156,8 @@ void SVGRectElement::synchronizeProperty(const QualifiedName& attrName) synchronizeRy(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGRectElement::toPathData(Path& path) const diff --git a/WebCore/svg/SVGRectElement.h b/WebCore/svg/SVGRectElement.h index 8cc262f..706c41c 100644 --- a/WebCore/svg/SVGRectElement.h +++ b/WebCore/svg/SVGRectElement.h @@ -31,36 +31,37 @@ namespace WebCore { - class SVGRectElement : public SVGStyledTransformableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired { - public: - static PassRefPtr<SVGRectElement> create(const QualifiedName&, Document*); +class SVGRectElement : public SVGStyledTransformableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired { +public: + static PassRefPtr<SVGRectElement> create(const QualifiedName&, Document*); - private: - SVGRectElement(const QualifiedName&, Document*); - - virtual bool isValid() const { return SVGTests::isValid(); } +private: + SVGRectElement(const QualifiedName&, Document*); + + virtual bool isValid() const { return SVGTests::isValid(); } - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual void toPathData(Path&) const; + virtual void toPathData(Path&) const; - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - DECLARE_ANIMATED_PROPERTY_NEW(SVGRectElement, SVGNames::xAttr, SVGLength, X, x) - DECLARE_ANIMATED_PROPERTY_NEW(SVGRectElement, SVGNames::yAttr, SVGLength, Y, y) - DECLARE_ANIMATED_PROPERTY_NEW(SVGRectElement, SVGNames::widthAttr, SVGLength, Width, width) - DECLARE_ANIMATED_PROPERTY_NEW(SVGRectElement, SVGNames::heightAttr, SVGLength, Height, height) - DECLARE_ANIMATED_PROPERTY_NEW(SVGRectElement, SVGNames::rxAttr, SVGLength, Rx, rx) - DECLARE_ANIMATED_PROPERTY_NEW(SVGRectElement, SVGNames::ryAttr, SVGLength, Ry, ry) + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) + DECLARE_ANIMATED_LENGTH(Width, width) + DECLARE_ANIMATED_LENGTH(Height, height) + DECLARE_ANIMATED_LENGTH(Rx, rx) + DECLARE_ANIMATED_LENGTH(Ry, ry) - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGRectElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - }; + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGRectElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGSVGElement.cpp b/WebCore/svg/SVGSVGElement.cpp index e90fba4..f418315 100644 --- a/WebCore/svg/SVGSVGElement.cpp +++ b/WebCore/svg/SVGSVGElement.cpp @@ -40,7 +40,6 @@ #include "RenderSVGViewportContainer.h" #include "SMILTimeContainer.h" #include "SVGAngle.h" -#include "SVGLength.h" #include "SVGNames.h" #include "SVGPreserveAspectRatio.h" #include "SVGTransform.h" @@ -57,13 +56,14 @@ namespace WebCore { using namespace HTMLNames; using namespace SVGNames; -SVGSVGElement::SVGSVGElement(const QualifiedName& tagName, Document* doc) +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGSVGElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGSVGElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH(SVGSVGElement, SVGNames::widthAttr, Width, width) +DEFINE_ANIMATED_LENGTH(SVGSVGElement, SVGNames::heightAttr, Height, height) + +inline SVGSVGElement::SVGSVGElement(const QualifiedName& tagName, Document* doc) : SVGStyledLocatableElement(tagName, doc) - , SVGTests() - , SVGLangSpace() - , SVGExternalResourcesRequired() - , SVGFitToViewBox() - , SVGZoomAndPan() , m_x(LengthModeWidth) , m_y(LengthModeHeight) , m_width(LengthModeWidth, "100%") @@ -357,6 +357,7 @@ void SVGSVGElement::synchronizeProperty(const QualifiedName& attrName) synchronizeExternalResourcesRequired(); synchronizeViewBox(); synchronizePreserveAspectRatio(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -370,10 +371,12 @@ void SVGSVGElement::synchronizeProperty(const QualifiedName& attrName) synchronizeHeight(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); - else if (SVGFitToViewBox::isKnownAttribute(attrName)) { + else if (attrName == SVGNames::viewBoxAttr) synchronizeViewBox(); + else if (attrName == SVGNames::preserveAspectRatioAttr) synchronizePreserveAspectRatio(); - } + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } unsigned SVGSVGElement::suspendRedraw(unsigned /* maxWaitMilliseconds */) diff --git a/WebCore/svg/SVGSVGElement.h b/WebCore/svg/SVGSVGElement.h index f73fb3f..4a0ac58 100644 --- a/WebCore/svg/SVGSVGElement.h +++ b/WebCore/svg/SVGSVGElement.h @@ -28,148 +28,152 @@ #include "SVGExternalResourcesRequired.h" #include "SVGFitToViewBox.h" #include "SVGLangSpace.h" +#include "SVGPreserveAspectRatio.h" +#include "SVGRect.h" #include "SVGStyledLocatableElement.h" #include "SVGTests.h" #include "SVGZoomAndPan.h" namespace WebCore { - class SVGAngle; - class SVGLength; - class SVGMatrix; - class SVGTransform; - class SVGViewSpec; - class SVGViewElement; - class SMILTimeContainer; - class SVGSVGElement : public SVGStyledLocatableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired, - public SVGFitToViewBox, - public SVGZoomAndPan { - public: - static PassRefPtr<SVGSVGElement> create(const QualifiedName&, Document*); - - virtual bool isValid() const { return SVGTests::isValid(); } - // 'SVGSVGElement' functions - const AtomicString& contentScriptType() const; - void setContentScriptType(const AtomicString& type); +class SVGAngle; +class SVGMatrix; +class SVGTransform; +class SVGViewSpec; +class SVGViewElement; +class SMILTimeContainer; - const AtomicString& contentStyleType() const; - void setContentStyleType(const AtomicString& type); +class SVGSVGElement : public SVGStyledLocatableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired, + public SVGFitToViewBox, + public SVGZoomAndPan { +public: + static PassRefPtr<SVGSVGElement> create(const QualifiedName&, Document*); - FloatRect viewport() const; + virtual bool isValid() const { return SVGTests::isValid(); } - void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; m_hasSetContainerSize = true; } - IntSize containerSize() const { return m_containerSize; } - bool hasSetContainerSize() const { return m_hasSetContainerSize; } - int relativeWidthValue() const; - int relativeHeightValue() const; + // 'SVGSVGElement' functions + const AtomicString& contentScriptType() const; + void setContentScriptType(const AtomicString& type); - float pixelUnitToMillimeterX() const; - float pixelUnitToMillimeterY() const; - float screenPixelToMillimeterX() const; - float screenPixelToMillimeterY() const; + const AtomicString& contentStyleType() const; + void setContentStyleType(const AtomicString& type); - bool useCurrentView() const; - void setUseCurrentView(bool currentView); + FloatRect viewport() const; - SVGViewSpec* currentView() const; + void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; m_hasSetContainerSize = true; } + IntSize containerSize() const { return m_containerSize; } + bool hasSetContainerSize() const { return m_hasSetContainerSize; } + int relativeWidthValue() const; + int relativeHeightValue() const; - float currentScale() const; - void setCurrentScale(float scale); + float pixelUnitToMillimeterX() const; + float pixelUnitToMillimeterY() const; + float screenPixelToMillimeterX() const; + float screenPixelToMillimeterY() const; - FloatPoint& currentTranslate() { return m_translation; } - void setCurrentTranslate(const FloatPoint&); + bool useCurrentView() const; + void setUseCurrentView(bool currentView); - // Only used from the bindings. - void updateCurrentTranslate(); + SVGViewSpec* currentView() const; - SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); } - - void pauseAnimations(); - void unpauseAnimations(); - bool animationsPaused() const; + float currentScale() const; + void setCurrentScale(float scale); - float getCurrentTime() const; - void setCurrentTime(float seconds); + FloatPoint& currentTranslate() { return m_translation; } + void setCurrentTranslate(const FloatPoint&); - unsigned suspendRedraw(unsigned maxWaitMilliseconds); - void unsuspendRedraw(unsigned suspendHandleId); - void unsuspendRedrawAll(); - void forceRedraw(); + // Only used from the bindings. + void updateCurrentTranslate(); - NodeList* getIntersectionList(const FloatRect&, SVGElement* referenceElement); - NodeList* getEnclosureList(const FloatRect&, SVGElement* referenceElement); - bool checkIntersection(SVGElement*, const FloatRect&); - bool checkEnclosure(SVGElement*, const FloatRect&); - void deselectAll(); + SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); } + + void pauseAnimations(); + void unpauseAnimations(); + bool animationsPaused() const; - static float createSVGNumber(); - static SVGLength createSVGLength(); - static SVGAngle createSVGAngle(); - static FloatPoint createSVGPoint(); - static SVGMatrix createSVGMatrix(); - static FloatRect createSVGRect(); - static SVGTransform createSVGTransform(); - static SVGTransform createSVGTransformFromMatrix(const SVGMatrix&); + float getCurrentTime() const; + void setCurrentTime(float seconds); - AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const; + unsigned suspendRedraw(unsigned maxWaitMilliseconds); + void unsuspendRedraw(unsigned suspendHandleId); + void unsuspendRedrawAll(); + void forceRedraw(); - void inheritViewAttributes(SVGViewElement*); + NodeList* getIntersectionList(const FloatRect&, SVGElement* referenceElement); + NodeList* getEnclosureList(const FloatRect&, SVGElement* referenceElement); + bool checkIntersection(SVGElement*, const FloatRect&); + bool checkEnclosure(SVGElement*, const FloatRect&); + void deselectAll(); - bool isOutermostSVG() const; + static float createSVGNumber(); + static SVGLength createSVGLength(); + static SVGAngle createSVGAngle(); + static FloatPoint createSVGPoint(); + static SVGMatrix createSVGMatrix(); + static FloatRect createSVGRect(); + static SVGTransform createSVGTransform(); + static SVGTransform createSVGTransformFromMatrix(const SVGMatrix&); - Element* getElementById(const AtomicString&) const; + AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const; - protected: - virtual void willMoveToNewOwnerDocument(); - virtual void didMoveToNewOwnerDocument(); + void inheritViewAttributes(SVGViewElement*); - private: - SVGSVGElement(const QualifiedName&, Document*); - virtual ~SVGSVGElement(); + bool isOutermostSVG() const; - virtual bool isSVG() const { return true; } - - virtual void parseMappedAttribute(Attribute*); + Element* getElementById(const AtomicString&) const; - virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); } - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); +protected: + virtual void willMoveToNewOwnerDocument(); + virtual void didMoveToNewOwnerDocument(); - virtual void insertedIntoDocument(); - virtual void removedFromDocument(); +private: + SVGSVGElement(const QualifiedName&, Document*); + virtual ~SVGSVGElement(); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual bool isSVG() const { return true; } + + virtual void parseMappedAttribute(Attribute*); - virtual bool selfHasRelativeLengths() const; + virtual bool rendererIsNeeded(RenderStyle* style) { return StyledElement::rendererIsNeeded(style); } + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::xAttr, SVGLength, X, x) - DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::yAttr, SVGLength, Y, y) - DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::widthAttr, SVGLength, Width, width) - DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::heightAttr, SVGLength, Height, height) + virtual void insertedIntoDocument(); + virtual void removedFromDocument(); - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGSVGElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - // SVGFitToViewBox - DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox) - DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + virtual bool selfHasRelativeLengths() const; + + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) + DECLARE_ANIMATED_LENGTH(Width, width) + DECLARE_ANIMATED_LENGTH(Height, height) + + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGSVGElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) + + // SVGFitToViewBox + DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox) + DECLARE_ANIMATED_PROPERTY_NEW(SVGSVGElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) - virtual void documentWillBecomeInactive(); - virtual void documentDidBecomeActive(); - - virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const; - - bool m_useCurrentView; - RefPtr<SMILTimeContainer> m_timeContainer; - FloatPoint m_translation; - float m_scale; - mutable OwnPtr<SVGViewSpec> m_viewSpec; - IntSize m_containerSize; - bool m_hasSetContainerSize; - }; + virtual void documentWillBecomeInactive(); + virtual void documentDidBecomeActive(); + + virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const; + + bool m_useCurrentView; + RefPtr<SMILTimeContainer> m_timeContainer; + FloatPoint m_translation; + float m_scale; + mutable OwnPtr<SVGViewSpec> m_viewSpec; + IntSize m_containerSize; + bool m_hasSetContainerSize; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGScriptElement.cpp b/WebCore/svg/SVGScriptElement.cpp index 9146ddc..af5bd5f 100644 --- a/WebCore/svg/SVGScriptElement.cpp +++ b/WebCore/svg/SVGScriptElement.cpp @@ -31,15 +31,15 @@ namespace WebCore { -inline SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document* document, bool createdByParser, bool isEvaluated) +inline SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document* document, bool wasInsertedByParser, bool wasAlreadyStarted) : SVGElement(tagName, document) - , ScriptElement(this, createdByParser, isEvaluated) + , ScriptElement(this, wasInsertedByParser, wasAlreadyStarted) { } -PassRefPtr<SVGScriptElement> SVGScriptElement::create(const QualifiedName& tagName, Document* document, bool createdByParser) +PassRefPtr<SVGScriptElement> SVGScriptElement::create(const QualifiedName& tagName, Document* document, bool insertedByParser) { - return adoptRef(new SVGScriptElement(tagName, document, createdByParser, false)); + return adoptRef(new SVGScriptElement(tagName, document, insertedByParser, false)); } void SVGScriptElement::parseMappedAttribute(Attribute* attr) @@ -68,7 +68,7 @@ void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) // Handle dynamic updates of the 'externalResourcesRequired' attribute. Only possible case: changing from 'true' to 'false' // causes an immediate dispatch of the SVGLoad event. If the attribute value was 'false' before inserting the script element // in the document, the SVGLoad event has already been dispatched. - if (!externalResourcesRequiredBaseValue() && !haveFiredLoadEvent() && !createdByParser()) { + if (!externalResourcesRequiredBaseValue() && !haveFiredLoadEvent() && !wasInsertedByParser()) { setHaveFiredLoadEvent(true); ASSERT(haveLoadedRequiredResources()); @@ -98,7 +98,7 @@ void SVGScriptElement::insertedIntoDocument() SVGElement::insertedIntoDocument(); ScriptElement::insertedIntoDocument(sourceAttributeValue()); - if (createdByParser()) + if (wasInsertedByParser()) return; // Eventually send SVGLoad event now for the dynamically inserted script element @@ -201,7 +201,7 @@ void SVGScriptElement::dispatchLoadEvent() { bool externalResourcesRequired = externalResourcesRequiredBaseValue(); - if (createdByParser()) + if (wasInsertedByParser()) ASSERT(externalResourcesRequired != haveFiredLoadEvent()); else if (haveFiredLoadEvent()) { // If we've already fired an load event and externalResourcesRequired is set to 'true' @@ -232,7 +232,7 @@ void SVGScriptElement::dispatchErrorEvent() PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren() const { - return adoptRef(new SVGScriptElement(tagQName(), document(), false, isEvaluated())); + return adoptRef(new SVGScriptElement(tagQName(), document(), false, wasAlreadyStarted())); } } diff --git a/WebCore/svg/SVGScriptElement.h b/WebCore/svg/SVGScriptElement.h index 7532bf2..84615d3 100644 --- a/WebCore/svg/SVGScriptElement.h +++ b/WebCore/svg/SVGScriptElement.h @@ -35,13 +35,13 @@ namespace WebCore { , public SVGExternalResourcesRequired , public ScriptElement { public: - static PassRefPtr<SVGScriptElement> create(const QualifiedName&, Document*, bool createdByParser); + static PassRefPtr<SVGScriptElement> create(const QualifiedName&, Document*, bool wasInsertedByParser); String type() const; void setType(const String&); private: - SVGScriptElement(const QualifiedName&, Document*, bool createdByParser, bool isEvaluated); + SVGScriptElement(const QualifiedName&, Document*, bool wasInsertedByParser, bool wasAlreadyStarted); virtual void parseMappedAttribute(Attribute*); virtual void insertedIntoDocument(); diff --git a/WebCore/svg/SVGStopElement.cpp b/WebCore/svg/SVGStopElement.cpp index cd78a46..10bd9ae 100644 --- a/WebCore/svg/SVGStopElement.cpp +++ b/WebCore/svg/SVGStopElement.cpp @@ -32,6 +32,9 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_NUMBER(SVGStopElement, SVGNames::offsetAttr, Offset, offset) + inline SVGStopElement::SVGStopElement(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) , m_offset(0) diff --git a/WebCore/svg/SVGStopElement.h b/WebCore/svg/SVGStopElement.h index 8da2655..907afae 100644 --- a/WebCore/svg/SVGStopElement.h +++ b/WebCore/svg/SVGStopElement.h @@ -22,30 +22,31 @@ #define SVGStopElement_h #if ENABLE(SVG) -#include "SVGAnimatedPropertyMacros.h" +#include "SVGAnimatedNumber.h" #include "SVGStyledElement.h" namespace WebCore { - class SVGStopElement : public SVGStyledElement { - public: - static PassRefPtr<SVGStopElement> create(const QualifiedName&, Document*); +class SVGStopElement : public SVGStyledElement { +public: + static PassRefPtr<SVGStopElement> create(const QualifiedName&, Document*); - Color stopColorIncludingOpacity() const; + Color stopColorIncludingOpacity() const; - private: - SVGStopElement(const QualifiedName&, Document*); +private: + SVGStopElement(const QualifiedName&, Document*); - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual bool isGradientStop() const { return true; } + virtual bool isGradientStop() const { return true; } - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGStopElement, SVGNames::offsetAttr, float, Offset, offset) - }; + // Animated property declarations + DECLARE_ANIMATED_NUMBER(Offset, offset) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGStringList.cpp b/WebCore/svg/SVGStringList.cpp index 3eb392a..2a1238b 100644 --- a/WebCore/svg/SVGStringList.cpp +++ b/WebCore/svg/SVGStringList.cpp @@ -25,6 +25,7 @@ #include "SVGElement.h" #include "SVGParserUtilities.h" +#include <wtf/text/StringBuilder.h> namespace WebCore { @@ -62,6 +63,21 @@ void SVGStringList::parse(const String& data, UChar delimiter) } } +String SVGStringList::valueAsString() const +{ + StringBuilder builder; + + unsigned size = this->size(); + for (unsigned i = 0; i < size; ++i) { + if (i > 0) + builder.append(' '); + + builder.append(at(i)); + } + + return builder.toString(); +} + } #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGStringList.h b/WebCore/svg/SVGStringList.h index c741b9d..5463cc2 100644 --- a/WebCore/svg/SVGStringList.h +++ b/WebCore/svg/SVGStringList.h @@ -23,8 +23,8 @@ #if ENABLE(SVG) #include "QualifiedName.h" +#include "SVGPropertyTraits.h" #include <wtf/Vector.h> -#include <wtf/text/WTFString.h> namespace WebCore { @@ -43,10 +43,17 @@ public: // Only used by SVGStringListPropertyTearOff. void commitChange(SVGElement* contextElement); + String valueAsString() const; + private: const QualifiedName& m_attributeName; }; +template<> +struct SVGPropertyTraits<SVGStringList> { + typedef String ListItemType; +}; + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGStringList.idl b/WebCore/svg/SVGStringList.idl index 12eed8d..82af72d 100644 --- a/WebCore/svg/SVGStringList.idl +++ b/WebCore/svg/SVGStringList.idl @@ -30,17 +30,17 @@ module svg { void clear() raises(DOMException); - DOMString initialize(in DOMString item) + [StrictTypeChecking, RequiresAllArguments=Raise] DOMString initialize(in DOMString item) raises(DOMException, SVGException); - DOMString getItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] DOMString getItem(in unsigned long index) raises(DOMException); - DOMString insertItemBefore(in DOMString item, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] DOMString insertItemBefore(in DOMString item, in unsigned long index) raises(DOMException, SVGException); - DOMString replaceItem(in DOMString item, in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] DOMString replaceItem(in DOMString item, in unsigned long index) raises(DOMException, SVGException); - DOMString removeItem(in unsigned long index) + [StrictTypeChecking, RequiresAllArguments=Raise] DOMString removeItem(in unsigned long index) raises(DOMException); - DOMString appendItem(in DOMString item) + [StrictTypeChecking, RequiresAllArguments=Raise] DOMString appendItem(in DOMString item) raises(DOMException, SVGException); }; diff --git a/WebCore/svg/SVGStyledTransformableElement.cpp b/WebCore/svg/SVGStyledTransformableElement.cpp index e5cd42b..18f902a 100644 --- a/WebCore/svg/SVGStyledTransformableElement.cpp +++ b/WebCore/svg/SVGStyledTransformableElement.cpp @@ -32,6 +32,9 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_TRANSFORM_LIST(SVGStyledTransformableElement, SVGNames::transformAttr, Transform, transform) + SVGStyledTransformableElement::SVGStyledTransformableElement(const QualifiedName& tagName, Document* document) : SVGStyledLocatableElement(tagName, document) { @@ -72,7 +75,7 @@ void SVGStyledTransformableElement::parseMappedAttribute(Attribute* attr) if (!SVGTransformable::parseTransformAttribute(newList, attr->value())) newList.clear(); detachAnimatedTransformListWrappers(newList.size()); - transformBaseValue() = newList; + setTransformBaseValue(newList); } else SVGStyledLocatableElement::parseMappedAttribute(attr); } diff --git a/WebCore/svg/SVGStyledTransformableElement.h b/WebCore/svg/SVGStyledTransformableElement.h index 54907c1..1d882e5 100644 --- a/WebCore/svg/SVGStyledTransformableElement.h +++ b/WebCore/svg/SVGStyledTransformableElement.h @@ -22,14 +22,14 @@ #define SVGStyledTransformableElement_h #if ENABLE(SVG) -#include "Path.h" -#include "SVGAnimatedPropertyMacros.h" +#include "SVGAnimatedTransformList.h" #include "SVGStyledLocatableElement.h" #include "SVGTransformable.h" namespace WebCore { class AffineTransform; +class Path; class SVGStyledTransformableElement : public SVGStyledLocatableElement, public SVGTransformable { @@ -60,7 +60,8 @@ protected: virtual void parseMappedAttribute(Attribute*); virtual void synchronizeProperty(const QualifiedName&); - DECLARE_ANIMATED_TRANSFORM_LIST_PROPERTY_NEW(SVGStyledTransformableElement, SVGNames::transformAttr, SVGTransformList, Transform, transform) + // Animated property declarations + DECLARE_ANIMATED_TRANSFORM_LIST(Transform, transform) private: virtual bool isStyledTransformable() const { return true; } diff --git a/WebCore/svg/SVGSwitchElement.cpp b/WebCore/svg/SVGSwitchElement.cpp index 9b40a02..b2588f5 100644 --- a/WebCore/svg/SVGSwitchElement.cpp +++ b/WebCore/svg/SVGSwitchElement.cpp @@ -62,8 +62,16 @@ void SVGSwitchElement::synchronizeProperty(const QualifiedName& attrName) { SVGStyledTransformableElement::synchronizeProperty(attrName); - if (attrName == anyQName() || SVGExternalResourcesRequired::isKnownAttribute(attrName)) + if (attrName == anyQName()) { synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); + return; + } + + if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) + synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } } diff --git a/WebCore/svg/SVGSymbolElement.h b/WebCore/svg/SVGSymbolElement.h index 1aa7cbf..d416150 100644 --- a/WebCore/svg/SVGSymbolElement.h +++ b/WebCore/svg/SVGSymbolElement.h @@ -26,6 +26,8 @@ #include "SVGExternalResourcesRequired.h" #include "SVGFitToViewBox.h" #include "SVGLangSpace.h" +#include "SVGPreserveAspectRatio.h" +#include "SVGRect.h" #include "SVGStyledElement.h" namespace WebCore { diff --git a/WebCore/svg/SVGTests.cpp b/WebCore/svg/SVGTests.cpp index 2b9cb14..63733bf 100644 --- a/WebCore/svg/SVGTests.cpp +++ b/WebCore/svg/SVGTests.cpp @@ -33,8 +33,8 @@ namespace WebCore { SVGTests::SVGTests() - : m_features(SVGNames::requiredFeaturesAttr) - , m_extensions(SVGNames::requiredExtensionsAttr) + : m_requiredFeatures(SVGNames::requiredFeaturesAttr) + , m_requiredExtensions(SVGNames::requiredExtensionsAttr) , m_systemLanguage(SVGNames::systemLanguageAttr) { } @@ -47,21 +47,21 @@ bool SVGTests::hasExtension(const String&) const bool SVGTests::isValid() const { - unsigned featuresSize = m_features.size(); + unsigned featuresSize = m_requiredFeatures.value.size(); for (unsigned i = 0; i < featuresSize; ++i) { - String value = m_features.at(i); + String value = m_requiredFeatures.value.at(i); if (value.isEmpty() || !DOMImplementation::hasFeature(value, String())) return false; } - unsigned systemLanguageSize = m_systemLanguage.size(); + unsigned systemLanguageSize = m_systemLanguage.value.size(); for (unsigned i = 0; i < systemLanguageSize; ++i) { - String value = m_systemLanguage.at(i); + String value = m_systemLanguage.value.at(i); if (value != defaultLanguage().substring(0, 2)) return false; } - if (!m_extensions.isEmpty()) + if (!m_requiredExtensions.value.isEmpty()) return false; return true; @@ -70,34 +70,29 @@ bool SVGTests::isValid() const bool SVGTests::parseMappedAttribute(Attribute* attr) { if (attr->name() == SVGNames::requiredFeaturesAttr) { - m_features.reset(attr->value()); + m_requiredFeatures.value.reset(attr->value()); return true; } else if (attr->name() == SVGNames::requiredExtensionsAttr) { - m_extensions.reset(attr->value()); + m_requiredExtensions.value.reset(attr->value()); return true; } else if (attr->name() == SVGNames::systemLanguageAttr) { - m_systemLanguage.reset(attr->value()); + m_systemLanguage.value.reset(attr->value()); return true; } return false; } -static bool knownAttribute(const QualifiedName& attrName) +bool SVGTests::isKnownAttribute(const QualifiedName& attrName) { return attrName == SVGNames::requiredFeaturesAttr || attrName == SVGNames::requiredExtensionsAttr || attrName == SVGNames::systemLanguageAttr; } -bool SVGTests::isKnownAttribute(const QualifiedName& attrName) -{ - return knownAttribute(attrName); -} - bool SVGTests::handleAttributeChange(const SVGElement* targetElement, const QualifiedName& attrName) { - if (!knownAttribute(attrName)) + if (!isKnownAttribute(attrName)) return false; if (!targetElement->inDocument()) return false; @@ -111,6 +106,65 @@ bool SVGTests::handleAttributeChange(const SVGElement* targetElement, const Qual return true; } +void SVGTests::synchronizeProperties(SVGElement* contextElement, const QualifiedName& attrName) +{ + if (attrName == anyQName()) { + synchronizeRequiredFeatures(contextElement); + synchronizeRequiredExtensions(contextElement); + synchronizeSystemLanguage(contextElement); + return; + } + + if (attrName == SVGNames::requiredFeaturesAttr) + synchronizeRequiredFeatures(contextElement); + else if (attrName == SVGNames::requiredExtensionsAttr) + synchronizeRequiredExtensions(contextElement); + else if (attrName == SVGNames::systemLanguageAttr) + synchronizeSystemLanguage(contextElement); +} + +void SVGTests::synchronizeRequiredFeatures(SVGElement* contextElement) +{ + if (!m_requiredFeatures.shouldSynchronize) + return; + AtomicString value(m_requiredFeatures.value.valueAsString()); + SVGAnimatedPropertySynchronizer<true>::synchronize(contextElement, SVGNames::requiredFeaturesAttr, value); +} + +void SVGTests::synchronizeRequiredExtensions(SVGElement* contextElement) +{ + if (!m_requiredExtensions.shouldSynchronize) + return; + AtomicString value(m_requiredExtensions.value.valueAsString()); + SVGAnimatedPropertySynchronizer<true>::synchronize(contextElement, SVGNames::requiredExtensionsAttr, value); +} + +void SVGTests::synchronizeSystemLanguage(SVGElement* contextElement) +{ + if (!m_systemLanguage.shouldSynchronize) + return; + AtomicString value(m_systemLanguage.value.valueAsString()); + SVGAnimatedPropertySynchronizer<true>::synchronize(contextElement, SVGNames::systemLanguageAttr, value); +} + +SVGStringList& SVGTests::requiredFeatures() +{ + m_requiredFeatures.shouldSynchronize = true; + return m_requiredFeatures.value; +} + +SVGStringList& SVGTests::requiredExtensions() +{ + m_requiredExtensions.shouldSynchronize = true; + return m_requiredExtensions.value; +} + +SVGStringList& SVGTests::systemLanguage() +{ + m_systemLanguage.shouldSynchronize = true; + return m_systemLanguage.value; +} + } #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGTests.h b/WebCore/svg/SVGTests.h index 8cba9d2..8160955 100644 --- a/WebCore/svg/SVGTests.h +++ b/WebCore/svg/SVGTests.h @@ -22,6 +22,7 @@ #define SVGTests_h #if ENABLE(SVG) +#include "SVGAnimatedPropertyMacros.h" #include "SVGStringList.h" namespace WebCore { @@ -32,9 +33,9 @@ class SVGElement; class SVGTests { public: - SVGStringList& requiredFeatures() { return m_features; } - SVGStringList& requiredExtensions() { return m_extensions; } - SVGStringList& systemLanguage() { return m_systemLanguage; } + SVGStringList& requiredFeatures(); + SVGStringList& requiredExtensions(); + SVGStringList& systemLanguage(); bool hasExtension(const String&) const; bool isValid() const; @@ -42,15 +43,20 @@ public: bool parseMappedAttribute(Attribute*); bool isKnownAttribute(const QualifiedName&); - static bool handleAttributeChange(const SVGElement*, const QualifiedName&); + bool handleAttributeChange(const SVGElement*, const QualifiedName&); + void synchronizeProperties(SVGElement*, const QualifiedName&); protected: SVGTests(); private: - SVGStringList m_features; - SVGStringList m_extensions; - SVGStringList m_systemLanguage; + void synchronizeRequiredFeatures(SVGElement*); + void synchronizeRequiredExtensions(SVGElement*); + void synchronizeSystemLanguage(SVGElement*); + + SVGSynchronizableAnimatedProperty<SVGStringList> m_requiredFeatures; + SVGSynchronizableAnimatedProperty<SVGStringList> m_requiredExtensions; + SVGSynchronizableAnimatedProperty<SVGStringList> m_systemLanguage; }; } // namespace WebCore diff --git a/WebCore/svg/SVGTextContentElement.cpp b/WebCore/svg/SVGTextContentElement.cpp index 0cbcc9a..6f8b73a 100644 --- a/WebCore/svg/SVGTextContentElement.cpp +++ b/WebCore/svg/SVGTextContentElement.cpp @@ -33,6 +33,9 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGTextContentElement, SVGNames::textLengthAttr, TextLength, textLength) + SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) , m_textLength(LengthModeOther) @@ -190,6 +193,7 @@ void SVGTextContentElement::synchronizeProperty(const QualifiedName& attrName) synchronizeLengthAdjust(); synchronizeTextLength(); synchronizeExternalResourcesRequired(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -199,6 +203,8 @@ void SVGTextContentElement::synchronizeProperty(const QualifiedName& attrName) synchronizeTextLength(); else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) synchronizeExternalResourcesRequired(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } void SVGTextContentElement::svgAttributeChanged(const QualifiedName& attrName) diff --git a/WebCore/svg/SVGTextContentElement.h b/WebCore/svg/SVGTextContentElement.h index fd2e003..5edd8aa 100644 --- a/WebCore/svg/SVGTextContentElement.h +++ b/WebCore/svg/SVGTextContentElement.h @@ -31,53 +31,52 @@ namespace WebCore { - class SVGLength; - - class SVGTextContentElement : public SVGStyledElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired { - public: - enum SVGLengthAdjustType { - LENGTHADJUST_UNKNOWN = 0, - LENGTHADJUST_SPACING = 1, - LENGTHADJUST_SPACINGANDGLYPHS = 2 - }; +class SVGTextContentElement : public SVGStyledElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired { +public: + enum SVGLengthAdjustType { + LENGTHADJUST_UNKNOWN = 0, + LENGTHADJUST_SPACING = 1, + LENGTHADJUST_SPACINGANDGLYPHS = 2 + }; - unsigned getNumberOfChars() const; - float getComputedTextLength() const; - float getSubStringLength(unsigned charnum, unsigned nchars, ExceptionCode&) const; - FloatPoint getStartPositionOfChar(unsigned charnum, ExceptionCode&) const; - FloatPoint getEndPositionOfChar(unsigned charnum, ExceptionCode&) const; - FloatRect getExtentOfChar(unsigned charnum, ExceptionCode&) const; - float getRotationOfChar(unsigned charnum, ExceptionCode&) const; - int getCharNumAtPosition(const FloatPoint&) const; - void selectSubString(unsigned charnum, unsigned nchars, ExceptionCode&) const; + unsigned getNumberOfChars() const; + float getComputedTextLength() const; + float getSubStringLength(unsigned charnum, unsigned nchars, ExceptionCode&) const; + FloatPoint getStartPositionOfChar(unsigned charnum, ExceptionCode&) const; + FloatPoint getEndPositionOfChar(unsigned charnum, ExceptionCode&) const; + FloatRect getExtentOfChar(unsigned charnum, ExceptionCode&) const; + float getRotationOfChar(unsigned charnum, ExceptionCode&) const; + int getCharNumAtPosition(const FloatPoint&) const; + void selectSubString(unsigned charnum, unsigned nchars, ExceptionCode&) const; - bool isKnownAttribute(const QualifiedName&); + bool isKnownAttribute(const QualifiedName&); - static SVGTextContentElement* elementFromRenderer(RenderObject*); + static SVGTextContentElement* elementFromRenderer(RenderObject*); - protected: - SVGTextContentElement(const QualifiedName&, Document*); +protected: + SVGTextContentElement(const QualifiedName&, Document*); - virtual bool isValid() const { return SVGTests::isValid(); } + virtual bool isValid() const { return SVGTests::isValid(); } - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - private: - virtual bool isTextContent() const { return true; } +private: + virtual bool isTextContent() const { return true; } - DECLARE_ANIMATED_PROPERTY_NEW(SVGTextContentElement, SVGNames::textLengthAttr, SVGLength, TextLength, textLength) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextContentElement, SVGNames::lengthAdjustAttr, int, LengthAdjust, lengthAdjust) + // Animated property declarations + DECLARE_ANIMATED_LENGTH(TextLength, textLength) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextContentElement, SVGNames::lengthAdjustAttr, int, LengthAdjust, lengthAdjust) - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextContentElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - }; + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextContentElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGTextElement.cpp b/WebCore/svg/SVGTextElement.cpp index bfa36c8..dc7ce55 100644 --- a/WebCore/svg/SVGTextElement.cpp +++ b/WebCore/svg/SVGTextElement.cpp @@ -35,9 +35,11 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_TRANSFORM_LIST(SVGTextElement, SVGNames::transformAttr, Transform, transform) + inline SVGTextElement::SVGTextElement(const QualifiedName& tagName, Document* doc) : SVGTextPositioningElement(tagName, doc) - , SVGTransformable() { } @@ -54,7 +56,7 @@ void SVGTextElement::parseMappedAttribute(Attribute* attr) newList.clear(); detachAnimatedTransformListWrappers(newList.size()); - transformBaseValue() = newList; + setTransformBaseValue(newList); } else SVGTextPositioningElement::parseMappedAttribute(attr); } diff --git a/WebCore/svg/SVGTextElement.h b/WebCore/svg/SVGTextElement.h index 3bfee46..8dda8c6 100644 --- a/WebCore/svg/SVGTextElement.h +++ b/WebCore/svg/SVGTextElement.h @@ -28,38 +28,39 @@ namespace WebCore { - class SVGTextElement : public SVGTextPositioningElement, - public SVGTransformable { - public: - static PassRefPtr<SVGTextElement> create(const QualifiedName&, Document*); +class SVGTextElement : public SVGTextPositioningElement, + public SVGTransformable { +public: + static PassRefPtr<SVGTextElement> create(const QualifiedName&, Document*); - virtual SVGElement* nearestViewportElement() const; - virtual SVGElement* farthestViewportElement() const; + virtual SVGElement* nearestViewportElement() const; + virtual SVGElement* farthestViewportElement() const; - virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) const; - virtual AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate) const; - virtual AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate) const; - virtual AffineTransform animatedLocalTransform() const; + virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) const; + virtual AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate) const; + virtual AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate) const; + virtual AffineTransform animatedLocalTransform() const; - private: - SVGTextElement(const QualifiedName&, Document*); +private: + SVGTextElement(const QualifiedName&, Document*); - virtual void parseMappedAttribute(Attribute*); + virtual void parseMappedAttribute(Attribute*); - virtual AffineTransform* supplementalTransform(); - virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const { return SVGTransformable::localCoordinateSpaceTransform(mode); } + virtual AffineTransform* supplementalTransform(); + virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const { return SVGTransformable::localCoordinateSpaceTransform(mode); } - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - virtual bool childShouldCreateRenderer(Node*) const; - - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + virtual bool childShouldCreateRenderer(Node*) const; + + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - DECLARE_ANIMATED_TRANSFORM_LIST_PROPERTY_NEW(SVGTextElement, SVGNames::transformAttr, SVGTransformList, Transform, transform) - - // Used by <animateMotion> - OwnPtr<AffineTransform> m_supplementalTransform; - }; + // Animated property declarations + DECLARE_ANIMATED_TRANSFORM_LIST(Transform, transform) + + // Used by <animateMotion> + OwnPtr<AffineTransform> m_supplementalTransform; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGTextPathElement.cpp b/WebCore/svg/SVGTextPathElement.cpp index bbfa0e2..4ae5c04 100644 --- a/WebCore/svg/SVGTextPathElement.cpp +++ b/WebCore/svg/SVGTextPathElement.cpp @@ -23,18 +23,15 @@ #if ENABLE(SVG) #include "SVGTextPathElement.h" -#include "AffineTransform.h" #include "Attribute.h" -#include "FloatRect.h" #include "RenderSVGResource.h" #include "RenderSVGTextPath.h" -#include "SVGLengthList.h" -#include "SVGPathElement.h" -#include "SVGRenderStyle.h" -#include "SVGTransformList.h" namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGTextPathElement, SVGNames::startOffsetAttr, StartOffset, startOffset) + inline SVGTextPathElement::SVGTextPathElement(const QualifiedName& tagName, Document* document) : SVGTextContentElement(tagName, document) , m_startOffset(LengthModeOther) diff --git a/WebCore/svg/SVGTextPathElement.h b/WebCore/svg/SVGTextPathElement.h index 2375078..a6efdb6 100644 --- a/WebCore/svg/SVGTextPathElement.h +++ b/WebCore/svg/SVGTextPathElement.h @@ -26,54 +26,56 @@ #include "SVGURIReference.h" namespace WebCore { + enum SVGTextPathMethodType { - SVG_TEXTPATH_METHODTYPE_UNKNOWN = 0, - SVG_TEXTPATH_METHODTYPE_ALIGN = 1, - SVG_TEXTPATH_METHODTYPE_STRETCH = 2 - }; + SVG_TEXTPATH_METHODTYPE_UNKNOWN = 0, + SVG_TEXTPATH_METHODTYPE_ALIGN = 1, + SVG_TEXTPATH_METHODTYPE_STRETCH = 2 +}; + +enum SVGTextPathSpacingType { + SVG_TEXTPATH_SPACINGTYPE_UNKNOWN = 0, + SVG_TEXTPATH_SPACINGTYPE_AUTO = 1, + SVG_TEXTPATH_SPACINGTYPE_EXACT = 2 +}; - enum SVGTextPathSpacingType { - SVG_TEXTPATH_SPACINGTYPE_UNKNOWN = 0, - SVG_TEXTPATH_SPACINGTYPE_AUTO = 1, - SVG_TEXTPATH_SPACINGTYPE_EXACT = 2 +class SVGTextPathElement : public SVGTextContentElement, + public SVGURIReference { +public: + // Forward declare these enums in the w3c naming scheme, for IDL generation + enum { + TEXTPATH_METHODTYPE_UNKNOWN = SVG_TEXTPATH_METHODTYPE_UNKNOWN, + TEXTPATH_METHODTYPE_ALIGN = SVG_TEXTPATH_METHODTYPE_ALIGN, + TEXTPATH_METHODTYPE_STRETCH = SVG_TEXTPATH_METHODTYPE_STRETCH, + TEXTPATH_SPACINGTYPE_UNKNOWN = SVG_TEXTPATH_SPACINGTYPE_UNKNOWN, + TEXTPATH_SPACINGTYPE_AUTO = SVG_TEXTPATH_SPACINGTYPE_AUTO, + TEXTPATH_SPACINGTYPE_EXACT = SVG_TEXTPATH_SPACINGTYPE_EXACT }; - class SVGTextPathElement : public SVGTextContentElement, - public SVGURIReference { - public: - // Forward declare these enums in the w3c naming scheme, for IDL generation - enum { - TEXTPATH_METHODTYPE_UNKNOWN = SVG_TEXTPATH_METHODTYPE_UNKNOWN, - TEXTPATH_METHODTYPE_ALIGN = SVG_TEXTPATH_METHODTYPE_ALIGN, - TEXTPATH_METHODTYPE_STRETCH = SVG_TEXTPATH_METHODTYPE_STRETCH, - TEXTPATH_SPACINGTYPE_UNKNOWN = SVG_TEXTPATH_SPACINGTYPE_UNKNOWN, - TEXTPATH_SPACINGTYPE_AUTO = SVG_TEXTPATH_SPACINGTYPE_AUTO, - TEXTPATH_SPACINGTYPE_EXACT = SVG_TEXTPATH_SPACINGTYPE_EXACT - }; - - static PassRefPtr<SVGTextPathElement> create(const QualifiedName&, Document*); + static PassRefPtr<SVGTextPathElement> create(const QualifiedName&, Document*); - private: - SVGTextPathElement(const QualifiedName&, Document*); +private: + SVGTextPathElement(const QualifiedName&, Document*); - virtual void insertedIntoDocument(); + virtual void insertedIntoDocument(); - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - virtual bool childShouldCreateRenderer(Node*) const; + virtual bool childShouldCreateRenderer(Node*) const; - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - DECLARE_ANIMATED_PROPERTY_NEW(SVGTextPathElement, SVGNames::startOffsetAttr, SVGLength, StartOffset, startOffset) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextPathElement, SVGNames::methodAttr, int, Method, method) - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextPathElement, SVGNames::spacingAttr, int, Spacing, spacing) - - // SVGURIReference - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextPathElement, XLinkNames::hrefAttr, String, Href, href) - }; + // Animated property declarations + DECLARE_ANIMATED_LENGTH(StartOffset, startOffset) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextPathElement, SVGNames::methodAttr, int, Method, method) + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGTextPathElement, SVGNames::spacingAttr, int, Spacing, spacing) + + // SVGURIReference + 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 dc1f915..544d192 100644 --- a/WebCore/svg/SVGTextPositioningElement.cpp +++ b/WebCore/svg/SVGTextPositioningElement.cpp @@ -32,6 +32,13 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH_LIST(SVGTextPositioningElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH_LIST(SVGTextPositioningElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH_LIST(SVGTextPositioningElement, SVGNames::dxAttr, Dx, dx) +DEFINE_ANIMATED_LENGTH_LIST(SVGTextPositioningElement, SVGNames::dyAttr, Dy, dy) +DEFINE_ANIMATED_NUMBER_LIST(SVGTextPositioningElement, SVGNames::rotateAttr, Rotate, rotate) + SVGTextPositioningElement::SVGTextPositioningElement(const QualifiedName& tagName, Document* document) : SVGTextContentElement(tagName, document) { @@ -43,27 +50,27 @@ void SVGTextPositioningElement::parseMappedAttribute(Attribute* attr) SVGLengthList newList; newList.parse(attr->value(), LengthModeWidth); detachAnimatedXListWrappers(newList.size()); - xBaseValue() = newList; + setXBaseValue(newList); } else if (attr->name() == SVGNames::yAttr) { SVGLengthList newList; newList.parse(attr->value(), LengthModeHeight); detachAnimatedYListWrappers(newList.size()); - yBaseValue() = newList; + setYBaseValue(newList); } else if (attr->name() == SVGNames::dxAttr) { SVGLengthList newList; newList.parse(attr->value(), LengthModeWidth); detachAnimatedDxListWrappers(newList.size()); - dxBaseValue() = newList; + setDxBaseValue(newList); } else if (attr->name() == SVGNames::dyAttr) { SVGLengthList newList; newList.parse(attr->value(), LengthModeHeight); detachAnimatedDyListWrappers(newList.size()); - dyBaseValue() = newList; + setDyBaseValue(newList); } else if (attr->name() == SVGNames::rotateAttr) { SVGNumberList newList; newList.parse(attr->value()); detachAnimatedRotateListWrappers(newList.size()); - rotateBaseValue() = newList; + setRotateBaseValue(newList); } else SVGTextContentElement::parseMappedAttribute(attr); } diff --git a/WebCore/svg/SVGTextPositioningElement.h b/WebCore/svg/SVGTextPositioningElement.h index e1798de..e4bc4ea 100644 --- a/WebCore/svg/SVGTextPositioningElement.h +++ b/WebCore/svg/SVGTextPositioningElement.h @@ -22,32 +22,33 @@ #define SVGTextPositioningElement_h #if ENABLE(SVG) +#include "SVGAnimatedLengthList.h" +#include "SVGAnimatedNumberList.h" #include "SVGTextContentElement.h" -#include "SVGLengthList.h" -#include "SVGNumberList.h" namespace WebCore { - class SVGTextPositioningElement : public SVGTextContentElement { - public: - static SVGTextPositioningElement* elementFromRenderer(RenderObject*); +class SVGTextPositioningElement : public SVGTextContentElement { +public: + static SVGTextPositioningElement* elementFromRenderer(RenderObject*); - protected: - SVGTextPositioningElement(const QualifiedName&, Document*); +protected: + SVGTextPositioningElement(const QualifiedName&, Document*); - virtual void parseMappedAttribute(Attribute*); - virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - DECLARE_ANIMATED_LIST_PROPERTY_NEW(SVGTextPositioningElement, SVGNames::xAttr, SVGLengthList, X, x) - 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_LIST_PROPERTY_NEW(SVGTextPositioningElement, SVGNames::rotateAttr, SVGNumberList, Rotate, rotate) - }; + // Animated property declarations + DECLARE_ANIMATED_LENGTH_LIST(X, x) + DECLARE_ANIMATED_LENGTH_LIST(Y, y) + DECLARE_ANIMATED_LENGTH_LIST(Dx, dx) + DECLARE_ANIMATED_LENGTH_LIST(Dy, dy) + DECLARE_ANIMATED_NUMBER_LIST(Rotate, rotate) +}; } // namespace WebCore diff --git a/WebCore/svg/SVGTransform.cpp b/WebCore/svg/SVGTransform.cpp index c39fe39..4878b57 100644 --- a/WebCore/svg/SVGTransform.cpp +++ b/WebCore/svg/SVGTransform.cpp @@ -21,13 +21,16 @@ #include "config.h" #if ENABLE(SVG) +#include "SVGTransform.h" + +#include "FloatConversion.h" #include "FloatPoint.h" #include "FloatSize.h" #include "SVGAngle.h" #include "SVGSVGElement.h" -#include "SVGTransform.h" - #include <wtf/MathExtras.h> +#include <wtf/text/StringBuilder.h> +#include <wtf/text/StringConcatenate.h> namespace WebCore { @@ -126,6 +129,41 @@ void SVGTransform::setSkewY(float angle) m_matrix.skewY(angle); } +String SVGTransform::valueAsString() const +{ + switch (m_type) { + case SVG_TRANSFORM_UNKNOWN: + return String(); + case SVG_TRANSFORM_MATRIX: { + StringBuilder builder; + builder.append(makeString("matrix(", String::number(m_matrix.a()), ' ', String::number(m_matrix.b()), ' ', String::number(m_matrix.c()), ' ')); + builder.append(makeString(String::number(m_matrix.d()), ' ', String::number(m_matrix.e()), ' ', String::number(m_matrix.f()), ')')); + return builder.toString(); + } + case SVG_TRANSFORM_TRANSLATE: + return makeString("translate(", String::number(m_matrix.e()), ' ', String::number(m_matrix.f()), ')'); + case SVG_TRANSFORM_SCALE: + return makeString("scale(", String::number(m_matrix.xScale()), ' ', String::number(m_matrix.yScale()), ')'); + case SVG_TRANSFORM_ROTATE: { + double angleInRad = deg2rad(m_angle); + double cosAngle = cos(angleInRad); + double sinAngle = sin(angleInRad); + float cx = narrowPrecisionToFloat(cosAngle != 1 ? (m_matrix.e() * (1 - cosAngle) - m_matrix.f() * sinAngle) / (1 - cosAngle) / 2 : 0); + float cy = narrowPrecisionToFloat(cosAngle != 1 ? (m_matrix.e() * sinAngle / (1 - cosAngle) + m_matrix.f()) / 2 : 0); + if (cx || cy) + return makeString("rotate(", String::number(m_angle), ' ', String::number(cx), ' ', String::number(cy), ')'); + return makeString("rotate(", String::number(m_angle), ')'); + } + case SVG_TRANSFORM_SKEWX: + return makeString("skewX(", String::number(m_angle), ')'); + case SVG_TRANSFORM_SKEWY: + return makeString("skewY(", String::number(m_angle), ')'); + } + + ASSERT_NOT_REACHED(); + return String(); +} + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGTransform.h b/WebCore/svg/SVGTransform.h index 36dd038..14718ae 100644 --- a/WebCore/svg/SVGTransform.h +++ b/WebCore/svg/SVGTransform.h @@ -66,6 +66,7 @@ public: FloatSize scale() const; bool isValid() const { return m_type != SVG_TRANSFORM_UNKNOWN; } + String valueAsString() const; private: friend bool operator==(const SVGTransform& a, const SVGTransform& b); diff --git a/WebCore/svg/SVGTransformList.cpp b/WebCore/svg/SVGTransformList.cpp index 9137a89..759b064 100644 --- a/WebCore/svg/SVGTransformList.cpp +++ b/WebCore/svg/SVGTransformList.cpp @@ -62,13 +62,15 @@ bool SVGTransformList::concatenate(AffineTransform& result) const String SVGTransformList::valueAsString() const { - // TODO: We may want to build a real transform string, instead of concatting to a matrix(...). - AffineTransform matrix; - concatenate(matrix); - StringBuilder builder; - builder.append(makeString("matrix(", String::number(matrix.a()), ' ', String::number(matrix.b()), ' ', String::number(matrix.c()), ' ')); - builder.append(makeString(String::number(matrix.d()), ' ', String::number(matrix.e()), ' ', String::number(matrix.f()), ')')); + unsigned size = this->size(); + for (unsigned i = 0; i < size; ++i) { + if (i > 0) + builder.append(' '); + + builder.append(at(i).valueAsString()); + } + return builder.toString(); } diff --git a/WebCore/svg/SVGTransformList.h b/WebCore/svg/SVGTransformList.h index e071355..0afc832 100644 --- a/WebCore/svg/SVGTransformList.h +++ b/WebCore/svg/SVGTransformList.h @@ -22,9 +22,9 @@ #define SVGTransformList_h #if ENABLE(SVG) +#include "SVGPropertyTraits.h" #include "SVGTransform.h" #include <wtf/Vector.h> -#include <wtf/text/WTFString.h> namespace WebCore { @@ -41,6 +41,13 @@ public: String valueAsString() const; }; +template<> +struct SVGPropertyTraits<SVGTransformList> { + static SVGTransformList initialValue() { return SVGTransformList(); } + static String toString(const SVGTransformList& type) { return type.valueAsString(); } + typedef SVGTransform ListItemType; +}; + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGTransformable.cpp b/WebCore/svg/SVGTransformable.cpp index 006bb94..e637e7c 100644 --- a/WebCore/svg/SVGTransformable.cpp +++ b/WebCore/svg/SVGTransformable.cpp @@ -143,25 +143,25 @@ static inline bool parseAndSkipType(const UChar*& currTransform, const UChar* en { if (currTransform >= end) return false; - + if (*currTransform == 's') { - if (skipString(currTransform, end, skewXDesc, sizeof(skewXDesc) / sizeof(UChar))) + if (skipString(currTransform, end, skewXDesc, WTF_ARRAY_LENGTH(skewXDesc))) type = SVGTransform::SVG_TRANSFORM_SKEWX; - else if (skipString(currTransform, end, skewYDesc, sizeof(skewYDesc) / sizeof(UChar))) + else if (skipString(currTransform, end, skewYDesc, WTF_ARRAY_LENGTH(skewYDesc))) type = SVGTransform::SVG_TRANSFORM_SKEWY; - else if (skipString(currTransform, end, scaleDesc, sizeof(scaleDesc) / sizeof(UChar))) + else if (skipString(currTransform, end, scaleDesc, WTF_ARRAY_LENGTH(scaleDesc))) type = SVGTransform::SVG_TRANSFORM_SCALE; else return false; - } else if (skipString(currTransform, end, translateDesc, sizeof(translateDesc) / sizeof(UChar))) + } else if (skipString(currTransform, end, translateDesc, WTF_ARRAY_LENGTH(translateDesc))) type = SVGTransform::SVG_TRANSFORM_TRANSLATE; - else if (skipString(currTransform, end, rotateDesc, sizeof(rotateDesc) / sizeof(UChar))) + else if (skipString(currTransform, end, rotateDesc, WTF_ARRAY_LENGTH(rotateDesc))) type = SVGTransform::SVG_TRANSFORM_ROTATE; - else if (skipString(currTransform, end, matrixDesc, sizeof(matrixDesc) / sizeof(UChar))) + else if (skipString(currTransform, end, matrixDesc, WTF_ARRAY_LENGTH(matrixDesc))) type = SVGTransform::SVG_TRANSFORM_MATRIX; - else + else return false; - + return true; } diff --git a/WebCore/svg/SVGUseElement.cpp b/WebCore/svg/SVGUseElement.cpp index a69334c..1abdbf2 100644 --- a/WebCore/svg/SVGUseElement.cpp +++ b/WebCore/svg/SVGUseElement.cpp @@ -57,6 +57,12 @@ namespace WebCore { +// Animated property definitions +DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::xAttr, X, x) +DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::yAttr, Y, y) +DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::widthAttr, Width, width) +DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::heightAttr, Height, height) + inline SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document* document) : SVGStyledTransformableElement(tagName, document) , m_x(LengthModeWidth) @@ -199,6 +205,7 @@ void SVGUseElement::synchronizeProperty(const QualifiedName& attrName) synchronizeHeight(); synchronizeExternalResourcesRequired(); synchronizeHref(); + SVGTests::synchronizeProperties(this, attrName); return; } @@ -214,6 +221,8 @@ void SVGUseElement::synchronizeProperty(const QualifiedName& attrName) synchronizeExternalResourcesRequired(); else if (SVGURIReference::isKnownAttribute(attrName)) synchronizeHref(); + else if (SVGTests::isKnownAttribute(attrName)) + SVGTests::synchronizeProperties(this, attrName); } static void updateContainerSize(SVGUseElement* useElement, SVGElementInstance* targetInstance) diff --git a/WebCore/svg/SVGUseElement.h b/WebCore/svg/SVGUseElement.h index b127450..5a11ace 100644 --- a/WebCore/svg/SVGUseElement.h +++ b/WebCore/svg/SVGUseElement.h @@ -32,94 +32,94 @@ namespace WebCore { - class SVGElementInstance; - class SVGLength; - class SVGShadowTreeRootElement; +class SVGElementInstance; +class SVGShadowTreeRootElement; - class SVGUseElement : public SVGStyledTransformableElement, - public SVGTests, - public SVGLangSpace, - public SVGExternalResourcesRequired, - public SVGURIReference { - public: - static PassRefPtr<SVGUseElement> create(const QualifiedName&, Document*); +class SVGUseElement : public SVGStyledTransformableElement, + public SVGTests, + public SVGLangSpace, + public SVGExternalResourcesRequired, + public SVGURIReference { +public: + static PassRefPtr<SVGUseElement> create(const QualifiedName&, Document*); - SVGElementInstance* instanceRoot() const; - SVGElementInstance* animatedInstanceRoot() const; - SVGElementInstance* instanceForShadowTreeElement(Node*) const; - void invalidateShadowTree(); + SVGElementInstance* instanceRoot() const; + SVGElementInstance* animatedInstanceRoot() const; + SVGElementInstance* instanceForShadowTreeElement(Node*) const; + void invalidateShadowTree(); - RenderObject* rendererClipChild() const; + RenderObject* rendererClipChild() const; - private: - SVGUseElement(const QualifiedName&, Document*); +private: + SVGUseElement(const QualifiedName&, Document*); - virtual bool isValid() const { return SVGTests::isValid(); } + virtual bool isValid() const { return SVGTests::isValid(); } - virtual void insertedIntoDocument(); - virtual void removedFromDocument(); - virtual void buildPendingResource(); + virtual void insertedIntoDocument(); + virtual void removedFromDocument(); + virtual void buildPendingResource(); - virtual void parseMappedAttribute(Attribute*); - virtual void svgAttributeChanged(const QualifiedName&); - virtual void synchronizeProperty(const QualifiedName&); + virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); + virtual void synchronizeProperty(const QualifiedName&); - virtual void recalcStyle(StyleChange = NoChange); - virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - virtual void attach(); - virtual void detach(); + virtual void recalcStyle(StyleChange = NoChange); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + virtual void attach(); + virtual void detach(); - virtual void toClipPath(Path&) const; + virtual void toClipPath(Path&) const; - static void removeDisallowedElementsFromSubtree(Node* element); + static void removeDisallowedElementsFromSubtree(Node* element); - void setUpdatesBlocked(bool blocked) { m_updatesBlocked = blocked; } + void setUpdatesBlocked(bool blocked) { m_updatesBlocked = blocked; } - friend class RenderSVGShadowTreeRootContainer; - bool isPendingResource() const { return m_isPendingResource; } - void buildShadowAndInstanceTree(SVGShadowTreeRootElement*); + friend class RenderSVGShadowTreeRootContainer; + bool isPendingResource() const { return m_isPendingResource; } + void buildShadowAndInstanceTree(SVGShadowTreeRootElement*); - virtual bool selfHasRelativeLengths() const; + virtual bool selfHasRelativeLengths() const; - DECLARE_ANIMATED_PROPERTY_NEW(SVGUseElement, SVGNames::xAttr, SVGLength, X, x) - DECLARE_ANIMATED_PROPERTY_NEW(SVGUseElement, SVGNames::yAttr, SVGLength, Y, y) - DECLARE_ANIMATED_PROPERTY_NEW(SVGUseElement, SVGNames::widthAttr, SVGLength, Width, width) - DECLARE_ANIMATED_PROPERTY_NEW(SVGUseElement, SVGNames::heightAttr, SVGLength, Height, height) + // Instance tree handling + void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle); + void handleDeepUseReferencing(SVGUseElement* use, SVGElementInstance* targetInstance, bool& foundCycle); - // SVGURIReference - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGUseElement, XLinkNames::hrefAttr, String, Href, href) + // Shadow tree handling + void buildShadowTree(SVGShadowTreeRootElement*, SVGElement* target, SVGElementInstance* targetInstance); - // SVGExternalResourcesRequired - DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGUseElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) +#if ENABLE(SVG) && ENABLE(SVG_USE) + void expandUseElementsInShadowTree(SVGShadowTreeRootElement*, Node* element); + void expandSymbolElementsInShadowTree(SVGShadowTreeRootElement*, Node* element); +#endif - // Instance tree handling - void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle); - void handleDeepUseReferencing(SVGUseElement* use, SVGElementInstance* targetInstance, bool& foundCycle); + // "Tree connector" + void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance); + SVGElementInstance* instanceForShadowTreeElement(Node* element, SVGElementInstance* instance) const; - // Shadow tree handling - void buildShadowTree(SVGShadowTreeRootElement*, SVGElement* target, SVGElementInstance* targetInstance); + void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const; + void transferEventListenersToShadowTree(SVGElementInstance* target); -#if ENABLE(SVG) && ENABLE(SVG_USE) - void expandUseElementsInShadowTree(SVGShadowTreeRootElement*, Node* element); - void expandSymbolElementsInShadowTree(SVGShadowTreeRootElement*, Node* element); -#endif + void updateContainerOffsets(); + void updateContainerSizes(); - // "Tree connector" - void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance); - SVGElementInstance* instanceForShadowTreeElement(Node* element, SVGElementInstance* instance) const; + // Animated property declarations + DECLARE_ANIMATED_LENGTH(X, x) + DECLARE_ANIMATED_LENGTH(Y, y) + DECLARE_ANIMATED_LENGTH(Width, width) + DECLARE_ANIMATED_LENGTH(Height, height) - void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const; - void transferEventListenersToShadowTree(SVGElementInstance* target); + // SVGURIReference + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGUseElement, XLinkNames::hrefAttr, String, Href, href) - void updateContainerOffsets(); - void updateContainerSizes(); + // SVGExternalResourcesRequired + DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGUseElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired) - bool m_updatesBlocked; - bool m_isPendingResource; - bool m_needsShadowTreeRecreation; - String m_resourceId; - RefPtr<SVGElementInstance> m_targetElementInstance; - }; + bool m_updatesBlocked; + bool m_isPendingResource; + bool m_needsShadowTreeRecreation; + String m_resourceId; + RefPtr<SVGElementInstance> m_targetElementInstance; +}; } diff --git a/WebCore/svg/SVGViewElement.h b/WebCore/svg/SVGViewElement.h index 7e239e3..b3a0f39 100644 --- a/WebCore/svg/SVGViewElement.h +++ b/WebCore/svg/SVGViewElement.h @@ -23,10 +23,12 @@ #if ENABLE(SVG) #include "SVGAnimatedPropertyMacros.h" -#include "SVGStringList.h" -#include "SVGStyledElement.h" #include "SVGExternalResourcesRequired.h" #include "SVGFitToViewBox.h" +#include "SVGPreserveAspectRatio.h" +#include "SVGRect.h" +#include "SVGStringList.h" +#include "SVGStyledElement.h" #include "SVGZoomAndPan.h" namespace WebCore { diff --git a/WebCore/svg/SVGViewSpec.cpp b/WebCore/svg/SVGViewSpec.cpp index d6bade3..a0a683b 100644 --- a/WebCore/svg/SVGViewSpec.cpp +++ b/WebCore/svg/SVGViewSpec.cpp @@ -81,7 +81,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) if (currViewSpec >= end) return false; - if (!skipString(currViewSpec, end, svgViewSpec, sizeof(svgViewSpec) / sizeof(UChar))) + if (!skipString(currViewSpec, end, svgViewSpec, WTF_ARRAY_LENGTH(svgViewSpec))) return false; if (currViewSpec >= end || *currViewSpec != '(' ) @@ -90,7 +90,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) while (currViewSpec < end && *currViewSpec != ')') { if (*currViewSpec == 'v') { - if (skipString(currViewSpec, end, viewBoxSpec, sizeof(viewBoxSpec) / sizeof(UChar))) { + if (skipString(currViewSpec, end, viewBoxSpec, WTF_ARRAY_LENGTH(viewBoxSpec))) { if (currViewSpec >= end || *currViewSpec != '(') return false; currViewSpec++; @@ -101,7 +101,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) if (currViewSpec >= end || *currViewSpec != ')') return false; currViewSpec++; - } else if (skipString(currViewSpec, end, viewTargetSpec, sizeof(viewTargetSpec) / sizeof(UChar))) { + } else if (skipString(currViewSpec, end, viewTargetSpec, WTF_ARRAY_LENGTH(viewTargetSpec))) { if (currViewSpec >= end || *currViewSpec != '(') return false; const UChar* viewTargetStart = ++currViewSpec; @@ -114,7 +114,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) } else return false; } else if (*currViewSpec == 'z') { - if (!skipString(currViewSpec, end, zoomAndPanSpec, sizeof(zoomAndPanSpec) / sizeof(UChar))) + if (!skipString(currViewSpec, end, zoomAndPanSpec, WTF_ARRAY_LENGTH(zoomAndPanSpec))) return false; if (currViewSpec >= end || *currViewSpec != '(') return false; @@ -125,7 +125,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) return false; currViewSpec++; } else if (*currViewSpec == 'p') { - if (!skipString(currViewSpec, end, preserveAspectRatioSpec, sizeof(preserveAspectRatioSpec) / sizeof(UChar))) + if (!skipString(currViewSpec, end, preserveAspectRatioSpec, WTF_ARRAY_LENGTH(preserveAspectRatioSpec))) return false; if (currViewSpec >= end || *currViewSpec != '(') return false; @@ -138,7 +138,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) return false; currViewSpec++; } else if (*currViewSpec == 't') { - if (!skipString(currViewSpec, end, transformSpec, sizeof(transformSpec) / sizeof(UChar))) + if (!skipString(currViewSpec, end, transformSpec, WTF_ARRAY_LENGTH(transformSpec))) return false; if (currViewSpec >= end || *currViewSpec != '(') return false; diff --git a/WebCore/svg/SVGViewSpec.h b/WebCore/svg/SVGViewSpec.h index dd466ef..7427f4b 100644 --- a/WebCore/svg/SVGViewSpec.h +++ b/WebCore/svg/SVGViewSpec.h @@ -24,6 +24,8 @@ #include "SVGAnimatedPropertyMacros.h" #include "SVGElement.h" #include "SVGFitToViewBox.h" +#include "SVGPreserveAspectRatio.h" +#include "SVGRect.h" #include "SVGZoomAndPan.h" #include <wtf/RefPtr.h> diff --git a/WebCore/svg/SVGZoomAndPan.cpp b/WebCore/svg/SVGZoomAndPan.cpp index 93ab3ad..36d4a60 100644 --- a/WebCore/svg/SVGZoomAndPan.cpp +++ b/WebCore/svg/SVGZoomAndPan.cpp @@ -56,9 +56,9 @@ static const UChar magnify[] = {'m', 'a', 'g', 'n', 'i', 'f', 'y'}; bool SVGZoomAndPan::parseZoomAndPan(const UChar*& start, const UChar* end) { - if (skipString(start, end, disable, sizeof(disable) / sizeof(UChar))) + if (skipString(start, end, disable, WTF_ARRAY_LENGTH(disable))) setZoomAndPan(SVG_ZOOMANDPAN_DISABLE); - else if (skipString(start, end, magnify, sizeof(magnify) / sizeof(UChar))) + else if (skipString(start, end, magnify, WTF_ARRAY_LENGTH(magnify))) setZoomAndPan(SVG_ZOOMANDPAN_MAGNIFY); else return false; diff --git a/WebCore/svg/graphics/filters/SVGFEImage.cpp b/WebCore/svg/graphics/filters/SVGFEImage.cpp index ed90588..6a1914a 100644 --- a/WebCore/svg/graphics/filters/SVGFEImage.cpp +++ b/WebCore/svg/graphics/filters/SVGFEImage.cpp @@ -32,19 +32,19 @@ namespace WebCore { -FEImage::FEImage(RefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio) - : FilterEffect() +FEImage::FEImage(Filter* filter, RefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio) + : FilterEffect(filter) , m_image(image) , m_preserveAspectRatio(preserveAspectRatio) { } -PassRefPtr<FEImage> FEImage::create(RefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio) +PassRefPtr<FEImage> FEImage::create(Filter* filter, RefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio) { - return adoptRef(new FEImage(image, preserveAspectRatio)); + return adoptRef(new FEImage(filter, image, preserveAspectRatio)); } -void FEImage::determineAbsolutePaintRect(Filter*) +void FEImage::determineAbsolutePaintRect() { ASSERT(m_image); FloatRect srcRect(FloatPoint(), m_image->size()); @@ -54,12 +54,12 @@ void FEImage::determineAbsolutePaintRect(Filter*) setAbsolutePaintRect(enclosingIntRect(paintRect)); } -void FEImage::apply(Filter* filter) +void FEImage::apply() { if (!m_image.get()) return; - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/svg/graphics/filters/SVGFEImage.h b/WebCore/svg/graphics/filters/SVGFEImage.h index 9efb5f1..9ac5527 100644 --- a/WebCore/svg/graphics/filters/SVGFEImage.h +++ b/WebCore/svg/graphics/filters/SVGFEImage.h @@ -31,21 +31,21 @@ namespace WebCore { class FEImage : public FilterEffect { public: - static PassRefPtr<FEImage> create(RefPtr<Image>, const SVGPreserveAspectRatio&); + static PassRefPtr<FEImage> create(Filter*, RefPtr<Image>, const SVGPreserveAspectRatio&); void setAbsoluteSubregion(const FloatRect& absoluteSubregion) { m_absoluteSubregion = absoluteSubregion; } - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual FilterEffectType filterEffectType() const { return FilterEffectTypeImage; } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEImage(RefPtr<Image>, const SVGPreserveAspectRatio&); + FEImage(Filter*, RefPtr<Image>, const SVGPreserveAspectRatio&); RefPtr<Image> m_image; SVGPreserveAspectRatio m_preserveAspectRatio; diff --git a/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp b/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp index 091379e..b31b994 100644 --- a/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp +++ b/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp @@ -31,11 +31,11 @@ namespace WebCore { -SVGFilterBuilder::SVGFilterBuilder() +SVGFilterBuilder::SVGFilterBuilder(Filter* filter) : m_lastEffect(0) { - m_builtinEffects.add(SourceGraphic::effectName(), SourceGraphic::create()); - m_builtinEffects.add(SourceAlpha::effectName(), SourceAlpha::create()); + m_builtinEffects.add(SourceGraphic::effectName(), SourceGraphic::create(filter)); + m_builtinEffects.add(SourceAlpha::effectName(), SourceAlpha::create(filter)); addBuiltinEffects(); } diff --git a/WebCore/svg/graphics/filters/SVGFilterBuilder.h b/WebCore/svg/graphics/filters/SVGFilterBuilder.h index 320088d..f767cac 100644 --- a/WebCore/svg/graphics/filters/SVGFilterBuilder.h +++ b/WebCore/svg/graphics/filters/SVGFilterBuilder.h @@ -37,7 +37,7 @@ namespace WebCore { public: typedef HashSet<FilterEffect*> FilterEffectSet; - static PassRefPtr<SVGFilterBuilder> create() { return adoptRef(new SVGFilterBuilder); } + static PassRefPtr<SVGFilterBuilder> create(Filter* filter) { return adoptRef(new SVGFilterBuilder(filter)); } void add(const AtomicString& id, RefPtr<FilterEffect> effect); @@ -56,7 +56,7 @@ namespace WebCore { void clearEffects(); private: - SVGFilterBuilder(); + SVGFilterBuilder(Filter*); inline void addBuiltinEffects() { diff --git a/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h b/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h new file mode 100644 index 0000000..f515ab4 --- /dev/null +++ b/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h @@ -0,0 +1,72 @@ +/* + * 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 SVGAnimatedPathSegListPropertyTearOff_h +#define SVGAnimatedPathSegListPropertyTearOff_h + +#if ENABLE(SVG) +#include "SVGAnimatedListPropertyTearOff.h" +#include "SVGPathSegList.h" +#include "SVGPathSegListPropertyTearOff.h" + +namespace WebCore { + +class SVGPathSegListPropertyTearOff; + +class SVGAnimatedPathSegListPropertyTearOff : public SVGAnimatedListPropertyTearOff<SVGPathSegList> { +public: + SVGProperty* baseVal(SVGPathSegRole role) + { + if (!m_baseVal) + m_baseVal = SVGPathSegListPropertyTearOff::create(this, BaseValRole, role); + return m_baseVal.get(); + } + + SVGProperty* animVal(SVGPathSegRole role) + { + if (!m_animVal) + m_animVal = SVGPathSegListPropertyTearOff::create(this, AnimValRole, role); + return m_animVal.get(); + } + + int removeItemFromList(const RefPtr<SVGPathSeg>& segment, bool shouldSynchronizeWrappers) + { + // This should ever be called for our baseVal, as animVal can't modify the list. + return static_pointer_cast<SVGPathSegListPropertyTearOff>(m_baseVal)->removeItemFromList(segment, shouldSynchronizeWrappers); + } + +private: + friend class SVGAnimatedProperty; + + static PassRefPtr<SVGAnimatedPathSegListPropertyTearOff> create(SVGElement* contextElement, const QualifiedName& attributeName, SVGPathSegList& values) + { + ASSERT(contextElement); + return adoptRef(new SVGAnimatedPathSegListPropertyTearOff(contextElement, attributeName, values)); + } + + SVGAnimatedPathSegListPropertyTearOff(SVGElement* contextElement, const QualifiedName& attributeName, SVGPathSegList& values) + : SVGAnimatedListPropertyTearOff<SVGPathSegList>(contextElement, attributeName, values) + { + } +}; + +} + +#endif // ENABLE(SVG) +#endif // SVGAnimatedPathSegListPropertyTearOff_h diff --git a/WebCore/svg/properties/SVGAnimatedPropertyMacros.h b/WebCore/svg/properties/SVGAnimatedPropertyMacros.h index 870d26e..a24a25d 100644 --- a/WebCore/svg/properties/SVGAnimatedPropertyMacros.h +++ b/WebCore/svg/properties/SVGAnimatedPropertyMacros.h @@ -111,8 +111,6 @@ PropertyType& LowerProperty##BaseValue() const \ void set##UpperProperty##BaseValue(const PropertyType& type) \ { \ m_##LowerProperty.value = type; \ - SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ - contextElement->invalidateSVGAttributes(); \ } \ \ void synchronize##UpperProperty() \ @@ -145,31 +143,64 @@ DECLARE_ANIMATED_PROPERTY_NEW_SHARED(OwnerType, DOMAttribute, SVGDOMAttributeIde #define DECLARE_ANIMATED_STATIC_PROPERTY_NEW(OwnerType, DOMAttribute, PropertyType, UpperProperty, LowerProperty) \ DECLARE_ANIMATED_PROPERTY_NEW_SHARED(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedStaticPropertyTearOff<PropertyType>, PropertyType, UpperProperty, LowerProperty) -#define DECLARE_ANIMATED_LIST_PROPERTY_NEW(OwnerType, DOMAttribute, PropertyType, UpperProperty, LowerProperty) \ -DECLARE_ANIMATED_PROPERTY_NEW_SHARED(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedListPropertyTearOff<PropertyType>, PropertyType, UpperProperty, LowerProperty) \ +// FIXME: Remove all macros above, once these two below are deployed everywhere. + +#define DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, TearOffType, PropertyType, UpperProperty, LowerProperty) \ +void OwnerType::synchronize##UpperProperty() \ +{ \ + if (!m_##LowerProperty.shouldSynchronize) \ + return; \ + AtomicString value(SVGPropertyTraits<PropertyType>::toString(LowerProperty##BaseValue())); \ + SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ + SVGAnimatedPropertySynchronizer<IsDerivedFromSVGElement<OwnerType>::value>::synchronize(contextElement, DOMAttribute, value); \ +} \ \ -void detachAnimated##UpperProperty##ListWrappers(unsigned newListSize) \ +PassRefPtr<TearOffType> OwnerType::LowerProperty##Animated() \ { \ + m_##LowerProperty.shouldSynchronize = true; \ SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ - SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGAnimatedListPropertyTearOff<PropertyType> >(contextElement, DOMAttribute.localName()); \ - if (!wrapper) \ - return; \ - static_cast<SVGAnimatedListPropertyTearOff<PropertyType>*>(wrapper)->detachListWrappers(newListSize); \ + return SVGAnimatedProperty::lookupOrCreateWrapper<TearOffType, PropertyType>(contextElement, DOMAttribute, SVGDOMAttributeIdentifier, m_##LowerProperty.value); \ } -#define DECLARE_ANIMATED_TRANSFORM_LIST_PROPERTY_NEW(OwnerType, DOMAttribute, PropertyType, UpperProperty, LowerProperty) \ -DECLARE_ANIMATED_PROPERTY_NEW_SHARED(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedTransformListPropertyTearOff, PropertyType, UpperProperty, LowerProperty) \ +#define DECLARE_ANIMATED_PROPERTY(TearOffType, PropertyType, UpperProperty, LowerProperty) \ +public: \ +PropertyType& LowerProperty() const \ +{ \ + return m_##LowerProperty.value; \ +} \ \ -void detachAnimated##UpperProperty##ListWrappers(unsigned newListSize) \ +PropertyType& LowerProperty##BaseValue() const \ +{ \ + return m_##LowerProperty.value; \ +} \ +\ +void set##UpperProperty##BaseValue(const PropertyType& type) \ +{ \ + m_##LowerProperty.value = type; \ +} \ +\ +PassRefPtr<TearOffType> LowerProperty##Animated(); \ +\ +private: \ + void synchronize##UpperProperty(); \ +\ + mutable SVGSynchronizableAnimatedProperty<PropertyType> m_##LowerProperty; + +#define DECLARE_ANIMATED_LIST_PROPERTY(TearOffType, PropertyType, UpperProperty, LowerProperty) \ +DECLARE_ANIMATED_PROPERTY(TearOffType, PropertyType, UpperProperty, LowerProperty) \ +void detachAnimated##UpperProperty##ListWrappers(unsigned newListSize); + +#define DEFINE_ANIMATED_LIST_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, TearOffType, PropertyType, UpperProperty, LowerProperty) \ +DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, TearOffType, PropertyType, UpperProperty, LowerProperty) \ +void OwnerType::detachAnimated##UpperProperty##ListWrappers(unsigned newListSize) \ { \ SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ - SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGAnimatedTransformListPropertyTearOff>(contextElement, DOMAttribute.localName()); \ + SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<TearOffType>(contextElement, DOMAttribute.localName()); \ if (!wrapper) \ return; \ - static_cast<SVGAnimatedTransformListPropertyTearOff*>(wrapper)->detachListWrappers(newListSize); \ + static_cast<TearOffType*>(wrapper)->detachListWrappers(newListSize); \ } - } #endif // ENABLE(SVG) diff --git a/WebCore/svg/properties/SVGListProperty.h b/WebCore/svg/properties/SVGListProperty.h index f143389..0985ddb 100644 --- a/WebCore/svg/properties/SVGListProperty.h +++ b/WebCore/svg/properties/SVGListProperty.h @@ -21,8 +21,8 @@ #define SVGListProperty_h #if ENABLE(SVG) -#include "ExceptionCode.h" #include "SVGAnimatedProperty.h" +#include "SVGException.h" #include "SVGPropertyTearOff.h" #include "SVGPropertyTraits.h" @@ -110,7 +110,7 @@ public: // Not specified, but FF/Opera do it this way, and it's just sane. if (!passNewItem) { - ec = TYPE_MISMATCH_ERR; + ec = SVGException::SVG_WRONG_TYPE_ERR; return 0; } @@ -207,7 +207,7 @@ public: // Not specified, but FF/Opera do it this way, and it's just sane. if (!passNewItem) { - ec = TYPE_MISMATCH_ERR; + ec = SVGException::SVG_WRONG_TYPE_ERR; return 0; } @@ -258,6 +258,12 @@ public: // 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); + if (values.isEmpty()) { + // 'newItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace. + ec = INDEX_SIZE_ERR; + return ListItemType(); + } + // Update the value at the desired position 'index'. values.at(index) = newItem; @@ -274,7 +280,7 @@ public: // Not specified, but FF/Opera do it this way, and it's just sane. if (!passNewItem) { - ec = TYPE_MISMATCH_ERR; + ec = SVGException::SVG_WRONG_TYPE_ERR; return 0; } @@ -286,6 +292,13 @@ public: // 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); + if (values.isEmpty()) { + ASSERT(wrappers.isEmpty()); + // 'passNewItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace. + ec = INDEX_SIZE_ERR; + return 0; + } + // Detach the existing wrapper. RefPtr<ListItemTearOff> oldItem = wrappers.at(index); if (oldItem) @@ -337,9 +350,10 @@ public: // Detach the existing wrapper. RefPtr<ListItemTearOff> oldItem = wrappers.at(index); - if (oldItem) - oldItem->detachWrapper(); + if (!oldItem) + oldItem = ListItemTearOff::create(animatedList, UndefinedRole, values.at(index)); + oldItem->detachWrapper(); wrappers.remove(index); values.remove(index); @@ -371,7 +385,7 @@ public: // Not specified, but FF/Opera do it this way, and it's just sane. if (!passNewItem) { - ec = TYPE_MISMATCH_ERR; + ec = SVGException::SVG_WRONG_TYPE_ERR; return 0; } @@ -392,6 +406,8 @@ public: return newItem.release(); } + virtual SVGPropertyRole role() const { return m_role; } + protected: SVGListProperty(SVGPropertyRole role) : m_role(role) diff --git a/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp b/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp new file mode 100644 index 0000000..af1b30c --- /dev/null +++ b/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp @@ -0,0 +1,110 @@ +/* + * 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. + */ + +#include "config.h" + +#if ENABLE(SVG) +#include "SVGPathSegListPropertyTearOff.h" + +#include "SVGAnimatedPathSegListPropertyTearOff.h" +#include "SVGPathElement.h" +#include "SVGPathSegWithContext.h" + +namespace WebCore { + +void SVGPathSegListPropertyTearOff::clear(ExceptionCode& ec) +{ + SVGPathSegList& values = m_animatedProperty->values(); + if (values.isEmpty()) + return; + + unsigned size = values.size(); + for (unsigned i = 0; i < size; ++i) { + ListItemType item = values.at(i); + static_cast<SVGPathSegWithContext*>(item.get())->setContextAndRole(0, PathSegUndefinedRole); + } + + SVGPathSegListPropertyTearOff::Base::clearValues(values, ec); +} + +SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::getItem(unsigned index, ExceptionCode& ec) +{ + SVGPathSegList& values = m_animatedProperty->values(); + ListItemType returnedItem = Base::getItemValues(values, index, ec); + if (returnedItem) { + ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->contextElement() == contextElement()); + ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->role() == m_pathSegRole); + } + return returnedItem.release(); +} + +SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::removeItem(unsigned index, ExceptionCode& ec) +{ + SVGPathSegList& values = m_animatedProperty->values(); + SVGPathSegListPropertyTearOff::ListItemType removedItem = SVGPathSegListPropertyTearOff::Base::removeItemValues(values, index, ec); + if (removedItem) + static_cast<SVGPathSegWithContext*>(removedItem.get())->setContextAndRole(0, PathSegUndefinedRole); + return removedItem.release(); +} + +SVGPathElement* SVGPathSegListPropertyTearOff::contextElement() const +{ + SVGElement* contextElement = m_animatedProperty->contextElement(); + ASSERT(contextElement); + ASSERT(contextElement->hasTagName(SVGNames::pathTag)); + return static_cast<SVGPathElement*>(contextElement); +} + +void SVGPathSegListPropertyTearOff::processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify) +{ + SVGPathSegWithContext* newItemWithContext = static_cast<SVGPathSegWithContext*>(newItem.get()); + SVGAnimatedProperty* animatedPropertyOfItem = newItemWithContext->animatedProperty(); + + // Alter the role, after calling animatedProperty(), as that may influence the returned animated property. + newItemWithContext->setContextAndRole(contextElement(), m_pathSegRole); + + if (!animatedPropertyOfItem) + return; + + // newItem belongs to a SVGPathElement, but its associated SVGAnimatedProperty is not an animated list tear off. + // (for example: "pathElement.pathSegList.appendItem(pathElement.createSVGPathSegClosepath())") + if (!animatedPropertyOfItem->isAnimatedListTearOff()) + 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<SVGAnimatedPathSegListPropertyTearOff*>(animatedPropertyOfItem)->removeItemFromList(newItem.get(), livesInOtherList); + ASSERT(removedIndex != -1); + + if (!indexToModify) + return; + + // If the item lived in our list, adjust the insertion index. + if (!livesInOtherList) { + unsigned& index = *indexToModify; + // Spec: If the item is already in this list, note that the index of the item to (replace|insert before) is before the removal of the item. + if (static_cast<unsigned>(removedIndex) < index) + --index; + } +} + +} + +#endif // ENABLE(SVG) diff --git a/WebCore/svg/properties/SVGPathSegListPropertyTearOff.h b/WebCore/svg/properties/SVGPathSegListPropertyTearOff.h new file mode 100644 index 0000000..94acda1 --- /dev/null +++ b/WebCore/svg/properties/SVGPathSegListPropertyTearOff.h @@ -0,0 +1,160 @@ +/* + * 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 SVGPathSegListPropertyTearOff_h +#define SVGPathSegListPropertyTearOff_h + +#if ENABLE(SVG) +#include "SVGAnimatedListPropertyTearOff.h" +#include "SVGPathSegList.h" + +namespace WebCore { + +class SVGPathElement; + +class SVGPathSegListPropertyTearOff : public SVGListProperty<SVGPathSegList> { +public: + typedef SVGListProperty<SVGPathSegList> Base; + typedef SVGAnimatedListPropertyTearOff<SVGPathSegList> AnimatedListPropertyTearOff; + typedef SVGPropertyTraits<SVGPathSegList>::ListItemType ListItemType; + typedef PassRefPtr<SVGPathSeg> PassListItemType; + + static PassRefPtr<SVGPathSegListPropertyTearOff> create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role, SVGPathSegRole pathSegRole) + { + ASSERT(animatedProperty); + return adoptRef(new SVGPathSegListPropertyTearOff(animatedProperty, role, pathSegRole)); + } + + int removeItemFromList(const ListItemType& removeItem, bool shouldSynchronizeWrappers) + { + SVGPathSegList& values = m_animatedProperty->values(); + + unsigned size = values.size(); + for (unsigned i = 0; i < size; ++i) { + ListItemType& item = values.at(i); + if (item != removeItem) + continue; + + values.remove(i); + + if (shouldSynchronizeWrappers) + commitChange(); + + return i; + } + + return -1; + } + + // SVGList API + void clear(ExceptionCode&); + + unsigned numberOfItems() const + { + SVGPathSegList& values = m_animatedProperty->values(); + return Base::numberOfItemsValues(values); + } + + PassListItemType initialize(PassListItemType passNewItem, ExceptionCode& ec) + { + // Not specified, but FF/Opera do it this way, and it's just sane. + if (!passNewItem) { + ec = SVGException::SVG_WRONG_TYPE_ERR; + return 0; + } + + ListItemType newItem = passNewItem; + SVGPathSegList& values = m_animatedProperty->values(); + return Base::initializeValues(values, newItem, ec); + } + + PassListItemType getItem(unsigned index, ExceptionCode&); + + PassListItemType insertItemBefore(PassListItemType passNewItem, unsigned index, ExceptionCode& ec) + { + // Not specified, but FF/Opera do it this way, and it's just sane. + if (!passNewItem) { + ec = SVGException::SVG_WRONG_TYPE_ERR; + return 0; + } + + ListItemType newItem = passNewItem; + SVGPathSegList& values = m_animatedProperty->values(); + return Base::insertItemBeforeValues(values, newItem, index, ec); + } + + PassListItemType replaceItem(PassListItemType passNewItem, unsigned index, ExceptionCode& ec) + { + // Not specified, but FF/Opera do it this way, and it's just sane. + if (!passNewItem) { + ec = SVGException::SVG_WRONG_TYPE_ERR; + return 0; + } + + ListItemType newItem = passNewItem; + SVGPathSegList& values = m_animatedProperty->values(); + return Base::replaceItemValues(values, newItem, index, ec); + } + + PassListItemType removeItem(unsigned index, ExceptionCode&); + + PassListItemType appendItem(PassListItemType passNewItem, ExceptionCode& ec) + { + // Not specified, but FF/Opera do it this way, and it's just sane. + if (!passNewItem) { + ec = SVGException::SVG_WRONG_TYPE_ERR; + return 0; + } + + ListItemType newItem = passNewItem; + SVGPathSegList& values = m_animatedProperty->values(); + return Base::appendItemValues(values, newItem, ec); + } + +private: + SVGPathSegListPropertyTearOff(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role, SVGPathSegRole pathSegRole) + : SVGListProperty<SVGPathSegList>(role) + , m_animatedProperty(animatedProperty) + , m_pathSegRole(pathSegRole) + { + } + + SVGPathElement* contextElement() const; + + virtual void commitChange() + { + SVGPathSegList& values = m_animatedProperty->values(); + values.commitChange(m_animatedProperty->contextElement()); + } + + virtual void processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify); + virtual void processIncomingListItemWrapper(RefPtr<ListItemTearOff>&, unsigned*) + { + ASSERT_NOT_REACHED(); + } + +private: + RefPtr<AnimatedListPropertyTearOff> m_animatedProperty; + SVGPathSegRole m_pathSegRole; +}; + +} + +#endif // ENABLE(SVG) +#endif // SVGListPropertyTearOff_h diff --git a/WebCore/svg/properties/SVGProperty.h b/WebCore/svg/properties/SVGProperty.h index 104fb0e..609e264 100644 --- a/WebCore/svg/properties/SVGProperty.h +++ b/WebCore/svg/properties/SVGProperty.h @@ -35,6 +35,7 @@ class SVGProperty : public RefCounted<SVGProperty> { public: virtual ~SVGProperty() { } + virtual SVGPropertyRole role() const = 0; virtual void commitChange() = 0; }; diff --git a/WebCore/svg/properties/SVGPropertyTearOff.h b/WebCore/svg/properties/SVGPropertyTearOff.h index 219a4a6..d0eac3b 100644 --- a/WebCore/svg/properties/SVGPropertyTearOff.h +++ b/WebCore/svg/properties/SVGPropertyTearOff.h @@ -34,10 +34,10 @@ public: // 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) + static PassRefPtr<Self> create(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType& value) { ASSERT(animatedProperty); - return adoptRef(new Self(animatedProperty, value)); + return adoptRef(new Self(animatedProperty, role, value)); } // Used for non-animated POD types (for example: SVGSVGElement::createSVGLength()). @@ -91,9 +91,12 @@ public: m_animatedProperty->commitChange(); } + virtual SVGPropertyRole role() const { return m_role; } + protected: - SVGPropertyTearOff(SVGAnimatedProperty* animatedProperty, PropertyType& value) + SVGPropertyTearOff(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType& value) : m_animatedProperty(animatedProperty) + , m_role(role) , m_value(&value) , m_valueIsCopy(false) { @@ -103,6 +106,7 @@ protected: SVGPropertyTearOff(const PropertyType& initialValue) : m_animatedProperty(0) + , m_role(UndefinedRole) , m_value(new PropertyType(initialValue)) , m_valueIsCopy(true) { @@ -115,6 +119,7 @@ protected: } RefPtr<SVGAnimatedProperty> m_animatedProperty; + SVGPropertyRole m_role; PropertyType* m_value; bool m_valueIsCopy : 1; }; diff --git a/WebCore/svg/properties/SVGPropertyTraits.h b/WebCore/svg/properties/SVGPropertyTraits.h index 5364853..0ed9339 100644 --- a/WebCore/svg/properties/SVGPropertyTraits.h +++ b/WebCore/svg/properties/SVGPropertyTraits.h @@ -22,16 +22,7 @@ #define SVGPropertyTraits_h #if ENABLE(SVG) -#include "FloatRect.h" -#include "SVGAngle.h" -#include "SVGLength.h" -#include "SVGLengthList.h" -#include "SVGNumberList.h" -#include "SVGPointList.h" -#include "SVGPreserveAspectRatio.h" -#include "SVGStringList.h" -#include "SVGTransformList.h" -#include <wtf/text/StringBuilder.h> +#include <wtf/text/WTFString.h> namespace WebCore { @@ -39,12 +30,6 @@ template<typename PropertyType> struct SVGPropertyTraits { }; template<> -struct SVGPropertyTraits<SVGAngle> { - static SVGAngle initialValue() { return SVGAngle(); } - static String toString(const SVGAngle& type) { return type.valueAsString(); } -}; - -template<> struct SVGPropertyTraits<bool> { static bool initialValue() { return false; } static String toString(bool type) { return type ? "true" : "false"; } @@ -63,81 +48,17 @@ struct SVGPropertyTraits<long> { }; template<> -struct SVGPropertyTraits<SVGLength> { - static SVGLength initialValue() { return SVGLength(); } - static String toString(const SVGLength& type) { return type.valueAsString(); } -}; - -template<> -struct SVGPropertyTraits<SVGLengthList> { - typedef SVGLength ListItemType; - - static SVGLengthList initialValue() { return SVGLengthList(); } - static String toString(const SVGLengthList& type) { return type.valueAsString(); } -}; - -template<> struct SVGPropertyTraits<float> { static float initialValue() { return 0; } static String toString(float type) { return String::number(type); } }; 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(); } -}; - -template<> -struct SVGPropertyTraits<FloatRect> { - static FloatRect initialValue() { return FloatRect(); } - static String toString(const FloatRect& type) - { - StringBuilder builder; - builder.append(String::number(type.x())); - builder.append(' '); - builder.append(String::number(type.y())); - builder.append(' '); - builder.append(String::number(type.width())); - builder.append(' '); - builder.append(String::number(type.height())); - builder.append(' '); - return builder.toString(); - } -}; - -template<> struct SVGPropertyTraits<String> { static String initialValue() { return 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; -}; - -template<> -struct SVGPropertyTraits<SVGTransformList> { - static SVGTransformList initialValue() { return SVGTransformList(); } - static String toString(const SVGTransformList& type) { return type.valueAsString(); } - typedef SVGTransform ListItemType; -}; - } #endif diff --git a/WebCore/svg/properties/SVGStaticPropertyTearOff.h b/WebCore/svg/properties/SVGStaticPropertyTearOff.h index 8f31909..233880f 100644 --- a/WebCore/svg/properties/SVGStaticPropertyTearOff.h +++ b/WebCore/svg/properties/SVGStaticPropertyTearOff.h @@ -48,7 +48,7 @@ public: private: SVGStaticPropertyTearOff(ContextElement* contextElement, PropertyType& value, UpdateMethod update) - : SVGPropertyTearOff<PropertyType>(0, value) + : SVGPropertyTearOff<PropertyType>(0, UndefinedRole, value) , m_update(update) , m_contextElement(contextElement) { diff --git a/WebCore/svg/properties/SVGStaticPropertyWithParentTearOff.h b/WebCore/svg/properties/SVGStaticPropertyWithParentTearOff.h index 1e58341..cf47960 100644 --- a/WebCore/svg/properties/SVGStaticPropertyWithParentTearOff.h +++ b/WebCore/svg/properties/SVGStaticPropertyWithParentTearOff.h @@ -53,7 +53,7 @@ public: private: SVGStaticPropertyWithParentTearOff(SVGProperty* parent, PropertyType& value, UpdateMethod update) - : SVGPropertyTearOff<PropertyType>(0, value) + : SVGPropertyTearOff<PropertyType>(0, UndefinedRole, value) , m_update(update) , m_parent(parent) { diff --git a/WebCore/svg/properties/SVGTransformListPropertyTearOff.h b/WebCore/svg/properties/SVGTransformListPropertyTearOff.h index 636871a..d3ad1ca 100644 --- a/WebCore/svg/properties/SVGTransformListPropertyTearOff.h +++ b/WebCore/svg/properties/SVGTransformListPropertyTearOff.h @@ -22,6 +22,7 @@ #if ENABLE(SVG) #include "SVGListPropertyTearOff.h" +#include "SVGTransformList.h" namespace WebCore { @@ -53,6 +54,10 @@ public: ListWrapperCache& wrappers = m_animatedProperty->wrappers(); ASSERT(values.size() == wrappers.size()); + // Spec: If the list was empty, then a value of null is returned. + if (values.isEmpty()) + return 0; + m_animatedProperty->detachListWrappers(0); RefPtr<SVGPropertyTearOff<SVGTransform> > wrapper = SVGPropertyTearOff<SVGTransform>::create(values.consolidate()); wrappers.append(wrapper); |