OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2008 Apple Inc. All rights reserved. |
5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 */ | 21 */ |
22 | 22 |
23 #include "core/svg/SVGAnimateElement.h" | 23 #include "core/svg/SVGAnimateElement.h" |
24 | 24 |
| 25 #include "core/XLinkNames.h" |
25 #include "core/css/CSSComputedStyleDeclaration.h" | 26 #include "core/css/CSSComputedStyleDeclaration.h" |
26 #include "core/css/StylePropertySet.h" | 27 #include "core/css/StylePropertySet.h" |
27 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
28 #include "core/dom/QualifiedName.h" | 29 #include "core/dom/QualifiedName.h" |
29 #include "core/dom/StyleChangeReason.h" | 30 #include "core/dom/StyleChangeReason.h" |
30 #include "core/svg/SVGAnimatedColor.h" | 31 #include "core/svg/SVGAnimatedColor.h" |
31 #include "core/svg/SVGLength.h" | 32 #include "core/svg/SVGLength.h" |
32 #include "core/svg/SVGLengthList.h" | 33 #include "core/svg/SVGLengthList.h" |
33 #include "core/svg/SVGNumber.h" | 34 #include "core/svg/SVGNumber.h" |
34 #include "core/svg/SVGString.h" | 35 #include "core/svg/SVGString.h" |
(...skipping 27 matching lines...) Expand all Loading... |
62 | 63 |
63 AnimatedPropertyValueType propertyValueType(const QualifiedName& attributeName, | 64 AnimatedPropertyValueType propertyValueType(const QualifiedName& attributeName, |
64 const String& value) { | 65 const String& value) { |
65 DEFINE_STATIC_LOCAL(const AtomicString, inherit, ("inherit")); | 66 DEFINE_STATIC_LOCAL(const AtomicString, inherit, ("inherit")); |
66 if (value.isEmpty() || value != inherit || | 67 if (value.isEmpty() || value != inherit || |
67 !SVGElement::isAnimatableCSSProperty(attributeName)) | 68 !SVGElement::isAnimatableCSSProperty(attributeName)) |
68 return RegularPropertyValue; | 69 return RegularPropertyValue; |
69 return InheritValue; | 70 return InheritValue; |
70 } | 71 } |
71 | 72 |
| 73 QualifiedName constructQualifiedName(const SVGElement& svgElement, |
| 74 const AtomicString& attributeName) { |
| 75 if (attributeName.isEmpty()) |
| 76 return anyQName(); |
| 77 if (!attributeName.contains(':')) |
| 78 return QualifiedName(nullAtom, attributeName, nullAtom); |
| 79 |
| 80 AtomicString prefix; |
| 81 AtomicString localName; |
| 82 if (!Document::parseQualifiedName(attributeName, prefix, localName, |
| 83 IGNORE_EXCEPTION)) |
| 84 return anyQName(); |
| 85 |
| 86 const AtomicString& namespaceURI = svgElement.lookupNamespaceURI(prefix); |
| 87 if (namespaceURI.isEmpty()) |
| 88 return anyQName(); |
| 89 |
| 90 QualifiedName resolvedAttrName(nullAtom, localName, namespaceURI); |
| 91 // "Animation elements treat attributeName='xlink:href' as being an alias |
| 92 // for targetting the 'href' attribute." |
| 93 // https://svgwg.org/svg2-draft/types.html#__svg__SVGURIReference__href |
| 94 if (resolvedAttrName == XLinkNames::hrefAttr) |
| 95 return SVGNames::hrefAttr; |
| 96 return resolvedAttrName; |
| 97 } |
| 98 |
72 } // unnamed namespace | 99 } // unnamed namespace |
73 | 100 |
74 SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, | 101 SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, |
75 Document& document) | 102 Document& document) |
76 : SVGAnimationElement(tagName, document), | 103 : SVGAnimationElement(tagName, document), |
77 m_type(AnimatedUnknown), | 104 m_type(AnimatedUnknown), |
78 m_cssPropertyId(CSSPropertyInvalid), | 105 m_cssPropertyId(CSSPropertyInvalid), |
79 m_fromPropertyValueType(RegularPropertyValue), | 106 m_fromPropertyValueType(RegularPropertyValue), |
80 m_toPropertyValueType(RegularPropertyValue), | 107 m_toPropertyValueType(RegularPropertyValue), |
81 m_attributeType(AttributeTypeAuto), | 108 m_attributeType(AttributeTypeAuto), |
(...skipping 20 matching lines...) Expand all Loading... |
102 } | 129 } |
103 for (const auto& part : parts) { | 130 for (const auto& part : parts) { |
104 if (protocolIsJavaScript(part)) | 131 if (protocolIsJavaScript(part)) |
105 return true; | 132 return true; |
106 } | 133 } |
107 } | 134 } |
108 | 135 |
109 return SVGSMILElement::isSVGAnimationAttributeSettingJavaScriptURL(attribute); | 136 return SVGSMILElement::isSVGAnimationAttributeSettingJavaScriptURL(attribute); |
110 } | 137 } |
111 | 138 |
| 139 Node::InsertionNotificationRequest SVGAnimateElement::insertedInto( |
| 140 ContainerNode* rootParent) { |
| 141 SVGAnimationElement::insertedInto(rootParent); |
| 142 if (rootParent->isConnected()) { |
| 143 setAttributeName(constructQualifiedName( |
| 144 *this, fastGetAttribute(SVGNames::attributeNameAttr))); |
| 145 } |
| 146 return InsertionDone; |
| 147 } |
| 148 |
| 149 void SVGAnimateElement::removedFrom(ContainerNode* rootParent) { |
| 150 if (rootParent->isConnected()) |
| 151 setAttributeName(anyQName()); |
| 152 SVGAnimationElement::removedFrom(rootParent); |
| 153 } |
| 154 |
112 void SVGAnimateElement::parseAttribute(const QualifiedName& name, | 155 void SVGAnimateElement::parseAttribute(const QualifiedName& name, |
113 const AtomicString& oldValue, | 156 const AtomicString& oldValue, |
114 const AtomicString& value) { | 157 const AtomicString& value) { |
115 if (name == SVGNames::attributeTypeAttr) { | 158 if (name == SVGNames::attributeTypeAttr) { |
116 setAttributeType(value); | 159 setAttributeType(value); |
117 return; | 160 return; |
118 } | 161 } |
119 SVGAnimationElement::parseAttribute(name, oldValue, value); | 162 SVGAnimationElement::parseAttribute(name, oldValue, value); |
120 } | 163 } |
121 | 164 |
122 void SVGAnimateElement::svgAttributeChanged(const QualifiedName& attrName) { | 165 void SVGAnimateElement::svgAttributeChanged(const QualifiedName& attrName) { |
123 if (attrName == SVGNames::attributeTypeAttr) { | 166 if (attrName == SVGNames::attributeTypeAttr) { |
124 animationAttributeChanged(); | 167 } else if (attrName == SVGNames::attributeNameAttr) { |
| 168 setAttributeName(constructQualifiedName( |
| 169 *this, fastGetAttribute(SVGNames::attributeNameAttr))); |
| 170 } else { |
| 171 SVGAnimationElement::svgAttributeChanged(attrName); |
125 return; | 172 return; |
126 } | 173 } |
127 SVGAnimationElement::svgAttributeChanged(attrName); | 174 animationAttributeChanged(); |
128 } | 175 } |
129 | 176 |
130 void SVGAnimateElement::resolveTargetProperty() { | 177 void SVGAnimateElement::resolveTargetProperty() { |
131 DCHECK(targetElement()); | 178 DCHECK(targetElement()); |
132 m_targetProperty = targetElement()->propertyFromAttribute(attributeName()); | 179 m_targetProperty = targetElement()->propertyFromAttribute(attributeName()); |
133 if (m_targetProperty) { | 180 if (m_targetProperty) { |
134 m_type = m_targetProperty->type(); | 181 m_type = m_targetProperty->type(); |
135 m_cssPropertyId = m_targetProperty->cssPropertyId(); | 182 m_cssPropertyId = m_targetProperty->cssPropertyId(); |
136 | 183 |
137 // Only <animateTransform> is allowed to animate AnimatedTransformList. | 184 // Only <animateTransform> is allowed to animate AnimatedTransformList. |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 return fromValue->calculateDistance(toValue, targetElement()); | 556 return fromValue->calculateDistance(toValue, targetElement()); |
510 } | 557 } |
511 | 558 |
512 void SVGAnimateElement::setTargetElement(SVGElement* target) { | 559 void SVGAnimateElement::setTargetElement(SVGElement* target) { |
513 SVGAnimationElement::setTargetElement(target); | 560 SVGAnimationElement::setTargetElement(target); |
514 checkInvalidCSSAttributeType(); | 561 checkInvalidCSSAttributeType(); |
515 resetAnimatedPropertyType(); | 562 resetAnimatedPropertyType(); |
516 } | 563 } |
517 | 564 |
518 void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) { | 565 void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) { |
519 SVGAnimationElement::setAttributeName(attributeName); | 566 unscheduleIfScheduled(); |
| 567 if (targetElement()) |
| 568 clearAnimatedType(); |
| 569 m_attributeName = attributeName; |
| 570 schedule(); |
520 checkInvalidCSSAttributeType(); | 571 checkInvalidCSSAttributeType(); |
521 resetAnimatedPropertyType(); | 572 resetAnimatedPropertyType(); |
522 } | 573 } |
523 | 574 |
524 void SVGAnimateElement::setAttributeType(const AtomicString& attributeType) { | 575 void SVGAnimateElement::setAttributeType(const AtomicString& attributeType) { |
525 if (attributeType == "CSS") | 576 if (attributeType == "CSS") |
526 m_attributeType = AttributeTypeCSS; | 577 m_attributeType = AttributeTypeCSS; |
527 else if (attributeType == "XML") | 578 else if (attributeType == "XML") |
528 m_attributeType = AttributeTypeXML; | 579 m_attributeType = AttributeTypeXML; |
529 else | 580 else |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 DEFINE_TRACE(SVGAnimateElement) { | 614 DEFINE_TRACE(SVGAnimateElement) { |
564 visitor->trace(m_fromProperty); | 615 visitor->trace(m_fromProperty); |
565 visitor->trace(m_toProperty); | 616 visitor->trace(m_toProperty); |
566 visitor->trace(m_toAtEndOfDurationProperty); | 617 visitor->trace(m_toAtEndOfDurationProperty); |
567 visitor->trace(m_animatedValue); | 618 visitor->trace(m_animatedValue); |
568 visitor->trace(m_targetProperty); | 619 visitor->trace(m_targetProperty); |
569 SVGAnimationElement::trace(visitor); | 620 SVGAnimationElement::trace(visitor); |
570 } | 621 } |
571 | 622 |
572 } // namespace blink | 623 } // namespace blink |
OLD | NEW |