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

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

Issue 180113007: [SVG] refactor determineAnimatedPropertyType logic. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 { 482 {
483 ASSERT(!m_keyPoints.isEmpty()); 483 ASSERT(!m_keyPoints.isEmpty());
484 ASSERT(m_keyPoints.size() == m_keyTimes.size()); 484 ASSERT(m_keyPoints.size() == m_keyTimes.size());
485 ASSERT(calcMode() != CalcModePaced); 485 ASSERT(calcMode() != CalcModePaced);
486 effectivePercent = calculatePercentFromKeyPoints(percent); 486 effectivePercent = calculatePercentFromKeyPoints(percent);
487 unsigned index = effectivePercent == 1 ? m_values.size() - 2 : static_cast<u nsigned>(effectivePercent * (m_values.size() - 1)); 487 unsigned index = effectivePercent == 1 ? m_values.size() - 2 : static_cast<u nsigned>(effectivePercent * (m_values.size() - 1));
488 from = m_values[index]; 488 from = m_values[index];
489 to = m_values[index + 1]; 489 to = m_values[index + 1];
490 } 490 }
491 491
492 AnimatedPropertyType SVGAnimationElement::determineAnimatedPropertyType() const
493 {
494 if (!targetElement())
495 return AnimatedString;
496
497 AnimatedPropertyType propertyType;
fs 2014/03/05 11:53:32 Nit: Move this into the if-block (first definition
kouhei (in TOK) 2014/03/06 03:53:30 Done.
498 RefPtr<NewSVGAnimatedPropertyBase> property = targetElement()->propertyFromA ttribute(attributeName());
499 if (property) {
500 propertyType = property->type();
501
502 // Only <animatedTransform> is allowed to animate AnimatedTransformList.
503 if (propertyType == AnimatedTransformList && !hasTagName(SVGNames::anima teTransformTag))
504 return AnimatedUnknown;
505
506 return propertyType;
507 }
508
509 return SVGElement::animatedPropertyTypeForCSSAttribute(attributeName());
510 }
511
492 void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to) 512 void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to)
493 { 513 {
494 unsigned valuesCount = m_values.size(); 514 unsigned valuesCount = m_values.size();
495 ASSERT(m_animationValid); 515 ASSERT(m_animationValid);
496 ASSERT(valuesCount >= 1); 516 ASSERT(valuesCount >= 1);
497 517
498 if (percent == 1 || valuesCount == 1) { 518 if (percent == 1 || valuesCount == 1) {
499 from = m_values[valuesCount - 1]; 519 from = m_values[valuesCount - 1];
500 to = m_values[valuesCount - 1]; 520 to = m_values[valuesCount - 1];
501 effectivePercent = 1; 521 effectivePercent = 1;
502 return; 522 return;
503 } 523 }
504 524
505 CalcMode calcMode = this->calcMode(); 525 CalcMode calcMode = this->calcMode();
506 if (hasTagName(SVGNames::animateTag)) { 526 if (hasTagName(SVGNames::animateTag)) {
507 AnimatedPropertyType attributeType = toSVGAnimateElement(this)->determin eAnimatedPropertyType(targetElement()); 527 AnimatedPropertyType attributeType = determineAnimatedPropertyType();
508 // Fall back to discrete animations for Strings. 528 // Fall back to discrete animations for Strings.
509 if (attributeType == AnimatedBoolean 529 if (attributeType == AnimatedBoolean
510 || attributeType == AnimatedEnumeration 530 || attributeType == AnimatedEnumeration
511 || attributeType == AnimatedPreserveAspectRatio 531 || attributeType == AnimatedPreserveAspectRatio
512 || attributeType == AnimatedString) 532 || attributeType == AnimatedString)
513 calcMode = CalcModeDiscrete; 533 calcMode = CalcModeDiscrete;
514 } 534 }
515 if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced) 535 if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced)
516 return currentValuesFromKeyPoints(percent, effectivePercent, from, to); 536 return currentValuesFromKeyPoints(percent, effectivePercent, from, to);
517 537
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 SVGSMILElement::setAttributeName(attributeName); 712 SVGSMILElement::setAttributeName(attributeName);
693 checkInvalidCSSAttributeType(targetElement()); 713 checkInvalidCSSAttributeType(targetElement());
694 } 714 }
695 715
696 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) 716 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target)
697 { 717 {
698 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa me()); 718 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa me());
699 } 719 }
700 720
701 } 721 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698