diff options
Diffstat (limited to 'WebCore/svg')
76 files changed, 605 insertions, 313 deletions
diff --git a/WebCore/svg/SVGAnimatedProperty.h b/WebCore/svg/DeprecatedSVGAnimatedProperty.h index d9cbeec..e2f2af7 100644 --- a/WebCore/svg/SVGAnimatedProperty.h +++ b/WebCore/svg/DeprecatedSVGAnimatedProperty.h @@ -18,27 +18,27 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SVGAnimatedProperty_h -#define SVGAnimatedProperty_h +#ifndef DeprecatedSVGAnimatedProperty_h +#define DeprecatedSVGAnimatedProperty_h #if ENABLE(SVG) #include "SVGAnimatedPropertySynchronizer.h" -#include "SVGAnimatedPropertyTraits.h" -#include "SVGAnimatedTemplate.h" +#include "DeprecatedSVGAnimatedPropertyTraits.h" +#include "DeprecatedSVGAnimatedTemplate.h" namespace WebCore { template<typename AnimatedType> -class SVGAnimatedProperty; +class DeprecatedSVGAnimatedProperty; template<typename AnimatedType> -class SVGAnimatedPropertyTearOff : public SVGAnimatedTemplate<AnimatedType> { +class DeprecatedSVGAnimatedPropertyTearOff : public DeprecatedSVGAnimatedTemplate<AnimatedType> { public: - typedef typename SVGAnimatedPropertyTraits<AnimatedType>::PassType PassType; - typedef typename SVGAnimatedPropertyTraits<AnimatedType>::ReturnType ReturnType; + typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::PassType PassType; + typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType ReturnType; - typedef SVGAnimatedPropertyTearOff<AnimatedType> Self; - typedef SVGAnimatedProperty<AnimatedType> Creator; + typedef DeprecatedSVGAnimatedPropertyTearOff<AnimatedType> Self; + typedef DeprecatedSVGAnimatedProperty<AnimatedType> Creator; static PassRefPtr<Self> create(Creator& creator, SVGElement* contextElement) { @@ -62,14 +62,14 @@ public: virtual const QualifiedName& associatedAttributeName() const { return m_creator.associatedAttributeName(); } private: - SVGAnimatedPropertyTearOff(Creator& creator, SVGElement* contextElement) + DeprecatedSVGAnimatedPropertyTearOff(Creator& creator, SVGElement* contextElement) : m_creator(creator) , m_contextElement(contextElement) { m_creator.setShouldSynchronize(true); } - virtual ~SVGAnimatedPropertyTearOff() + virtual ~DeprecatedSVGAnimatedPropertyTearOff() { m_creator.setShouldSynchronize(false); } @@ -79,36 +79,36 @@ private: }; template<typename AnimatedType> -class SVGAnimatedProperty { +class DeprecatedSVGAnimatedProperty { public: - virtual ~SVGAnimatedProperty() { } + virtual ~DeprecatedSVGAnimatedProperty() { } - typedef typename SVGAnimatedPropertyTraits<AnimatedType>::PassType PassType; - typedef typename SVGAnimatedPropertyTraits<AnimatedType>::ReturnType ReturnType; - typedef typename SVGAnimatedPropertyTraits<AnimatedType>::StoredType StoredType; + typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::PassType PassType; + typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType ReturnType; + typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::StoredType StoredType; - SVGAnimatedProperty() - : m_value(SVGAnimatedPropertyTraits<AnimatedType>::null()) + DeprecatedSVGAnimatedProperty() + : m_value(DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::null()) , m_shouldSynchronize(false) { } template<typename ConstructorParameterOne> - SVGAnimatedProperty(const ConstructorParameterOne& value1) + DeprecatedSVGAnimatedProperty(const ConstructorParameterOne& value1) : m_value(value1) , m_shouldSynchronize(false) { } template<typename ConstructorParameterOne, typename ConstructorParameterTwo> - SVGAnimatedProperty(const ConstructorParameterOne& value1, const ConstructorParameterTwo& value2) + DeprecatedSVGAnimatedProperty(const ConstructorParameterOne& value1, const ConstructorParameterTwo& value2) : m_value(value1, value2) , m_shouldSynchronize(false) { } - ReturnType value() const { return SVGAnimatedPropertyTraits<AnimatedType>::toReturnType(m_value); } - ReturnType baseValue() const { return SVGAnimatedPropertyTraits<AnimatedType>::toReturnType(m_value); } + 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; } @@ -127,29 +127,29 @@ protected: // Helper macro used within DECLARE_ANIMATED_PROPERTY below #define DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, AnimatedType, UpperProperty) \ -class SVGAnimatedProperty##UpperProperty : public SVGAnimatedProperty<AnimatedType> { \ +class DeprecatedSVGAnimatedProperty##UpperProperty : public DeprecatedSVGAnimatedProperty<AnimatedType> { \ public: \ - SVGAnimatedProperty##UpperProperty() \ - : SVGAnimatedProperty<AnimatedType>() \ + DeprecatedSVGAnimatedProperty##UpperProperty() \ + : DeprecatedSVGAnimatedProperty<AnimatedType>() \ { \ } \ \ template<typename ConstructorParameterOne> \ - SVGAnimatedProperty##UpperProperty(const ConstructorParameterOne& value1) \ - : SVGAnimatedProperty<AnimatedType>(value1) \ + DeprecatedSVGAnimatedProperty##UpperProperty(const ConstructorParameterOne& value1) \ + : DeprecatedSVGAnimatedProperty<AnimatedType>(value1) \ { \ } \ \ template<typename ConstructorParameterOne, typename ConstructorParameterTwo> \ - SVGAnimatedProperty##UpperProperty(const ConstructorParameterOne& value1, const ConstructorParameterTwo& value2) \ - : SVGAnimatedProperty<AnimatedType>(value1, value2) \ + DeprecatedSVGAnimatedProperty##UpperProperty(const ConstructorParameterOne& value1, const ConstructorParameterTwo& value2) \ + : DeprecatedSVGAnimatedProperty<AnimatedType>(value1, value2) \ { \ } \ \ void synchronize(SVGElement* contextElement) \ { \ ASSERT(m_shouldSynchronize); \ - AtomicString value(SVGAnimatedPropertyTraits<AnimatedType>::toString(baseValue())); \ + AtomicString value(DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::toString(baseValue())); \ SVGAnimatedPropertySynchronizer<IsDerivedFromSVGElement<OwnerType>::value>::synchronize(contextElement, DOMAttribute, value); \ } \ \ @@ -162,29 +162,29 @@ public: \ // 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 SVGAnimatedPropertyTearOff<AnimatedType> SVGAnimatedPropertyTearOff##UpperProperty; \ + typedef DeprecatedSVGAnimatedPropertyTearOff<AnimatedType> DeprecatedSVGAnimatedPropertyTearOff##UpperProperty; \ DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, AnimatedType, UpperProperty); \ - SVGAnimatedProperty##UpperProperty m_##LowerProperty; \ + DeprecatedSVGAnimatedProperty##UpperProperty m_##LowerProperty; \ \ public: \ - SVGAnimatedPropertyTraits<AnimatedType>::ReturnType LowerProperty() const \ + DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType LowerProperty() const \ { \ return m_##LowerProperty.value(); \ } \ \ - SVGAnimatedPropertyTraits<AnimatedType>::ReturnType LowerProperty##BaseValue() const \ + DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType LowerProperty##BaseValue() const \ { \ return m_##LowerProperty.baseValue(); \ } \ \ - void set##UpperProperty(SVGAnimatedPropertyTraits<AnimatedType>::PassType type) \ + 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(SVGAnimatedPropertyTraits<AnimatedType>::PassType type) \ + void set##UpperProperty##BaseValue(DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::PassType type) \ { \ m_##LowerProperty.setBaseValue(type); \ SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ @@ -199,10 +199,10 @@ public: \ m_##LowerProperty.synchronize(contextElement); \ } \ \ - PassRefPtr<SVGAnimatedPropertyTearOff##UpperProperty> LowerProperty##Animated() \ + PassRefPtr<DeprecatedSVGAnimatedPropertyTearOff##UpperProperty> LowerProperty##Animated() \ { \ SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \ - return lookupOrCreateWrapper<AnimatedType, SVGAnimatedPropertyTearOff##UpperProperty>(contextElement, m_##LowerProperty, DOMAttribute); \ + return lookupOrCreateWrapper<AnimatedType, DeprecatedSVGAnimatedPropertyTearOff##UpperProperty>(contextElement, m_##LowerProperty, DOMAttribute); \ } // Used for SVG DOM properties that map exactly to one XML DOM attribute diff --git a/WebCore/svg/SVGAnimatedPropertyTraits.h b/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h index 5cc69a9..a660198 100644 --- a/WebCore/svg/SVGAnimatedPropertyTraits.h +++ b/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h @@ -18,8 +18,8 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SVGAnimatedPropertyTraits_h -#define SVGAnimatedPropertyTraits_h +#ifndef DeprecatedSVGAnimatedPropertyTraits_h +#define DeprecatedSVGAnimatedPropertyTraits_h #if ENABLE(SVG) #include "FloatRect.h" @@ -34,11 +34,11 @@ namespace WebCore { template<typename Type> -struct SVGAnimatedPropertyTraits : public Noncopyable { }; +struct DeprecatedSVGAnimatedPropertyTraits : public Noncopyable { }; // SVGAnimatedAngle template<> -struct SVGAnimatedPropertyTraits<SVGAngle> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<SVGAngle> : public Noncopyable { typedef const SVGAngle& PassType; typedef SVGAngle ReturnType; typedef SVGAngle StoredType; @@ -50,7 +50,7 @@ struct SVGAnimatedPropertyTraits<SVGAngle> : public Noncopyable { // SVGAnimatedBoolean template<> -struct SVGAnimatedPropertyTraits<bool> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<bool> : public Noncopyable { typedef const bool& PassType; typedef bool ReturnType; typedef bool StoredType; @@ -62,7 +62,7 @@ struct SVGAnimatedPropertyTraits<bool> : public Noncopyable { // SVGAnimatedEnumeration template<> -struct SVGAnimatedPropertyTraits<int> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<int> : public Noncopyable { typedef const int& PassType; typedef int ReturnType; typedef int StoredType; @@ -74,7 +74,7 @@ struct SVGAnimatedPropertyTraits<int> : public Noncopyable { // SVGAnimatedInteger template<> -struct SVGAnimatedPropertyTraits<long> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<long> : public Noncopyable { typedef const long& PassType; typedef long ReturnType; typedef long StoredType; @@ -86,7 +86,7 @@ struct SVGAnimatedPropertyTraits<long> : public Noncopyable { // SVGAnimatedLength template<> -struct SVGAnimatedPropertyTraits<SVGLength> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<SVGLength> : public Noncopyable { typedef const SVGLength& PassType; typedef SVGLength ReturnType; typedef SVGLength StoredType; @@ -98,7 +98,7 @@ struct SVGAnimatedPropertyTraits<SVGLength> : public Noncopyable { // SVGAnimatedLengthList template<> -struct SVGAnimatedPropertyTraits<SVGLengthList*> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<SVGLengthList*> : public Noncopyable { typedef SVGLengthList* PassType; typedef SVGLengthList* ReturnType; typedef RefPtr<SVGLengthList> StoredType; @@ -110,7 +110,7 @@ struct SVGAnimatedPropertyTraits<SVGLengthList*> : public Noncopyable { // SVGAnimatedNumber template<> -struct SVGAnimatedPropertyTraits<float> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<float> : public Noncopyable { typedef const float& PassType; typedef float ReturnType; typedef float StoredType; @@ -122,7 +122,7 @@ struct SVGAnimatedPropertyTraits<float> : public Noncopyable { // SVGAnimatedNumberList template<> -struct SVGAnimatedPropertyTraits<SVGNumberList*> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<SVGNumberList*> : public Noncopyable { typedef SVGNumberList* PassType; typedef SVGNumberList* ReturnType; typedef RefPtr<SVGNumberList> StoredType; @@ -134,7 +134,7 @@ struct SVGAnimatedPropertyTraits<SVGNumberList*> : public Noncopyable { // SVGAnimatedPreserveAspectRatio template<> -struct SVGAnimatedPropertyTraits<SVGPreserveAspectRatio> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<SVGPreserveAspectRatio> : public Noncopyable { typedef const SVGPreserveAspectRatio& PassType; typedef SVGPreserveAspectRatio ReturnType; typedef SVGPreserveAspectRatio StoredType; @@ -146,7 +146,7 @@ struct SVGAnimatedPropertyTraits<SVGPreserveAspectRatio> : public Noncopyable { // SVGAnimatedRect template<> -struct SVGAnimatedPropertyTraits<FloatRect> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<FloatRect> : public Noncopyable { typedef const FloatRect& PassType; typedef FloatRect ReturnType; typedef FloatRect StoredType; @@ -158,7 +158,7 @@ struct SVGAnimatedPropertyTraits<FloatRect> : public Noncopyable { // SVGAnimatedString template<> -struct SVGAnimatedPropertyTraits<String> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<String> : public Noncopyable { typedef const String& PassType; typedef String ReturnType; typedef String StoredType; @@ -170,7 +170,7 @@ struct SVGAnimatedPropertyTraits<String> : public Noncopyable { // SVGAnimatedTransformList template<> -struct SVGAnimatedPropertyTraits<SVGTransformList*> : public Noncopyable { +struct DeprecatedSVGAnimatedPropertyTraits<SVGTransformList*> : public Noncopyable { typedef SVGTransformList* PassType; typedef SVGTransformList* ReturnType; typedef RefPtr<SVGTransformList> StoredType; diff --git a/WebCore/svg/SVGAnimatedTemplate.h b/WebCore/svg/DeprecatedSVGAnimatedTemplate.h index 307c66a..8e29f50 100644 --- a/WebCore/svg/SVGAnimatedTemplate.h +++ b/WebCore/svg/DeprecatedSVGAnimatedTemplate.h @@ -18,11 +18,11 @@ * Boston, MA 02110-1301, USA. */ -#ifndef SVGAnimatedTemplate_h -#define SVGAnimatedTemplate_h +#ifndef DeprecatedSVGAnimatedTemplate_h +#define DeprecatedSVGAnimatedTemplate_h #if ENABLE(SVG) -#include "SVGAnimatedPropertyTraits.h" +#include "DeprecatedSVGAnimatedPropertyTraits.h" #include <wtf/Forward.h> #include <wtf/HashMap.h> @@ -36,15 +36,15 @@ namespace WebCore { class SVGTransformList; class QualifiedName; - struct SVGAnimatedTypeWrapperKey { + struct DeprecatedSVGAnimatedTypeWrapperKey { // Empty value - SVGAnimatedTypeWrapperKey() + DeprecatedSVGAnimatedTypeWrapperKey() : element(0) , attributeName(0) { } // Deleted value - SVGAnimatedTypeWrapperKey(WTF::HashTableDeletedValueType) + DeprecatedSVGAnimatedTypeWrapperKey(WTF::HashTableDeletedValueType) : element(reinterpret_cast<SVGElement*>(-1)) { } @@ -54,7 +54,7 @@ namespace WebCore { return element == reinterpret_cast<SVGElement*>(-1); } - SVGAnimatedTypeWrapperKey(const SVGElement* _element, const AtomicString& _attributeName) + DeprecatedSVGAnimatedTypeWrapperKey(const SVGElement* _element, const AtomicString& _attributeName) : element(_element) , attributeName(_attributeName.impl()) { @@ -62,7 +62,7 @@ namespace WebCore { ASSERT(attributeName); } - bool operator==(const SVGAnimatedTypeWrapperKey& other) const + bool operator==(const DeprecatedSVGAnimatedTypeWrapperKey& other) const { return element == other.element && attributeName == other.attributeName; } @@ -71,13 +71,13 @@ namespace WebCore { AtomicStringImpl* attributeName; }; - struct SVGAnimatedTypeWrapperKeyHash { - static unsigned hash(const SVGAnimatedTypeWrapperKey& key) + struct DeprecatedSVGAnimatedTypeWrapperKeyHash { + static unsigned hash(const DeprecatedSVGAnimatedTypeWrapperKey& key) { - return StringImpl::computeHash(reinterpret_cast<const UChar*>(&key), sizeof(SVGAnimatedTypeWrapperKey) / sizeof(UChar)); + return StringImpl::computeHash(reinterpret_cast<const UChar*>(&key), sizeof(DeprecatedSVGAnimatedTypeWrapperKey) / sizeof(UChar)); } - static bool equal(const SVGAnimatedTypeWrapperKey& a, const SVGAnimatedTypeWrapperKey& b) + static bool equal(const DeprecatedSVGAnimatedTypeWrapperKey& a, const DeprecatedSVGAnimatedTypeWrapperKey& b) { return a == b; } @@ -85,27 +85,27 @@ namespace WebCore { static const bool safeToCompareToEmptyOrDeleted = true; }; - struct SVGAnimatedTypeWrapperKeyHashTraits : WTF::GenericHashTraits<SVGAnimatedTypeWrapperKey> { + struct DeprecatedSVGAnimatedTypeWrapperKeyHashTraits : WTF::GenericHashTraits<DeprecatedSVGAnimatedTypeWrapperKey> { static const bool emptyValueIsZero = true; - static void constructDeletedValue(SVGAnimatedTypeWrapperKey& slot) + static void constructDeletedValue(DeprecatedSVGAnimatedTypeWrapperKey& slot) { - new (&slot) SVGAnimatedTypeWrapperKey(WTF::HashTableDeletedValue); + new (&slot) DeprecatedSVGAnimatedTypeWrapperKey(WTF::HashTableDeletedValue); } - static bool isDeletedValue(const SVGAnimatedTypeWrapperKey& value) + static bool isDeletedValue(const DeprecatedSVGAnimatedTypeWrapperKey& value) { return value.isHashTableDeletedValue(); } }; template<typename AnimatedType> - class SVGAnimatedTemplate : public RefCounted<SVGAnimatedTemplate<AnimatedType> > { + class DeprecatedSVGAnimatedTemplate : public RefCounted<DeprecatedSVGAnimatedTemplate<AnimatedType> > { public: - typedef typename SVGAnimatedPropertyTraits<AnimatedType>::PassType PassType; - typedef typename SVGAnimatedPropertyTraits<AnimatedType>::ReturnType ReturnType; + typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::PassType PassType; + typedef typename DeprecatedSVGAnimatedPropertyTraits<AnimatedType>::ReturnType ReturnType; - virtual ~SVGAnimatedTemplate() { forgetWrapper(this); } + virtual ~DeprecatedSVGAnimatedTemplate() { forgetWrapper(this); } virtual ReturnType baseVal() const = 0; virtual void setBaseVal(PassType) = 0; @@ -115,7 +115,7 @@ namespace WebCore { virtual const QualifiedName& associatedAttributeName() const = 0; - typedef HashMap<SVGAnimatedTypeWrapperKey, SVGAnimatedTemplate<AnimatedType>*, SVGAnimatedTypeWrapperKeyHash, SVGAnimatedTypeWrapperKeyHashTraits > ElementToWrapperMap; + typedef HashMap<DeprecatedSVGAnimatedTypeWrapperKey, DeprecatedSVGAnimatedTemplate<AnimatedType>*, DeprecatedSVGAnimatedTypeWrapperKeyHash, DeprecatedSVGAnimatedTypeWrapperKeyHashTraits > ElementToWrapperMap; typedef typename ElementToWrapperMap::const_iterator ElementToWrapperMapIterator; static ElementToWrapperMap* wrapperCache() @@ -124,7 +124,7 @@ namespace WebCore { return s_wrapperCache; } - static void forgetWrapper(SVGAnimatedTemplate<AnimatedType>* wrapper) + static void forgetWrapper(DeprecatedSVGAnimatedTemplate<AnimatedType>* wrapper) { ElementToWrapperMap* cache = wrapperCache(); ElementToWrapperMapIterator itr = cache->begin(); @@ -139,12 +139,12 @@ namespace WebCore { }; template<typename AnimatedType> - class SVGAnimatedProperty; + class DeprecatedSVGAnimatedProperty; template<typename AnimatedType, typename AnimatedTearOff> - PassRefPtr<AnimatedTearOff> lookupOrCreateWrapper(SVGElement* element, SVGAnimatedProperty<AnimatedType>& creator, const QualifiedName& attrName) + PassRefPtr<AnimatedTearOff> lookupOrCreateWrapper(SVGElement* element, DeprecatedSVGAnimatedProperty<AnimatedType>& creator, const QualifiedName& attrName) { - SVGAnimatedTypeWrapperKey key(element, attrName.localName()); + DeprecatedSVGAnimatedTypeWrapperKey key(element, attrName.localName()); RefPtr<AnimatedTearOff> wrapper = static_cast<AnimatedTearOff*>(AnimatedTearOff::wrapperCache()->get(key)); if (!wrapper) { @@ -156,18 +156,18 @@ namespace WebCore { } // Common type definitions, to ease IDL generation. - typedef SVGAnimatedTemplate<SVGAngle> SVGAnimatedAngle; - typedef SVGAnimatedTemplate<bool> SVGAnimatedBoolean; - typedef SVGAnimatedTemplate<int> SVGAnimatedEnumeration; - typedef SVGAnimatedTemplate<long> SVGAnimatedInteger; - typedef SVGAnimatedTemplate<SVGLength> SVGAnimatedLength; - typedef SVGAnimatedTemplate<SVGLengthList*> SVGAnimatedLengthList; - typedef SVGAnimatedTemplate<float> SVGAnimatedNumber; - typedef SVGAnimatedTemplate<SVGNumberList*> SVGAnimatedNumberList; - typedef SVGAnimatedTemplate<SVGPreserveAspectRatio> SVGAnimatedPreserveAspectRatio; - typedef SVGAnimatedTemplate<FloatRect> SVGAnimatedRect; - typedef SVGAnimatedTemplate<String> SVGAnimatedString; - typedef SVGAnimatedTemplate<SVGTransformList*> SVGAnimatedTransformList; + typedef DeprecatedSVGAnimatedTemplate<SVGAngle> SVGAnimatedAngle; + typedef DeprecatedSVGAnimatedTemplate<bool> SVGAnimatedBoolean; + typedef DeprecatedSVGAnimatedTemplate<int> SVGAnimatedEnumeration; + typedef DeprecatedSVGAnimatedTemplate<long> SVGAnimatedInteger; + typedef DeprecatedSVGAnimatedTemplate<SVGLength> SVGAnimatedLength; + typedef DeprecatedSVGAnimatedTemplate<SVGLengthList*> SVGAnimatedLengthList; + typedef DeprecatedSVGAnimatedTemplate<float> SVGAnimatedNumber; + typedef DeprecatedSVGAnimatedTemplate<SVGNumberList*> SVGAnimatedNumberList; + typedef DeprecatedSVGAnimatedTemplate<SVGPreserveAspectRatio> SVGAnimatedPreserveAspectRatio; + typedef DeprecatedSVGAnimatedTemplate<FloatRect> SVGAnimatedRect; + typedef DeprecatedSVGAnimatedTemplate<String> SVGAnimatedString; + typedef DeprecatedSVGAnimatedTemplate<SVGTransformList*> SVGAnimatedTransformList; } diff --git a/WebCore/svg/SVGAElement.cpp b/WebCore/svg/SVGAElement.cpp index d711a52..56078ad 100644 --- a/WebCore/svg/SVGAElement.cpp +++ b/WebCore/svg/SVGAElement.cpp @@ -27,7 +27,6 @@ #include "Attr.h" #include "Attribute.h" -#include "CSSHelper.h" #include "Document.h" #include "EventHandler.h" #include "EventNames.h" @@ -35,6 +34,7 @@ #include "FrameLoader.h" #include "FrameLoaderTypes.h" #include "HTMLAnchorElement.h" +#include "HTMLParserIdioms.h" #include "KeyboardEvent.h" #include "MouseEvent.h" #include "PlatformMouseEvent.h" @@ -137,7 +137,7 @@ void SVGAElement::defaultEventHandler(Event* event) } if (isLinkClick(event)) { - String url = deprecatedParseURL(href()); + String url = stripLeadingAndTrailingHTMLSpaces(href()); #if ENABLE(SVG_ANIMATION) if (url[0] == '#') { diff --git a/WebCore/svg/SVGAnimateMotionElement.cpp b/WebCore/svg/SVGAnimateMotionElement.cpp index b50a993..26151ed 100644 --- a/WebCore/svg/SVGAnimateMotionElement.cpp +++ b/WebCore/svg/SVGAnimateMotionElement.cpp @@ -112,9 +112,10 @@ Path SVGAnimateMotionElement::animationPath() const if (child->hasTagName(SVGNames::mpathTag)) { SVGMPathElement* mPath = static_cast<SVGMPathElement*>(child); SVGPathElement* pathElement = mPath->pathElement(); + Path path; if (pathElement) - return pathElement->toPathData(); - return Path(); + pathElement->toPathData(path); + return path; } } if (hasAttribute(SVGNames::pathAttr)) diff --git a/WebCore/svg/SVGCircleElement.cpp b/WebCore/svg/SVGCircleElement.cpp index b5a5184..eb38b87 100644 --- a/WebCore/svg/SVGCircleElement.cpp +++ b/WebCore/svg/SVGCircleElement.cpp @@ -25,7 +25,7 @@ #include "Attribute.h" #include "FloatPoint.h" -#include "RenderPath.h" +#include "RenderSVGPath.h" #include "RenderSVGResource.h" #include "SVGLength.h" #include "SVGNames.h" @@ -77,7 +77,7 @@ void SVGCircleElement::svgAttributeChanged(const QualifiedName& attrName) if (isLengthAttribute) updateRelativeLengthsInformation(); - RenderPath* renderer = static_cast<RenderPath*>(this->renderer()); + RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer()); if (!renderer) return; @@ -121,9 +121,16 @@ void SVGCircleElement::synchronizeProperty(const QualifiedName& attrName) synchronizeExternalResourcesRequired(); } -Path SVGCircleElement::toPathData() const +void SVGCircleElement::toPathData(Path& path) const { - return Path::createCircle(FloatPoint(cx().value(this), cy().value(this)), r().value(this)); + ASSERT(path.isEmpty()); + + float radius = r().value(this); + + if (radius <= 0) + return; + + path.addEllipse(FloatRect(cx().value(this) - radius, cy().value(this) - radius, radius * 2, radius * 2)); } bool SVGCircleElement::selfHasRelativeLengths() const diff --git a/WebCore/svg/SVGCircleElement.h b/WebCore/svg/SVGCircleElement.h index dd11792..4eb9262 100644 --- a/WebCore/svg/SVGCircleElement.h +++ b/WebCore/svg/SVGCircleElement.h @@ -45,7 +45,7 @@ namespace WebCore { virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual Path toPathData() const; + virtual void toPathData(Path&) const; virtual bool selfHasRelativeLengths() const; diff --git a/WebCore/svg/SVGElement.cpp b/WebCore/svg/SVGElement.cpp index 1b19f25..ea79e78 100644 --- a/WebCore/svg/SVGElement.cpp +++ b/WebCore/svg/SVGElement.cpp @@ -116,7 +116,7 @@ void SVGElement::setXmlbase(const String& value, ExceptionCode&) SVGSVGElement* SVGElement::ownerSVGElement() const { - Node* n = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode(); + ContainerNode* n = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode(); while (n) { if (n->hasTagName(SVGNames::svgTag)) return static_cast<SVGSVGElement*>(n); @@ -131,7 +131,7 @@ SVGElement* SVGElement::viewportElement() const { // This function needs shadow tree support - as RenderSVGContainer uses this function // to determine the "overflow" property. <use> on <symbol> wouldn't work otherwhise. - Node* n = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode(); + ContainerNode* n = isShadowNode() ? const_cast<SVGElement*>(this)->shadowParentNode() : parentNode(); while (n) { if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::imageTag) || n->hasTagName(SVGNames::symbolTag)) return static_cast<SVGElement*>(n); diff --git a/WebCore/svg/SVGElement.h b/WebCore/svg/SVGElement.h index fb28279..5681284 100644 --- a/WebCore/svg/SVGElement.h +++ b/WebCore/svg/SVGElement.h @@ -110,7 +110,7 @@ namespace WebCore { } // This file needs to be included after the SVGElement declaration -#include "SVGAnimatedProperty.h" +#include "DeprecatedSVGAnimatedProperty.h" // NOLINT #endif #endif diff --git a/WebCore/svg/SVGEllipseElement.cpp b/WebCore/svg/SVGEllipseElement.cpp index 5e18910..7615a24 100644 --- a/WebCore/svg/SVGEllipseElement.cpp +++ b/WebCore/svg/SVGEllipseElement.cpp @@ -25,7 +25,7 @@ #include "Attribute.h" #include "FloatPoint.h" -#include "RenderPath.h" +#include "RenderSVGPath.h" #include "RenderSVGResource.h" #include "SVGLength.h" #include "SVGNames.h" @@ -83,7 +83,7 @@ void SVGEllipseElement::svgAttributeChanged(const QualifiedName& attrName) if (isLengthAttribute) updateRelativeLengthsInformation(); - RenderPath* renderer = static_cast<RenderPath*>(this->renderer()); + RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer()); if (!renderer) return; @@ -130,10 +130,19 @@ void SVGEllipseElement::synchronizeProperty(const QualifiedName& attrName) synchronizeExternalResourcesRequired(); } -Path SVGEllipseElement::toPathData() const +void SVGEllipseElement::toPathData(Path& path) const { - return Path::createEllipse(FloatPoint(cx().value(this), cy().value(this)), - rx().value(this), ry().value(this)); + ASSERT(path.isEmpty()); + + float radiusX = rx().value(this); + if (radiusX <= 0) + return; + + float radiusY = ry().value(this); + if (radiusY <= 0) + return; + + path.addEllipse(FloatRect(cx().value(this) - radiusX, cy().value(this) - radiusY, radiusX * 2, radiusY * 2)); } bool SVGEllipseElement::selfHasRelativeLengths() const diff --git a/WebCore/svg/SVGEllipseElement.h b/WebCore/svg/SVGEllipseElement.h index bee815c..cad329e 100644 --- a/WebCore/svg/SVGEllipseElement.h +++ b/WebCore/svg/SVGEllipseElement.h @@ -45,7 +45,7 @@ namespace WebCore { virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual Path toPathData() const; + virtual void toPathData(Path&) const; virtual bool selfHasRelativeLengths() const; diff --git a/WebCore/svg/SVGExternalResourcesRequired.h b/WebCore/svg/SVGExternalResourcesRequired.h index 6322538..5f0d8e9 100644 --- a/WebCore/svg/SVGExternalResourcesRequired.h +++ b/WebCore/svg/SVGExternalResourcesRequired.h @@ -42,7 +42,7 @@ namespace WebCore { bool isKnownAttribute(const QualifiedName&); protected: - virtual void setExternalResourcesRequiredBaseValue(SVGAnimatedPropertyTraits<bool>::PassType) = 0; + virtual void setExternalResourcesRequiredBaseValue(DeprecatedSVGAnimatedPropertyTraits<bool>::PassType) = 0; }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEColorMatrixElement.cpp b/WebCore/svg/SVGFEColorMatrixElement.cpp index f14b4e7..83d112c 100644 --- a/WebCore/svg/SVGFEColorMatrixElement.cpp +++ b/WebCore/svg/SVGFEColorMatrixElement.cpp @@ -62,6 +62,16 @@ void SVGFEColorMatrixElement::parseMappedAttribute(Attribute* attr) SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); } +void SVGFEColorMatrixElement::svgAttributeChanged(const QualifiedName& attrName) +{ + SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); + + if (attrName == SVGNames::typeAttr + || attrName == SVGNames::inAttr + || attrName == SVGNames::valuesAttr) + invalidate(); +} + void SVGFEColorMatrixElement::synchronizeProperty(const QualifiedName& attrName) { SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName); diff --git a/WebCore/svg/SVGFEColorMatrixElement.h b/WebCore/svg/SVGFEColorMatrixElement.h index 873d530..5d626a2 100644 --- a/WebCore/svg/SVGFEColorMatrixElement.h +++ b/WebCore/svg/SVGFEColorMatrixElement.h @@ -36,6 +36,7 @@ private: SVGFEColorMatrixElement(const QualifiedName&, Document*); virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); diff --git a/WebCore/svg/SVGFECompositeElement.cpp b/WebCore/svg/SVGFECompositeElement.cpp index b6f1002..6d7e7b2 100644 --- a/WebCore/svg/SVGFECompositeElement.cpp +++ b/WebCore/svg/SVGFECompositeElement.cpp @@ -71,6 +71,20 @@ void SVGFECompositeElement::parseMappedAttribute(Attribute* attr) SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); } +void SVGFECompositeElement::svgAttributeChanged(const QualifiedName& attrName) +{ + SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); + + if (attrName == SVGNames::inAttr + || attrName == SVGNames::in2Attr + || attrName == SVGNames::operatorAttr + || attrName == SVGNames::k1Attr + || attrName == SVGNames::k2Attr + || attrName == SVGNames::k3Attr + || attrName == SVGNames::k4Attr) + invalidate(); +} + void SVGFECompositeElement::synchronizeProperty(const QualifiedName& attrName) { SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName); diff --git a/WebCore/svg/SVGFECompositeElement.h b/WebCore/svg/SVGFECompositeElement.h index 19683de..6d47cac 100644 --- a/WebCore/svg/SVGFECompositeElement.h +++ b/WebCore/svg/SVGFECompositeElement.h @@ -35,6 +35,7 @@ private: SVGFECompositeElement(const QualifiedName&, Document*); virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); diff --git a/WebCore/svg/SVGFEConvolveMatrixElement.cpp b/WebCore/svg/SVGFEConvolveMatrixElement.cpp index db2fad5..d7f14a2 100644 --- a/WebCore/svg/SVGFEConvolveMatrixElement.cpp +++ b/WebCore/svg/SVGFEConvolveMatrixElement.cpp @@ -93,14 +93,35 @@ void SVGFEConvolveMatrixElement::parseMappedAttribute(Attribute* attr) SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); } -void SVGFEConvolveMatrixElement::setOrder(float, float) +void SVGFEConvolveMatrixElement::setOrder(float x, float y) { - // FIXME: Needs an implementation. + setOrderXBaseValue(x); + setOrderYBaseValue(y); + invalidate(); } -void SVGFEConvolveMatrixElement::setKernelUnitLength(float, float) +void SVGFEConvolveMatrixElement::setKernelUnitLength(float x, float y) { - // FIXME: Needs an implementation. + setKernelUnitLengthXBaseValue(x); + setKernelUnitLengthYBaseValue(y); + invalidate(); +} + +void SVGFEConvolveMatrixElement::svgAttributeChanged(const QualifiedName& attrName) +{ + SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); + + if (attrName == SVGNames::inAttr + || attrName == SVGNames::orderAttr + || attrName == SVGNames::edgeModeAttr + || attrName == SVGNames::kernelMatrixAttr + || attrName == SVGNames::divisorAttr + || attrName == SVGNames::biasAttr + || attrName == SVGNames::targetXAttr + || attrName == SVGNames::targetYAttr + || attrName == SVGNames::kernelUnitLengthAttr + || attrName == SVGNames::preserveAlphaAttr) + invalidate(); } PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* filterBuilder) diff --git a/WebCore/svg/SVGFEConvolveMatrixElement.h b/WebCore/svg/SVGFEConvolveMatrixElement.h index b1fe7e2..5c4e8c4 100644 --- a/WebCore/svg/SVGFEConvolveMatrixElement.h +++ b/WebCore/svg/SVGFEConvolveMatrixElement.h @@ -38,6 +38,7 @@ private: SVGFEConvolveMatrixElement(const QualifiedName&, Document*); virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); DECLARE_ANIMATED_PROPERTY(SVGFEConvolveMatrixElement, SVGNames::inAttr, String, In1, in1) diff --git a/WebCore/svg/SVGFEGaussianBlurElement.cpp b/WebCore/svg/SVGFEGaussianBlurElement.cpp index 3dfd51c..a9fef61 100644 --- a/WebCore/svg/SVGFEGaussianBlurElement.cpp +++ b/WebCore/svg/SVGFEGaussianBlurElement.cpp @@ -42,9 +42,11 @@ PassRefPtr<SVGFEGaussianBlurElement> SVGFEGaussianBlurElement::create(const Qual return adoptRef(new SVGFEGaussianBlurElement(tagName, document)); } -void SVGFEGaussianBlurElement::setStdDeviation(float, float) +void SVGFEGaussianBlurElement::setStdDeviation(float x, float y) { - // FIXME: Needs an implementation. + setStdDeviationXBaseValue(x); + setStdDeviationYBaseValue(y); + invalidate(); } void SVGFEGaussianBlurElement::parseMappedAttribute(Attribute* attr) @@ -62,6 +64,15 @@ void SVGFEGaussianBlurElement::parseMappedAttribute(Attribute* attr) SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); } +void SVGFEGaussianBlurElement::svgAttributeChanged(const QualifiedName& attrName) +{ + SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); + + if (attrName == SVGNames::inAttr + || attrName == SVGNames::stdDeviationAttr) + invalidate(); +} + void SVGFEGaussianBlurElement::synchronizeProperty(const QualifiedName& attrName) { SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName); diff --git a/WebCore/svg/SVGFEGaussianBlurElement.h b/WebCore/svg/SVGFEGaussianBlurElement.h index 36b7383..90f956c 100644 --- a/WebCore/svg/SVGFEGaussianBlurElement.h +++ b/WebCore/svg/SVGFEGaussianBlurElement.h @@ -40,6 +40,7 @@ private: SVGFEGaussianBlurElement(const QualifiedName&, Document*); virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp index b9d1a3d..0ea7933 100644 --- a/WebCore/svg/SVGFEImageElement.cpp +++ b/WebCore/svg/SVGFEImageElement.cpp @@ -27,6 +27,7 @@ #include "Attr.h" #include "CachedImage.h" #include "CachedResourceLoader.h" +#include "ColorSpace.h" #include "Document.h" #include "RenderObject.h" #include "RenderSVGResource.h" @@ -134,7 +135,7 @@ PassRefPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder*) return 0; IntRect targetRect = enclosingIntRect(renderer->objectBoundingBox()); - m_targetImage = ImageBuffer::create(targetRect.size(), LinearRGB); + m_targetImage = ImageBuffer::create(targetRect.size(), ColorSpaceLinearRGB); AffineTransform contentTransformation; SVGImageBufferTools::renderSubtreeToImageBuffer(m_targetImage.get(), renderer, contentTransformation); diff --git a/WebCore/svg/SVGFELightElement.cpp b/WebCore/svg/SVGFELightElement.cpp index 61d7df0..315aa29 100644 --- a/WebCore/svg/SVGFELightElement.cpp +++ b/WebCore/svg/SVGFELightElement.cpp @@ -78,7 +78,7 @@ void SVGFELightElement::svgAttributeChanged(const QualifiedName& attrName) || attrName == SVGNames::pointsAtZAttr || attrName == SVGNames::specularExponentAttr || attrName == SVGNames::limitingConeAngleAttr) { - if (Node* parentNode = parent()) { + if (ContainerNode* parentNode = parent()) { RenderObject* renderer = parentNode->renderer(); if (renderer && renderer->isSVGResourceFilterPrimitive()) RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); @@ -131,7 +131,7 @@ void SVGFELightElement::childrenChanged(bool changedByParser, Node* beforeChange SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); if (!changedByParser) { - if (Node* parentNode = parent()) { + if (ContainerNode* parentNode = parent()) { RenderObject* renderer = parentNode->renderer(); if (renderer && renderer->isSVGResourceFilterPrimitive()) RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); diff --git a/WebCore/svg/SVGFEMergeNodeElement.cpp b/WebCore/svg/SVGFEMergeNodeElement.cpp index 4bd5ac5..ee1ac3a 100644 --- a/WebCore/svg/SVGFEMergeNodeElement.cpp +++ b/WebCore/svg/SVGFEMergeNodeElement.cpp @@ -24,6 +24,8 @@ #include "SVGFEMergeNodeElement.h" #include "Attribute.h" +#include "RenderSVGResource.h" +#include "SVGFilterElement.h" namespace WebCore { @@ -46,6 +48,24 @@ void SVGFEMergeNodeElement::parseMappedAttribute(Attribute* attr) SVGElement::parseMappedAttribute(attr); } +void SVGFEMergeNodeElement::svgAttributeChanged(const QualifiedName& attrName) +{ + SVGElement::svgAttributeChanged(attrName); + + if (attrName != SVGNames::inAttr) + return; + + ContainerNode* parentNode = parent(); + if (!parentNode) + return; + + RenderObject* renderer = parentNode->renderer(); + if (!renderer || !renderer->isSVGResourceFilterPrimitive()) + return; + + RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); +} + void SVGFEMergeNodeElement::synchronizeProperty(const QualifiedName& attrName) { SVGElement::synchronizeProperty(attrName); diff --git a/WebCore/svg/SVGFEMergeNodeElement.h b/WebCore/svg/SVGFEMergeNodeElement.h index 65c5d3d..89506dc 100644 --- a/WebCore/svg/SVGFEMergeNodeElement.h +++ b/WebCore/svg/SVGFEMergeNodeElement.h @@ -35,6 +35,7 @@ namespace WebCore { SVGFEMergeNodeElement(const QualifiedName&, Document*); virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); DECLARE_ANIMATED_PROPERTY(SVGFEMergeNodeElement, SVGNames::inAttr, String, In1, in1) diff --git a/WebCore/svg/SVGFitToViewBox.h b/WebCore/svg/SVGFitToViewBox.h index d6551f5..ecc89bb 100644 --- a/WebCore/svg/SVGFitToViewBox.h +++ b/WebCore/svg/SVGFitToViewBox.h @@ -39,8 +39,8 @@ public: bool parseMappedAttribute(Document*, Attribute*); bool isKnownAttribute(const QualifiedName&); - virtual void setViewBoxBaseValue(SVGAnimatedPropertyTraits<FloatRect>::PassType) = 0; - virtual void setPreserveAspectRatioBaseValue(SVGAnimatedPropertyTraits<SVGPreserveAspectRatio>::PassType) = 0; + virtual void setViewBoxBaseValue(DeprecatedSVGAnimatedPropertyTraits<FloatRect>::PassType) = 0; + virtual void setPreserveAspectRatioBaseValue(DeprecatedSVGAnimatedPropertyTraits<SVGPreserveAspectRatio>::PassType) = 0; private: bool parseViewBox(Document*, const String&, FloatRect&); diff --git a/WebCore/svg/SVGFontFaceFormatElement.cpp b/WebCore/svg/SVGFontFaceFormatElement.cpp index e3182c4..939b062 100644 --- a/WebCore/svg/SVGFontFaceFormatElement.cpp +++ b/WebCore/svg/SVGFontFaceFormatElement.cpp @@ -46,7 +46,7 @@ void SVGFontFaceFormatElement::childrenChanged(bool changedByParser, Node* befor if (!parentNode() || !parentNode()->hasTagName(font_face_uriTag)) return; - Node* ancestor = parentNode()->parentNode(); + ContainerNode* ancestor = parentNode()->parentNode(); if (!ancestor || !ancestor->hasTagName(font_face_srcTag)) return; diff --git a/WebCore/svg/SVGFontFaceUriElement.cpp b/WebCore/svg/SVGFontFaceUriElement.cpp index 3ecba16..58a22c7 100644 --- a/WebCore/svg/SVGFontFaceUriElement.cpp +++ b/WebCore/svg/SVGFontFaceUriElement.cpp @@ -76,9 +76,9 @@ void SVGFontFaceUriElement::childrenChanged(bool changedByParser, Node* beforeCh if (!parentNode() || !parentNode()->hasTagName(font_face_srcTag)) return; - Node* grandParent = parentNode()->parentNode(); - if (grandParent && grandParent->hasTagName(font_faceTag)) - static_cast<SVGFontFaceElement*>(grandParent)->rebuildFontFace(); + ContainerNode* grandparent = parentNode()->parentNode(); + if (grandparent && grandparent->hasTagName(font_faceTag)) + static_cast<SVGFontFaceElement*>(grandparent)->rebuildFontFace(); } void SVGFontFaceUriElement::insertedIntoDocument() diff --git a/WebCore/svg/SVGGlyphElement.cpp b/WebCore/svg/SVGGlyphElement.cpp index 8ded0fc..baa9966 100644 --- a/WebCore/svg/SVGGlyphElement.cpp +++ b/WebCore/svg/SVGGlyphElement.cpp @@ -49,7 +49,7 @@ PassRefPtr<SVGGlyphElement> SVGGlyphElement::create(const QualifiedName& tagName void SVGGlyphElement::invalidateGlyphCache() { - Node* fontNode = parentNode(); + ContainerNode* fontNode = parentNode(); if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) { if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode)) element->invalidateGlyphCache(); diff --git a/WebCore/svg/SVGGlyphElement.h b/WebCore/svg/SVGGlyphElement.h index a7dd570..7dc7430 100644 --- a/WebCore/svg/SVGGlyphElement.h +++ b/WebCore/svg/SVGGlyphElement.h @@ -72,16 +72,15 @@ namespace WebCore { bool operator==(const SVGGlyphIdentifier& other) const { - return isValid == other.isValid && - orientation == other.orientation && - arabicForm == other.arabicForm && - glyphName == other.glyphName && - horizontalAdvanceX == other.horizontalAdvanceX && - verticalOriginX == other.verticalOriginX && - verticalOriginY == other.verticalOriginY && - verticalAdvanceY == other.verticalAdvanceY && - pathData.debugString() == other.pathData.debugString() && - languages == other.languages; + return isValid == other.isValid + && orientation == other.orientation + && arabicForm == other.arabicForm + && glyphName == other.glyphName + && horizontalAdvanceX == other.horizontalAdvanceX + && verticalOriginX == other.verticalOriginX + && verticalOriginY == other.verticalOriginY + && verticalAdvanceY == other.verticalAdvanceY + && languages == other.languages; } bool isValid : 1; diff --git a/WebCore/svg/SVGGradientElement.cpp b/WebCore/svg/SVGGradientElement.cpp index 523e4df..ca61088 100644 --- a/WebCore/svg/SVGGradientElement.cpp +++ b/WebCore/svg/SVGGradientElement.cpp @@ -26,7 +26,7 @@ #include "Attribute.h" #include "CSSStyleSelector.h" -#include "RenderPath.h" +#include "RenderSVGPath.h" #include "RenderSVGHiddenContainer.h" #include "RenderSVGResourceLinearGradient.h" #include "RenderSVGResourceRadialGradient.h" diff --git a/WebCore/svg/SVGHKernElement.cpp b/WebCore/svg/SVGHKernElement.cpp index a432daa..7f83241 100644 --- a/WebCore/svg/SVGHKernElement.cpp +++ b/WebCore/svg/SVGHKernElement.cpp @@ -47,7 +47,7 @@ PassRefPtr<SVGHKernElement> SVGHKernElement::create(const QualifiedName& tagName void SVGHKernElement::insertedIntoDocument() { - Node* fontNode = parentNode(); + ContainerNode* fontNode = parentNode(); if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) { if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode)) element->invalidateGlyphCache(); @@ -56,7 +56,7 @@ void SVGHKernElement::insertedIntoDocument() void SVGHKernElement::removedFromDocument() { - Node* fontNode = parentNode(); + ContainerNode* fontNode = parentNode(); if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) { if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode)) element->invalidateGlyphCache(); diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp index f6fa013..fcfa54f 100644 --- a/WebCore/svg/SVGImageElement.cpp +++ b/WebCore/svg/SVGImageElement.cpp @@ -108,8 +108,13 @@ void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) return; } - if (isLengthAttribute - || attrName == SVGNames::preserveAspectRatioAttr + if (isLengthAttribute) { + renderer->updateFromElement(); + RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, false); + return; + } + + if (attrName == SVGNames::preserveAspectRatioAttr || SVGTests::isKnownAttribute(attrName) || SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired::isKnownAttribute(attrName)) diff --git a/WebCore/svg/SVGImageLoader.cpp b/WebCore/svg/SVGImageLoader.cpp index 2079f74..8f1c1b5 100644 --- a/WebCore/svg/SVGImageLoader.cpp +++ b/WebCore/svg/SVGImageLoader.cpp @@ -25,6 +25,7 @@ #include "Event.h" #include "EventNames.h" +#include "HTMLParserIdioms.h" #include "SVGImageElement.h" #include "RenderImage.h" @@ -48,7 +49,7 @@ void SVGImageLoader::dispatchLoadEvent() String SVGImageLoader::sourceURI(const AtomicString& attr) const { - return KURL(element()->baseURI(), deprecatedParseURL(attr)).string(); + return KURL(element()->baseURI(), stripLeadingAndTrailingHTMLSpaces(attr)).string(); } } diff --git a/WebCore/svg/SVGLineElement.cpp b/WebCore/svg/SVGLineElement.cpp index bd15890..4ee5f0d 100644 --- a/WebCore/svg/SVGLineElement.cpp +++ b/WebCore/svg/SVGLineElement.cpp @@ -25,7 +25,7 @@ #include "Attribute.h" #include "FloatPoint.h" -#include "RenderPath.h" +#include "RenderSVGPath.h" #include "RenderSVGResource.h" #include "SVGLength.h" #include "SVGNames.h" @@ -79,7 +79,7 @@ void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName) if (isLengthAttribute) updateRelativeLengthsInformation(); - RenderPath* renderer = static_cast<RenderPath*>(this->renderer()); + RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer()); if (!renderer) return; @@ -126,10 +126,12 @@ void SVGLineElement::synchronizeProperty(const QualifiedName& attrName) synchronizeExternalResourcesRequired(); } -Path SVGLineElement::toPathData() const +void SVGLineElement::toPathData(Path& path) const { - return Path::createLine(FloatPoint(x1().value(this), y1().value(this)), - FloatPoint(x2().value(this), y2().value(this))); + ASSERT(path.isEmpty()); + + path.moveTo(FloatPoint(x1().value(this), y1().value(this))); + path.addLineTo(FloatPoint(x2().value(this), y2().value(this))); } bool SVGLineElement::selfHasRelativeLengths() const diff --git a/WebCore/svg/SVGLineElement.h b/WebCore/svg/SVGLineElement.h index 21007f0..55a268c 100644 --- a/WebCore/svg/SVGLineElement.h +++ b/WebCore/svg/SVGLineElement.h @@ -47,7 +47,7 @@ namespace WebCore { virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual Path toPathData() const; + virtual void toPathData(Path&) const; virtual bool supportsMarkers() const { return true; } diff --git a/WebCore/svg/SVGLinearGradientElement.cpp b/WebCore/svg/SVGLinearGradientElement.cpp index ec351d7..840a31e 100644 --- a/WebCore/svg/SVGLinearGradientElement.cpp +++ b/WebCore/svg/SVGLinearGradientElement.cpp @@ -113,9 +113,8 @@ RenderObject* SVGLinearGradientElement::createRenderer(RenderArena* arena, Rende return new (arena) RenderSVGResourceLinearGradient(this); } -LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() +void SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttributes& attributes) { - LinearGradientAttributes attributes; HashSet<SVGGradientElement*> processedGradients; bool isLinear = true; @@ -170,8 +169,6 @@ LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() } else current = 0; } - - return attributes; } void SVGLinearGradientElement::calculateStartEndPoints(const LinearGradientAttributes& attributes, FloatPoint& startPoint, FloatPoint& endPoint) diff --git a/WebCore/svg/SVGLinearGradientElement.h b/WebCore/svg/SVGLinearGradientElement.h index dec912f..86bebf3 100644 --- a/WebCore/svg/SVGLinearGradientElement.h +++ b/WebCore/svg/SVGLinearGradientElement.h @@ -33,7 +33,7 @@ namespace WebCore { public: static PassRefPtr<SVGLinearGradientElement> create(const QualifiedName&, Document*); - LinearGradientAttributes collectGradientProperties(); + void collectGradientAttributes(LinearGradientAttributes&); void calculateStartEndPoints(const LinearGradientAttributes&, FloatPoint& startPoint, FloatPoint& endPoint); private: diff --git a/WebCore/svg/SVGLocatable.cpp b/WebCore/svg/SVGLocatable.cpp index 3311a5a..9a823ff 100644 --- a/WebCore/svg/SVGLocatable.cpp +++ b/WebCore/svg/SVGLocatable.cpp @@ -44,7 +44,7 @@ static bool isViewportElement(Node* node) SVGElement* SVGLocatable::nearestViewportElement(const SVGElement* element) { ASSERT(element); - for (Node* n = element->parentNode(); n && !n->isDocumentNode(); n = n->parentNode()) { + for (ContainerNode* n = element->parentNode(); n; n = n->parentNode()) { if (isViewportElement(n)) return static_cast<SVGElement*>(n); } @@ -56,7 +56,7 @@ SVGElement* SVGLocatable::farthestViewportElement(const SVGElement* element) { ASSERT(element); SVGElement* farthest = 0; - for (Node* n = element->parentNode(); n && !n->isDocumentNode(); n = n->parentNode()) { + for (ContainerNode* n = element->parentNode(); n; n = n->parentNode()) { if (isViewportElement(n)) farthest = static_cast<SVGElement*>(n); } diff --git a/WebCore/svg/SVGPathElement.cpp b/WebCore/svg/SVGPathElement.cpp index 3ed85a3..920e947 100644 --- a/WebCore/svg/SVGPathElement.cpp +++ b/WebCore/svg/SVGPathElement.cpp @@ -24,7 +24,7 @@ #include "SVGPathElement.h" #include "Attribute.h" -#include "RenderPath.h" +#include "RenderSVGPath.h" #include "RenderSVGResource.h" #include "SVGNames.h" #include "SVGPathParserFactory.h" @@ -57,14 +57,18 @@ PassRefPtr<SVGPathElement> SVGPathElement::create(const QualifiedName& tagName, float SVGPathElement::getTotalLength() { // FIXME: this may wish to use the pathSegList instead of the pathdata if that's cheaper to build (or cached) - return toPathData().length(); + Path path; + toPathData(path); + return path.length(); } FloatPoint SVGPathElement::getPointAtLength(float length) { // FIXME: this may wish to use the pathSegList instead of the pathdata if that's cheaper to build (or cached) bool ok = false; - return toPathData().pointAtLength(length, ok); + Path path; + toPathData(path); + return path.pointAtLength(length, ok); } unsigned long SVGPathElement::getPathSegAtLength(float length) @@ -197,7 +201,7 @@ void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) { SVGStyledTransformableElement::svgAttributeChanged(attrName); - RenderPath* renderer = static_cast<RenderPath*>(this->renderer()); + RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer()); if (!renderer) return; @@ -262,12 +266,12 @@ SVGPathSegList* SVGPathElement::animatedNormalizedPathSegList() const return 0; } -Path SVGPathElement::toPathData() const +void SVGPathElement::toPathData(Path& path) const { - Path result; + ASSERT(path.isEmpty()); + SVGPathParserFactory* factory = SVGPathParserFactory::self(); - factory->buildPathFromSVGPathSegList(pathSegList(), result); - return result; + factory->buildPathFromSVGPathSegList(pathSegList(), path); } } diff --git a/WebCore/svg/SVGPathElement.h b/WebCore/svg/SVGPathElement.h index cc4e7bd..394983d 100644 --- a/WebCore/svg/SVGPathElement.h +++ b/WebCore/svg/SVGPathElement.h @@ -89,7 +89,7 @@ namespace WebCore { virtual SVGPathSegList* animatedPathSegList() const; virtual SVGPathSegList* animatedNormalizedPathSegList() const; - virtual Path toPathData() const; + virtual void toPathData(Path&) const; private: SVGPathElement(const QualifiedName&, Document*); diff --git a/WebCore/svg/SVGPathParserFactory.cpp b/WebCore/svg/SVGPathParserFactory.cpp index b251ec4..e707c20 100644 --- a/WebCore/svg/SVGPathParserFactory.cpp +++ b/WebCore/svg/SVGPathParserFactory.cpp @@ -33,7 +33,6 @@ #include "SVGPathStringBuilder.h" #include "SVGPathStringSource.h" #include "SVGPathTraversalStateBuilder.h" -#include "StringBuilder.h" namespace WebCore { diff --git a/WebCore/svg/SVGPathStringBuilder.cpp b/WebCore/svg/SVGPathStringBuilder.cpp index 951956d..e5f4419 100644 --- a/WebCore/svg/SVGPathStringBuilder.cpp +++ b/WebCore/svg/SVGPathStringBuilder.cpp @@ -24,81 +24,92 @@ namespace WebCore { +String SVGPathStringBuilder::result() +{ + unsigned size = m_stringBuilder.length(); + if (!size) + return String(); + + // Remove trailing space. + m_stringBuilder.resize(size - 1); + return m_stringBuilder.toString(); +} + void SVGPathStringBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) - m_stringBuilder.append(String::format("M %.6lg %.6lg", targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("M %.6lg %.6lg ", targetPoint.x(), targetPoint.y())); else - m_stringBuilder.append(String::format("m %.6lg %.6lg", targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("m %.6lg %.6lg ", targetPoint.x(), targetPoint.y())); } void SVGPathStringBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) - m_stringBuilder.append(String::format("L %.6lg %.6lg", targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("L %.6lg %.6lg ", targetPoint.x(), targetPoint.y())); else - m_stringBuilder.append(String::format("l %.6lg %.6lg", targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("l %.6lg %.6lg ", targetPoint.x(), targetPoint.y())); } void SVGPathStringBuilder::lineToHorizontal(float x, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) - m_stringBuilder.append(String::format("H %.6lg", x)); + m_stringBuilder.append(String::format("H %.6lg ", x)); else - m_stringBuilder.append(String::format("h %.6lg", x)); + m_stringBuilder.append(String::format("h %.6lg ", x)); } void SVGPathStringBuilder::lineToVertical(float y, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) - m_stringBuilder.append(String::format("V %.6lg", y)); + m_stringBuilder.append(String::format("V %.6lg ", y)); else - m_stringBuilder.append(String::format("v %.6lg", y)); + m_stringBuilder.append(String::format("v %.6lg ", y)); } void SVGPathStringBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) - m_stringBuilder.append(String::format("C %.6lg %.6lg %.6lg %.6lg %.6lg %.6lg", point1.x(), point1.y(), point2.x(), point2.y(), targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("C %.6lg %.6lg %.6lg %.6lg %.6lg %.6lg ", point1.x(), point1.y(), point2.x(), point2.y(), targetPoint.x(), targetPoint.y())); else - m_stringBuilder.append(String::format("c %.6lg %.6lg %.6lg %.6lg %.6lg %.6lg", point1.x(), point1.y(), point2.x(), point2.y(), targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("c %.6lg %.6lg %.6lg %.6lg %.6lg %.6lg ", point1.x(), point1.y(), point2.x(), point2.y(), targetPoint.x(), targetPoint.y())); } void SVGPathStringBuilder::curveToCubicSmooth(const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) - m_stringBuilder.append(String::format("S %.6lg %.6lg %.6lg %.6lg", point2.x(), point2.y(), targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("S %.6lg %.6lg %.6lg %.6lg ", point2.x(), point2.y(), targetPoint.x(), targetPoint.y())); else - m_stringBuilder.append(String::format("s %.6lg %.6lg %.6lg %.6lg", point2.x(), point2.y(), targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("s %.6lg %.6lg %.6lg %.6lg ", point2.x(), point2.y(), targetPoint.x(), targetPoint.y())); } void SVGPathStringBuilder::curveToQuadratic(const FloatPoint& point1, const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) - m_stringBuilder.append(String::format("Q %.6lg %.6lg %.6lg %.6lg", point1.x(), point1.y(), targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("Q %.6lg %.6lg %.6lg %.6lg ", point1.x(), point1.y(), targetPoint.x(), targetPoint.y())); else - m_stringBuilder.append(String::format("q %.6lg %.6lg %.6lg %.6lg", point1.x(), point1.y(), targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("q %.6lg %.6lg %.6lg %.6lg ", point1.x(), point1.y(), targetPoint.x(), targetPoint.y())); } void SVGPathStringBuilder::curveToQuadraticSmooth(const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) - m_stringBuilder.append(String::format("T %.6lg %.6lg", targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("T %.6lg %.6lg ", targetPoint.x(), targetPoint.y())); else - m_stringBuilder.append(String::format("t %.6lg %.6lg", targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("t %.6lg %.6lg ", targetPoint.x(), targetPoint.y())); } void SVGPathStringBuilder::arcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, const FloatPoint& targetPoint, PathCoordinateMode mode) { if (mode == AbsoluteCoordinates) - m_stringBuilder.append(String::format("A %.6lg %.6lg %.6lg %d %d %.6lg %.6lg", r1, r2, angle, largeArcFlag, sweepFlag, targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("A %.6lg %.6lg %.6lg %d %d %.6lg %.6lg ", r1, r2, angle, largeArcFlag, sweepFlag, targetPoint.x(), targetPoint.y())); else - m_stringBuilder.append(String::format("a %.6lg %.6lg %.6lg %d %d %.6lg %.6lg", r1, r2, angle, largeArcFlag, sweepFlag, targetPoint.x(), targetPoint.y())); + m_stringBuilder.append(String::format("a %.6lg %.6lg %.6lg %d %d %.6lg %.6lg ", r1, r2, angle, largeArcFlag, sweepFlag, targetPoint.x(), targetPoint.y())); } void SVGPathStringBuilder::closePath() { - m_stringBuilder.append("Z"); + m_stringBuilder.append("Z "); } } // namespace WebCore diff --git a/WebCore/svg/SVGPathStringBuilder.h b/WebCore/svg/SVGPathStringBuilder.h index a51c40c..6a7e980 100644 --- a/WebCore/svg/SVGPathStringBuilder.h +++ b/WebCore/svg/SVGPathStringBuilder.h @@ -23,16 +23,16 @@ #if ENABLE(SVG) #include "FloatPoint.h" #include "SVGPathConsumer.h" -#include "StringBuilder.h" +#include <wtf/text/StringBuilder.h> namespace WebCore { class SVGPathStringBuilder : public SVGPathConsumer { public: - String result() { return m_stringBuilder.toString(ConcatAddingSpacesBetweenIndividualStrings); } + String result(); private: - virtual void cleanup() { m_stringBuilder.clear(); } + virtual void cleanup() { m_stringBuilder = StringBuilder(); } virtual void incrementPathSegmentCount() { } virtual bool continueConsuming() { return true; } diff --git a/WebCore/svg/SVGPatternElement.cpp b/WebCore/svg/SVGPatternElement.cpp index 6a8a108..0f3b5d4 100644 --- a/WebCore/svg/SVGPatternElement.cpp +++ b/WebCore/svg/SVGPatternElement.cpp @@ -200,9 +200,8 @@ RenderObject* SVGPatternElement::createRenderer(RenderArena* arena, RenderStyle* return new (arena) RenderSVGResourcePattern(this); } -PatternAttributes SVGPatternElement::collectPatternProperties() const +void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const { - PatternAttributes attributes; HashSet<const SVGPatternElement*> processedPatterns; const SVGPatternElement* current = this; @@ -246,8 +245,6 @@ PatternAttributes SVGPatternElement::collectPatternProperties() const } else current = 0; } - - return attributes; } bool SVGPatternElement::selfHasRelativeLengths() const diff --git a/WebCore/svg/SVGPatternElement.h b/WebCore/svg/SVGPatternElement.h index 497660a..a93c54c 100644 --- a/WebCore/svg/SVGPatternElement.h +++ b/WebCore/svg/SVGPatternElement.h @@ -45,7 +45,7 @@ namespace WebCore { public: static PassRefPtr<SVGPatternElement> create(const QualifiedName&, Document*); - PatternAttributes collectPatternProperties() const; + void collectPatternAttributes(PatternAttributes&) const; private: SVGPatternElement(const QualifiedName&, Document*); diff --git a/WebCore/svg/SVGPolyElement.cpp b/WebCore/svg/SVGPolyElement.cpp index da8aba4..6e935f1 100644 --- a/WebCore/svg/SVGPolyElement.cpp +++ b/WebCore/svg/SVGPolyElement.cpp @@ -26,7 +26,7 @@ #include "Attribute.h" #include "Document.h" #include "FloatPoint.h" -#include "RenderPath.h" +#include "RenderSVGPath.h" #include "RenderSVGResource.h" #include "SVGNames.h" #include "SVGParserUtilities.h" @@ -81,7 +81,7 @@ void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName) if (attrName == SVGNames::pointsAttr) invalidateSVGAttributes(); - RenderPath* renderer = static_cast<RenderPath*>(this->renderer()); + RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer()); if (!renderer) return; diff --git a/WebCore/svg/SVGPolygonElement.cpp b/WebCore/svg/SVGPolygonElement.cpp index 57e2d53..38f5bce 100644 --- a/WebCore/svg/SVGPolygonElement.cpp +++ b/WebCore/svg/SVGPolygonElement.cpp @@ -37,22 +37,21 @@ PassRefPtr<SVGPolygonElement> SVGPolygonElement::create(const QualifiedName& tag return adoptRef(new SVGPolygonElement(tagName, document)); } -Path SVGPolygonElement::toPathData() const +void SVGPolygonElement::toPathData(Path& path) const { - Path polyData; + ASSERT(path.isEmpty()); int len = points()->numberOfItems(); if (len < 1) - return polyData; + return; ExceptionCode ec = 0; - polyData.moveTo(points()->getItem(0, ec)); + path.moveTo(points()->getItem(0, ec)); for (int i = 1; i < len; ++i) - polyData.addLineTo(points()->getItem(i, ec)); + path.addLineTo(points()->getItem(i, ec)); - polyData.closeSubpath(); - return polyData; + path.closeSubpath(); } } diff --git a/WebCore/svg/SVGPolygonElement.h b/WebCore/svg/SVGPolygonElement.h index 7a5bda8..5c88d11 100644 --- a/WebCore/svg/SVGPolygonElement.h +++ b/WebCore/svg/SVGPolygonElement.h @@ -33,7 +33,7 @@ namespace WebCore { private: SVGPolygonElement(const QualifiedName&, Document*); - virtual Path toPathData() const; + virtual void toPathData(Path&) const; }; } // namespace WebCore diff --git a/WebCore/svg/SVGPolylineElement.cpp b/WebCore/svg/SVGPolylineElement.cpp index 7ec8431..c9750b2 100644 --- a/WebCore/svg/SVGPolylineElement.cpp +++ b/WebCore/svg/SVGPolylineElement.cpp @@ -37,21 +37,19 @@ PassRefPtr<SVGPolylineElement> SVGPolylineElement::create(const QualifiedName& t return adoptRef(new SVGPolylineElement(tagName, document)); } -Path SVGPolylineElement::toPathData() const +void SVGPolylineElement::toPathData(Path& path) const { - Path polyData; + ASSERT(path.isEmpty()); int len = points()->numberOfItems(); if (len < 1) - return polyData; + return; ExceptionCode ec = 0; - polyData.moveTo(points()->getItem(0, ec)); + path.moveTo(points()->getItem(0, ec)); for (int i = 1; i < len; ++i) - polyData.addLineTo(points()->getItem(i, ec)); - - return polyData; + path.addLineTo(points()->getItem(i, ec)); } } diff --git a/WebCore/svg/SVGPolylineElement.h b/WebCore/svg/SVGPolylineElement.h index d3fe555..dfcfcda 100644 --- a/WebCore/svg/SVGPolylineElement.h +++ b/WebCore/svg/SVGPolylineElement.h @@ -33,7 +33,7 @@ namespace WebCore { private: SVGPolylineElement(const QualifiedName&, Document*); - virtual Path toPathData() const; + virtual void toPathData(Path&) const; }; } // namespace WebCore diff --git a/WebCore/svg/SVGRadialGradientElement.cpp b/WebCore/svg/SVGRadialGradientElement.cpp index 80aba78..584b1b6 100644 --- a/WebCore/svg/SVGRadialGradientElement.cpp +++ b/WebCore/svg/SVGRadialGradientElement.cpp @@ -123,9 +123,8 @@ RenderObject* SVGRadialGradientElement::createRenderer(RenderArena* arena, Rende return new (arena) RenderSVGResourceRadialGradient(this); } -RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() +void SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttributes& attributes) { - RadialGradientAttributes attributes; HashSet<SVGGradientElement*> processedGradients; bool isRadial = true; @@ -190,8 +189,6 @@ RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() if (!attributes.hasFy()) attributes.setFy(attributes.cy()); - - return attributes; } void SVGRadialGradientElement::calculateFocalCenterPointsAndRadius(const RadialGradientAttributes& attributes, FloatPoint& focalPoint, FloatPoint& centerPoint, float& radius) diff --git a/WebCore/svg/SVGRadialGradientElement.h b/WebCore/svg/SVGRadialGradientElement.h index e528a13..61333af 100644 --- a/WebCore/svg/SVGRadialGradientElement.h +++ b/WebCore/svg/SVGRadialGradientElement.h @@ -33,7 +33,7 @@ namespace WebCore { public: static PassRefPtr<SVGRadialGradientElement> create(const QualifiedName&, Document*); - RadialGradientAttributes collectGradientProperties(); + void collectGradientAttributes(RadialGradientAttributes&); void calculateFocalCenterPointsAndRadius(const RadialGradientAttributes&, FloatPoint& focalPoint, FloatPoint& centerPoint, float& radius); private: diff --git a/WebCore/svg/SVGRectElement.cpp b/WebCore/svg/SVGRectElement.cpp index 43ba888..46ed8de 100644 --- a/WebCore/svg/SVGRectElement.cpp +++ b/WebCore/svg/SVGRectElement.cpp @@ -24,7 +24,7 @@ #include "SVGRectElement.h" #include "Attribute.h" -#include "RenderPath.h" +#include "RenderSVGPath.h" #include "RenderSVGResource.h" #include "SVGLength.h" #include "SVGNames.h" @@ -94,7 +94,7 @@ void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName) if (isLengthAttribute) updateRelativeLengthsInformation(); - RenderPath* renderer = static_cast<RenderPath*>(this->renderer()); + RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer()); if (!renderer) return; @@ -147,19 +147,37 @@ void SVGRectElement::synchronizeProperty(const QualifiedName& attrName) synchronizeExternalResourcesRequired(); } -Path SVGRectElement::toPathData() const +void SVGRectElement::toPathData(Path& path) const { - FloatRect rect(x().value(this), y().value(this), width().value(this), height().value(this)); + ASSERT(path.isEmpty()); + + float widthValue = width().value(this); + if (widthValue <= 0) + return; + + float heightValue = height().value(this); + if (heightValue <= 0) + return; + + float xValue = x().value(this); + float yValue = y().value(this); + + FloatRect rect(xValue, yValue, widthValue, heightValue); bool hasRx = hasAttribute(SVGNames::rxAttr); bool hasRy = hasAttribute(SVGNames::ryAttr); if (hasRx || hasRy) { - float _rx = hasRx ? rx().value(this) : ry().value(this); - float _ry = hasRy ? ry().value(this) : rx().value(this); - return Path::createRoundedRectangle(rect, FloatSize(_rx, _ry)); + float rxValue = rx().value(this); + float ryValue = ry().value(this); + if (!hasRx) + rxValue = ryValue; + else if (!hasRy) + ryValue = rxValue; + path.addRoundedRect(rect, FloatSize(rxValue, ryValue)); + return; } - return Path::createRectangle(rect); + path.addRect(rect); } bool SVGRectElement::selfHasRelativeLengths() const diff --git a/WebCore/svg/SVGRectElement.h b/WebCore/svg/SVGRectElement.h index 382078d..668366b 100644 --- a/WebCore/svg/SVGRectElement.h +++ b/WebCore/svg/SVGRectElement.h @@ -45,7 +45,7 @@ namespace WebCore { virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); - virtual Path toPathData() const; + virtual void toPathData(Path&) const; virtual bool selfHasRelativeLengths() const; diff --git a/WebCore/svg/SVGStyledElement.cpp b/WebCore/svg/SVGStyledElement.cpp index f554846..d4fa89c 100644 --- a/WebCore/svg/SVGStyledElement.cpp +++ b/WebCore/svg/SVGStyledElement.cpp @@ -60,6 +60,10 @@ SVGStyledElement::SVGStyledElement(const QualifiedName& tagName, Document* docum { } +SVGStyledElement::~SVGStyledElement() +{ +} + String SVGStyledElement::title() const { // According to spec, we should not return titles when hovering over <svg> elements (those diff --git a/WebCore/svg/SVGStyledElement.h b/WebCore/svg/SVGStyledElement.h index 3482a4f..5e996b3 100644 --- a/WebCore/svg/SVGStyledElement.h +++ b/WebCore/svg/SVGStyledElement.h @@ -35,6 +35,8 @@ namespace WebCore { class SVGStyledElement : public SVGElement, public SVGStylable { public: + virtual ~SVGStyledElement(); + virtual String title() const; bool hasRelativeLengths() const { return !m_elementsWithRelativeLengths.isEmpty(); } diff --git a/WebCore/svg/SVGStyledLocatableElement.cpp b/WebCore/svg/SVGStyledLocatableElement.cpp index d22e708..f29121b 100644 --- a/WebCore/svg/SVGStyledLocatableElement.cpp +++ b/WebCore/svg/SVGStyledLocatableElement.cpp @@ -24,7 +24,6 @@ #include "SVGStyledLocatableElement.h" #include "AffineTransform.h" -#include "RenderPath.h" #include "SVGElement.h" #include "SVGSVGElement.h" diff --git a/WebCore/svg/SVGStyledTransformableElement.cpp b/WebCore/svg/SVGStyledTransformableElement.cpp index af10ed7..9b34203 100644 --- a/WebCore/svg/SVGStyledTransformableElement.cpp +++ b/WebCore/svg/SVGStyledTransformableElement.cpp @@ -25,7 +25,7 @@ #include "AffineTransform.h" #include "Attr.h" -#include "RenderPath.h" +#include "RenderSVGPath.h" #include "SVGDocument.h" #include "SVGStyledElement.h" #include "SVGTransformList.h" @@ -38,6 +38,10 @@ SVGStyledTransformableElement::SVGStyledTransformableElement(const QualifiedName { } +SVGStyledTransformableElement::~SVGStyledTransformableElement() +{ +} + AffineTransform SVGStyledTransformableElement::getCTM(StyleUpdateStrategy styleUpdateStrategy) const { return SVGLocatable::computeCTM(this, SVGLocatable::NearestViewportScope, styleUpdateStrategy); @@ -104,15 +108,14 @@ FloatRect SVGStyledTransformableElement::getBBox(StyleUpdateStrategy styleUpdate RenderObject* SVGStyledTransformableElement::createRenderer(RenderArena* arena, RenderStyle*) { // By default, any subclass is expected to do path-based drawing - return new (arena) RenderPath(this); + return new (arena) RenderSVGPath(this); } -Path SVGStyledTransformableElement::toClipPath() const +void SVGStyledTransformableElement::toClipPath(Path& path) const { - Path pathData = toPathData(); + toPathData(path); // FIXME: How do we know the element has done a layout? - pathData.transform(animatedLocalTransform()); - return pathData; + path.transform(animatedLocalTransform()); } } diff --git a/WebCore/svg/SVGStyledTransformableElement.h b/WebCore/svg/SVGStyledTransformableElement.h index 7668889..5349cfa 100644 --- a/WebCore/svg/SVGStyledTransformableElement.h +++ b/WebCore/svg/SVGStyledTransformableElement.h @@ -33,6 +33,8 @@ class AffineTransform; class SVGStyledTransformableElement : public SVGStyledLocatableElement, public SVGTransformable { public: + virtual ~SVGStyledTransformableElement(); + virtual AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate) const; virtual AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate) const; virtual SVGElement* nearestViewportElement() const; @@ -47,8 +49,8 @@ public: bool isKnownAttribute(const QualifiedName&); // "base class" methods for all the elements which render as paths - virtual Path toPathData() const { return Path(); } - virtual Path toClipPath() const; + virtual void toPathData(Path&) const { } + virtual void toClipPath(Path&) const; virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); protected: diff --git a/WebCore/svg/SVGTSpanElement.cpp b/WebCore/svg/SVGTSpanElement.cpp index d1deb70..b88600a 100644 --- a/WebCore/svg/SVGTSpanElement.cpp +++ b/WebCore/svg/SVGTSpanElement.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> + * Copyright (C) 2004, 2005, 2006, 2010 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 @@ -45,7 +45,10 @@ bool SVGTSpanElement::childShouldCreateRenderer(Node* child) const #if ENABLE(SVG_FONTS) || child->hasTagName(SVGNames::altGlyphTag) #endif - || child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::textPathTag)) + || child->hasTagName(SVGNames::tspanTag) + || child->hasTagName(SVGNames::trefTag) + || child->hasTagName(SVGNames::aTag) + || child->hasTagName(SVGNames::textPathTag)) return true; return false; diff --git a/WebCore/svg/SVGTextContentElement.cpp b/WebCore/svg/SVGTextContentElement.cpp index 9d44b10..cdb9d81 100644 --- a/WebCore/svg/SVGTextContentElement.cpp +++ b/WebCore/svg/SVGTextContentElement.cpp @@ -26,6 +26,7 @@ #include "CSSPropertyNames.h" #include "CSSValueKeywords.h" #include "Frame.h" +#include "RenderObject.h" #include "SVGTextQuery.h" #include "SelectionController.h" #include "XMLNames.h" @@ -215,6 +216,30 @@ bool SVGTextContentElement::selfHasRelativeLengths() const return textLength().isRelative(); } +SVGTextContentElement* SVGTextContentElement::elementFromRenderer(RenderObject* renderer) +{ + if (!renderer) + return 0; + + if (!renderer->isSVGText() && !renderer->isSVGInline()) + return 0; + + Node* node = renderer->node(); + ASSERT(node); + ASSERT(node->isSVGElement()); + + if (!node->hasTagName(SVGNames::textTag) + && !node->hasTagName(SVGNames::tspanTag) +#if ENABLE(SVG_FONTS) + && !node->hasTagName(SVGNames::altGlyphTag) +#endif + && !node->hasTagName(SVGNames::trefTag) + && !node->hasTagName(SVGNames::textPathTag)) + return 0; + + return static_cast<SVGTextContentElement*>(node); +} + } #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGTextContentElement.h b/WebCore/svg/SVGTextContentElement.h index cf3698b..a63e27a 100644 --- a/WebCore/svg/SVGTextContentElement.h +++ b/WebCore/svg/SVGTextContentElement.h @@ -54,6 +54,8 @@ namespace WebCore { bool isKnownAttribute(const QualifiedName&); + static SVGTextContentElement* elementFromRenderer(RenderObject*); + protected: SVGTextContentElement(const QualifiedName&, Document*); diff --git a/WebCore/svg/SVGTextPathElement.cpp b/WebCore/svg/SVGTextPathElement.cpp index 82adb29..bbfa0e2 100644 --- a/WebCore/svg/SVGTextPathElement.cpp +++ b/WebCore/svg/SVGTextPathElement.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2010 Rob Buis <rwlbuis@gmail.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -119,7 +120,10 @@ bool SVGTextPathElement::childShouldCreateRenderer(Node* child) const #if ENABLE(SVG_FONTS) || child->hasTagName(SVGNames::altGlyphTag) #endif - || child->hasTagName(SVGNames::trefTag) || child->hasTagName(SVGNames::tspanTag) || child->hasTagName(SVGNames::textPathTag)) + || child->hasTagName(SVGNames::trefTag) + || child->hasTagName(SVGNames::tspanTag) + || child->hasTagName(SVGNames::aTag) + || child->hasTagName(SVGNames::textPathTag)) return true; return false; diff --git a/WebCore/svg/SVGTextPositioningElement.cpp b/WebCore/svg/SVGTextPositioningElement.cpp index 4703482..cbc324d 100644 --- a/WebCore/svg/SVGTextPositioningElement.cpp +++ b/WebCore/svg/SVGTextPositioningElement.cpp @@ -24,8 +24,8 @@ #include "SVGTextPositioningElement.h" #include "Attribute.h" -#include "RenderObject.h" #include "RenderSVGResource.h" +#include "RenderSVGText.h" #include "SVGLengthList.h" #include "SVGNames.h" #include "SVGNumberList.h" @@ -58,21 +58,65 @@ void SVGTextPositioningElement::parseMappedAttribute(Attribute* attr) SVGTextContentElement::parseMappedAttribute(attr); } +static inline void updatePositioningValuesInRenderer(RenderObject* renderer) +{ + RenderSVGText* textRenderer = 0; + + if (renderer->isSVGText()) + textRenderer = toRenderSVGText(renderer); + else { + // Locate RenderSVGText parent renderer. + RenderObject* parent = renderer->parent(); + while (parent && !parent->isSVGText()) + parent = parent->parent(); + + if (parent) { + ASSERT(parent->isSVGText()); + textRenderer = toRenderSVGText(parent); + } + } + + if (!textRenderer) + return; + + textRenderer->setNeedsPositioningValuesUpdate(); +} + void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrName) { SVGTextContentElement::svgAttributeChanged(attrName); - if (attrName == SVGNames::xAttr - || attrName == SVGNames::yAttr - || attrName == SVGNames::dxAttr - || attrName == SVGNames::dyAttr) + bool updateRelativeLengths = attrName == SVGNames::xAttr + || attrName == SVGNames::yAttr + || attrName == SVGNames::dxAttr + || attrName == SVGNames::dyAttr; + + if (updateRelativeLengths) updateRelativeLengthsInformation(); - if (!renderer()) + RenderObject* renderer = this->renderer(); + if (!renderer) + return; + + if (updateRelativeLengths || attrName == SVGNames::rotateAttr) { + updatePositioningValuesInRenderer(renderer); + RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); + return; + } + + if (SVGTextContentElement::isKnownAttribute(attrName)) + RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); +} + +void SVGTextPositioningElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) +{ + SVGTextContentElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); + + if (changedByParser) return; - if (isKnownAttribute(attrName)) - RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer()); + if (RenderObject* object = renderer()) + updatePositioningValuesInRenderer(object); } void SVGTextPositioningElement::synchronizeProperty(const QualifiedName& attrName) @@ -100,16 +144,6 @@ void SVGTextPositioningElement::synchronizeProperty(const QualifiedName& attrNam synchronizeRotate(); } -bool SVGTextPositioningElement::isKnownAttribute(const QualifiedName& attrName) -{ - return (attrName.matches(SVGNames::xAttr) || - attrName.matches(SVGNames::yAttr) || - attrName.matches(SVGNames::dxAttr) || - attrName.matches(SVGNames::dyAttr) || - attrName.matches(SVGNames::rotateAttr) || - SVGTextContentElement::isKnownAttribute(attrName)); -} - static inline bool listContainsRelativeValue(SVGLengthList* list) { if (!list) @@ -143,6 +177,30 @@ bool SVGTextPositioningElement::selfHasRelativeLengths() const return false; } +SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject* renderer) +{ + if (!renderer) + return 0; + + if (!renderer->isSVGText() && !renderer->isSVGInline()) + return 0; + + Node* node = renderer->node(); + ASSERT(node); + ASSERT(node->isSVGElement()); + + if (!node->hasTagName(SVGNames::textTag) + && !node->hasTagName(SVGNames::tspanTag) +#if ENABLE(SVG_FONTS) + && !node->hasTagName(SVGNames::altGlyphTag) +#endif + && !node->hasTagName(SVGNames::trefTag)) + return 0; + + return static_cast<SVGTextPositioningElement*>(node); +} + + } #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGTextPositioningElement.h b/WebCore/svg/SVGTextPositioningElement.h index 57a4028..41de9f3 100644 --- a/WebCore/svg/SVGTextPositioningElement.h +++ b/WebCore/svg/SVGTextPositioningElement.h @@ -29,15 +29,17 @@ namespace WebCore { class SVGTextPositioningElement : public SVGTextContentElement { + public: + static SVGTextPositioningElement* elementFromRenderer(RenderObject*); + 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&); - bool isKnownAttribute(const QualifiedName&); - virtual bool selfHasRelativeLengths() const; DECLARE_ANIMATED_PROPERTY(SVGTextPositioningElement, SVGNames::xAttr, SVGLengthList*, X, x) diff --git a/WebCore/svg/SVGURIReference.h b/WebCore/svg/SVGURIReference.h index 92a93a9..096f5a5 100644 --- a/WebCore/svg/SVGURIReference.h +++ b/WebCore/svg/SVGURIReference.h @@ -39,7 +39,7 @@ namespace WebCore { static String getTarget(const String& url); protected: - virtual void setHrefBaseValue(SVGAnimatedPropertyTraits<String>::PassType) = 0; + virtual void setHrefBaseValue(DeprecatedSVGAnimatedPropertyTraits<String>::PassType) = 0; }; } // namespace WebCore diff --git a/WebCore/svg/SVGUseElement.cpp b/WebCore/svg/SVGUseElement.cpp index 782efa8..474b0a4 100644 --- a/WebCore/svg/SVGUseElement.cpp +++ b/WebCore/svg/SVGUseElement.cpp @@ -47,6 +47,8 @@ #include "XMLDocumentParser.h" #include "XMLSerializer.h" +#include <wtf/text/StringConcatenate.h> + // Dump SVGElementInstance object tree - useful to debug instanceRoot problems // #define DUMP_INSTANCE_TREE @@ -296,7 +298,7 @@ void SVGUseElement::updateContainerOffsets() SVGElement* shadowRoot = m_targetElementInstance->shadowTreeElement(); ASSERT(shadowRoot); - Node* parentNode = shadowRoot->parentNode(); + ContainerNode* parentNode = shadowRoot->parentNode(); ASSERT(parentNode); ASSERT(parentNode->isSVGElement()); ASSERT(parentNode->hasTagName(SVGNames::gTag)); @@ -370,7 +372,7 @@ void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstance* tar text += " "; const HashSet<SVGElementInstance*>& elementInstances = element->instancesForElement(); - text += String::format("Corresponding element is associated with %i instance(s):\n", elementInstances.size()); + text += makeString("Corresponding element is associated with ", String::number(elementInstances.size()), " instance(s):\n"); const HashSet<SVGElementInstance*>::const_iterator end = elementInstances.end(); for (HashSet<SVGElementInstance*>::const_iterator it = elementInstances.begin(); it != end; ++it) { @@ -477,7 +479,7 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGShadowTreeRootElement* shadowR // Do not build the shadow/instance tree for <use> elements living in a shadow tree. // The will be expanded soon anyway - see expandUseElementsInShadowTree(). - Node* parent = parentNode(); + ContainerNode* parent = parentNode(); while (parent) { if (parent->isShadowNode()) return; @@ -624,25 +626,24 @@ static bool isDirectReference(Node* n) n->hasTagName(SVGNames::textTag); } -Path SVGUseElement::toClipPath() const +void SVGUseElement::toClipPath(Path& path) const { + ASSERT(path.isEmpty()); + Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0; if (!n) - return Path(); + return; if (n->isSVGElement() && static_cast<SVGElement*>(n)->isStyledTransformable()) { if (!isDirectReference(n)) // Spec: Indirect references are an error (14.3.5) document()->accessSVGExtensions()->reportError("Not allowed to use indirect reference in <clip-path>"); else { - Path clipPath = static_cast<SVGStyledTransformableElement*>(n)->toClipPath(); - clipPath.translate(FloatSize(x().value(this), y().value(this))); - clipPath.transform(animatedLocalTransform()); - return clipPath; + static_cast<SVGStyledTransformableElement*>(n)->toClipPath(path); + path.translate(FloatSize(x().value(this), y().value(this))); + path.transform(animatedLocalTransform()); } } - - return Path(); } RenderObject* SVGUseElement::rendererClipChild() const @@ -797,6 +798,7 @@ void SVGUseElement::expandUseElementsInShadowTree(SVGShadowTreeRootElement* shad // Don't ASSERT(target) here, it may be "pending", too. // Setup sub-shadow tree root node RefPtr<SVGShadowTreeContainerElement> cloneParent = SVGShadowTreeContainerElement::create(document()); + use->cloneChildNodes(cloneParent.get()); // Spec: In the generated content, the 'use' will be replaced by 'g', where all attributes from the // 'use' element except for x, y, width, height and xlink:href are transferred to the generated 'g' element. @@ -806,14 +808,6 @@ void SVGUseElement::expandUseElementsInShadowTree(SVGShadowTreeRootElement* shad if (target && !isDisallowedElement(target)) { RefPtr<Element> newChild = target->cloneElementWithChildren(); - // We don't walk the target tree element-by-element, and clone each element, - // but instead use cloneElementWithChildren(). This is an optimization for the common - // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). - // Though if there are disallowed elements in the subtree, we have to remove them. - // For instance: <use> on <g> containing <foreignObject> (indirect case). - if (subtreeContainsDisallowedElement(newChild.get())) - removeDisallowedElementsFromSubtree(newChild.get()); - SVGElement* newChildPtr = 0; if (newChild->isSVGElement()) newChildPtr = static_cast<SVGElement*>(newChild.get()); @@ -823,6 +817,14 @@ void SVGUseElement::expandUseElementsInShadowTree(SVGShadowTreeRootElement* shad ASSERT(!ec); } + // We don't walk the target tree element-by-element, and clone each element, + // but instead use cloneElementWithChildren(). This is an optimization for the common + // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). + // Though if there are disallowed elements in the subtree, we have to remove them. + // For instance: <use> on <g> containing <foreignObject> (indirect case). + if (subtreeContainsDisallowedElement(cloneParent.get())) + removeDisallowedElementsFromSubtree(cloneParent.get()); + // Replace <use> with referenced content. ASSERT(use->parentNode()); use->parentNode()->replaceChild(cloneParent.release(), use, ec); diff --git a/WebCore/svg/SVGUseElement.h b/WebCore/svg/SVGUseElement.h index 9366d25..b8ba71d 100644 --- a/WebCore/svg/SVGUseElement.h +++ b/WebCore/svg/SVGUseElement.h @@ -67,7 +67,7 @@ namespace WebCore { virtual void attach(); virtual void detach(); - virtual Path toClipPath() const; + virtual void toClipPath(Path&) const; static void removeDisallowedElementsFromSubtree(Node* element); diff --git a/WebCore/svg/SVGVKernElement.cpp b/WebCore/svg/SVGVKernElement.cpp index b9f3c17..eed13d2 100644 --- a/WebCore/svg/SVGVKernElement.cpp +++ b/WebCore/svg/SVGVKernElement.cpp @@ -45,7 +45,7 @@ PassRefPtr<SVGVKernElement> SVGVKernElement::create(const QualifiedName& tagName void SVGVKernElement::insertedIntoDocument() { - Node* fontNode = parentNode(); + ContainerNode* fontNode = parentNode(); if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) { if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode)) element->invalidateGlyphCache(); @@ -54,7 +54,7 @@ void SVGVKernElement::insertedIntoDocument() void SVGVKernElement::removedFromDocument() { - Node* fontNode = parentNode(); + ContainerNode* fontNode = parentNode(); if (fontNode && fontNode->hasTagName(SVGNames::fontTag)) { if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode)) element->invalidateGlyphCache(); diff --git a/WebCore/svg/animation/SVGSMILElement.cpp b/WebCore/svg/animation/SVGSMILElement.cpp index 99a5189..a90b444 100644 --- a/WebCore/svg/animation/SVGSMILElement.cpp +++ b/WebCore/svg/animation/SVGSMILElement.cpp @@ -463,7 +463,7 @@ void SVGSMILElement::reschedule() SVGElement* SVGSMILElement::targetElement() const { String href = xlinkHref(); - Node* target = href.isEmpty() ? parentNode() : document()->getElementById(SVGURIReference::getTarget(href)); + ContainerNode* target = href.isEmpty() ? parentNode() : document()->getElementById(SVGURIReference::getTarget(href)); if (target && target->isSVGElement()) return static_cast<SVGElement*>(target); return 0; diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp index 2d1d592..c9804ae 100644 --- a/WebCore/svg/graphics/SVGImage.cpp +++ b/WebCore/svg/graphics/SVGImage.cpp @@ -224,7 +224,7 @@ NativeImagePtr SVGImage::nativeImageForCurrentFrame() OwnPtr<ImageBuffer> buffer = ImageBuffer::create(size()); if (!buffer) // failed to allocate image return 0; - draw(buffer->context(), rect(), rect(), DeviceColorSpace, CompositeSourceOver); + draw(buffer->context(), rect(), rect(), ColorSpaceDeviceRGB, CompositeSourceOver); m_frameCache = buffer->copyImage(); } return m_frameCache->nativeImageForCurrentFrame(); diff --git a/WebCore/svg/graphics/filters/SVGFEImage.cpp b/WebCore/svg/graphics/filters/SVGFEImage.cpp index c94547b..ed90588 100644 --- a/WebCore/svg/graphics/filters/SVGFEImage.cpp +++ b/WebCore/svg/graphics/filters/SVGFEImage.cpp @@ -44,21 +44,33 @@ PassRefPtr<FEImage> FEImage::create(RefPtr<Image> image, const SVGPreserveAspect return adoptRef(new FEImage(image, preserveAspectRatio)); } -void FEImage::apply(Filter*) +void FEImage::determineAbsolutePaintRect(Filter*) +{ + ASSERT(m_image); + FloatRect srcRect(FloatPoint(), m_image->size()); + FloatRect paintRect(m_absoluteSubregion); + m_preserveAspectRatio.transformRect(paintRect, srcRect); + paintRect.intersect(maxEffectRect()); + setAbsolutePaintRect(enclosingIntRect(paintRect)); +} + +void FEImage::apply(Filter* filter) { if (!m_image.get()) return; - GraphicsContext* filterContext = effectContext(); + GraphicsContext* filterContext = effectContext(filter); if (!filterContext) return; FloatRect srcRect(FloatPoint(), m_image->size()); - FloatRect destRect(FloatPoint(), filterPrimitiveSubregion().size()); - + FloatRect destRect(m_absoluteSubregion); m_preserveAspectRatio.transformRect(destRect, srcRect); - filterContext->drawImage(m_image.get(), DeviceColorSpace, destRect, srcRect); + IntPoint paintLocation = absolutePaintRect().location(); + destRect.move(-paintLocation.x(), -paintLocation.y()); + + filterContext->drawImage(m_image.get(), ColorSpaceDeviceRGB, destRect, srcRect); } void FEImage::dump() diff --git a/WebCore/svg/graphics/filters/SVGFEImage.h b/WebCore/svg/graphics/filters/SVGFEImage.h index fe2d8c4..9efb5f1 100644 --- a/WebCore/svg/graphics/filters/SVGFEImage.h +++ b/WebCore/svg/graphics/filters/SVGFEImage.h @@ -33,9 +33,15 @@ class FEImage : public FilterEffect { public: static PassRefPtr<FEImage> create(RefPtr<Image>, const SVGPreserveAspectRatio&); + void setAbsoluteSubregion(const FloatRect& absoluteSubregion) { m_absoluteSubregion = absoluteSubregion; } + virtual void apply(Filter*); virtual void dump(); + virtual void determineAbsolutePaintRect(Filter*); + + virtual FilterEffectType filterEffectType() const { return FilterEffectTypeImage; } + virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: @@ -43,6 +49,7 @@ private: RefPtr<Image> m_image; SVGPreserveAspectRatio m_preserveAspectRatio; + FloatRect m_absoluteSubregion; }; } // namespace WebCore diff --git a/WebCore/svg/graphics/filters/SVGFilter.cpp b/WebCore/svg/graphics/filters/SVGFilter.cpp index d72dc3d..dfdccd7 100644 --- a/WebCore/svg/graphics/filters/SVGFilter.cpp +++ b/WebCore/svg/graphics/filters/SVGFilter.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> + * Copyright (C) Research In Motion Limited 2010. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -22,14 +23,19 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFilter.h" +#include "SVGFEImage.h" + namespace WebCore { -SVGFilter::SVGFilter(const FloatRect& targetBoundingBox, const FloatRect& filterRect, bool effectBBoxMode) +SVGFilter::SVGFilter(const AffineTransform& absoluteTransform, const FloatRect& absoluteSourceDrawingRegion, const FloatRect& targetBoundingBox, const FloatRect& filterRegion, bool effectBBoxMode) : Filter() + , m_absoluteTransform(absoluteTransform) + , m_absoluteSourceDrawingRegion(absoluteSourceDrawingRegion) , m_targetBoundingBox(targetBoundingBox) - , m_filterRect(filterRect) + , m_filterRegion(filterRegion) , m_effectBBoxMode(effectBBoxMode) { + m_absoluteFilterRegion = absoluteTransform.mapRect(filterRegion); } void SVGFilter::determineFilterPrimitiveSubregion(FilterEffect* effect, const FloatRect& unionOfPreviousPrimitiveSubregions) @@ -65,23 +71,48 @@ void SVGFilter::determineFilterPrimitiveSubregion(FilterEffect* effect, const Fl newSubRegion.setHeight(unionOfPreviousPrimitiveSubregions.height()); } - // clip every filter effect to the filter region - newSubRegion.intersect(m_filterRect); - effect->setFilterPrimitiveSubregion(newSubRegion); - // TODO: Everything above should be moved to a first phase of layout in RenderSVGResourceFilterPrimitive. // The scaling of the subregion to the repaint rect should be merged with a more intelligent repaint logic // and moved to the second phase of layout in RenderSVGResourceFilterPrimitive. // See bug https://bugs.webkit.org/show_bug.cgi?id=45614. + newSubRegion = m_absoluteTransform.mapRect(newSubRegion); newSubRegion.scale(filterResolution().width(), filterResolution().height()); - effect->setRepaintRectInLocalCoordinates(newSubRegion); - m_maxImageSize = m_maxImageSize.expandedTo(newSubRegion.size()); + + // FEImage needs the unclipped subregion in absolute coordinates to determine the correct + // destination rect in combination with preserveAspectRatio. + if (effect->filterEffectType() == FilterEffectTypeImage) { + FEImage* imageEffect = static_cast<FEImage*>(effect); + imageEffect->setAbsoluteSubregion(newSubRegion); + } + + // Clip every filter effect to the filter region. + FloatRect absoluteScaledFilterRegion = m_absoluteFilterRegion; + absoluteScaledFilterRegion.scale(filterResolution().width(), filterResolution().height()); + newSubRegion.intersect(absoluteScaledFilterRegion); + + effect->setMaxEffectRect(enclosingIntRect(newSubRegion)); + if (effect->filterEffectType() != FilterEffectTypeSourceInput) + m_maxImageSize = m_maxImageSize.expandedTo(newSubRegion.size()); +} + +float SVGFilter::applyHorizontalScale(float value) const +{ + if (m_effectBBoxMode) + value *= m_targetBoundingBox.width(); + return Filter::applyHorizontalScale(value) * m_absoluteFilterRegion.width() / m_filterRegion.width(); +} + +float SVGFilter::applyVerticalScale(float value) const +{ + if (m_effectBBoxMode) + value *= m_targetBoundingBox.height(); + return Filter::applyVerticalScale(value) * m_absoluteFilterRegion.height() / m_filterRegion.height(); } -PassRefPtr<SVGFilter> SVGFilter::create(const FloatRect& targetBoundingBox, const FloatRect& filterRect, bool effectBBoxMode) +PassRefPtr<SVGFilter> SVGFilter::create(const AffineTransform& absoluteTransform, const FloatRect& absoluteSourceDrawingRegion, const FloatRect& targetBoundingBox, const FloatRect& filterRegion, bool effectBBoxMode) { - return adoptRef(new SVGFilter(targetBoundingBox, filterRect, effectBBoxMode)); + return adoptRef(new SVGFilter(absoluteTransform, absoluteSourceDrawingRegion, targetBoundingBox, filterRegion, effectBBoxMode)); } } // namespace WebCore diff --git a/WebCore/svg/graphics/filters/SVGFilter.h b/WebCore/svg/graphics/filters/SVGFilter.h index 631f1ee..1b19e9f 100644 --- a/WebCore/svg/graphics/filters/SVGFilter.h +++ b/WebCore/svg/graphics/filters/SVGFilter.h @@ -21,6 +21,7 @@ #define SVGFilter_h #if ENABLE(SVG) && ENABLE(FILTERS) +#include "AffineTransform.h" #include "Filter.h" #include "FilterEffect.h" #include "FloatRect.h" @@ -32,27 +33,36 @@ namespace WebCore { - class SVGFilter : public Filter { - public: - static PassRefPtr<SVGFilter> create(const FloatRect&, const FloatRect&, bool); +class SVGFilter : public Filter { +public: + static PassRefPtr<SVGFilter> create(const AffineTransform&, const FloatRect&, const FloatRect&, const FloatRect&, bool); - virtual bool effectBoundingBoxMode() const { return m_effectBBoxMode; } + virtual bool effectBoundingBoxMode() const { return m_effectBBoxMode; } - virtual FloatRect filterRegion() const { return m_filterRect; } - - virtual FloatRect sourceImageRect() const { return m_targetBoundingBox; } + virtual FloatRect filterRegionInUserSpace() const { return m_filterRegion; } + virtual FloatRect filterRegion() const { return m_absoluteFilterRegion; } - virtual FloatSize maxImageSize() const { return m_maxImageSize; } - virtual void determineFilterPrimitiveSubregion(FilterEffect*, const FloatRect&); + virtual FloatPoint mapAbsolutePointToLocalPoint(const FloatPoint& point) const { return m_absoluteTransform.inverse().mapPoint(point); } - private: - SVGFilter(const FloatRect& targetBoundingBox, const FloatRect& filterRect, bool effectBBoxMode); + virtual float applyHorizontalScale(float value) const; + virtual float applyVerticalScale(float value) const; - FloatSize m_maxImageSize; - FloatRect m_targetBoundingBox; - FloatRect m_filterRect; - bool m_effectBBoxMode; - }; + virtual FloatRect sourceImageRect() const { return m_absoluteSourceDrawingRegion; } + + virtual FloatSize maxImageSize() const { return m_maxImageSize; } + virtual void determineFilterPrimitiveSubregion(FilterEffect*, const FloatRect&); + +private: + SVGFilter(const AffineTransform& absoluteTransform, const FloatRect& absoluteSourceDrawingRegion, const FloatRect& targetBoundingBox, const FloatRect& filterRegion, bool effectBBoxMode); + + AffineTransform m_absoluteTransform; + FloatRect m_absoluteSourceDrawingRegion; + FloatRect m_targetBoundingBox; + FloatRect m_absoluteFilterRegion; + FloatRect m_filterRegion; + bool m_effectBBoxMode; + FloatSize m_maxImageSize; +}; } // namespace WebCore diff --git a/WebCore/svg/SVGAnimatedPropertySynchronizer.h b/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h index 55f77b1..476f1fd 100644 --- a/WebCore/svg/SVGAnimatedPropertySynchronizer.h +++ b/WebCore/svg/properties/SVGAnimatedPropertySynchronizer.h @@ -20,7 +20,7 @@ #ifndef SVGAnimatedPropertySynchronizer_h #define SVGAnimatedPropertySynchronizer_h -#include "SVGAnimatedPropertyTraits.h" +#include "DeprecatedSVGAnimatedPropertyTraits.h" #if ENABLE(SVG) namespace WebCore { |