Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp

Issue 2391993006: Move handling of 'attributeType' to SVGAnimateElement (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return InheritValue; 58 return InheritValue;
59 } 59 }
60 60
61 } // unnamed namespace 61 } // unnamed namespace
62 62
63 SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, 63 SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName,
64 Document& document) 64 Document& document)
65 : SVGAnimationElement(tagName, document), 65 : SVGAnimationElement(tagName, document),
66 m_animator(this), 66 m_animator(this),
67 m_fromPropertyValueType(RegularPropertyValue), 67 m_fromPropertyValueType(RegularPropertyValue),
68 m_toPropertyValueType(RegularPropertyValue) {} 68 m_toPropertyValueType(RegularPropertyValue),
69 m_attributeType(AttributeTypeAuto),
70 m_hasInvalidCSSAttributeType(false) {}
69 71
70 SVGAnimateElement* SVGAnimateElement::create(Document& document) { 72 SVGAnimateElement* SVGAnimateElement::create(Document& document) {
71 return new SVGAnimateElement(SVGNames::animateTag, document); 73 return new SVGAnimateElement(SVGNames::animateTag, document);
72 } 74 }
73 75
74 SVGAnimateElement::~SVGAnimateElement() {} 76 SVGAnimateElement::~SVGAnimateElement() {}
75 77
76 bool SVGAnimateElement::isSVGAnimationAttributeSettingJavaScriptURL( 78 bool SVGAnimateElement::isSVGAnimationAttributeSettingJavaScriptURL(
77 const Attribute& attribute) const { 79 const Attribute& attribute) const {
78 if ((attribute.name() == SVGNames::fromAttr || 80 if ((attribute.name() == SVGNames::fromAttr ||
79 attribute.name() == SVGNames::toAttr) && 81 attribute.name() == SVGNames::toAttr) &&
80 attributeValueIsJavaScriptURL(attribute)) 82 attributeValueIsJavaScriptURL(attribute))
81 return true; 83 return true;
82 84
83 if (attribute.name() == SVGNames::valuesAttr) { 85 if (attribute.name() == SVGNames::valuesAttr) {
84 Vector<String> parts; 86 Vector<String> parts;
85 if (!parseValues(attribute.value(), parts)) { 87 if (!parseValues(attribute.value(), parts)) {
86 // Assume the worst. 88 // Assume the worst.
87 return true; 89 return true;
88 } 90 }
89 for (const auto& part : parts) { 91 for (const auto& part : parts) {
90 if (protocolIsJavaScript(part)) 92 if (protocolIsJavaScript(part))
91 return true; 93 return true;
92 } 94 }
93 } 95 }
94 96
95 return SVGSMILElement::isSVGAnimationAttributeSettingJavaScriptURL(attribute); 97 return SVGSMILElement::isSVGAnimationAttributeSettingJavaScriptURL(attribute);
96 } 98 }
97 99
100 void SVGAnimateElement::parseAttribute(const QualifiedName& name,
101 const AtomicString& oldValue,
102 const AtomicString& value) {
103 if (name == SVGNames::attributeTypeAttr) {
104 setAttributeType(value);
105 return;
106 }
107 SVGAnimationElement::parseAttribute(name, oldValue, value);
108 }
109
110 void SVGAnimateElement::svgAttributeChanged(const QualifiedName& attrName) {
111 if (attrName == SVGNames::attributeTypeAttr) {
112 animationAttributeChanged();
113 return;
114 }
115 SVGAnimationElement::svgAttributeChanged(attrName);
116 }
117
98 AnimatedPropertyType SVGAnimateElement::animatedPropertyType() { 118 AnimatedPropertyType SVGAnimateElement::animatedPropertyType() {
99 if (!targetElement()) 119 if (!targetElement())
100 return AnimatedUnknown; 120 return AnimatedUnknown;
101 121
102 m_animator.reset(targetElement()); 122 m_animator.reset(targetElement());
103 return m_animator.type(); 123 return m_animator.type();
104 } 124 }
105 125
106 bool SVGAnimateElement::hasValidAttributeType() { 126 bool SVGAnimateElement::hasValidAttributeType() {
107 SVGElement* targetElement = this->targetElement(); 127 SVGElement* targetElement = this->targetElement();
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // FIXME: A return value of float is not enough to support paced animations on 403 // FIXME: A return value of float is not enough to support paced animations on
384 // lists. 404 // lists.
385 SVGPropertyBase* fromValue = 405 SVGPropertyBase* fromValue =
386 m_animator.createPropertyForAnimation(fromString); 406 m_animator.createPropertyForAnimation(fromString);
387 SVGPropertyBase* toValue = m_animator.createPropertyForAnimation(toString); 407 SVGPropertyBase* toValue = m_animator.createPropertyForAnimation(toString);
388 return fromValue->calculateDistance(toValue, targetElement()); 408 return fromValue->calculateDistance(toValue, targetElement());
389 } 409 }
390 410
391 void SVGAnimateElement::setTargetElement(SVGElement* target) { 411 void SVGAnimateElement::setTargetElement(SVGElement* target) {
392 SVGAnimationElement::setTargetElement(target); 412 SVGAnimationElement::setTargetElement(target);
413 checkInvalidCSSAttributeType();
393 resetAnimatedPropertyType(); 414 resetAnimatedPropertyType();
394 } 415 }
395 416
396 void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) { 417 void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) {
397 SVGAnimationElement::setAttributeName(attributeName); 418 SVGAnimationElement::setAttributeName(attributeName);
419 checkInvalidCSSAttributeType();
398 resetAnimatedPropertyType(); 420 resetAnimatedPropertyType();
399 } 421 }
400 422
423 void SVGAnimateElement::setAttributeType(const AtomicString& attributeType) {
424 if (attributeType == "CSS")
425 m_attributeType = AttributeTypeCSS;
426 else if (attributeType == "XML")
427 m_attributeType = AttributeTypeXML;
428 else
429 m_attributeType = AttributeTypeAuto;
430 checkInvalidCSSAttributeType();
431 }
432
433 void SVGAnimateElement::checkInvalidCSSAttributeType() {
434 bool hasInvalidCSSAttributeType =
435 targetElement() && hasValidAttributeName() &&
436 getAttributeType() == AttributeTypeCSS &&
437 !isTargetAttributeCSSProperty(targetElement(), attributeName());
438
439 if (hasInvalidCSSAttributeType != m_hasInvalidCSSAttributeType) {
440 if (hasInvalidCSSAttributeType)
441 unscheduleIfScheduled();
442
443 m_hasInvalidCSSAttributeType = hasInvalidCSSAttributeType;
444
445 if (!hasInvalidCSSAttributeType)
446 schedule();
447 }
448
449 // Clear values that may depend on the previous target.
450 if (targetElement())
451 clearAnimatedType();
452 }
453
401 void SVGAnimateElement::resetAnimatedPropertyType() { 454 void SVGAnimateElement::resetAnimatedPropertyType() {
402 ASSERT(!m_animatedProperty); 455 ASSERT(!m_animatedProperty);
403 m_fromProperty.clear(); 456 m_fromProperty.clear();
404 m_toProperty.clear(); 457 m_toProperty.clear();
405 m_toAtEndOfDurationProperty.clear(); 458 m_toAtEndOfDurationProperty.clear();
406 m_animator.clear(); 459 m_animator.clear();
407 } 460 }
408 461
409 DEFINE_TRACE(SVGAnimateElement) { 462 DEFINE_TRACE(SVGAnimateElement) {
410 visitor->trace(m_fromProperty); 463 visitor->trace(m_fromProperty);
411 visitor->trace(m_toProperty); 464 visitor->trace(m_toProperty);
412 visitor->trace(m_toAtEndOfDurationProperty); 465 visitor->trace(m_toAtEndOfDurationProperty);
413 visitor->trace(m_animatedProperty); 466 visitor->trace(m_animatedProperty);
414 visitor->trace(m_animator); 467 visitor->trace(m_animator);
415 SVGAnimationElement::trace(visitor); 468 SVGAnimationElement::trace(visitor);
416 } 469 }
417 470
418 } // namespace blink 471 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAnimateElement.h ('k') | third_party/WebKit/Source/core/svg/SVGAnimationElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698