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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGAnimationElement.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
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAnimationElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 19 matching lines...) Expand all
30 #include "core/svg/SVGAnimateElement.h" 30 #include "core/svg/SVGAnimateElement.h"
31 #include "core/svg/SVGParserUtilities.h" 31 #include "core/svg/SVGParserUtilities.h"
32 #include "wtf/MathExtras.h" 32 #include "wtf/MathExtras.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 SVGAnimationElement::SVGAnimationElement(const QualifiedName& tagName, 36 SVGAnimationElement::SVGAnimationElement(const QualifiedName& tagName,
37 Document& document) 37 Document& document)
38 : SVGSMILElement(tagName, document), 38 : SVGSMILElement(tagName, document),
39 m_animationValid(false), 39 m_animationValid(false),
40 m_attributeType(AttributeTypeAuto),
41 m_hasInvalidCSSAttributeType(false),
42 m_calcMode(CalcModeLinear), 40 m_calcMode(CalcModeLinear),
43 m_animationMode(NoAnimation) { 41 m_animationMode(NoAnimation) {
44 ASSERT(RuntimeEnabledFeatures::smilEnabled()); 42 ASSERT(RuntimeEnabledFeatures::smilEnabled());
45 UseCounter::count(document, UseCounter::SVGAnimationElement); 43 UseCounter::count(document, UseCounter::SVGAnimationElement);
46 } 44 }
47 45
48 bool SVGAnimationElement::parseValues(const String& value, 46 bool SVGAnimationElement::parseValues(const String& value,
49 Vector<String>& result) { 47 Vector<String>& result) {
50 // Per the SMIL specification, leading and trailing white space, and white 48 // Per the SMIL specification, leading and trailing white space, and white
51 // space before and after semicolon separators, is allowed and will be 49 // space before and after semicolon separators, is allowed and will be
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 179 }
182 return; 180 return;
183 } 181 }
184 182
185 if (name == SVGNames::keySplinesAttr) { 183 if (name == SVGNames::keySplinesAttr) {
186 if (!parseKeySplines(value, m_keySplines)) 184 if (!parseKeySplines(value, m_keySplines))
187 reportAttributeParsingError(SVGParseStatus::ParsingFailed, name, value); 185 reportAttributeParsingError(SVGParseStatus::ParsingFailed, name, value);
188 return; 186 return;
189 } 187 }
190 188
191 if (name == SVGNames::attributeTypeAttr) {
192 setAttributeType(value);
193 return;
194 }
195
196 if (name == SVGNames::calcModeAttr) { 189 if (name == SVGNames::calcModeAttr) {
197 setCalcMode(value); 190 setCalcMode(value);
198 return; 191 return;
199 } 192 }
200 193
201 if (name == SVGNames::fromAttr || name == SVGNames::toAttr || 194 if (name == SVGNames::fromAttr || name == SVGNames::toAttr ||
202 name == SVGNames::byAttr) { 195 name == SVGNames::byAttr) {
203 updateAnimationMode(); 196 updateAnimationMode();
204 return; 197 return;
205 } 198 }
206 199
207 SVGSMILElement::parseAttribute(name, oldValue, value); 200 SVGSMILElement::parseAttribute(name, oldValue, value);
208 } 201 }
209 202
210 void SVGAnimationElement::svgAttributeChanged(const QualifiedName& attrName) { 203 void SVGAnimationElement::svgAttributeChanged(const QualifiedName& attrName) {
211 if (attrName == SVGNames::valuesAttr || attrName == SVGNames::byAttr || 204 if (attrName == SVGNames::valuesAttr || attrName == SVGNames::byAttr ||
212 attrName == SVGNames::fromAttr || attrName == SVGNames::toAttr || 205 attrName == SVGNames::fromAttr || attrName == SVGNames::toAttr ||
213 attrName == SVGNames::calcModeAttr || 206 attrName == SVGNames::calcModeAttr ||
214 attrName == SVGNames::attributeTypeAttr ||
215 attrName == SVGNames::keySplinesAttr || 207 attrName == SVGNames::keySplinesAttr ||
216 attrName == SVGNames::keyPointsAttr || 208 attrName == SVGNames::keyPointsAttr ||
217 attrName == SVGNames::keyTimesAttr) { 209 attrName == SVGNames::keyTimesAttr) {
218 animationAttributeChanged(); 210 animationAttributeChanged();
219 return; 211 return;
220 } 212 }
221 213
222 SVGSMILElement::svgAttributeChanged(attrName); 214 SVGSMILElement::svgAttributeChanged(attrName);
223 } 215 }
224 216
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // else paced is the default. 297 // else paced is the default.
306 setCalcMode(CalcModePaced); 298 setCalcMode(CalcModePaced);
307 } else if (calcMode == spline) { 299 } else if (calcMode == spline) {
308 UseCounter::count(document(), UseCounter::SVGCalcModeSpline); 300 UseCounter::count(document(), UseCounter::SVGCalcModeSpline);
309 setCalcMode(CalcModeSpline); 301 setCalcMode(CalcModeSpline);
310 } else 302 } else
311 setCalcMode(isSVGAnimateMotionElement(*this) ? CalcModePaced 303 setCalcMode(isSVGAnimateMotionElement(*this) ? CalcModePaced
312 : CalcModeLinear); 304 : CalcModeLinear);
313 } 305 }
314 306
315 void SVGAnimationElement::setAttributeType(const AtomicString& attributeType) {
316 DEFINE_STATIC_LOCAL(const AtomicString, css, ("CSS"));
317 DEFINE_STATIC_LOCAL(const AtomicString, xml, ("XML"));
318 if (attributeType == css)
319 m_attributeType = AttributeTypeCSS;
320 else if (attributeType == xml)
321 m_attributeType = AttributeTypeXML;
322 else
323 m_attributeType = AttributeTypeAuto;
324 checkInvalidCSSAttributeType();
325 }
326
327 String SVGAnimationElement::toValue() const { 307 String SVGAnimationElement::toValue() const {
328 return fastGetAttribute(SVGNames::toAttr); 308 return fastGetAttribute(SVGNames::toAttr);
329 } 309 }
330 310
331 String SVGAnimationElement::byValue() const { 311 String SVGAnimationElement::byValue() const {
332 return fastGetAttribute(SVGNames::byAttr); 312 return fastGetAttribute(SVGNames::byAttr);
333 } 313 }
334 314
335 String SVGAnimationElement::fromValue() const { 315 String SVGAnimationElement::fromValue() const {
336 return fastGetAttribute(SVGNames::fromAttr); 316 return fastGetAttribute(SVGNames::fromAttr);
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 effectivePercent = 630 effectivePercent =
651 calculatePercentForSpline(percent, calculateKeyTimesIndex(percent)); 631 calculatePercentForSpline(percent, calculateKeyTimesIndex(percent));
652 else if (animationMode == FromToAnimation || animationMode == ToAnimation) 632 else if (animationMode == FromToAnimation || animationMode == ToAnimation)
653 effectivePercent = calculatePercentForFromTo(percent); 633 effectivePercent = calculatePercentForFromTo(percent);
654 else 634 else
655 effectivePercent = percent; 635 effectivePercent = percent;
656 636
657 calculateAnimatedValue(effectivePercent, repeatCount, resultElement); 637 calculateAnimatedValue(effectivePercent, repeatCount, resultElement);
658 } 638 }
659 639
660 void SVGAnimationElement::setTargetElement(SVGElement* target) {
661 SVGSMILElement::setTargetElement(target);
662 checkInvalidCSSAttributeType();
663 }
664
665 void SVGAnimationElement::setAttributeName(const QualifiedName& attributeName) {
666 SVGSMILElement::setAttributeName(attributeName);
667 checkInvalidCSSAttributeType();
668 }
669
670 void SVGAnimationElement::checkInvalidCSSAttributeType() {
671 bool hasInvalidCSSAttributeType =
672 targetElement() && hasValidAttributeName() &&
673 getAttributeType() == AttributeTypeCSS &&
674 !isTargetAttributeCSSProperty(targetElement(), attributeName());
675
676 if (hasInvalidCSSAttributeType != m_hasInvalidCSSAttributeType) {
677 if (hasInvalidCSSAttributeType)
678 unscheduleIfScheduled();
679
680 m_hasInvalidCSSAttributeType = hasInvalidCSSAttributeType;
681
682 if (!hasInvalidCSSAttributeType)
683 schedule();
684 }
685
686 // Clear values that may depend on the previous target.
687 if (targetElement())
688 clearAnimatedType();
689 }
690
691 } // namespace blink 640 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAnimationElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698