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

Side by Side Diff: Source/core/svg/SVGAnimationElement.cpp

Issue 303093002: SVG: remove |SVGAnimateElement::m_animatedPropertyType| (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix wrong if Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 String SVGAnimationElement::byValue() const 329 String SVGAnimationElement::byValue() const
330 { 330 {
331 return fastGetAttribute(SVGNames::byAttr); 331 return fastGetAttribute(SVGNames::byAttr);
332 } 332 }
333 333
334 String SVGAnimationElement::fromValue() const 334 String SVGAnimationElement::fromValue() const
335 { 335 {
336 return fastGetAttribute(SVGNames::fromAttr); 336 return fastGetAttribute(SVGNames::fromAttr);
337 } 337 }
338 338
339 bool SVGAnimationElement::isAdditive() const 339 bool SVGAnimationElement::isAdditive()
340 { 340 {
341 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct FromLiteral)); 341 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct FromLiteral));
342 const AtomicString& value = fastGetAttribute(SVGNames::additiveAttr); 342 const AtomicString& value = fastGetAttribute(SVGNames::additiveAttr);
343 return value == sum || animationMode() == ByAnimation; 343 return value == sum || animationMode() == ByAnimation;
344 } 344 }
345 345
346 bool SVGAnimationElement::isAccumulated() const 346 bool SVGAnimationElement::isAccumulated() const
347 { 347 {
348 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct FromLiteral)); 348 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct FromLiteral));
349 const AtomicString& value = fastGetAttribute(SVGNames::accumulateAttr); 349 const AtomicString& value = fastGetAttribute(SVGNames::accumulateAttr);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 { 479 {
480 ASSERT(!m_keyPoints.isEmpty()); 480 ASSERT(!m_keyPoints.isEmpty());
481 ASSERT(m_keyPoints.size() == m_keyTimes.size()); 481 ASSERT(m_keyPoints.size() == m_keyTimes.size());
482 ASSERT(calcMode() != CalcModePaced); 482 ASSERT(calcMode() != CalcModePaced);
483 effectivePercent = calculatePercentFromKeyPoints(percent); 483 effectivePercent = calculatePercentFromKeyPoints(percent);
484 unsigned index = effectivePercent == 1 ? m_values.size() - 2 : static_cast<u nsigned>(effectivePercent * (m_values.size() - 1)); 484 unsigned index = effectivePercent == 1 ? m_values.size() - 2 : static_cast<u nsigned>(effectivePercent * (m_values.size() - 1));
485 from = m_values[index]; 485 from = m_values[index];
486 to = m_values[index + 1]; 486 to = m_values[index + 1];
487 } 487 }
488 488
489 AnimatedPropertyType SVGAnimationElement::determineAnimatedPropertyType() const
490 {
491 if (!targetElement())
492 return AnimatedString;
493
494 RefPtr<SVGAnimatedPropertyBase> property = targetElement()->propertyFromAttr ibute(attributeName());
495 if (property) {
496 AnimatedPropertyType propertyType = property->type();
497
498 // Only <animatedTransform> is allowed to animate AnimatedTransformList.
499 // http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndPropertie s
500 if (propertyType == AnimatedTransformList && !isSVGAnimateTransformEleme nt(*this))
501 return AnimatedUnknown;
502
503 return propertyType;
504 }
505
506 return SVGElement::animatedPropertyTypeForCSSAttribute(attributeName());
507 }
508
509 void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to) 489 void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to)
510 { 490 {
511 unsigned valuesCount = m_values.size(); 491 unsigned valuesCount = m_values.size();
512 ASSERT(m_animationValid); 492 ASSERT(m_animationValid);
513 ASSERT(valuesCount >= 1); 493 ASSERT(valuesCount >= 1);
514 494
515 if (percent == 1 || valuesCount == 1) { 495 if (percent == 1 || valuesCount == 1) {
516 from = m_values[valuesCount - 1]; 496 from = m_values[valuesCount - 1];
517 to = m_values[valuesCount - 1]; 497 to = m_values[valuesCount - 1];
518 effectivePercent = 1; 498 effectivePercent = 1;
519 return; 499 return;
520 } 500 }
521 501
522 CalcMode calcMode = this->calcMode(); 502 CalcMode calcMode = this->calcMode();
523 if (hasTagName(SVGNames::animateTag)) { 503 if (isSVGAnimateElement(*this) && !toSVGAnimateElement(*this).animatedProper tyTypeSupportsAddition())
524 AnimatedPropertyType attributeType = determineAnimatedPropertyType(); 504 calcMode = CalcModeDiscrete;
pdr. 2014/05/29 21:38:00 This looks like it could lead to a change in behav
kouhei (in TOK) 2014/05/30 01:15:23 Done.
525 // Fall back to discrete animations for Strings.
526 if (attributeType == AnimatedBoolean
527 || attributeType == AnimatedEnumeration
528 || attributeType == AnimatedPreserveAspectRatio
529 || attributeType == AnimatedString)
530 calcMode = CalcModeDiscrete;
531 }
532 if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced) 505 if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced)
533 return currentValuesFromKeyPoints(percent, effectivePercent, from, to); 506 return currentValuesFromKeyPoints(percent, effectivePercent, from, to);
534 507
535 unsigned keyTimesCount = m_keyTimes.size(); 508 unsigned keyTimesCount = m_keyTimes.size();
536 ASSERT(!keyTimesCount || valuesCount == keyTimesCount); 509 ASSERT(!keyTimesCount || valuesCount == keyTimesCount);
537 ASSERT(!keyTimesCount || (keyTimesCount > 1 && !m_keyTimes[0])); 510 ASSERT(!keyTimesCount || (keyTimesCount > 1 && !m_keyTimes[0]));
538 511
539 unsigned index = calculateKeyTimesIndex(percent); 512 unsigned index = calculateKeyTimesIndex(percent);
540 if (calcMode == CalcModeDiscrete) { 513 if (calcMode == CalcModeDiscrete) {
541 if (!keyTimesCount) 514 if (!keyTimesCount)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 SVGSMILElement::setAttributeName(attributeName); 682 SVGSMILElement::setAttributeName(attributeName);
710 checkInvalidCSSAttributeType(targetElement()); 683 checkInvalidCSSAttributeType(targetElement());
711 } 684 }
712 685
713 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) 686 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target)
714 { 687 {
715 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa me()); 688 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa me());
716 } 689 }
717 690
718 } 691 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGAnimationElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698