diff options
| author | Steve Block <steveblock@google.com> | 2011-05-18 13:36:51 +0100 | 
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2011-05-24 15:38:28 +0100 | 
| commit | 2fc2651226baac27029e38c9d6ef883fa32084db (patch) | |
| tree | e396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebCore/svg | |
| parent | b3725cedeb43722b3b175aaeff70552e562d2c94 (diff) | |
| download | external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2 | |
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebCore/svg')
133 files changed, 1525 insertions, 144 deletions
| diff --git a/Source/WebCore/svg/SVGAElement.cpp b/Source/WebCore/svg/SVGAElement.cpp index 8fbfc01..601b432 100644 --- a/Source/WebCore/svg/SVGAElement.cpp +++ b/Source/WebCore/svg/SVGAElement.cpp @@ -105,6 +105,21 @@ void SVGAElement::svgAttributeChanged(const QualifiedName& attrName)      }  } +AttributeToPropertyTypeMap& SVGAElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGAElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::targetAttr, AnimatedString); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +} +  void SVGAElement::synchronizeProperty(const QualifiedName& attrName)  {      SVGStyledTransformableElement::synchronizeProperty(attrName); diff --git a/Source/WebCore/svg/SVGAElement.h b/Source/WebCore/svg/SVGAElement.h index 20a4e07..6d9cd43 100644 --- a/Source/WebCore/svg/SVGAElement.h +++ b/Source/WebCore/svg/SVGAElement.h @@ -52,6 +52,9 @@ private:      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap(); +      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);      virtual void defaultEventHandler(Event*); diff --git a/Source/WebCore/svg/SVGAltGlyphElement.cpp b/Source/WebCore/svg/SVGAltGlyphElement.cpp index ca13740..96fbac6 100644 --- a/Source/WebCore/svg/SVGAltGlyphElement.cpp +++ b/Source/WebCore/svg/SVGAltGlyphElement.cpp @@ -54,6 +54,20 @@ void SVGAltGlyphElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeHref();  } +AttributeToPropertyTypeMap& SVGAltGlyphElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGAltGlyphElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGTextPositioningElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +} +  void SVGAltGlyphElement::setGlyphRef(const AtomicString&, ExceptionCode& ec)  {      ec = NO_MODIFICATION_ALLOWED_ERR; diff --git a/Source/WebCore/svg/SVGAltGlyphElement.h b/Source/WebCore/svg/SVGAltGlyphElement.h index 0cbee79..114e666 100644 --- a/Source/WebCore/svg/SVGAltGlyphElement.h +++ b/Source/WebCore/svg/SVGAltGlyphElement.h @@ -47,6 +47,9 @@ private:      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap(); +      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);      virtual bool childShouldCreateRenderer(Node*) const; diff --git a/Source/WebCore/svg/SVGAnimateElement.cpp b/Source/WebCore/svg/SVGAnimateElement.cpp index 7fe4c87..0dfe086 100644 --- a/Source/WebCore/svg/SVGAnimateElement.cpp +++ b/Source/WebCore/svg/SVGAnimateElement.cpp @@ -24,8 +24,11 @@  #if ENABLE(SVG) && ENABLE(SVG_ANIMATION)  #include "SVGAnimateElement.h" +#include "CSSPropertyNames.h"  #include "ColorDistance.h"  #include "FloatConversion.h" +#include "QualifiedName.h" +#include "RenderObject.h"  #include "SVGColor.h"  #include "SVGNames.h"  #include "SVGParserUtilities.h" @@ -82,17 +85,31 @@ static bool parseNumberValueAndUnit(const String& in, double& value, String& uni      return ok;  } +static inline bool adjustForCurrentColor(Color& color, const String& value, SVGElement* target) +{ +    if (!target || !target->isStyled() || value != "currentColor") +        return false; +     +    if (RenderObject* targetRenderer = target->renderer()) +        color = targetRenderer->style()->visitedDependentColor(CSSPropertyColor); + +    return true; +} +  SVGAnimateElement::PropertyType SVGAnimateElement::determinePropertyType(const String& attribute) const  { -    // FIXME: We need a full property table for figuring this out reliably. +    // FIXME: We should not allow animation of attribute types other than AnimatedColor for <animateColor>.      if (hasTagName(SVGNames::animateColorTag))          return ColorProperty; -    if (attribute == "d") + +    // FIXME: Now that we have a full property table we need a more granular type specific animation. +    AnimatedAttributeType type = targetElement()->animatedPropertyTypeForAttribute(QualifiedName(nullAtom, attribute, nullAtom)); +    if (type == AnimatedColor) +        return ColorProperty; +    if (type == AnimatedPath)          return PathProperty; -    if (attribute == "points") +    if (type == AnimatedPoints)          return PointsProperty; -    if (attribute == "color" || attribute == "fill" || attribute == "stroke") -        return ColorProperty;      return NumberProperty;  } @@ -100,6 +117,9 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat  {      ASSERT(percentage >= 0.f && percentage <= 1.f);      ASSERT(resultElement); +    bool isInFirstHalfOfAnimation = percentage < 0.5; +    AnimationMode animationMode = this->animationMode(); +          if (hasTagName(SVGNames::setTag))          percentage = 1.f;      if (!resultElement->hasTagName(SVGNames::animateTag) && !resultElement->hasTagName(SVGNames::animateColorTag)  @@ -111,33 +131,45 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat          return;      if (m_propertyType == NumberProperty) {          // To animation uses contributions from the lower priority animations as the base value. -        if (animationMode() == ToAnimation) +        if (animationMode == ToAnimation)              m_fromNumber = results->m_animatedNumber; -     -        double number = (m_toNumber - m_fromNumber) * percentage + m_fromNumber; +         +        double number; +        if (calcMode() == CalcModeDiscrete) +            number = isInFirstHalfOfAnimation ? m_fromNumber : m_toNumber; +        else +            number = (m_toNumber - m_fromNumber) * percentage + m_fromNumber;          // FIXME: This is not correct for values animation.          if (isAccumulated() && repeat)              number += m_toNumber * repeat; -        if (isAdditive() && animationMode() != ToAnimation) +        if (isAdditive() && animationMode != ToAnimation)              results->m_animatedNumber += number;          else               results->m_animatedNumber = number;          return;      }       if (m_propertyType == ColorProperty) { -        if (animationMode() == ToAnimation) +        if (animationMode == ToAnimation)              m_fromColor = results->m_animatedColor; -        Color color = ColorDistance(m_fromColor, m_toColor).scaledDistance(percentage).addToColorAndClamp(m_fromColor); +        Color color; +        if (calcMode() == CalcModeDiscrete) +            color = isInFirstHalfOfAnimation ? m_fromColor : m_toColor; +        else +            color = ColorDistance(m_fromColor, m_toColor).scaledDistance(percentage).addToColorAndClamp(m_fromColor); +          // FIXME: Accumulate colors. -        if (isAdditive() && animationMode() != ToAnimation) +        if (isAdditive() && animationMode != ToAnimation)              results->m_animatedColor = ColorDistance::addColorsAndClamp(results->m_animatedColor, color);          else              results->m_animatedColor = color;          return;      } -    AnimationMode animationMode = this->animationMode();      if (m_propertyType == PathProperty) { +        if (animationMode == ToAnimation) { +            ASSERT(results->m_animatedPathPointer); +            m_fromPath = results->m_animatedPathPointer->copy(); +        }          if (!percentage) {              ASSERT(m_fromPath);              ASSERT(percentage >= 0); @@ -197,8 +229,11 @@ bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const      // FIXME: Needs more solid way determine target attribute type.      m_propertyType = determinePropertyType(attributeName());      if (m_propertyType == ColorProperty) { -        m_fromColor = SVGColor::colorFromRGBColorString(fromString); -        m_toColor = SVGColor::colorFromRGBColorString(toString); +        SVGElement* targetElement = this->targetElement(); +        if (!adjustForCurrentColor(m_fromColor, fromString, targetElement)) +            m_fromColor = SVGColor::colorFromRGBColorString(fromString); +        if (!adjustForCurrentColor(m_toColor, toString, targetElement)) +            m_toColor = SVGColor::colorFromRGBColorString(toString);          if ((m_fromColor.isValid() && m_toColor.isValid()) || (m_toColor.isValid() && animationMode() == ToAnimation))              return true;      } else if (m_propertyType == NumberProperty) { @@ -210,8 +245,9 @@ bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const          }      } else if (m_propertyType == PathProperty) {          SVGPathParserFactory* factory = SVGPathParserFactory::self(); -        if (factory->buildSVGPathByteStreamFromString(fromString, m_fromPath, UnalteredParsing)) { -            if (factory->buildSVGPathByteStreamFromString(toString, m_toPath, UnalteredParsing)) +        if (factory->buildSVGPathByteStreamFromString(toString, m_toPath, UnalteredParsing)) { +            // For to-animations the from number is calculated later +            if (animationMode() == ToAnimation || factory->buildSVGPathByteStreamFromString(fromString, m_fromPath, UnalteredParsing))                  return true;          }          m_fromPath.clear(); @@ -235,8 +271,12 @@ bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, const      ASSERT(!hasTagName(SVGNames::setTag));      m_propertyType = determinePropertyType(attributeName());      if (m_propertyType == ColorProperty) { -        m_fromColor = fromString.isEmpty() ? Color() : SVGColor::colorFromRGBColorString(fromString); -        m_toColor = ColorDistance::addColorsAndClamp(m_fromColor, SVGColor::colorFromRGBColorString(byString)); +        SVGElement* targetElement = this->targetElement(); +        if (!adjustForCurrentColor(m_fromColor, fromString, targetElement)) +            m_fromColor = fromString.isEmpty() ? Color() : SVGColor::colorFromRGBColorString(fromString); +        if (!adjustForCurrentColor(m_toColor, byString, targetElement)) +            m_toColor = SVGColor::colorFromRGBColorString(byString); +        m_toColor = ColorDistance::addColorsAndClamp(m_fromColor, m_toColor);          if (!m_fromColor.isValid() || !m_toColor.isValid())              return false;      } else { @@ -272,7 +312,9 @@ void SVGAnimateElement::resetToBaseValue(const String& baseString)              return;      } else if (m_propertyType == PathProperty) {          m_animatedPath.clear(); -        m_animatedPathPointer = 0; +        SVGPathParserFactory* factory = SVGPathParserFactory::self(); +        factory->buildSVGPathByteStreamFromString(baseString, m_animatedPath, UnalteredParsing); +        m_animatedPathPointer = m_animatedPath.get();          return;      } else if (m_propertyType == PointsProperty) {          m_animatedPoints.clear(); diff --git a/Source/WebCore/svg/SVGAnimationElement.cpp b/Source/WebCore/svg/SVGAnimationElement.cpp index 0fcda6d..c56e3b6 100644 --- a/Source/WebCore/svg/SVGAnimationElement.cpp +++ b/Source/WebCore/svg/SVGAnimationElement.cpp @@ -38,7 +38,6 @@  #include "FloatConversion.h"  #include "HTMLNames.h"  #include "PlatformString.h" -#include "RenderObject.h"  #include "SVGElementInstance.h"  #include "SVGNames.h"  #include "SVGParserUtilities.h" @@ -499,14 +498,6 @@ void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float&          effectivePercent = calculatePercentForSpline(effectivePercent, index);      }  } -static inline void adjustForCurrentColor(String& value, SVGElement* target) -{ -    if (!target || !target->isStyled() || value != "currentColor") -        return; - -    if (RenderObject* targetRenderer = target->renderer()) -        value = targetRenderer->style()->visitedDependentColor(CSSPropertyColor).name(); -}  void SVGAnimationElement::startedActiveInterval()  { @@ -531,29 +522,22 @@ void SVGAnimationElement::startedActiveInterval()      String from = fromValue();      String to = toValue();      String by = byValue(); -    SVGElement* target = targetElement();      if (animationMode == NoAnimation)          return; -    if (animationMode == FromToAnimation) { -        adjustForCurrentColor(from, target); -        adjustForCurrentColor(to, target); +    if (animationMode == FromToAnimation)          m_animationValid = calculateFromAndToValues(from, to); -    } else if (animationMode == ToAnimation) { +    else if (animationMode == ToAnimation) {          // For to-animations the from value is the current accumulated value from lower priority animations.          // The value is not static and is determined during the animation. -        adjustForCurrentColor(to, target);          m_animationValid = calculateFromAndToValues(String(), to); -    } else if (animationMode == FromByAnimation) { -        adjustForCurrentColor(from, target); -        adjustForCurrentColor(by, target); +    } else if (animationMode == FromByAnimation)          m_animationValid = calculateFromAndByValues(from, by); -    } else if (animationMode == ByAnimation) { -        adjustForCurrentColor(by, target); +    else if (animationMode == ByAnimation)          m_animationValid = calculateFromAndByValues(String(), by); -    } else if (animationMode == ValuesAnimation) { +    else if (animationMode == ValuesAnimation) {          m_animationValid = m_values.size() > 1              && (calcMode == CalcModePaced || !hasAttribute(SVGNames::keyTimesAttr) || hasAttribute(SVGNames::keyPointsAttr) || (m_values.size() == m_keyTimes.size())) -            && (calcMode == CalcModeDiscrete || !m_keyTimes.size() || m_keyTimes.last() == 1.0) +            && (calcMode == CalcModeDiscrete || !m_keyTimes.size() || m_keyTimes.last() == 1)              && (calcMode != CalcModeSpline || ((m_keySplines.size() && (m_keySplines.size() == m_values.size() - 1)) || m_keySplines.size() == m_keyPoints.size() - 1))              && (!hasAttribute(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size()));          if (calcMode == CalcModePaced && m_animationValid) diff --git a/Source/WebCore/svg/SVGCircleElement.cpp b/Source/WebCore/svg/SVGCircleElement.cpp index 0ac4600..6a3a0d4 100644 --- a/Source/WebCore/svg/SVGCircleElement.cpp +++ b/Source/WebCore/svg/SVGCircleElement.cpp @@ -132,6 +132,22 @@ void SVGCircleElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGCircleElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGCircleElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::cxAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::cyAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::rAttr, AnimatedLength); +} +  void SVGCircleElement::toPathData(Path& path) const  {      ASSERT(path.isEmpty()); diff --git a/Source/WebCore/svg/SVGCircleElement.h b/Source/WebCore/svg/SVGCircleElement.h index f6946dd..32d3a22 100644 --- a/Source/WebCore/svg/SVGCircleElement.h +++ b/Source/WebCore/svg/SVGCircleElement.h @@ -47,6 +47,9 @@ private:      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap(); +      virtual void toPathData(Path&) const;      virtual bool selfHasRelativeLengths() const; diff --git a/Source/WebCore/svg/SVGClipPathElement.cpp b/Source/WebCore/svg/SVGClipPathElement.cpp index d86370d..74727ee 100644 --- a/Source/WebCore/svg/SVGClipPathElement.cpp +++ b/Source/WebCore/svg/SVGClipPathElement.cpp @@ -102,6 +102,20 @@ void SVGClipPathElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGClipPathElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGClipPathElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::clipPathUnitsAttr, AnimatedEnumeration); +} +  void SVGClipPathElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)  {      SVGStyledTransformableElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); diff --git a/Source/WebCore/svg/SVGClipPathElement.h b/Source/WebCore/svg/SVGClipPathElement.h index 23242e8..ed2e13c 100644 --- a/Source/WebCore/svg/SVGClipPathElement.h +++ b/Source/WebCore/svg/SVGClipPathElement.h @@ -49,6 +49,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); diff --git a/Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp b/Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp index 142d82d..c35a344 100644 --- a/Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp +++ b/Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp @@ -112,6 +112,24 @@ void SVGComponentTransferFunctionElement::synchronizeProperty(const QualifiedNam          synchronizeOffset();  } +AttributeToPropertyTypeMap& SVGComponentTransferFunctionElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGComponentTransferFunctionElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); +    attributeToPropertyTypeMap.set(SVGNames::typeAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::tableValuesAttr, AnimatedNumberList); +    attributeToPropertyTypeMap.set(SVGNames::slopeAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::interceptAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::amplitudeAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::exponentAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::offsetAttr, AnimatedNumber); +} +  ComponentTransferFunction SVGComponentTransferFunctionElement::transferFunction() const  {      ComponentTransferFunction func; diff --git a/Source/WebCore/svg/SVGComponentTransferFunctionElement.h b/Source/WebCore/svg/SVGComponentTransferFunctionElement.h index 5f836f7..2be693b 100644 --- a/Source/WebCore/svg/SVGComponentTransferFunctionElement.h +++ b/Source/WebCore/svg/SVGComponentTransferFunctionElement.h @@ -38,6 +38,8 @@ protected:      virtual void parseMappedAttribute(Attribute*);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();  private:      // Animated property declarations diff --git a/Source/WebCore/svg/SVGCursorElement.cpp b/Source/WebCore/svg/SVGCursorElement.cpp index 0c6a5d9..c49f799 100644 --- a/Source/WebCore/svg/SVGCursorElement.cpp +++ b/Source/WebCore/svg/SVGCursorElement.cpp @@ -72,6 +72,20 @@ void SVGCursorElement::parseMappedAttribute(Attribute* attr)      }  } +AttributeToPropertyTypeMap& SVGCursorElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGCursorElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +} +  void SVGCursorElement::addClient(SVGElement* element)  {      m_clients.add(element); diff --git a/Source/WebCore/svg/SVGCursorElement.h b/Source/WebCore/svg/SVGCursorElement.h index cd4a44e..c670009 100644 --- a/Source/WebCore/svg/SVGCursorElement.h +++ b/Source/WebCore/svg/SVGCursorElement.h @@ -53,6 +53,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; diff --git a/Source/WebCore/svg/SVGDocumentExtensions.cpp b/Source/WebCore/svg/SVGDocumentExtensions.cpp index 3fd9761..7f7ba67 100644 --- a/Source/WebCore/svg/SVGDocumentExtensions.cpp +++ b/Source/WebCore/svg/SVGDocumentExtensions.cpp @@ -93,8 +93,12 @@ void SVGDocumentExtensions::startAnimations()      // FIXME: Eventually every "Time Container" will need a way to latch on to some global timer      // starting animations for a document will do this "latching"  #if ENABLE(SVG_ANIMATION)     -    HashSet<SVGSVGElement*>::iterator end = m_timeContainers.end(); -    for (HashSet<SVGSVGElement*>::iterator itr = m_timeContainers.begin(); itr != end; ++itr) +    // FIXME: We hold a ref pointers to prevent a shadow tree from getting removed out from underneath us. +    // In the future we should refactor the use-element to avoid this. See https://webkit.org/b/53704 +    Vector<RefPtr<SVGSVGElement> > timeContainers; +    timeContainers.appendRange(m_timeContainers.begin(), m_timeContainers.end()); +    Vector<RefPtr<SVGSVGElement> >::iterator end = timeContainers.end(); +    for (Vector<RefPtr<SVGSVGElement> >::iterator itr = timeContainers.begin(); itr != end; ++itr)          (*itr)->timeContainer()->begin();  #endif  } diff --git a/Source/WebCore/svg/SVGElement.cpp b/Source/WebCore/svg/SVGElement.cpp index c9efae8..99134b2 100644 --- a/Source/WebCore/svg/SVGElement.cpp +++ b/Source/WebCore/svg/SVGElement.cpp @@ -256,6 +256,25 @@ void SVGElement::parseMappedAttribute(Attribute* attr)          StyledElement::parseMappedAttribute(attr);  } +AttributeToPropertyTypeMap& SVGElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +AnimatedAttributeType SVGElement::animatedPropertyTypeForAttribute(const QualifiedName& attrName) +{ +    AttributeToPropertyTypeMap& animatedAttributeMap = attributeToPropertyTypeMap(); +    if (animatedAttributeMap.isEmpty()) +        fillAttributeToPropertyTypeMap(); +    if (animatedAttributeMap.contains(attrName)) +        return animatedAttributeMap.get(attrName); +    if (isStyled()) +        return static_cast<SVGStyledElement*>(this)->animatedPropertyTypeForCSSProperty(attrName); + +    return AnimatedUnknown; +} +  bool SVGElement::haveLoadedRequiredResources()  {      Node* child = firstChild(); diff --git a/Source/WebCore/svg/SVGElement.h b/Source/WebCore/svg/SVGElement.h index 2c87f6e..ceb0973 100644 --- a/Source/WebCore/svg/SVGElement.h +++ b/Source/WebCore/svg/SVGElement.h @@ -25,9 +25,32 @@  #if ENABLE(SVG)  #include "SVGLocatable.h"  #include "StyledElement.h" +#include <wtf/HashMap.h>  namespace WebCore { +enum AnimatedAttributeType { +    AnimatedAngle, +    AnimatedBoolean, +    AnimatedColor, +    AnimatedEnumeration, +    AnimatedInteger, +    AnimatedLength, +    AnimatedLengthList, +    AnimatedNumber, +    AnimatedNumberList, +    AnimatedNumberOptionalNumber, +    AnimatedPath, +    AnimatedPoints, +    AnimatedPreserveAspectRatio, +    AnimatedRect, +    AnimatedString, +    AnimatedTransformList, +    AnimatedUnknown +}; + +typedef HashMap<QualifiedName, AnimatedAttributeType> AttributeToPropertyTypeMap; +  class CSSCursorImageValue;  class Document;  class SVGCursorElement; @@ -64,6 +87,11 @@ public:      virtual void svgAttributeChanged(const QualifiedName&) { }      virtual void synchronizeProperty(const QualifiedName&) { } +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap(); +    AnimatedAttributeType animatedPropertyTypeForAttribute(const QualifiedName&); + +    virtual void fillAttributeToPropertyTypeMap() { } +      void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);      virtual AffineTransform* supplementalTransform() { return 0; } diff --git a/Source/WebCore/svg/SVGEllipseElement.cpp b/Source/WebCore/svg/SVGEllipseElement.cpp index 4a12aa7..129e1cd 100644 --- a/Source/WebCore/svg/SVGEllipseElement.cpp +++ b/Source/WebCore/svg/SVGEllipseElement.cpp @@ -142,6 +142,23 @@ void SVGEllipseElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGEllipseElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGEllipseElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap);     +    attributeToPropertyTypeMap.set(SVGNames::cxAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::cyAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::rxAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::ryAttr, AnimatedLength); +} +  void SVGEllipseElement::toPathData(Path& path) const  {      ASSERT(path.isEmpty()); diff --git a/Source/WebCore/svg/SVGEllipseElement.h b/Source/WebCore/svg/SVGEllipseElement.h index 7ba2085..2c8a864 100644 --- a/Source/WebCore/svg/SVGEllipseElement.h +++ b/Source/WebCore/svg/SVGEllipseElement.h @@ -46,6 +46,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void toPathData(Path&) const; diff --git a/Source/WebCore/svg/SVGFEBlendElement.cpp b/Source/WebCore/svg/SVGFEBlendElement.cpp index 4128232..b0f580c 100644 --- a/Source/WebCore/svg/SVGFEBlendElement.cpp +++ b/Source/WebCore/svg/SVGFEBlendElement.cpp @@ -97,6 +97,22 @@ void SVGFEBlendElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeIn2();  } +AttributeToPropertyTypeMap& SVGFEBlendElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEBlendElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap);     +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::in2Attr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::modeAttr, AnimatedEnumeration); +} +  PassRefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFEBlendElement.h b/Source/WebCore/svg/SVGFEBlendElement.h index 292f385..c579ac5 100644 --- a/Source/WebCore/svg/SVGFEBlendElement.h +++ b/Source/WebCore/svg/SVGFEBlendElement.h @@ -38,6 +38,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      // Animated property declarations diff --git a/Source/WebCore/svg/SVGFEColorMatrixElement.cpp b/Source/WebCore/svg/SVGFEColorMatrixElement.cpp index 4c7ac0b..d3229d0 100644 --- a/Source/WebCore/svg/SVGFEColorMatrixElement.cpp +++ b/Source/WebCore/svg/SVGFEColorMatrixElement.cpp @@ -98,6 +98,22 @@ void SVGFEColorMatrixElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeValues();  } +AttributeToPropertyTypeMap& SVGFEColorMatrixElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEColorMatrixElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::typeAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::valuesAttr, AnimatedNumberList); +} +  PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFEColorMatrixElement.h b/Source/WebCore/svg/SVGFEColorMatrixElement.h index 04a8966..7bff011 100644 --- a/Source/WebCore/svg/SVGFEColorMatrixElement.h +++ b/Source/WebCore/svg/SVGFEColorMatrixElement.h @@ -39,6 +39,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      // Animated property declarations diff --git a/Source/WebCore/svg/SVGFEComponentTransferElement.cpp b/Source/WebCore/svg/SVGFEComponentTransferElement.cpp index 243f856..1b62ed9 100644 --- a/Source/WebCore/svg/SVGFEComponentTransferElement.cpp +++ b/Source/WebCore/svg/SVGFEComponentTransferElement.cpp @@ -64,6 +64,20 @@ void SVGFEComponentTransferElement::synchronizeProperty(const QualifiedName& att          synchronizeIn1();  } +AttributeToPropertyTypeMap& SVGFEComponentTransferElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEComponentTransferElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +} +  PassRefPtr<FilterEffect> SVGFEComponentTransferElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFEComponentTransferElement.h b/Source/WebCore/svg/SVGFEComponentTransferElement.h index ea7f84d..0b3608c 100644 --- a/Source/WebCore/svg/SVGFEComponentTransferElement.h +++ b/Source/WebCore/svg/SVGFEComponentTransferElement.h @@ -36,6 +36,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      // Animated property declarations diff --git a/Source/WebCore/svg/SVGFECompositeElement.cpp b/Source/WebCore/svg/SVGFECompositeElement.cpp index 4c83d4f..af738a9 100644 --- a/Source/WebCore/svg/SVGFECompositeElement.cpp +++ b/Source/WebCore/svg/SVGFECompositeElement.cpp @@ -127,6 +127,26 @@ void SVGFECompositeElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeK4();  } +AttributeToPropertyTypeMap& SVGFECompositeElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFECompositeElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap);     +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::in2Attr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::operatorAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::k1Attr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::k2Attr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::k3Attr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::k4Attr, AnimatedNumber); +} +  PassRefPtr<FilterEffect> SVGFECompositeElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFECompositeElement.h b/Source/WebCore/svg/SVGFECompositeElement.h index 6892220..a4a9617 100644 --- a/Source/WebCore/svg/SVGFECompositeElement.h +++ b/Source/WebCore/svg/SVGFECompositeElement.h @@ -39,6 +39,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      // Animated property declarations diff --git a/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp b/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp index 301e351..07ebc41 100644 --- a/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp +++ b/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp @@ -159,6 +159,29 @@ void SVGFEConvolveMatrixElement::svgAttributeChanged(const QualifiedName& attrNa          invalidate();  } +AttributeToPropertyTypeMap& SVGFEConvolveMatrixElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEConvolveMatrixElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::orderAttr, AnimatedNumberOptionalNumber); +    attributeToPropertyTypeMap.set(SVGNames::kernelMatrixAttr, AnimatedNumberList); +    attributeToPropertyTypeMap.set(SVGNames::divisorAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::biasAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::targetXAttr, AnimatedInteger); +    attributeToPropertyTypeMap.set(SVGNames::targetYAttr, AnimatedInteger); +    attributeToPropertyTypeMap.set(SVGNames::operatorAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::kernelUnitLengthAttr, AnimatedNumberOptionalNumber); +    attributeToPropertyTypeMap.set(SVGNames::preserveAlphaAttr, AnimatedBoolean); +} +  PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFEConvolveMatrixElement.h b/Source/WebCore/svg/SVGFEConvolveMatrixElement.h index 87709ab..ccc45ce 100644 --- a/Source/WebCore/svg/SVGFEConvolveMatrixElement.h +++ b/Source/WebCore/svg/SVGFEConvolveMatrixElement.h @@ -43,6 +43,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      static const AtomicString& orderXIdentifier(); diff --git a/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp b/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp index 49888da..1e86097 100644 --- a/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp +++ b/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp @@ -84,18 +84,69 @@ void SVGFEDiffuseLightingElement::parseMappedAttribute(Attribute* attr)          SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);  } +bool SVGFEDiffuseLightingElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName) +{ +    FEDiffuseLighting* diffuseLighting = static_cast<FEDiffuseLighting*>(effect); +    if (attrName == SVGNames::surfaceScaleAttr) +        return diffuseLighting->setSurfaceScale(surfaceScale()); +    if (attrName == SVGNames::diffuseConstantAttr) +        return diffuseLighting->setDiffuseConstant(diffuseConstant()); +    if (attrName == SVGNames::lighting_colorAttr) { +        RefPtr<RenderStyle> filterStyle = styleForRenderer(); +        return diffuseLighting->setLightingColor(filterStyle->svgStyle()->lightingColor()); +    } + +    LightSource* lightSource = const_cast<LightSource*>(diffuseLighting->lightSource()); +    const SVGFELightElement* lightElement = findLightElement(); + +    if (attrName == SVGNames::azimuthAttr) +        return lightSource->setAzimuth(lightElement->azimuth()); +    if (attrName == SVGNames::elevationAttr) +        return lightSource->setElevation(lightElement->elevation()); +    if (attrName == SVGNames::xAttr) +        return lightSource->setX(lightElement->x()); +    if (attrName == SVGNames::yAttr) +        return lightSource->setY(lightElement->y()); +    if (attrName == SVGNames::zAttr) +        return lightSource->setZ(lightElement->z()); +    if (attrName == SVGNames::pointsAtXAttr) +        return lightSource->setPointsAtX(lightElement->pointsAtX()); +    if (attrName == SVGNames::pointsAtYAttr) +        return lightSource->setPointsAtY(lightElement->pointsAtY()); +    if (attrName == SVGNames::pointsAtZAttr) +        return lightSource->setPointsAtZ(lightElement->pointsAtZ()); +    if (attrName == SVGNames::specularExponentAttr) +        return lightSource->setSpecularExponent(lightElement->specularExponent()); +    if (attrName == SVGNames::limitingConeAngleAttr) +        return lightSource->setLimitingConeAngle(lightElement->limitingConeAngle()); + +    ASSERT_NOT_REACHED(); +    return false; +} +  void SVGFEDiffuseLightingElement::svgAttributeChanged(const QualifiedName& attrName)  {      SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); -    if (attrName == SVGNames::inAttr -        || attrName == SVGNames::surfaceScaleAttr +    if (attrName == SVGNames::surfaceScaleAttr          || attrName == SVGNames::diffuseConstantAttr          || attrName == SVGNames::kernelUnitLengthAttr          || attrName == SVGNames::lighting_colorAttr) +        primitiveAttributeChanged(attrName); + +    if (attrName == SVGNames::inAttr)          invalidate();  } +void SVGFEDiffuseLightingElement::lightElementAttributeChanged(const SVGFELightElement* lightElement, const QualifiedName& attrName) +{ +    if (findLightElement() != lightElement) +        return; + +    // The light element has different attribute names. +    primitiveAttributeChanged(attrName); +} +  void SVGFEDiffuseLightingElement::synchronizeProperty(const QualifiedName& attrName)  {      SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName); @@ -121,6 +172,23 @@ void SVGFEDiffuseLightingElement::synchronizeProperty(const QualifiedName& attrN      }  } +AttributeToPropertyTypeMap& SVGFEDiffuseLightingElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEDiffuseLightingElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap);     +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::diffuseConstantAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::surfaceScaleAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::kernelUnitLengthAttr, AnimatedNumberOptionalNumber); +} +  PassRefPtr<FilterEffect> SVGFEDiffuseLightingElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); @@ -132,25 +200,31 @@ PassRefPtr<FilterEffect> SVGFEDiffuseLightingElement::build(SVGFilterBuilder* fi      Color color = filterStyle->svgStyle()->lightingColor();      RefPtr<FilterEffect> effect = FEDiffuseLighting::create(filter, color, surfaceScale(), diffuseConstant(),  -                                                                kernelUnitLengthX(), kernelUnitLengthY(), findLights()); +                                                                kernelUnitLengthX(), kernelUnitLengthY(), findLight());      effect->inputEffects().append(input1);      return effect.release();  } -PassRefPtr<LightSource> SVGFEDiffuseLightingElement::findLights() const +SVGFELightElement* SVGFEDiffuseLightingElement::findLightElement() const  {      for (Node* node = firstChild(); node; node = node->nextSibling()) {          if (node->hasTagName(SVGNames::feDistantLightTag)              || node->hasTagName(SVGNames::fePointLightTag)              || node->hasTagName(SVGNames::feSpotLightTag)) { -            SVGFELightElement* lightNode = static_cast<SVGFELightElement*>(node);  -            return lightNode->lightSource(); +            return static_cast<SVGFELightElement*>(node);          }      } -      return 0;  } +PassRefPtr<LightSource> SVGFEDiffuseLightingElement::findLight() const +{ +    SVGFELightElement* lightNode = findLightElement(); +    if (!lightNode) +        return 0; +    return lightNode->lightSource(); +} +  }  #endif // ENABLE(SVG) diff --git a/Source/WebCore/svg/SVGFEDiffuseLightingElement.h b/Source/WebCore/svg/SVGFEDiffuseLightingElement.h index d56ced9..5f698c2 100644 --- a/Source/WebCore/svg/SVGFEDiffuseLightingElement.h +++ b/Source/WebCore/svg/SVGFEDiffuseLightingElement.h @@ -34,13 +34,17 @@ class SVGColor;  class SVGFEDiffuseLightingElement : public SVGFilterPrimitiveStandardAttributes {  public:      static PassRefPtr<SVGFEDiffuseLightingElement> create(const QualifiedName&, Document*); +    void lightElementAttributeChanged(const SVGFELightElement*, const QualifiedName&);  private:      SVGFEDiffuseLightingElement(const QualifiedName&, Document*);      virtual void parseMappedAttribute(Attribute*); +    virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      static const AtomicString& kernelUnitLengthXIdentifier(); @@ -53,7 +57,8 @@ private:      DECLARE_ANIMATED_NUMBER(KernelUnitLengthX, kernelUnitLengthX)      DECLARE_ANIMATED_NUMBER(KernelUnitLengthY, kernelUnitLengthY) -    PassRefPtr<LightSource> findLights() const; +    SVGFELightElement* findLightElement() const; +    PassRefPtr<LightSource> findLight() const;  };  } // namespace WebCore diff --git a/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp b/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp index 56315b6..b5f2e32 100644 --- a/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp +++ b/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp @@ -116,6 +116,24 @@ void SVGFEDisplacementMapElement::synchronizeProperty(const QualifiedName& attrN          synchronizeScale();  } +AttributeToPropertyTypeMap& SVGFEDisplacementMapElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEDisplacementMapElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::in2Attr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::xChannelSelectorAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::yChannelSelectorAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::scaleAttr, AnimatedNumber); +} +  PassRefPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFEDisplacementMapElement.h b/Source/WebCore/svg/SVGFEDisplacementMapElement.h index 3af378c..c211de5 100644 --- a/Source/WebCore/svg/SVGFEDisplacementMapElement.h +++ b/Source/WebCore/svg/SVGFEDisplacementMapElement.h @@ -40,6 +40,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      // Animated property declarations diff --git a/Source/WebCore/svg/SVGFEFloodElement.cpp b/Source/WebCore/svg/SVGFEFloodElement.cpp index 53ad910..eb20927 100644 --- a/Source/WebCore/svg/SVGFEFloodElement.cpp +++ b/Source/WebCore/svg/SVGFEFloodElement.cpp @@ -49,6 +49,17 @@ PassRefPtr<FilterEffect> SVGFEFloodElement::build(SVGFilterBuilder*, Filter* fil      return FEFlood::create(filter, color, opacity);  } +AttributeToPropertyTypeMap& SVGFEFloodElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEFloodElement::fillAttributeToPropertyTypeMap() +{ +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap()); +} +  }  #endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/Source/WebCore/svg/SVGFEFloodElement.h b/Source/WebCore/svg/SVGFEFloodElement.h index 1485ddd..f7c7987 100644 --- a/Source/WebCore/svg/SVGFEFloodElement.h +++ b/Source/WebCore/svg/SVGFEFloodElement.h @@ -34,6 +34,8 @@ public:  private:      SVGFEFloodElement(const QualifiedName&, Document*); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);  }; diff --git a/Source/WebCore/svg/SVGFEGaussianBlurElement.cpp b/Source/WebCore/svg/SVGFEGaussianBlurElement.cpp index 03368ac..4bbfc3d 100644 --- a/Source/WebCore/svg/SVGFEGaussianBlurElement.cpp +++ b/Source/WebCore/svg/SVGFEGaussianBlurElement.cpp @@ -107,6 +107,21 @@ void SVGFEGaussianBlurElement::synchronizeProperty(const QualifiedName& attrName          synchronizeIn1();  } +AttributeToPropertyTypeMap& SVGFEGaussianBlurElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEGaussianBlurElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::stdDeviationAttr, AnimatedNumberOptionalNumber); +} +  PassRefPtr<FilterEffect> SVGFEGaussianBlurElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFEGaussianBlurElement.h b/Source/WebCore/svg/SVGFEGaussianBlurElement.h index 1b04658..0c8d8a3 100644 --- a/Source/WebCore/svg/SVGFEGaussianBlurElement.h +++ b/Source/WebCore/svg/SVGFEGaussianBlurElement.h @@ -40,6 +40,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      static const AtomicString& stdDeviationXIdentifier(); diff --git a/Source/WebCore/svg/SVGFEImageElement.cpp b/Source/WebCore/svg/SVGFEImageElement.cpp index 0fd4763..f33cd36 100644 --- a/Source/WebCore/svg/SVGFEImageElement.cpp +++ b/Source/WebCore/svg/SVGFEImageElement.cpp @@ -122,6 +122,21 @@ void SVGFEImageElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeExternalResourcesRequired();  } +AttributeToPropertyTypeMap& SVGFEImageElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEImageElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::preserveAspectRatioAttr, AnimatedPreserveAspectRatio); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +} +  void SVGFEImageElement::notifyFinished(CachedResource*)  {      if (!inDocument()) diff --git a/Source/WebCore/svg/SVGFEImageElement.h b/Source/WebCore/svg/SVGFEImageElement.h index 3f22805..8a63fc9 100644 --- a/Source/WebCore/svg/SVGFEImageElement.h +++ b/Source/WebCore/svg/SVGFEImageElement.h @@ -51,6 +51,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void notifyFinished(CachedResource*);      virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; diff --git a/Source/WebCore/svg/SVGFELightElement.cpp b/Source/WebCore/svg/SVGFELightElement.cpp index 8ff8eb1..58a2f26 100644 --- a/Source/WebCore/svg/SVGFELightElement.cpp +++ b/Source/WebCore/svg/SVGFELightElement.cpp @@ -27,7 +27,9 @@  #include "Attribute.h"  #include "RenderObject.h"  #include "RenderSVGResource.h" +#include "SVGFEDiffuseLightingElement.h"  #include "SVGFilterElement.h" +#include "SVGFilterPrimitiveStandardAttributes.h"  #include "SVGNames.h"  namespace WebCore { @@ -91,11 +93,21 @@ void SVGFELightElement::svgAttributeChanged(const QualifiedName& attrName)          || attrName == SVGNames::pointsAtZAttr          || attrName == SVGNames::specularExponentAttr          || attrName == SVGNames::limitingConeAngleAttr) { -        if (ContainerNode* parent = parentNode()) { -            RenderObject* renderer = parent->renderer(); -            if (renderer && renderer->isSVGResourceFilterPrimitive()) -                RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); +        ContainerNode* parent = parentNode(); +        if (!parent) +            return; + +        RenderObject* renderer = parent->renderer(); +        if (!renderer || !renderer->isSVGResourceFilterPrimitive()) +            return; + +        if (parent->hasTagName(SVGNames::feDiffuseLightingTag)) { +            SVGFEDiffuseLightingElement* diffuseLighting = static_cast<SVGFEDiffuseLightingElement*>(parent); +            diffuseLighting->lightElementAttributeChanged(this, attrName); +            return;          } +        // Handler for SpecularLighting has not implemented yet. +        RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);      }  } @@ -139,6 +151,27 @@ void SVGFELightElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeLimitingConeAngle();  } +AttributeToPropertyTypeMap& SVGFELightElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFELightElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); +    attributeToPropertyTypeMap.set(SVGNames::azimuthAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::elevationAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::zAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::pointsAtXAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::pointsAtYAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::pointsAtZAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::specularExponentAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::limitingConeAngleAttr, AnimatedNumber); +} +  void SVGFELightElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)  {      SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); diff --git a/Source/WebCore/svg/SVGFELightElement.h b/Source/WebCore/svg/SVGFELightElement.h index 2f6e687..606a499 100644 --- a/Source/WebCore/svg/SVGFELightElement.h +++ b/Source/WebCore/svg/SVGFELightElement.h @@ -40,6 +40,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);      // Animated property declarations diff --git a/Source/WebCore/svg/SVGFEMergeElement.cpp b/Source/WebCore/svg/SVGFEMergeElement.cpp index 8b1c753..f94acaa 100644 --- a/Source/WebCore/svg/SVGFEMergeElement.cpp +++ b/Source/WebCore/svg/SVGFEMergeElement.cpp @@ -59,6 +59,17 @@ PassRefPtr<FilterEffect> SVGFEMergeElement::build(SVGFilterBuilder* filterBuilde      return effect.release();  } +AttributeToPropertyTypeMap& SVGFEMergeElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEMergeElement::fillAttributeToPropertyTypeMap() +{ +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap()); +} +  }  #endif // ENABLE(SVG) diff --git a/Source/WebCore/svg/SVGFEMergeElement.h b/Source/WebCore/svg/SVGFEMergeElement.h index 2495a56..8241ea8 100644 --- a/Source/WebCore/svg/SVGFEMergeElement.h +++ b/Source/WebCore/svg/SVGFEMergeElement.h @@ -34,6 +34,8 @@ public:  private:      SVGFEMergeElement(const QualifiedName&, Document*); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);  }; diff --git a/Source/WebCore/svg/SVGFEMergeNodeElement.cpp b/Source/WebCore/svg/SVGFEMergeNodeElement.cpp index 83739de..b6e9f84 100644 --- a/Source/WebCore/svg/SVGFEMergeNodeElement.cpp +++ b/Source/WebCore/svg/SVGFEMergeNodeElement.cpp @@ -71,6 +71,17 @@ void SVGFEMergeNodeElement::svgAttributeChanged(const QualifiedName& attrName)      RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);  } +AttributeToPropertyTypeMap& SVGFEMergeNodeElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEMergeNodeElement::fillAttributeToPropertyTypeMap() +{ +    attributeToPropertyTypeMap().set(SVGNames::inAttr, AnimatedString); +} +  void SVGFEMergeNodeElement::synchronizeProperty(const QualifiedName& attrName)  {      SVGElement::synchronizeProperty(attrName); diff --git a/Source/WebCore/svg/SVGFEMergeNodeElement.h b/Source/WebCore/svg/SVGFEMergeNodeElement.h index 14f0e8e..d986829 100644 --- a/Source/WebCore/svg/SVGFEMergeNodeElement.h +++ b/Source/WebCore/svg/SVGFEMergeNodeElement.h @@ -37,6 +37,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      // Animated property declarations      DECLARE_ANIMATED_STRING(In1, in1) diff --git a/Source/WebCore/svg/SVGFEMorphologyElement.cpp b/Source/WebCore/svg/SVGFEMorphologyElement.cpp index caf8e7b..1a44e3c 100644 --- a/Source/WebCore/svg/SVGFEMorphologyElement.cpp +++ b/Source/WebCore/svg/SVGFEMorphologyElement.cpp @@ -118,6 +118,22 @@ void SVGFEMorphologyElement::synchronizeProperty(const QualifiedName& attrName)      }  } +AttributeToPropertyTypeMap& SVGFEMorphologyElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEMorphologyElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::operatorAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::radiusAttr, AnimatedNumberOptionalNumber); +} +  PassRefPtr<FilterEffect> SVGFEMorphologyElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFEMorphologyElement.h b/Source/WebCore/svg/SVGFEMorphologyElement.h index 77190e6..931288f 100644 --- a/Source/WebCore/svg/SVGFEMorphologyElement.h +++ b/Source/WebCore/svg/SVGFEMorphologyElement.h @@ -40,6 +40,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      static const AtomicString& radiusXIdentifier(); diff --git a/Source/WebCore/svg/SVGFEOffsetElement.cpp b/Source/WebCore/svg/SVGFEOffsetElement.cpp index 2bd8aee..03b3be3 100644 --- a/Source/WebCore/svg/SVGFEOffsetElement.cpp +++ b/Source/WebCore/svg/SVGFEOffsetElement.cpp @@ -87,6 +87,22 @@ void SVGFEOffsetElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeIn1();  } +AttributeToPropertyTypeMap& SVGFEOffsetElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFEOffsetElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::dxAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::dyAttr, AnimatedNumber); +} +  PassRefPtr<FilterEffect> SVGFEOffsetElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFEOffsetElement.h b/Source/WebCore/svg/SVGFEOffsetElement.h index 2092df2..e5b6fd1 100644 --- a/Source/WebCore/svg/SVGFEOffsetElement.h +++ b/Source/WebCore/svg/SVGFEOffsetElement.h @@ -38,6 +38,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      // Animated property declarations diff --git a/Source/WebCore/svg/SVGFESpecularLightingElement.cpp b/Source/WebCore/svg/SVGFESpecularLightingElement.cpp index 9298b3c..f4f2648 100644 --- a/Source/WebCore/svg/SVGFESpecularLightingElement.cpp +++ b/Source/WebCore/svg/SVGFESpecularLightingElement.cpp @@ -89,6 +89,18 @@ void SVGFESpecularLightingElement::parseMappedAttribute(Attribute* attr)          SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);  } +void SVGFESpecularLightingElement::svgAttributeChanged(const QualifiedName& attrName) +{ +    SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); + +    if (attrName == SVGNames::inAttr +        || attrName == SVGNames::surfaceScaleAttr +        || attrName == SVGNames::specularConstantAttr +        || attrName == SVGNames::specularExponentAttr +        || attrName == SVGNames::kernelUnitLengthAttr) +        invalidate(); +} +  void SVGFESpecularLightingElement::synchronizeProperty(const QualifiedName& attrName)  {      SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName); @@ -117,6 +129,24 @@ void SVGFESpecularLightingElement::synchronizeProperty(const QualifiedName& attr      }  } +AttributeToPropertyTypeMap& SVGFESpecularLightingElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFESpecularLightingElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::specularConstantAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::specularExponentAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::surfaceScaleAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::kernelUnitLengthAttr, AnimatedNumberOptionalNumber); +} +  PassRefPtr<LightSource> SVGFESpecularLightingElement::findLights() const  {      for (Node* node = firstChild(); node; node = node->nextSibling()) { diff --git a/Source/WebCore/svg/SVGFESpecularLightingElement.h b/Source/WebCore/svg/SVGFESpecularLightingElement.h index ace3a3e..9914123 100644 --- a/Source/WebCore/svg/SVGFESpecularLightingElement.h +++ b/Source/WebCore/svg/SVGFESpecularLightingElement.h @@ -37,7 +37,10 @@ private:      SVGFESpecularLightingElement(const QualifiedName&, Document*);      virtual void parseMappedAttribute(Attribute*); +    virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      static const AtomicString& kernelUnitLengthXIdentifier(); diff --git a/Source/WebCore/svg/SVGFETileElement.cpp b/Source/WebCore/svg/SVGFETileElement.cpp index 6fc19e6..7ed6ca0 100644 --- a/Source/WebCore/svg/SVGFETileElement.cpp +++ b/Source/WebCore/svg/SVGFETileElement.cpp @@ -69,6 +69,20 @@ void SVGFETileElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeIn1();  } +AttributeToPropertyTypeMap& SVGFETileElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFETileElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::inAttr, AnimatedString); +} +  PassRefPtr<FilterEffect> SVGFETileElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)  {      FilterEffect* input1 = filterBuilder->getEffectById(in1()); diff --git a/Source/WebCore/svg/SVGFETileElement.h b/Source/WebCore/svg/SVGFETileElement.h index f47d355..447827c 100644 --- a/Source/WebCore/svg/SVGFETileElement.h +++ b/Source/WebCore/svg/SVGFETileElement.h @@ -37,6 +37,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      // Animated property declarations diff --git a/Source/WebCore/svg/SVGFETurbulenceElement.cpp b/Source/WebCore/svg/SVGFETurbulenceElement.cpp index 0f59bf7..2eaf1fc 100644 --- a/Source/WebCore/svg/SVGFETurbulenceElement.cpp +++ b/Source/WebCore/svg/SVGFETurbulenceElement.cpp @@ -128,6 +128,24 @@ void SVGFETurbulenceElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeNumOctaves();  } +AttributeToPropertyTypeMap& SVGFETurbulenceElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFETurbulenceElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::baseFrequencyAttr, AnimatedNumberOptionalNumber); +    attributeToPropertyTypeMap.set(SVGNames::numOctavesAttr, AnimatedInteger); +    attributeToPropertyTypeMap.set(SVGNames::seedAttr, AnimatedNumber); +    attributeToPropertyTypeMap.set(SVGNames::stitchTilesAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::typeAttr, AnimatedEnumeration); +} +  PassRefPtr<FilterEffect> SVGFETurbulenceElement::build(SVGFilterBuilder*, Filter* filter)  {      if (baseFrequencyX() < 0 || baseFrequencyY() < 0) diff --git a/Source/WebCore/svg/SVGFETurbulenceElement.h b/Source/WebCore/svg/SVGFETurbulenceElement.h index f9d86cb..5e8a8b6 100644 --- a/Source/WebCore/svg/SVGFETurbulenceElement.h +++ b/Source/WebCore/svg/SVGFETurbulenceElement.h @@ -46,6 +46,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);      static const AtomicString& baseFrequencyXIdentifier(); diff --git a/Source/WebCore/svg/SVGFilterElement.cpp b/Source/WebCore/svg/SVGFilterElement.cpp index 03ff7fa..539d4df 100644 --- a/Source/WebCore/svg/SVGFilterElement.cpp +++ b/Source/WebCore/svg/SVGFilterElement.cpp @@ -196,6 +196,27 @@ void SVGFilterElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeHref();  } +AttributeToPropertyTypeMap& SVGFilterElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFilterElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::filterUnitsAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::primitiveUnitsAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::widthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::heightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::filterResAttr, AnimatedNumberOptionalNumber); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedEnumeration); +} +  void SVGFilterElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)  {      SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); diff --git a/Source/WebCore/svg/SVGFilterElement.h b/Source/WebCore/svg/SVGFilterElement.h index a438625..4851296 100644 --- a/Source/WebCore/svg/SVGFilterElement.h +++ b/Source/WebCore/svg/SVGFilterElement.h @@ -53,6 +53,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); diff --git a/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp b/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp index 00f99c5..d34a130 100644 --- a/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp +++ b/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp @@ -70,6 +70,13 @@ void SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(Attribute* attr)          return SVGStyledElement::parseMappedAttribute(attr);  } +bool SVGFilterPrimitiveStandardAttributes::setFilterEffectAttribute(FilterEffect*, const QualifiedName&) +{ +    // When all filters support this method, it will be changed to a pure virtual method. +    ASSERT_NOT_REACHED(); +    return false; +} +  void SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(const QualifiedName& attrName)  {      SVGStyledElement::svgAttributeChanged(attrName); @@ -145,6 +152,17 @@ void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(bool primitiveB      filterEffect->setEffectBoundaries(effectBBox);  } +void SVGFilterPrimitiveStandardAttributes::fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap& attributeToPropertyTypeMap) +{ +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +     +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::widthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::heightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::resultAttr, AnimatedString); +} +  RenderObject* SVGFilterPrimitiveStandardAttributes::createRenderer(RenderArena* arena, RenderStyle*)  {      return new (arena) RenderSVGResourceFilterPrimitive(this); diff --git a/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h b/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h index 34e19ea..526592a 100644 --- a/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h +++ b/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h @@ -22,7 +22,8 @@  #define SVGFilterPrimitiveStandardAttributes_h  #if ENABLE(SVG) && ENABLE(FILTERS) -#include "RenderSVGResource.h" +#include "RenderSVGResourceFilter.h" +#include "RenderSVGResourceFilterPrimitive.h"  #include "SVGAnimatedLength.h"  #include "SVGAnimatedString.h"  #include "SVGStyledElement.h" @@ -41,6 +42,8 @@ public:      void setStandardAttributes(bool, FilterEffect*) const;      virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter* filter) = 0; +    // Returns true, if the new value is different from the old one. +    virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&);  protected:      SVGFilterPrimitiveStandardAttributes(const QualifiedName&, Document*); @@ -48,15 +51,21 @@ protected:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    void fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap&);      virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); -protected:      inline void invalidate()      {          if (RenderObject* primitiveRenderer = renderer())              RenderSVGResource::markForLayoutAndParentResourceInvalidation(primitiveRenderer);      } +    inline void primitiveAttributeChanged(const QualifiedName& attribute) +    { +        if (RenderObject* primitiveRenderer = renderer()) +            static_cast<RenderSVGResourceFilterPrimitive*>(primitiveRenderer)->primitiveAttributeChanged(attribute); +    } +  private:      virtual bool isFilterEffect() const { return true; } diff --git a/Source/WebCore/svg/SVGFont.cpp b/Source/WebCore/svg/SVGFont.cpp index e5164c0..a92b9b6 100644 --- a/Source/WebCore/svg/SVGFont.cpp +++ b/Source/WebCore/svg/SVGFont.cpp @@ -26,6 +26,7 @@  #include "CSSFontSelector.h"  #include "GraphicsContext.h"  #include "RenderObject.h" +#include "RenderSVGInlineText.h"  #include "RenderSVGResourceSolidColor.h"  #include "SVGAltGlyphElement.h"  #include "SVGFontData.h" @@ -243,7 +244,7 @@ struct SVGTextRunWalker {      {          ASSERT(0 <= from && from <= to && to - from <= run.length()); -        const String text = Font::normalizeSpaces(String(run.data(from), run.length())); +        const String text = Font::normalizeSpaces(run.data(from), to - from);          Vector<SVGGlyphIdentifier::ArabicForm> chars(charactersWithArabicForm(text, run.rtl()));          SVGGlyphIdentifier identifier; @@ -254,8 +255,10 @@ struct SVGTextRunWalker {          bool haveAltGlyph = false;          SVGGlyphIdentifier altGlyphIdentifier;          if (RenderObject* renderObject = run.referencingRenderObject()) { -            if (renderObject->node() && renderObject->node()->hasTagName(SVGNames::altGlyphTag)) { -                SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(renderObject->node())->glyphElement(); +            RenderObject* parentRenderer = renderObject->parent(); +            ASSERT(parentRenderer); +            if (parentRenderer->node() && parentRenderer->node()->hasTagName(SVGNames::altGlyphTag)) { +                SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(parentRenderer->node())->glyphElement();                  if (glyphElement) {                      haveAltGlyph = true;                      altGlyphIdentifier = glyphElement->buildGlyphIdentifier(); @@ -271,7 +274,7 @@ struct SVGTextRunWalker {              // extended to the n-th next character (where n is 'characterLookupRange'), to check for any possible ligature.              characterLookupRange = endOfScanRange - i; -            String lookupString = Font::normalizeSpaces(String(run.data(i), characterLookupRange)); +            String lookupString = Font::normalizeSpaces(run.data(i), characterLookupRange);              Vector<SVGGlyphIdentifier> glyphs;              if (haveAltGlyph) @@ -407,9 +410,11 @@ static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun&          // TODO: language matching & svg glyphs should be possible for HTML text, too.          if (RenderObject* renderObject = run.referencingRenderObject()) { -            isVerticalText = isVerticalWritingMode(renderObject->style()->svgStyle()); +            RenderObject* parentRenderer = renderObject->parent(); +            ASSERT(parentRenderer); +            isVerticalText = isVerticalWritingMode(parentRenderer->style()->svgStyle()); -            if (SVGElement* element = static_cast<SVGElement*>(renderObject->node())) +            if (SVGElement* element = static_cast<SVGElement*>(parentRenderer->node()))                  language = element->getAttribute(XMLNames::langAttr);          } @@ -495,10 +500,15 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,          String language;          // TODO: language matching & svg glyphs should be possible for HTML text, too. -        if (run.referencingRenderObject()) { -            isVerticalText = isVerticalWritingMode(run.referencingRenderObject()->style()->svgStyle());     - -            if (SVGElement* element = static_cast<SVGElement*>(run.referencingRenderObject()->node())) +        RenderObject* referencingRenderObject = run.referencingRenderObject(); +        RenderObject* referencingRenderObjectParent = referencingRenderObject ? referencingRenderObject->parent() : 0; +        RenderStyle* referencingRenderObjectParentStyle = 0; +        if (referencingRenderObject) { +            ASSERT(referencingRenderObjectParent); +            referencingRenderObjectParentStyle = referencingRenderObjectParent->style(); + +            isVerticalText = isVerticalWritingMode(referencingRenderObjectParentStyle->svgStyle());     +            if (SVGElement* element = static_cast<SVGElement*>(referencingRenderObjectParent->node()))                  language = element->getAttribute(XMLNames::langAttr);          } @@ -536,9 +546,13 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,                      Path glyphPath = identifier.pathData;                      glyphPath.transform(glyphPathTransform); -                    RenderStyle* style = run.referencingRenderObject() ? run.referencingRenderObject()->style() : 0; -                    if (activePaintingResource->applyResource(run.referencingRenderObject(), style, context, resourceMode)) -                        activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode, &glyphPath); +                    if (activePaintingResource->applyResource(referencingRenderObjectParent, referencingRenderObjectParentStyle, context, resourceMode)) { +                        if (referencingRenderObject) { +                            RenderSVGInlineText* textRenderer = toRenderSVGInlineText(referencingRenderObject); +                            context->setStrokeThickness(context->strokeThickness() * textRenderer->scalingFactor()); +                        } +                        activePaintingResource->postApplyResource(referencingRenderObjectParent, context, resourceMode, &glyphPath); +                    }                      context->restore();                  } diff --git a/Source/WebCore/svg/SVGFontElement.cpp b/Source/WebCore/svg/SVGFontElement.cpp index d70d46a..2d67c51 100644 --- a/Source/WebCore/svg/SVGFontElement.cpp +++ b/Source/WebCore/svg/SVGFontElement.cpp @@ -179,6 +179,17 @@ void SVGFontElement::getGlyphIdentifiersForString(const String& string, Vector<S      m_glyphMap.get(string, glyphs);  } +AttributeToPropertyTypeMap& SVGFontElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGFontElement::fillAttributeToPropertyTypeMap() +{ +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap()); +} +  }  #endif // ENABLE(SVG_FONTS) diff --git a/Source/WebCore/svg/SVGFontElement.h b/Source/WebCore/svg/SVGFontElement.h index b2de38c..1559f43 100644 --- a/Source/WebCore/svg/SVGFontElement.h +++ b/Source/WebCore/svg/SVGFontElement.h @@ -70,7 +70,9 @@ private:      SVGFontElement(const QualifiedName&, Document*);      virtual void synchronizeProperty(const QualifiedName&); -    virtual bool rendererIsNeeded(RenderStyle*) { return false; }     +    virtual bool rendererIsNeeded(RenderStyle*) { return false; }   +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      void ensureGlyphCache() const; diff --git a/Source/WebCore/svg/SVGFontFaceElement.cpp b/Source/WebCore/svg/SVGFontFaceElement.cpp index ef7f5bd..68be2c6 100644 --- a/Source/WebCore/svg/SVGFontFaceElement.cpp +++ b/Source/WebCore/svg/SVGFontFaceElement.cpp @@ -125,7 +125,7 @@ unsigned SVGFontFaceElement::unitsPerEm() const  {      const AtomicString& value = getAttribute(units_per_emAttr);      if (value.isEmpty()) -        return defaultUnitsPerEm; +        return gDefaultUnitsPerEm;      return static_cast<unsigned>(ceilf(value.toFloat()));  } @@ -261,6 +261,11 @@ String SVGFontFaceElement::fontFamily() const      return m_styleDeclaration->getPropertyValue(CSSPropertyFontFamily);  } +SVGFontElement* SVGFontFaceElement::associatedFontElement() const +{ +    return m_fontElement.get(); +} +  void SVGFontFaceElement::rebuildFontFace()  {      if (!inDocument()) diff --git a/Source/WebCore/svg/SVGFontFaceElement.h b/Source/WebCore/svg/SVGFontFaceElement.h index 5e974a7..168f21c 100644 --- a/Source/WebCore/svg/SVGFontFaceElement.h +++ b/Source/WebCore/svg/SVGFontFaceElement.h @@ -47,7 +47,7 @@ public:      int descent() const;      String fontFamily() const; -    SVGFontElement* associatedFontElement() const { return m_fontElement; } +    SVGFontElement* associatedFontElement() const;      void rebuildFontFace();      void removeFromMappedElementSheet(); @@ -63,7 +63,7 @@ private:      RefPtr<CSSFontFaceRule> m_fontFaceRule;      RefPtr<CSSMutableStyleDeclaration> m_styleDeclaration; -    SVGFontElement* m_fontElement; +    RefPtr<SVGFontElement> m_fontElement;  };  } // namespace WebCore diff --git a/Source/WebCore/svg/SVGForeignObjectElement.cpp b/Source/WebCore/svg/SVGForeignObjectElement.cpp index 6b5cd41..f2175ac 100644 --- a/Source/WebCore/svg/SVGForeignObjectElement.cpp +++ b/Source/WebCore/svg/SVGForeignObjectElement.cpp @@ -137,6 +137,24 @@ void SVGForeignObjectElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGForeignObjectElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGForeignObjectElement::fillAttributeToPropertyTypeMap() +{     +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::widthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::heightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +} +  RenderObject* SVGForeignObjectElement::createRenderer(RenderArena* arena, RenderStyle*)  {      return new (arena) RenderSVGForeignObject(this); diff --git a/Source/WebCore/svg/SVGForeignObjectElement.h b/Source/WebCore/svg/SVGForeignObjectElement.h index 687d089..82f21b4 100644 --- a/Source/WebCore/svg/SVGForeignObjectElement.h +++ b/Source/WebCore/svg/SVGForeignObjectElement.h @@ -45,6 +45,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual bool childShouldCreateRenderer(Node*) const;      virtual RenderObject* createRenderer(RenderArena* arena, RenderStyle* style); diff --git a/Source/WebCore/svg/SVGGlyphElement.cpp b/Source/WebCore/svg/SVGGlyphElement.cpp index a64d833..9913f5f 100644 --- a/Source/WebCore/svg/SVGGlyphElement.cpp +++ b/Source/WebCore/svg/SVGGlyphElement.cpp @@ -132,6 +132,20 @@ static inline float parseSVGGlyphAttribute(const SVGElement* element, const WebC      return value.toFloat();  } +AttributeToPropertyTypeMap& SVGGlyphElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGGlyphElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::dAttr, AnimatedPath); +} +  SVGGlyphIdentifier SVGGlyphElement::buildGenericGlyphIdentifier(const SVGElement* element)  {      SVGGlyphIdentifier identifier; diff --git a/Source/WebCore/svg/SVGGlyphElement.h b/Source/WebCore/svg/SVGGlyphElement.h index 4ac5d9b..a79da4b 100644 --- a/Source/WebCore/svg/SVGGlyphElement.h +++ b/Source/WebCore/svg/SVGGlyphElement.h @@ -117,6 +117,8 @@ private:      SVGGlyphElement(const QualifiedName&, Document*);      virtual void parseMappedAttribute(Attribute*); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void insertedIntoDocument();      virtual void removedFromDocument(); diff --git a/Source/WebCore/svg/SVGGradientElement.cpp b/Source/WebCore/svg/SVGGradientElement.cpp index f36fea5..67eb8fb 100644 --- a/Source/WebCore/svg/SVGGradientElement.cpp +++ b/Source/WebCore/svg/SVGGradientElement.cpp @@ -124,6 +124,16 @@ void SVGGradientElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeHref();  } +void SVGGradientElement::fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap& attributeToPropertyTypeMap) +{ +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); + +    attributeToPropertyTypeMap.set(SVGNames::spreadMethodAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::gradientUnitsAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::gradientTransformAttr, AnimatedTransformList); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +} +      void SVGGradientElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)  {      SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); diff --git a/Source/WebCore/svg/SVGGradientElement.h b/Source/WebCore/svg/SVGGradientElement.h index 1fd1f0b..09da5b0 100644 --- a/Source/WebCore/svg/SVGGradientElement.h +++ b/Source/WebCore/svg/SVGGradientElement.h @@ -44,6 +44,7 @@ protected:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    void fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap&);  private:      virtual bool needsPendingResourceHandling() const { return false; } diff --git a/Source/WebCore/svg/SVGImageElement.cpp b/Source/WebCore/svg/SVGImageElement.cpp index 80bf34b..784c1ab 100644 --- a/Source/WebCore/svg/SVGImageElement.cpp +++ b/Source/WebCore/svg/SVGImageElement.cpp @@ -164,6 +164,25 @@ void SVGImageElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGImageElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGImageElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::widthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::heightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::preserveAspectRatioAttr, AnimatedPreserveAspectRatio); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +} +  bool SVGImageElement::selfHasRelativeLengths() const  {      return x().isRelative() diff --git a/Source/WebCore/svg/SVGImageElement.h b/Source/WebCore/svg/SVGImageElement.h index 06e6490..ec67823 100644 --- a/Source/WebCore/svg/SVGImageElement.h +++ b/Source/WebCore/svg/SVGImageElement.h @@ -50,6 +50,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void attach();      virtual void insertedIntoDocument(); diff --git a/Source/WebCore/svg/SVGLength.cpp b/Source/WebCore/svg/SVGLength.cpp index 6d75f8b..281ee14 100644 --- a/Source/WebCore/svg/SVGLength.cpp +++ b/Source/WebCore/svg/SVGLength.cpp @@ -438,7 +438,7 @@ float SVGLength::convertValueFromUserUnitsToEXS(float value, const SVGElement* c      // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg      // if this causes problems in real world cases maybe it would be best to remove this -    float xHeight = ceilf(style->font().xHeight()); +    float xHeight = ceilf(style->fontMetrics().xHeight());      if (!xHeight) {          ec = NOT_SUPPORTED_ERR;          return 0; @@ -457,7 +457,7 @@ float SVGLength::convertValueFromEXSToUserUnits(float value, const SVGElement* c      RenderStyle* style = context->renderer()->style();      // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg      // if this causes problems in real world cases maybe it would be best to remove this -    return value * ceilf(style->font().xHeight()); +    return value * ceilf(style->fontMetrics().xHeight());  }  SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value) diff --git a/Source/WebCore/svg/SVGLineElement.cpp b/Source/WebCore/svg/SVGLineElement.cpp index cfe43da..2e435c5 100644 --- a/Source/WebCore/svg/SVGLineElement.cpp +++ b/Source/WebCore/svg/SVGLineElement.cpp @@ -138,6 +138,23 @@ void SVGLineElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGLineElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGLineElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::x1Attr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::y1Attr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::x2Attr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::y2Attr, AnimatedLength); +} +  void SVGLineElement::toPathData(Path& path) const  {      ASSERT(path.isEmpty()); diff --git a/Source/WebCore/svg/SVGLineElement.h b/Source/WebCore/svg/SVGLineElement.h index ad60a95..4ba4ec1 100644 --- a/Source/WebCore/svg/SVGLineElement.h +++ b/Source/WebCore/svg/SVGLineElement.h @@ -46,6 +46,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void toPathData(Path&) const; diff --git a/Source/WebCore/svg/SVGLinearGradientElement.cpp b/Source/WebCore/svg/SVGLinearGradientElement.cpp index 5bece06..c109b4f 100644 --- a/Source/WebCore/svg/SVGLinearGradientElement.cpp +++ b/Source/WebCore/svg/SVGLinearGradientElement.cpp @@ -114,6 +114,23 @@ void SVGLinearGradientElement::synchronizeProperty(const QualifiedName& attrName          synchronizeY2();  } +AttributeToPropertyTypeMap& SVGLinearGradientElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGLinearGradientElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGGradientElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::x1Attr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::y1Attr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::x2Attr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::y2Attr, AnimatedLength); +} +  RenderObject* SVGLinearGradientElement::createRenderer(RenderArena* arena, RenderStyle*)  {      return new (arena) RenderSVGResourceLinearGradient(this); diff --git a/Source/WebCore/svg/SVGLinearGradientElement.h b/Source/WebCore/svg/SVGLinearGradientElement.h index 198f0ee..1c91556 100644 --- a/Source/WebCore/svg/SVGLinearGradientElement.h +++ b/Source/WebCore/svg/SVGLinearGradientElement.h @@ -42,6 +42,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); diff --git a/Source/WebCore/svg/SVGMPathElement.cpp b/Source/WebCore/svg/SVGMPathElement.cpp index 0df262e..9cc3c56 100644 --- a/Source/WebCore/svg/SVGMPathElement.cpp +++ b/Source/WebCore/svg/SVGMPathElement.cpp @@ -65,6 +65,17 @@ void SVGMPathElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeHref();  } +AttributeToPropertyTypeMap& SVGMPathElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGMPathElement::fillAttributeToPropertyTypeMap() +{ +    attributeToPropertyTypeMap().set(XLinkNames::hrefAttr, AnimatedString); +} +  SVGPathElement* SVGMPathElement::pathElement()  {      Element* target = document()->getElementById(getTarget(href())); diff --git a/Source/WebCore/svg/SVGMPathElement.h b/Source/WebCore/svg/SVGMPathElement.h index 2fa7c28..ad59650 100644 --- a/Source/WebCore/svg/SVGMPathElement.h +++ b/Source/WebCore/svg/SVGMPathElement.h @@ -43,6 +43,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      // Animated property declarations diff --git a/Source/WebCore/svg/SVGMarkerElement.cpp b/Source/WebCore/svg/SVGMarkerElement.cpp index 3174711..c255a9b 100644 --- a/Source/WebCore/svg/SVGMarkerElement.cpp +++ b/Source/WebCore/svg/SVGMarkerElement.cpp @@ -183,6 +183,26 @@ void SVGMarkerElement::synchronizeProperty(const QualifiedName& attrName)      }  } +AttributeToPropertyTypeMap& SVGMarkerElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGMarkerElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::refXAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::refYAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::markerWidthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::markerHeightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::markerUnitsAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::orientAttr, AnimatedAngle); +    attributeToPropertyTypeMap.set(SVGNames::viewBoxAttr, AnimatedRect); +} +  void SVGMarkerElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)  {      SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); diff --git a/Source/WebCore/svg/SVGMarkerElement.h b/Source/WebCore/svg/SVGMarkerElement.h index 472baa6..2275480 100644 --- a/Source/WebCore/svg/SVGMarkerElement.h +++ b/Source/WebCore/svg/SVGMarkerElement.h @@ -67,6 +67,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); diff --git a/Source/WebCore/svg/SVGMaskElement.cpp b/Source/WebCore/svg/SVGMaskElement.cpp index ec23e29..d5df621 100644 --- a/Source/WebCore/svg/SVGMaskElement.cpp +++ b/Source/WebCore/svg/SVGMaskElement.cpp @@ -148,6 +148,25 @@ void SVGMaskElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGMaskElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGMaskElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledLocatableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::widthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::heightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::maskUnitsAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::maskContentUnitsAttr, AnimatedEnumeration); +} +  void SVGMaskElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)  {      SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); diff --git a/Source/WebCore/svg/SVGMaskElement.h b/Source/WebCore/svg/SVGMaskElement.h index 87e91ff..1add472 100644 --- a/Source/WebCore/svg/SVGMaskElement.h +++ b/Source/WebCore/svg/SVGMaskElement.h @@ -49,6 +49,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); diff --git a/Source/WebCore/svg/SVGMissingGlyphElement.cpp b/Source/WebCore/svg/SVGMissingGlyphElement.cpp index 4c80494..9741231 100644 --- a/Source/WebCore/svg/SVGMissingGlyphElement.cpp +++ b/Source/WebCore/svg/SVGMissingGlyphElement.cpp @@ -34,6 +34,17 @@ PassRefPtr<SVGMissingGlyphElement> SVGMissingGlyphElement::create(const Qualifie      return adoptRef(new SVGMissingGlyphElement(tagName, document));  } +AttributeToPropertyTypeMap& SVGMissingGlyphElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGMissingGlyphElement::fillAttributeToPropertyTypeMap() +{ +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap()); +} +  }  #endif // ENABLE(SVG_FONTS) diff --git a/Source/WebCore/svg/SVGMissingGlyphElement.h b/Source/WebCore/svg/SVGMissingGlyphElement.h index a133d6d..528c53c 100644 --- a/Source/WebCore/svg/SVGMissingGlyphElement.h +++ b/Source/WebCore/svg/SVGMissingGlyphElement.h @@ -32,6 +32,9 @@ public:  private:      SVGMissingGlyphElement(const QualifiedName&, Document*); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap(); +      virtual bool rendererIsNeeded(RenderStyle*) { return false; }  }; diff --git a/Source/WebCore/svg/SVGPathBlender.cpp b/Source/WebCore/svg/SVGPathBlender.cpp index d46e24a..6de783d 100644 --- a/Source/WebCore/svg/SVGPathBlender.cpp +++ b/Source/WebCore/svg/SVGPathBlender.cpp @@ -1,5 +1,5 @@  /* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * Copyright (C) Research In Motion Limited 2010, 2011. 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 @@ -34,14 +34,60 @@ SVGPathBlender::SVGPathBlender()  {  } -float SVGPathBlender::blendAnimatedFloat(float from, float to) +// Helper functions +static inline FloatPoint blendFloatPoint(const FloatPoint& a, const FloatPoint& b, float progress)  { -    return (to - from) * m_progress + from; +    return FloatPoint((b.x() - a.x()) * progress + a.x(), (b.y() - a.y()) * progress + a.y());  } -FloatPoint SVGPathBlender::blendAnimatedFloatPoint(FloatPoint& from, FloatPoint& to) +static inline float blendAnimatedFloat(float from, float to, float progress)  { -    return FloatPoint((to.x() - from.x()) * m_progress + from.x(), (to.y() - from.y()) * m_progress + from.y()); +    return (to - from) * progress + from; +} + +float SVGPathBlender::blendAnimatedDimensonalFloat(float from, float to, FloatBlendMode blendMode) +{ +    if (m_fromMode == m_toMode) +        return blendAnimatedFloat(from, to, m_progress); +     +    float fromValue = blendMode == BlendHorizontal ? m_fromCurrentPoint.x() : m_fromCurrentPoint.y(); +    float toValue = blendMode == BlendHorizontal ? m_toCurrentPoint.x() : m_toCurrentPoint.y(); + +    // Transform toY to the coordinate mode of fromY +    float animValue = blendAnimatedFloat(from, m_fromMode == AbsoluteCoordinates ? to + toValue : to - toValue, m_progress); +     +    if (m_isInFirstHalfOfAnimation) +        return animValue; +     +    // Transform the animated point to the coordinate mode, needed for the current progress. +    float currentValue = blendAnimatedFloat(fromValue, toValue, m_progress); +    return m_toMode == AbsoluteCoordinates ? animValue + currentValue : animValue - currentValue; +} + +FloatPoint SVGPathBlender::blendAnimatedFloatPoint(const FloatPoint& fromPoint, const FloatPoint& toPoint) +{ +    if (m_fromMode == m_toMode) +        return blendFloatPoint(fromPoint, toPoint, m_progress); + +    // Transform toPoint to the coordinate mode of fromPoint +    FloatPoint animatedPoint = toPoint; +    if (m_fromMode == AbsoluteCoordinates) +        animatedPoint += m_toCurrentPoint; +    else +        animatedPoint.move(-m_toCurrentPoint.x(), -m_toCurrentPoint.y()); + +    animatedPoint = blendFloatPoint(fromPoint, animatedPoint, m_progress); + +    if (m_isInFirstHalfOfAnimation) +        return animatedPoint; + +    // Transform the animated point to the coordinate mode, needed for the current progress. +    FloatPoint currentPoint = blendFloatPoint(m_fromCurrentPoint, m_toCurrentPoint, m_progress); +    if (m_toMode == AbsoluteCoordinates) +        return animatedPoint + currentPoint; + +    animatedPoint.move(-currentPoint.x(), -currentPoint.y()); +    return animatedPoint;  }  bool SVGPathBlender::blendMoveToSegment() @@ -52,7 +98,9 @@ bool SVGPathBlender::blendMoveToSegment()          || !m_toSource->parseMoveToSegment(toTargetPoint))          return false; -    m_consumer->moveTo(blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), false, m_mode); +    m_consumer->moveTo(blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), false, m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); +    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint; +    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;      return true;  } @@ -64,7 +112,9 @@ bool SVGPathBlender::blendLineToSegment()          || !m_toSource->parseLineToSegment(toTargetPoint))          return false; -    m_consumer->lineTo(blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), m_mode); +    m_consumer->lineTo(blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); +    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint; +    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;      return true;  } @@ -76,7 +126,9 @@ bool SVGPathBlender::blendLineToHorizontalSegment()          || !m_toSource->parseLineToHorizontalSegment(toX))          return false; -    m_consumer->lineToHorizontal(blendAnimatedFloat(fromX, toX), m_mode); +    m_consumer->lineToHorizontal(blendAnimatedDimensonalFloat(fromX, toX, BlendHorizontal), m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); +    m_fromCurrentPoint.setX(m_fromMode == AbsoluteCoordinates ? fromX : m_fromCurrentPoint.x() + fromX); +    m_toCurrentPoint.setX(m_toMode == AbsoluteCoordinates ? toX : m_toCurrentPoint.x() + toX);      return true;  } @@ -88,7 +140,9 @@ bool SVGPathBlender::blendLineToVerticalSegment()          || !m_toSource->parseLineToVerticalSegment(toY))          return false; -    m_consumer->lineToVertical(blendAnimatedFloat(fromY, toY), m_mode); +    m_consumer->lineToVertical(blendAnimatedDimensonalFloat(fromY, toY, BlendVertical), m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); +    m_fromCurrentPoint.setY(m_fromMode == AbsoluteCoordinates ? fromY : m_fromCurrentPoint.y() + fromY); +    m_toCurrentPoint.setY(m_toMode == AbsoluteCoordinates ? toY : m_toCurrentPoint.y() + toY);      return true;  } @@ -107,7 +161,9 @@ bool SVGPathBlender::blendCurveToCubicSegment()      m_consumer->curveToCubic(blendAnimatedFloatPoint(fromPoint1, toPoint1),                               blendAnimatedFloatPoint(fromPoint2, toPoint2),                               blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), -                             m_mode); +                             m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); +    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint; +    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;      return true;  } @@ -123,7 +179,9 @@ bool SVGPathBlender::blendCurveToCubicSmoothSegment()      m_consumer->curveToCubicSmooth(blendAnimatedFloatPoint(fromPoint2, toPoint2),                                     blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), -                                   m_mode); +                                   m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); +    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint; +    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;      return true;  } @@ -139,7 +197,9 @@ bool SVGPathBlender::blendCurveToQuadraticSegment()      m_consumer->curveToQuadratic(blendAnimatedFloatPoint(fromPoint1, toPoint1),                                   blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), -                                 m_mode); +                                 m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); +    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint; +    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;      return true;  } @@ -151,7 +211,9 @@ bool SVGPathBlender::blendCurveToQuadraticSmoothSegment()          || !m_toSource->parseCurveToQuadraticSmoothSegment(toTargetPoint))          return false; -    m_consumer->curveToQuadraticSmooth(blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), m_mode); +    m_consumer->curveToQuadraticSmooth(blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); +    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint; +    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;      return true;  } @@ -173,16 +235,44 @@ bool SVGPathBlender::blendArcToSegment()          || !m_toSource->parseArcToSegment(toRx, toRy, toAngle, toLargeArc, toSweep, toTargetPoint))          return false; -    m_consumer->arcTo(blendAnimatedFloat(fromRx, toRx), -                      blendAnimatedFloat(fromRy, toRy), -                      blendAnimatedFloat(fromAngle, toAngle), -                      m_progress < 0.5 ? fromLargeArc : toLargeArc, -                      m_progress < 0.5 ? fromSweep : toSweep, +    m_consumer->arcTo(blendAnimatedFloat(fromRx, toRx, m_progress), +                      blendAnimatedFloat(fromRy, toRy, m_progress), +                      blendAnimatedFloat(fromAngle, toAngle, m_progress), +                      m_isInFirstHalfOfAnimation ? fromLargeArc : toLargeArc, +                      m_isInFirstHalfOfAnimation ? fromSweep : toSweep,                        blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), -                      m_mode); +                      m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); +    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint; +    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;      return true;  } +static inline PathCoordinateMode coordinateModeOfCommand(const SVGPathSegType& type) +{ +    if (type < PathSegMoveToAbs) +        return AbsoluteCoordinates; + +    // Odd number = relative command +    if (type % 2) +        return RelativeCoordinates; + +    return AbsoluteCoordinates; +} + +static inline bool isSegmentEqual(const SVGPathSegType& fromType, const SVGPathSegType& toType, const PathCoordinateMode& fromMode, const PathCoordinateMode& toMode) +{ +    if (fromType == toType && (fromType == PathSegUnknown || fromType == PathSegClosePath)) +        return true; + +    unsigned short from = fromType; +    unsigned short to = toType; +    if (fromMode == toMode) +        return from == to; +    if (fromMode == AbsoluteCoordinates) +        return from == to - 1; +    return to == from - 1; +} +  bool SVGPathBlender::blendAnimatedPath(float progress, SVGPathSource* fromSource, SVGPathSource* toSource, SVGPathConsumer* consumer)  {      ASSERT(fromSource); @@ -191,6 +281,7 @@ bool SVGPathBlender::blendAnimatedPath(float progress, SVGPathSource* fromSource      m_fromSource = fromSource;      m_toSource = toSource;      m_consumer = consumer; +    m_isInFirstHalfOfAnimation = progress < 0.5f;      m_progress = progress;      while (true) { @@ -198,31 +289,29 @@ bool SVGPathBlender::blendAnimatedPath(float progress, SVGPathSource* fromSource          SVGPathSegType toCommand;          if (!m_fromSource->parseSVGSegmentType(fromCommand) || !m_toSource->parseSVGSegmentType(toCommand))              return false; -        if (fromCommand != toCommand) + +        m_fromMode = coordinateModeOfCommand(fromCommand); +        m_toMode = coordinateModeOfCommand(toCommand); +        if (!isSegmentEqual(fromCommand, toCommand, m_fromMode, m_toMode))              return false; -        m_mode = AbsoluteCoordinates;          switch (fromCommand) {          case PathSegMoveToRel: -            m_mode = RelativeCoordinates;          case PathSegMoveToAbs:              if (!blendMoveToSegment())                  return false;              break;          case PathSegLineToRel: -            m_mode = RelativeCoordinates;          case PathSegLineToAbs:              if (!blendLineToSegment())                  return false;              break;          case PathSegLineToHorizontalRel: -            m_mode = RelativeCoordinates;          case PathSegLineToHorizontalAbs:              if (!blendLineToHorizontalSegment())                  return false;              break;          case PathSegLineToVerticalRel: -            m_mode = RelativeCoordinates;          case PathSegLineToVerticalAbs:              if (!blendLineToVerticalSegment())                  return false; @@ -231,31 +320,26 @@ bool SVGPathBlender::blendAnimatedPath(float progress, SVGPathSource* fromSource              m_consumer->closePath();              break;          case PathSegCurveToCubicRel: -            m_mode = RelativeCoordinates;          case PathSegCurveToCubicAbs:              if (!blendCurveToCubicSegment())                  return false;              break;          case PathSegCurveToCubicSmoothRel: -            m_mode = RelativeCoordinates;          case PathSegCurveToCubicSmoothAbs:              if (!blendCurveToCubicSmoothSegment())                  return false;              break;          case PathSegCurveToQuadraticRel: -            m_mode = RelativeCoordinates;          case PathSegCurveToQuadraticAbs:              if (!blendCurveToQuadraticSegment())                  return false;              break;          case PathSegCurveToQuadraticSmoothRel: -            m_mode = RelativeCoordinates;          case PathSegCurveToQuadraticSmoothAbs:              if (!blendCurveToQuadraticSmoothSegment())                  return false;              break;          case PathSegArcRel: -            m_mode = RelativeCoordinates;          case PathSegArcAbs:              if (!blendArcToSegment())                  return false; @@ -281,6 +365,8 @@ void SVGPathBlender::cleanup()      m_toSource = 0;      m_fromSource = 0;      m_consumer = 0; +    m_fromCurrentPoint = FloatPoint(); +    m_toCurrentPoint = FloatPoint();  }  } diff --git a/Source/WebCore/svg/SVGPathBlender.h b/Source/WebCore/svg/SVGPathBlender.h index 8e43b94..2290fbb 100644 --- a/Source/WebCore/svg/SVGPathBlender.h +++ b/Source/WebCore/svg/SVGPathBlender.h @@ -26,6 +26,11 @@  namespace WebCore { +enum FloatBlendMode { +    BlendHorizontal, +    BlendVertical +}; +  class SVGPathBlender {      WTF_MAKE_NONCOPYABLE(SVGPathBlender); WTF_MAKE_FAST_ALLOCATED;  public: @@ -45,14 +50,20 @@ private:      bool blendCurveToQuadraticSmoothSegment();      bool blendArcToSegment(); -    float blendAnimatedFloat(float, float); -    FloatPoint blendAnimatedFloatPoint(FloatPoint&, FloatPoint&); +    float blendAnimatedDimensonalFloat(float, float, FloatBlendMode); +    FloatPoint blendAnimatedFloatPoint(const FloatPoint& from, const FloatPoint& to);      SVGPathSource* m_fromSource;      SVGPathSource* m_toSource;      SVGPathConsumer* m_consumer; -    PathCoordinateMode m_mode; + +    FloatPoint m_fromCurrentPoint; +    FloatPoint m_toCurrentPoint; +     +    PathCoordinateMode m_fromMode; +    PathCoordinateMode m_toMode;      float m_progress; +    bool m_isInFirstHalfOfAnimation;  };  } // namespace WebCore diff --git a/Source/WebCore/svg/SVGPathByteStream.h b/Source/WebCore/svg/SVGPathByteStream.h index a444ac0..af283f7 100644 --- a/Source/WebCore/svg/SVGPathByteStream.h +++ b/Source/WebCore/svg/SVGPathByteStream.h @@ -51,6 +51,11 @@ public:          return adoptPtr(new SVGPathByteStream);      } +    PassOwnPtr<SVGPathByteStream> copy() +    { +        return adoptPtr(new SVGPathByteStream(m_data)); +    } +      typedef Vector<unsigned char> Data;      typedef Data::const_iterator DataIterator; @@ -62,6 +67,11 @@ public:  private:      SVGPathByteStream() { } +    SVGPathByteStream(Data& data) +        : m_data(data) +    { +    } +      Data m_data;  }; diff --git a/Source/WebCore/svg/SVGPathElement.cpp b/Source/WebCore/svg/SVGPathElement.cpp index 77b543f..c56873b 100644 --- a/Source/WebCore/svg/SVGPathElement.cpp +++ b/Source/WebCore/svg/SVGPathElement.cpp @@ -272,6 +272,21 @@ void SVGPathElement::synchronizeD()      SVGAnimatedPropertySynchronizer<true>::synchronize(this, SVGNames::dAttr, m_pathSegList.value.valueAsString());  } +AttributeToPropertyTypeMap& SVGPathElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGPathElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::dAttr, AnimatedPath); +    attributeToPropertyTypeMap.set(SVGNames::pathLengthAttr, AnimatedNumber); +} +  SVGPathSegListPropertyTearOff* SVGPathElement::pathSegList()  {      if (!m_animatablePathSegList) { diff --git a/Source/WebCore/svg/SVGPathElement.h b/Source/WebCore/svg/SVGPathElement.h index 6ea7d55..7f836c4 100644 --- a/Source/WebCore/svg/SVGPathElement.h +++ b/Source/WebCore/svg/SVGPathElement.h @@ -104,6 +104,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void synchronizeProperty(const QualifiedName&);      virtual void svgAttributeChanged(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual bool supportsMarkers() const { return true; }      // Animated property declarations diff --git a/Source/WebCore/svg/SVGPatternElement.cpp b/Source/WebCore/svg/SVGPatternElement.cpp index 60dfeaf..97e505e 100644 --- a/Source/WebCore/svg/SVGPatternElement.cpp +++ b/Source/WebCore/svg/SVGPatternElement.cpp @@ -194,6 +194,29 @@ void SVGPatternElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGPatternElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGPatternElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::widthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::heightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::patternUnitsAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::patternContentUnitsAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::patternTransformAttr, AnimatedTransformList); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +    attributeToPropertyTypeMap.set(SVGNames::viewBoxAttr, AnimatedRect); +    attributeToPropertyTypeMap.set(SVGNames::preserveAspectRatioAttr, AnimatedPreserveAspectRatio); +} +  void SVGPatternElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)  {      SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); diff --git a/Source/WebCore/svg/SVGPatternElement.h b/Source/WebCore/svg/SVGPatternElement.h index e581308..e7bfd80 100644 --- a/Source/WebCore/svg/SVGPatternElement.h +++ b/Source/WebCore/svg/SVGPatternElement.h @@ -59,6 +59,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); diff --git a/Source/WebCore/svg/SVGPolyElement.cpp b/Source/WebCore/svg/SVGPolyElement.cpp index 0fb48d7..8a70347 100644 --- a/Source/WebCore/svg/SVGPolyElement.cpp +++ b/Source/WebCore/svg/SVGPolyElement.cpp @@ -112,6 +112,20 @@ void SVGPolyElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGPolyElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGPolyElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::pointsAttr, AnimatedPoints); +} +  void SVGPolyElement::synchronizePoints()  {      if (!m_points.shouldSynchronize) diff --git a/Source/WebCore/svg/SVGPolyElement.h b/Source/WebCore/svg/SVGPolyElement.h index 3af8a79..7e3248e 100644 --- a/Source/WebCore/svg/SVGPolyElement.h +++ b/Source/WebCore/svg/SVGPolyElement.h @@ -50,6 +50,8 @@ private:      virtual void parseMappedAttribute(Attribute*);       virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual bool supportsMarkers() const { return true; } diff --git a/Source/WebCore/svg/SVGRadialGradientElement.cpp b/Source/WebCore/svg/SVGRadialGradientElement.cpp index d525531..4f0f203 100644 --- a/Source/WebCore/svg/SVGRadialGradientElement.cpp +++ b/Source/WebCore/svg/SVGRadialGradientElement.cpp @@ -124,6 +124,24 @@ void SVGRadialGradientElement::synchronizeProperty(const QualifiedName& attrName          synchronizeR();  } +AttributeToPropertyTypeMap& SVGRadialGradientElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGRadialGradientElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGGradientElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::cxAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::cyAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::rAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::fxAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::fyAttr, AnimatedLength); +} +  RenderObject* SVGRadialGradientElement::createRenderer(RenderArena* arena, RenderStyle*)  {      return new (arena) RenderSVGResourceRadialGradient(this); diff --git a/Source/WebCore/svg/SVGRadialGradientElement.h b/Source/WebCore/svg/SVGRadialGradientElement.h index 199eaba..40af133 100644 --- a/Source/WebCore/svg/SVGRadialGradientElement.h +++ b/Source/WebCore/svg/SVGRadialGradientElement.h @@ -42,6 +42,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); diff --git a/Source/WebCore/svg/SVGRectElement.cpp b/Source/WebCore/svg/SVGRectElement.cpp index d5db5b9..10c5743 100644 --- a/Source/WebCore/svg/SVGRectElement.cpp +++ b/Source/WebCore/svg/SVGRectElement.cpp @@ -161,6 +161,25 @@ void SVGRectElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGRectElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGRectElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::widthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::heightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::rxAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::ryAttr, AnimatedLength); +} +  void SVGRectElement::toPathData(Path& path) const  {      ASSERT(path.isEmpty()); diff --git a/Source/WebCore/svg/SVGRectElement.h b/Source/WebCore/svg/SVGRectElement.h index 0c30378..08ab4bf 100644 --- a/Source/WebCore/svg/SVGRectElement.h +++ b/Source/WebCore/svg/SVGRectElement.h @@ -46,6 +46,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void toPathData(Path&) const; diff --git a/Source/WebCore/svg/SVGSVGElement.cpp b/Source/WebCore/svg/SVGSVGElement.cpp index 483e45f..e2540e3 100644 --- a/Source/WebCore/svg/SVGSVGElement.cpp +++ b/Source/WebCore/svg/SVGSVGElement.cpp @@ -379,6 +379,23 @@ void SVGSVGElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGSVGElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGSVGElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::widthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::heightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::viewBoxAttr, AnimatedRect); +    attributeToPropertyTypeMap.set(SVGNames::preserveAspectRatioAttr, AnimatedPreserveAspectRatio); +} +  unsigned SVGSVGElement::suspendRedraw(unsigned /* maxWaitMilliseconds */)  {      // FIXME: Implement me (see bug 11275) diff --git a/Source/WebCore/svg/SVGSVGElement.h b/Source/WebCore/svg/SVGSVGElement.h index 0995c67..edb56d7 100644 --- a/Source/WebCore/svg/SVGSVGElement.h +++ b/Source/WebCore/svg/SVGSVGElement.h @@ -144,6 +144,8 @@ private:      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual bool selfHasRelativeLengths() const; diff --git a/Source/WebCore/svg/SVGScriptElement.cpp b/Source/WebCore/svg/SVGScriptElement.cpp index 6452700..babb1e7 100644 --- a/Source/WebCore/svg/SVGScriptElement.cpp +++ b/Source/WebCore/svg/SVGScriptElement.cpp @@ -97,6 +97,17 @@ void SVGScriptElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeHref();  } +AttributeToPropertyTypeMap& SVGScriptElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGScriptElement::fillAttributeToPropertyTypeMap() +{ +    attributeToPropertyTypeMap().set(XLinkNames::hrefAttr, AnimatedString); +} +  void SVGScriptElement::insertedIntoDocument()  {      SVGElement::insertedIntoDocument(); diff --git a/Source/WebCore/svg/SVGScriptElement.h b/Source/WebCore/svg/SVGScriptElement.h index df502e0..dabec79 100644 --- a/Source/WebCore/svg/SVGScriptElement.h +++ b/Source/WebCore/svg/SVGScriptElement.h @@ -51,6 +51,8 @@ private:      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual bool isURLAttribute(Attribute*) const;      virtual void finishParsingChildren(); diff --git a/Source/WebCore/svg/SVGStopElement.cpp b/Source/WebCore/svg/SVGStopElement.cpp index 10bd9ae..c6f5f98 100644 --- a/Source/WebCore/svg/SVGStopElement.cpp +++ b/Source/WebCore/svg/SVGStopElement.cpp @@ -77,6 +77,20 @@ void SVGStopElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeOffset();  } +AttributeToPropertyTypeMap& SVGStopElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGStopElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::offsetAttr, AnimatedLength); +} +  RenderObject* SVGStopElement::createRenderer(RenderArena* arena, RenderStyle*)  {      return new (arena) RenderSVGGradientStop(this); diff --git a/Source/WebCore/svg/SVGStopElement.h b/Source/WebCore/svg/SVGStopElement.h index 907afae..8ea1cf5 100644 --- a/Source/WebCore/svg/SVGStopElement.h +++ b/Source/WebCore/svg/SVGStopElement.h @@ -39,6 +39,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual bool isGradientStop() const { return true; } diff --git a/Source/WebCore/svg/SVGStyledElement.cpp b/Source/WebCore/svg/SVGStyledElement.cpp index 58248d8..7f3b041 100644 --- a/Source/WebCore/svg/SVGStyledElement.cpp +++ b/Source/WebCore/svg/SVGStyledElement.cpp @@ -43,6 +43,7 @@  #include "SVGSVGElement.h"  #include "SVGUseElement.h"  #include <wtf/Assertions.h> +#include <wtf/HashMap.h>  namespace WebCore { @@ -200,6 +201,83 @@ int SVGStyledElement::cssPropertyIdForSVGAttributeName(const QualifiedName& attr      return propertyNameToIdMap->get(attrName.localName().impl());  } +static inline AttributeToPropertyTypeMap& cssPropertyToTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_cssPropertyMap, ()); +     +    if (!s_cssPropertyMap.isEmpty()) +        return s_cssPropertyMap; + +    // Fill the map for the first use. +    s_cssPropertyMap.set(alignment_baselineAttr, AnimatedString); +    s_cssPropertyMap.set(baseline_shiftAttr, AnimatedString); +    s_cssPropertyMap.set(clipAttr, AnimatedRect); +    s_cssPropertyMap.set(clip_pathAttr, AnimatedString); +    s_cssPropertyMap.set(clip_ruleAttr, AnimatedString); +    s_cssPropertyMap.set(SVGNames::colorAttr, AnimatedColor); +    s_cssPropertyMap.set(color_interpolationAttr, AnimatedString); +    s_cssPropertyMap.set(color_interpolation_filtersAttr, AnimatedString); +    s_cssPropertyMap.set(color_profileAttr, AnimatedString); +    s_cssPropertyMap.set(color_renderingAttr, AnimatedString);  +    s_cssPropertyMap.set(cursorAttr, AnimatedString); +    s_cssPropertyMap.set(displayAttr, AnimatedString); +    s_cssPropertyMap.set(dominant_baselineAttr, AnimatedString); +    s_cssPropertyMap.set(fillAttr, AnimatedColor); +    s_cssPropertyMap.set(fill_opacityAttr, AnimatedNumber); +    s_cssPropertyMap.set(fill_ruleAttr, AnimatedString); +    s_cssPropertyMap.set(filterAttr, AnimatedString); +    s_cssPropertyMap.set(flood_colorAttr, AnimatedColor); +    s_cssPropertyMap.set(flood_opacityAttr, AnimatedNumber); +    s_cssPropertyMap.set(font_familyAttr, AnimatedString); +    s_cssPropertyMap.set(font_sizeAttr, AnimatedLength); +    s_cssPropertyMap.set(font_stretchAttr, AnimatedString); +    s_cssPropertyMap.set(font_styleAttr, AnimatedString); +    s_cssPropertyMap.set(font_variantAttr, AnimatedString); +    s_cssPropertyMap.set(font_weightAttr, AnimatedString); +    s_cssPropertyMap.set(image_renderingAttr, AnimatedString); +    s_cssPropertyMap.set(kerningAttr, AnimatedLength); +    s_cssPropertyMap.set(letter_spacingAttr, AnimatedLength); +    s_cssPropertyMap.set(lighting_colorAttr, AnimatedColor); +    s_cssPropertyMap.set(marker_endAttr, AnimatedString); +    s_cssPropertyMap.set(marker_midAttr, AnimatedString); +    s_cssPropertyMap.set(marker_startAttr, AnimatedString); +    s_cssPropertyMap.set(maskAttr, AnimatedString); +    s_cssPropertyMap.set(opacityAttr, AnimatedNumber); +    s_cssPropertyMap.set(overflowAttr, AnimatedString); +    s_cssPropertyMap.set(pointer_eventsAttr, AnimatedString); +    s_cssPropertyMap.set(shape_renderingAttr, AnimatedString); +    s_cssPropertyMap.set(stop_colorAttr, AnimatedColor); +    s_cssPropertyMap.set(stop_opacityAttr, AnimatedNumber); +    s_cssPropertyMap.set(strokeAttr, AnimatedColor); +    s_cssPropertyMap.set(stroke_dasharrayAttr, AnimatedLengthList); +    s_cssPropertyMap.set(stroke_dashoffsetAttr, AnimatedLength); +    s_cssPropertyMap.set(stroke_linecapAttr, AnimatedString); +    s_cssPropertyMap.set(stroke_linejoinAttr, AnimatedString); +    s_cssPropertyMap.set(stroke_miterlimitAttr, AnimatedNumber); +    s_cssPropertyMap.set(stroke_opacityAttr, AnimatedNumber); +    s_cssPropertyMap.set(stroke_widthAttr, AnimatedLength); +    s_cssPropertyMap.set(text_anchorAttr, AnimatedString); +    s_cssPropertyMap.set(text_decorationAttr, AnimatedString); +    s_cssPropertyMap.set(text_renderingAttr, AnimatedString); +    s_cssPropertyMap.set(vector_effectAttr, AnimatedString); +    s_cssPropertyMap.set(visibilityAttr, AnimatedString); +    s_cssPropertyMap.set(word_spacingAttr, AnimatedLength); +    return s_cssPropertyMap; +} + +AnimatedAttributeType SVGStyledElement::animatedPropertyTypeForCSSProperty(const QualifiedName& attrName) +{ +    AttributeToPropertyTypeMap& cssPropertyTypeMap = cssPropertyToTypeMap(); +    if (cssPropertyTypeMap.contains(attrName)) +        return cssPropertyTypeMap.get(attrName); +    return AnimatedUnknown; +} + +void SVGStyledElement::fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap& attributeToPropertyTypeMap) +{ +    attributeToPropertyTypeMap.set(HTMLNames::classAttr, AnimatedString); +} +  bool SVGStyledElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const  {      if (SVGStyledElement::cssPropertyIdForSVGAttributeName(attrName) > 0) { diff --git a/Source/WebCore/svg/SVGStyledElement.h b/Source/WebCore/svg/SVGStyledElement.h index 0714d43..85a2b5a 100644 --- a/Source/WebCore/svg/SVGStyledElement.h +++ b/Source/WebCore/svg/SVGStyledElement.h @@ -52,6 +52,8 @@ public:      bool instanceUpdatesBlocked() const;      void setInstanceUpdatesBlocked(bool); +    AnimatedAttributeType animatedPropertyTypeForCSSProperty(const QualifiedName&); +      virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const;      virtual CSSStyleDeclaration* style() { return StyledElement::style(); } @@ -66,6 +68,8 @@ protected:      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    void fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap&); +      virtual void attach();      virtual void insertedIntoDocument();      virtual void removedFromDocument(); diff --git a/Source/WebCore/svg/SVGStyledTransformableElement.cpp b/Source/WebCore/svg/SVGStyledTransformableElement.cpp index 15528e0..ce1c5fd 100644 --- a/Source/WebCore/svg/SVGStyledTransformableElement.cpp +++ b/Source/WebCore/svg/SVGStyledTransformableElement.cpp @@ -114,6 +114,13 @@ RenderObject* SVGStyledTransformableElement::createRenderer(RenderArena* arena,      return new (arena) RenderSVGPath(this);  } +void SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap& attributeToPropertyTypeMap) +{ +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +     +    attributeToPropertyTypeMap.set(SVGNames::transformAttr, AnimatedTransformList); +} +  void SVGStyledTransformableElement::toClipPath(Path& path) const  {      toPathData(path); diff --git a/Source/WebCore/svg/SVGStyledTransformableElement.h b/Source/WebCore/svg/SVGStyledTransformableElement.h index 1d882e5..cbd70ed 100644 --- a/Source/WebCore/svg/SVGStyledTransformableElement.h +++ b/Source/WebCore/svg/SVGStyledTransformableElement.h @@ -59,6 +59,7 @@ protected:      virtual void parseMappedAttribute(Attribute*);      virtual void synchronizeProperty(const QualifiedName&); +    void fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap&);      // Animated property declarations      DECLARE_ANIMATED_TRANSFORM_LIST(Transform, transform) diff --git a/Source/WebCore/svg/SVGSwitchElement.cpp b/Source/WebCore/svg/SVGSwitchElement.cpp index c225053..fb89f6f 100644 --- a/Source/WebCore/svg/SVGSwitchElement.cpp +++ b/Source/WebCore/svg/SVGSwitchElement.cpp @@ -80,6 +80,17 @@ void SVGSwitchElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGSwitchElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGSwitchElement::fillAttributeToPropertyTypeMap() +{ +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap()); +} +  }  #endif // ENABLE(SVG) diff --git a/Source/WebCore/svg/SVGSwitchElement.h b/Source/WebCore/svg/SVGSwitchElement.h index 937a1e4..b52a30d 100644 --- a/Source/WebCore/svg/SVGSwitchElement.h +++ b/Source/WebCore/svg/SVGSwitchElement.h @@ -46,6 +46,9 @@ private:      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);      virtual void synchronizeProperty(const QualifiedName&); +      +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      // Animated property declarations diff --git a/Source/WebCore/svg/SVGSymbolElement.cpp b/Source/WebCore/svg/SVGSymbolElement.cpp index ee4278d..31bb9a9 100644 --- a/Source/WebCore/svg/SVGSymbolElement.cpp +++ b/Source/WebCore/svg/SVGSymbolElement.cpp @@ -88,6 +88,21 @@ void SVGSymbolElement::synchronizeProperty(const QualifiedName& attrName)      }   } +AttributeToPropertyTypeMap& SVGSymbolElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGSymbolElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::viewBoxAttr, AnimatedRect); +    attributeToPropertyTypeMap.set(SVGNames::preserveAspectRatioAttr, AnimatedPreserveAspectRatio); +} +  bool SVGSymbolElement::selfHasRelativeLengths() const  {      return hasAttribute(SVGNames::viewBoxAttr); diff --git a/Source/WebCore/svg/SVGSymbolElement.h b/Source/WebCore/svg/SVGSymbolElement.h index e049f0d..8f3f251 100644 --- a/Source/WebCore/svg/SVGSymbolElement.h +++ b/Source/WebCore/svg/SVGSymbolElement.h @@ -45,6 +45,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual bool rendererIsNeeded(RenderStyle*) { return false; }      virtual bool selfHasRelativeLengths() const; diff --git a/Source/WebCore/svg/SVGTRefElement.cpp b/Source/WebCore/svg/SVGTRefElement.cpp index 14c4700..1161ffe 100644 --- a/Source/WebCore/svg/SVGTRefElement.cpp +++ b/Source/WebCore/svg/SVGTRefElement.cpp @@ -84,6 +84,20 @@ void SVGTRefElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeHref();  } +AttributeToPropertyTypeMap& SVGTRefElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGTRefElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGTextPositioningElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +} +  RenderObject* SVGTRefElement::createRenderer(RenderArena* arena, RenderStyle*)  {      return new (arena) RenderSVGInline(this); diff --git a/Source/WebCore/svg/SVGTRefElement.h b/Source/WebCore/svg/SVGTRefElement.h index 8b98383..2e7d005 100644 --- a/Source/WebCore/svg/SVGTRefElement.h +++ b/Source/WebCore/svg/SVGTRefElement.h @@ -38,6 +38,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);      virtual bool childShouldCreateRenderer(Node*) const; diff --git a/Source/WebCore/svg/SVGTSpanElement.cpp b/Source/WebCore/svg/SVGTSpanElement.cpp index 8fe30e2..24c979a 100644 --- a/Source/WebCore/svg/SVGTSpanElement.cpp +++ b/Source/WebCore/svg/SVGTSpanElement.cpp @@ -73,6 +73,17 @@ bool SVGTSpanElement::rendererIsNeeded(RenderStyle* style)      return false;  } +AttributeToPropertyTypeMap& SVGTSpanElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGTSpanElement::fillAttributeToPropertyTypeMap() +{         +    SVGTextPositioningElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap()); +} +  }  #endif // ENABLE(SVG) diff --git a/Source/WebCore/svg/SVGTSpanElement.h b/Source/WebCore/svg/SVGTSpanElement.h index 58a7990..ac02b57 100644 --- a/Source/WebCore/svg/SVGTSpanElement.h +++ b/Source/WebCore/svg/SVGTSpanElement.h @@ -36,6 +36,9 @@ private:      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);      virtual bool childShouldCreateRenderer(Node*) const;      virtual bool rendererIsNeeded(RenderStyle*); + +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();  };  } // namespace WebCore diff --git a/Source/WebCore/svg/SVGTextContentElement.cpp b/Source/WebCore/svg/SVGTextContentElement.cpp index f723ecc..0bb8b3b 100644 --- a/Source/WebCore/svg/SVGTextContentElement.cpp +++ b/Source/WebCore/svg/SVGTextContentElement.cpp @@ -221,6 +221,14 @@ void SVGTextContentElement::svgAttributeChanged(const QualifiedName& attrName)      // FIXME: also handle attribute changes for lengthAdjust and textLength  } +void SVGTextContentElement::fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap& attributeToPropertyTypeMap) +{ +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); + +    attributeToPropertyTypeMap.set(SVGNames::textLengthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::lengthAdjustAttr, AnimatedEnumeration); +} +  bool SVGTextContentElement::isKnownAttribute(const QualifiedName& attrName)  {      return attrName.matches(SVGNames::lengthAdjustAttr) @@ -232,7 +240,10 @@ bool SVGTextContentElement::isKnownAttribute(const QualifiedName& attrName)  bool SVGTextContentElement::selfHasRelativeLengths() const  { -    return textLength().isRelative(); +    // Any element of the <text> subtree is advertized as using relative lengths. +    // On any window size change, we have to relayout the text subtree, as the +    // effective 'on-screen' font size may change. +    return true;  }  SVGTextContentElement* SVGTextContentElement::elementFromRenderer(RenderObject* renderer) diff --git a/Source/WebCore/svg/SVGTextContentElement.h b/Source/WebCore/svg/SVGTextContentElement.h index 60b023b..7abffd8 100644 --- a/Source/WebCore/svg/SVGTextContentElement.h +++ b/Source/WebCore/svg/SVGTextContentElement.h @@ -65,6 +65,7 @@ protected:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    void fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap&);      virtual bool selfHasRelativeLengths() const; diff --git a/Source/WebCore/svg/SVGTextElement.cpp b/Source/WebCore/svg/SVGTextElement.cpp index b6094c9..3bb9b5e 100644 --- a/Source/WebCore/svg/SVGTextElement.cpp +++ b/Source/WebCore/svg/SVGTextElement.cpp @@ -143,6 +143,20 @@ void SVGTextElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeTransform();  } +AttributeToPropertyTypeMap& SVGTextElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGTextElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGTextPositioningElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::transformAttr, AnimatedTransformList); +} +  }  #endif // ENABLE(SVG) diff --git a/Source/WebCore/svg/SVGTextElement.h b/Source/WebCore/svg/SVGTextElement.h index 8dda8c6..1c57f82 100644 --- a/Source/WebCore/svg/SVGTextElement.h +++ b/Source/WebCore/svg/SVGTextElement.h @@ -54,6 +54,8 @@ private:      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      // Animated property declarations      DECLARE_ANIMATED_TRANSFORM_LIST(Transform, transform) diff --git a/Source/WebCore/svg/SVGTextPathElement.cpp b/Source/WebCore/svg/SVGTextPathElement.cpp index 9935b43..1bfc12c 100644 --- a/Source/WebCore/svg/SVGTextPathElement.cpp +++ b/Source/WebCore/svg/SVGTextPathElement.cpp @@ -110,6 +110,23 @@ void SVGTextPathElement::synchronizeProperty(const QualifiedName& attrName)          synchronizeHref();  } +AttributeToPropertyTypeMap& SVGTextPathElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGTextPathElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGTextContentElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::startOffsetAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::methodAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(SVGNames::spacingAttr, AnimatedEnumeration); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); +} +  RenderObject* SVGTextPathElement::createRenderer(RenderArena* arena, RenderStyle*)  {      return new (arena) RenderSVGTextPath(this); diff --git a/Source/WebCore/svg/SVGTextPathElement.h b/Source/WebCore/svg/SVGTextPathElement.h index 6c372f9..b113718 100644 --- a/Source/WebCore/svg/SVGTextPathElement.h +++ b/Source/WebCore/svg/SVGTextPathElement.h @@ -62,6 +62,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);      virtual bool childShouldCreateRenderer(Node*) const; diff --git a/Source/WebCore/svg/SVGTextPositioningElement.cpp b/Source/WebCore/svg/SVGTextPositioningElement.cpp index 544d192..a96f0cb 100644 --- a/Source/WebCore/svg/SVGTextPositioningElement.cpp +++ b/Source/WebCore/svg/SVGTextPositioningElement.cpp @@ -161,31 +161,15 @@ void SVGTextPositioningElement::synchronizeProperty(const QualifiedName& attrNam          synchronizeRotate();  } -static inline bool listContainsRelativeValue(const SVGLengthList& list) +void SVGTextPositioningElement::fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap& attributeToPropertyTypeMap)  { -    unsigned size = list.size(); -    for (unsigned i = 0; i < size; ++i) { -        const SVGLength& length = list.at(i); -        if (length.isRelative()) -            return true; -    } - -    return false; -} +    SVGTextContentElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); -bool SVGTextPositioningElement::selfHasRelativeLengths() const -{ -    if (SVGTextContentElement::selfHasRelativeLengths()) -        return true; -    if (listContainsRelativeValue(x())) -        return true; -    if (listContainsRelativeValue(y())) -        return true; -    if (listContainsRelativeValue(dx())) -        return true; -    if (listContainsRelativeValue(dy())) -        return true; -    return false; +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedNumberList); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedNumberList); +    attributeToPropertyTypeMap.set(SVGNames::dxAttr, AnimatedNumberList); +    attributeToPropertyTypeMap.set(SVGNames::dyAttr, AnimatedNumberList); +    attributeToPropertyTypeMap.set(SVGNames::rotateAttr, AnimatedNumberList);  }  SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject* renderer) diff --git a/Source/WebCore/svg/SVGTextPositioningElement.h b/Source/WebCore/svg/SVGTextPositioningElement.h index e4bc4ea..5e6dadc 100644 --- a/Source/WebCore/svg/SVGTextPositioningElement.h +++ b/Source/WebCore/svg/SVGTextPositioningElement.h @@ -39,8 +39,7 @@ protected:      virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); - -    virtual bool selfHasRelativeLengths() const; +    void fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap&);      // Animated property declarations      DECLARE_ANIMATED_LENGTH_LIST(X, x) diff --git a/Source/WebCore/svg/SVGTitleElement.cpp b/Source/WebCore/svg/SVGTitleElement.cpp index 5eb2204..6281f10 100644 --- a/Source/WebCore/svg/SVGTitleElement.cpp +++ b/Source/WebCore/svg/SVGTitleElement.cpp @@ -56,6 +56,17 @@ void SVGTitleElement::childrenChanged(bool changedByParser, Node* beforeChange,          document()->setTitle(textContent(), this);  } +AttributeToPropertyTypeMap& SVGTitleElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGTitleElement::fillAttributeToPropertyTypeMap() +{         +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap()); +} +  }  // vim:ts=4:noet diff --git a/Source/WebCore/svg/SVGTitleElement.h b/Source/WebCore/svg/SVGTitleElement.h index 5d0762f..c1cec49 100644 --- a/Source/WebCore/svg/SVGTitleElement.h +++ b/Source/WebCore/svg/SVGTitleElement.h @@ -40,6 +40,9 @@ private:      virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);      virtual bool rendererIsNeeded(RenderStyle*) { return false; } + +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();  };  } // namespace WebCore diff --git a/Source/WebCore/svg/SVGUseElement.cpp b/Source/WebCore/svg/SVGUseElement.cpp index 9f43f82..cc53bda 100644 --- a/Source/WebCore/svg/SVGUseElement.cpp +++ b/Source/WebCore/svg/SVGUseElement.cpp @@ -227,6 +227,24 @@ void SVGUseElement::synchronizeProperty(const QualifiedName& attrName)          SVGTests::synchronizeProperties(this, attrName);  } +AttributeToPropertyTypeMap& SVGUseElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGUseElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::xAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::yAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::widthAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(SVGNames::heightAttr, AnimatedLength); +    attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedLength); +} +  static void updateContainerSize(SVGUseElement* useElement, SVGElementInstance* targetInstance)  {      // Depth-first used to write the method in early exit style, no particular other reason. @@ -716,6 +734,8 @@ void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta          // Enter recursion, appending new instance tree nodes to the "instance" object.          buildInstanceTree(element, instancePtr, foundProblem); +        if (foundProblem) +            return;      }      if (!targetHasUseTag || !newTarget) diff --git a/Source/WebCore/svg/SVGUseElement.h b/Source/WebCore/svg/SVGUseElement.h index c1095ed..10c9be9 100644 --- a/Source/WebCore/svg/SVGUseElement.h +++ b/Source/WebCore/svg/SVGUseElement.h @@ -62,6 +62,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void svgAttributeChanged(const QualifiedName&);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual void recalcStyle(StyleChange = NoChange);      virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); diff --git a/Source/WebCore/svg/SVGViewElement.cpp b/Source/WebCore/svg/SVGViewElement.cpp index ee3c8d1..2dcf674 100644 --- a/Source/WebCore/svg/SVGViewElement.cpp +++ b/Source/WebCore/svg/SVGViewElement.cpp @@ -80,6 +80,21 @@ void SVGViewElement::synchronizeProperty(const QualifiedName& attrName)      }  } +AttributeToPropertyTypeMap& SVGViewElement::attributeToPropertyTypeMap() +{ +    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); +    return s_attributeToPropertyTypeMap; +} + +void SVGViewElement::fillAttributeToPropertyTypeMap() +{ +    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap(); + +    SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap); +    attributeToPropertyTypeMap.set(SVGNames::viewBoxAttr, AnimatedRect); +    attributeToPropertyTypeMap.set(SVGNames::preserveAspectRatioAttr, AnimatedPreserveAspectRatio); +} +  }  #endif // ENABLE(SVG) diff --git a/Source/WebCore/svg/SVGViewElement.h b/Source/WebCore/svg/SVGViewElement.h index 0e2e4fd..b371774 100644 --- a/Source/WebCore/svg/SVGViewElement.h +++ b/Source/WebCore/svg/SVGViewElement.h @@ -47,6 +47,8 @@ private:      virtual void parseMappedAttribute(Attribute*);      virtual void synchronizeProperty(const QualifiedName&); +    virtual void fillAttributeToPropertyTypeMap(); +    virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();      virtual bool rendererIsNeeded(RenderStyle*) { return false; } diff --git a/Source/WebCore/svg/graphics/SVGImage.cpp b/Source/WebCore/svg/graphics/SVGImage.cpp index fc2fd08..2d400a4 100644 --- a/Source/WebCore/svg/graphics/SVGImage.cpp +++ b/Source/WebCore/svg/graphics/SVGImage.cpp @@ -279,10 +279,10 @@ bool SVGImage::dataChanged(bool allDataReceived)          loader->load(fakeRequest, false); // Make sure the DocumentLoader is created          loader->policyChecker()->cancelCheck(); // cancel any policy checks          loader->commitProvisionalLoad(); -        loader->writer()->setMIMEType("image/svg+xml"); -        loader->writer()->begin(KURL()); // create the empty document -        loader->writer()->addData(data()->data(), data()->size()); -        loader->writer()->end(); +        loader->activeDocumentLoader()->writer()->setMIMEType("image/svg+xml"); +        loader->activeDocumentLoader()->writer()->begin(KURL()); // create the empty document +        loader->activeDocumentLoader()->writer()->addData(data()->data(), data()->size()); +        loader->activeDocumentLoader()->writer()->end();          frame->view()->setTransparent(true); // SVG Images are transparent.      } diff --git a/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp b/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp index b31b994..e6d0e65 100644 --- a/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp +++ b/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp @@ -68,10 +68,11 @@ FilterEffect* SVGFilterBuilder::getEffectById(const AtomicString& id) const      return m_namedEffects.get(id).get();  } -void SVGFilterBuilder::appendEffectToEffectReferences(RefPtr<FilterEffect> effectReference) +void SVGFilterBuilder::appendEffectToEffectReferences(RefPtr<FilterEffect> effectReference, RenderObject* object)  {      // The effect must be a newly created filter effect.      ASSERT(!m_effectReferences.contains(effectReference)); +    ASSERT(object && !m_effectRenderer.contains(object));      m_effectReferences.add(effectReference, FilterEffectSet());      FilterEffect* effect = effectReference.get(); @@ -79,7 +80,8 @@ void SVGFilterBuilder::appendEffectToEffectReferences(RefPtr<FilterEffect> effec      // It is not possible to add the same value to a set twice.      for (unsigned i = 0; i < numberOfInputEffects; ++i) -        getEffectReferences(effect->inputEffect(i)).add(effect); +        effectReferences(effect->inputEffect(i)).add(effect); +    m_effectRenderer.add(object, effectReference.get());  }  void SVGFilterBuilder::clearEffects() @@ -87,9 +89,23 @@ void SVGFilterBuilder::clearEffects()      m_lastEffect = 0;      m_namedEffects.clear();      m_effectReferences.clear(); +    m_effectRenderer.clear();      addBuiltinEffects();  } +void SVGFilterBuilder::clearResultsRecursive(FilterEffect* effect) +{ +    if (!effect->hasResult()) +        return; + +    effect->clearResult(); + +    HashSet<FilterEffect*>& effectReferences = this->effectReferences(effect); +    HashSet<FilterEffect*>::iterator end = effectReferences.end(); +    for (HashSet<FilterEffect*>::iterator it = effectReferences.begin(); it != end; ++it) +         clearResultsRecursive(*it); +} +  } // namespace WebCore  #endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h b/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h index a3c1244..9e7b2fe 100644 --- a/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h +++ b/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h @@ -24,6 +24,7 @@  #if ENABLE(SVG) && ENABLE(FILTERS)  #include "FilterEffect.h"  #include "PlatformString.h" +#include "RenderObject.h"  #include <wtf/HashMap.h>  #include <wtf/HashSet.h> @@ -43,16 +44,20 @@ public:      FilterEffect* getEffectById(const AtomicString& id) const;      FilterEffect* lastEffect() const { return m_lastEffect.get(); } -    void appendEffectToEffectReferences(RefPtr<FilterEffect>); +    void appendEffectToEffectReferences(RefPtr<FilterEffect>, RenderObject*); -    inline FilterEffectSet& getEffectReferences(FilterEffect* effect) +    inline FilterEffectSet& effectReferences(FilterEffect* effect)      {          // Only allowed for effects belongs to this builder.          ASSERT(m_effectReferences.contains(effect));          return m_effectReferences.find(effect)->second;      } +    // Required to change the attributes of a filter during an svgAttributeChanged. +    inline FilterEffect* effectByRenderer(RenderObject* object) { return m_effectRenderer.get(object); } +      void clearEffects(); +    void clearResultsRecursive(FilterEffect*);  private:      SVGFilterBuilder(Filter*); @@ -69,6 +74,7 @@ private:      // The value is a list, which contains those filter effects,      // which depends on the key filter effect.      HashMap<RefPtr<FilterEffect>, FilterEffectSet> m_effectReferences; +    HashMap<RenderObject*, FilterEffect*> m_effectRenderer;      RefPtr<FilterEffect> m_lastEffect;  }; | 
