 Chromium Code Reviews
 Chromium Code Reviews Issue 2602423002:
  Push attributeName handling down into SVGAnimateElement  (Closed)
    
  
    Issue 2602423002:
  Push attributeName handling down into SVGAnimateElement  (Closed) 
  | Index: third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp | 
| diff --git a/third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp b/third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp | 
| index 71ee51eba1df8af4c95f5de1347772df1c2ed709..fe132e034c3d84eb3e9d424747212800fd80df9f 100644 | 
| --- a/third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp | 
| +++ b/third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp | 
| @@ -22,6 +22,7 @@ | 
| #include "core/svg/SVGAnimateElement.h" | 
| +#include "core/XLinkNames.h" | 
| #include "core/css/CSSComputedStyleDeclaration.h" | 
| #include "core/css/StylePropertySet.h" | 
| #include "core/dom/Document.h" | 
| @@ -69,6 +70,32 @@ AnimatedPropertyValueType propertyValueType(const QualifiedName& attributeName, | 
| return InheritValue; | 
| } | 
| +QualifiedName constructQualifiedName(const SVGElement& svgElement, | 
| + const AtomicString& attributeName) { | 
| + if (attributeName.isEmpty()) | 
| + return anyQName(); | 
| + if (!attributeName.contains(':')) | 
| + return QualifiedName(nullAtom, attributeName, nullAtom); | 
| + | 
| + AtomicString prefix; | 
| + AtomicString localName; | 
| + if (!Document::parseQualifiedName(attributeName, prefix, localName, | 
| + IGNORE_EXCEPTION)) | 
| + return anyQName(); | 
| + | 
| + const AtomicString& namespaceURI = svgElement.lookupNamespaceURI(prefix); | 
| + if (namespaceURI.isEmpty()) | 
| + return anyQName(); | 
| + | 
| + QualifiedName resolvedAttrName(nullAtom, localName, namespaceURI); | 
| + // "Animation elements treat attributeName='xlink:href' as being an alias | 
| + // for targetting the 'href' attribute." | 
| 
pdr.
2017/01/03 18:23:02
Nit: extra space
 
fs
2017/01/04 09:37:36
Removed.
 | 
| + // https://svgwg.org/svg2-draft/types.html#__svg__SVGURIReference__href | 
| + if (resolvedAttrName == XLinkNames::hrefAttr) | 
| + return SVGNames::hrefAttr; | 
| + return resolvedAttrName; | 
| +} | 
| + | 
| } // unnamed namespace | 
| SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, | 
| @@ -109,6 +136,22 @@ bool SVGAnimateElement::isSVGAnimationAttributeSettingJavaScriptURL( | 
| return SVGSMILElement::isSVGAnimationAttributeSettingJavaScriptURL(attribute); | 
| } | 
| +Node::InsertionNotificationRequest SVGAnimateElement::insertedInto( | 
| + ContainerNode* rootParent) { | 
| + SVGAnimationElement::insertedInto(rootParent); | 
| + if (rootParent->isConnected()) { | 
| + setAttributeName(constructQualifiedName( | 
| + *this, fastGetAttribute(SVGNames::attributeNameAttr))); | 
| + } | 
| + return InsertionDone; | 
| +} | 
| + | 
| +void SVGAnimateElement::removedFrom(ContainerNode* rootParent) { | 
| + if (rootParent->isConnected()) | 
| + setAttributeName(anyQName()); | 
| + SVGAnimationElement::removedFrom(rootParent); | 
| +} | 
| + | 
| void SVGAnimateElement::parseAttribute(const QualifiedName& name, | 
| const AtomicString& oldValue, | 
| const AtomicString& value) { | 
| @@ -121,10 +164,14 @@ void SVGAnimateElement::parseAttribute(const QualifiedName& name, | 
| void SVGAnimateElement::svgAttributeChanged(const QualifiedName& attrName) { | 
| if (attrName == SVGNames::attributeTypeAttr) { | 
| - animationAttributeChanged(); | 
| + } else if (attrName == SVGNames::attributeNameAttr) { | 
| + setAttributeName(constructQualifiedName( | 
| + *this, fastGetAttribute(SVGNames::attributeNameAttr))); | 
| + } else { | 
| + SVGAnimationElement::svgAttributeChanged(attrName); | 
| return; | 
| } | 
| - SVGAnimationElement::svgAttributeChanged(attrName); | 
| + animationAttributeChanged(); | 
| } | 
| void SVGAnimateElement::resolveTargetProperty() { | 
| @@ -516,7 +563,11 @@ void SVGAnimateElement::setTargetElement(SVGElement* target) { | 
| } | 
| void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) { | 
| - SVGAnimationElement::setAttributeName(attributeName); | 
| + unscheduleIfScheduled(); | 
| + if (targetElement()) | 
| + clearAnimatedType(); | 
| + m_attributeName = attributeName; | 
| + schedule(); | 
| checkInvalidCSSAttributeType(); | 
| resetAnimatedPropertyType(); | 
| } |