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

Side by Side Diff: third_party/WebKit/Source/core/animation/StringKeyframe.cpp

Issue 1413463008: Web Animations: Migrate SVG path interpolation to interpolation types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/animation/StringKeyframe.h" 6 #include "core/animation/StringKeyframe.h"
7 7
8 #include "core/XLinkNames.h" 8 #include "core/XLinkNames.h"
9 #include "core/animation/AngleSVGInterpolation.h" 9 #include "core/animation/AngleSVGInterpolation.h"
10 #include "core/animation/CSSColorInterpolationType.h" 10 #include "core/animation/CSSColorInterpolationType.h"
(...skipping 16 matching lines...) Expand all
27 #include "core/animation/InvalidatableInterpolation.h" 27 #include "core/animation/InvalidatableInterpolation.h"
28 #include "core/animation/LegacyStyleInterpolation.h" 28 #include "core/animation/LegacyStyleInterpolation.h"
29 #include "core/animation/LengthBoxStyleInterpolation.h" 29 #include "core/animation/LengthBoxStyleInterpolation.h"
30 #include "core/animation/LengthPairStyleInterpolation.h" 30 #include "core/animation/LengthPairStyleInterpolation.h"
31 #include "core/animation/LengthSVGInterpolation.h" 31 #include "core/animation/LengthSVGInterpolation.h"
32 #include "core/animation/LengthStyleInterpolation.h" 32 #include "core/animation/LengthStyleInterpolation.h"
33 #include "core/animation/ListSVGInterpolation.h" 33 #include "core/animation/ListSVGInterpolation.h"
34 #include "core/animation/ListStyleInterpolation.h" 34 #include "core/animation/ListStyleInterpolation.h"
35 #include "core/animation/NumberOptionalNumberSVGInterpolation.h" 35 #include "core/animation/NumberOptionalNumberSVGInterpolation.h"
36 #include "core/animation/NumberSVGInterpolation.h" 36 #include "core/animation/NumberSVGInterpolation.h"
37 #include "core/animation/PathSVGInterpolation.h"
38 #include "core/animation/PointSVGInterpolation.h" 37 #include "core/animation/PointSVGInterpolation.h"
39 #include "core/animation/RectSVGInterpolation.h" 38 #include "core/animation/RectSVGInterpolation.h"
40 #include "core/animation/SVGIntegerInterpolationType.h" 39 #include "core/animation/SVGIntegerInterpolationType.h"
41 #include "core/animation/SVGNumberInterpolationType.h" 40 #include "core/animation/SVGNumberInterpolationType.h"
41 #include "core/animation/SVGPathInterpolationType.h"
42 #include "core/animation/SVGStrokeDasharrayStyleInterpolation.h" 42 #include "core/animation/SVGStrokeDasharrayStyleInterpolation.h"
43 #include "core/animation/SVGValueInterpolationType.h" 43 #include "core/animation/SVGValueInterpolationType.h"
44 #include "core/animation/TransformSVGInterpolation.h" 44 #include "core/animation/TransformSVGInterpolation.h"
45 #include "core/animation/VisibilityStyleInterpolation.h" 45 #include "core/animation/VisibilityStyleInterpolation.h"
46 #include "core/animation/css/CSSAnimations.h" 46 #include "core/animation/css/CSSAnimations.h"
47 #include "core/css/CSSPropertyMetadata.h" 47 #include "core/css/CSSPropertyMetadata.h"
48 #include "core/css/resolver/StyleResolver.h" 48 #include "core/css/resolver/StyleResolver.h"
49 #include "core/style/ComputedStyle.h" 49 #include "core/style/ComputedStyle.h"
50 #include "core/svg/SVGElement.h" 50 #include "core/svg/SVGElement.h"
51 #include "platform/RuntimeEnabledFeatures.h" 51 #include "platform/RuntimeEnabledFeatures.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 || attribute == SVGNames::pointsAtYAttr 282 || attribute == SVGNames::pointsAtYAttr
283 || attribute == SVGNames::pointsAtZAttr 283 || attribute == SVGNames::pointsAtZAttr
284 || attribute == SVGNames::scaleAttr 284 || attribute == SVGNames::scaleAttr
285 || attribute == SVGNames::seedAttr 285 || attribute == SVGNames::seedAttr
286 || attribute == SVGNames::slopeAttr 286 || attribute == SVGNames::slopeAttr
287 || attribute == SVGNames::specularConstantAttr 287 || attribute == SVGNames::specularConstantAttr
288 || attribute == SVGNames::specularExponentAttr 288 || attribute == SVGNames::specularExponentAttr
289 || attribute == SVGNames::surfaceScaleAttr 289 || attribute == SVGNames::surfaceScaleAttr
290 || attribute == SVGNames::zAttr) { 290 || attribute == SVGNames::zAttr) {
291 applicableTypes->append(new SVGNumberInterpolationType(attribute)); 291 applicableTypes->append(new SVGNumberInterpolationType(attribute));
292 } else if (attribute == SVGNames::dAttr) {
293 applicableTypes->append(new SVGPathInterpolationType(attribute));
292 } else if (attribute == SVGNames::numOctavesAttr 294 } else if (attribute == SVGNames::numOctavesAttr
293 || attribute == SVGNames::targetXAttr 295 || attribute == SVGNames::targetXAttr
294 || attribute == SVGNames::targetYAttr) { 296 || attribute == SVGNames::targetYAttr) {
295 applicableTypes->append(new SVGIntegerInterpolationType(attribute)); 297 applicableTypes->append(new SVGIntegerInterpolationType(attribute));
296 } else if (attribute == HTMLNames::classAttr 298 } else if (attribute == HTMLNames::classAttr
297 || attribute == SVGNames::clipPathUnitsAttr 299 || attribute == SVGNames::clipPathUnitsAttr
298 || attribute == SVGNames::edgeModeAttr 300 || attribute == SVGNames::edgeModeAttr
299 || attribute == SVGNames::filterUnitsAttr 301 || attribute == SVGNames::filterUnitsAttr
300 || attribute == SVGNames::gradientUnitsAttr 302 || attribute == SVGNames::gradientUnitsAttr
301 || attribute == SVGNames::inAttr 303 || attribute == SVGNames::inAttr
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 ASSERT(!isNull(m_offset)); 543 ASSERT(!isNull(m_offset));
542 } 544 }
543 545
544 PassOwnPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::clon eWithOffset(double offset) const 546 PassOwnPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::clon eWithOffset(double offset) const
545 { 547 {
546 return adoptPtr(new SVGPropertySpecificKeyframe(offset, m_easing, m_value)); 548 return adoptPtr(new SVGPropertySpecificKeyframe(offset, m_easing, m_value));
547 } 549 }
548 550
549 PassOwnPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neut ralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const 551 PassOwnPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neut ralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
550 { 552 {
551 return adoptPtr(new SVGPropertySpecificKeyframe(offset, easing, "", EffectMo del::CompositeAdd)); 553 return adoptPtr(new SVGPropertySpecificKeyframe(offset, easing, String(), Ef fectModel::CompositeAdd));
552 } 554 }
553 555
554 namespace { 556 namespace {
555 557
556 PassRefPtr<Interpolation> createSVGInterpolation(SVGPropertyBase* fromValue, SVG PropertyBase* toValue, SVGAnimatedPropertyBase* attribute) 558 PassRefPtr<Interpolation> createSVGInterpolation(SVGPropertyBase* fromValue, SVG PropertyBase* toValue, SVGAnimatedPropertyBase* attribute)
557 { 559 {
558 RefPtr<Interpolation> interpolation = nullptr; 560 RefPtr<Interpolation> interpolation = nullptr;
559 ASSERT(fromValue->type() == toValue->type()); 561 ASSERT(fromValue->type() == toValue->type());
560 switch (fromValue->type()) { 562 switch (fromValue->type()) {
561 case AnimatedAngle: 563 case AnimatedAngle:
562 if (AngleSVGInterpolation::canCreateFrom(fromValue) && AngleSVGInterpola tion::canCreateFrom(toValue)) 564 if (AngleSVGInterpolation::canCreateFrom(fromValue) && AngleSVGInterpola tion::canCreateFrom(toValue))
563 return AngleSVGInterpolation::create(fromValue, toValue, attribute); 565 return AngleSVGInterpolation::create(fromValue, toValue, attribute);
564 break; 566 break;
565 case AnimatedIntegerOptionalInteger: { 567 case AnimatedIntegerOptionalInteger: {
566 int min = &attribute->attributeName() == &SVGNames::orderAttr ? 1 : 0; 568 int min = &attribute->attributeName() == &SVGNames::orderAttr ? 1 : 0;
567 return IntegerOptionalIntegerSVGInterpolation::create(fromValue, toValue , attribute, min); 569 return IntegerOptionalIntegerSVGInterpolation::create(fromValue, toValue , attribute, min);
568 } 570 }
569 case AnimatedLength: 571 case AnimatedLength:
570 return LengthSVGInterpolation::create(fromValue, toValue, attribute); 572 return LengthSVGInterpolation::create(fromValue, toValue, attribute);
571 case AnimatedLengthList: 573 case AnimatedLengthList:
572 interpolation = ListSVGInterpolation<LengthSVGInterpolation>::maybeCreat e(fromValue, toValue, attribute); 574 interpolation = ListSVGInterpolation<LengthSVGInterpolation>::maybeCreat e(fromValue, toValue, attribute);
573 break; 575 break;
574 case AnimatedNumberOptionalNumber: 576 case AnimatedNumberOptionalNumber:
575 return NumberOptionalNumberSVGInterpolation::create(fromValue, toValue, attribute); 577 return NumberOptionalNumberSVGInterpolation::create(fromValue, toValue, attribute);
576 case AnimatedNumberList: 578 case AnimatedNumberList:
577 interpolation = ListSVGInterpolation<NumberSVGInterpolation>::maybeCreat e(fromValue, toValue, attribute); 579 interpolation = ListSVGInterpolation<NumberSVGInterpolation>::maybeCreat e(fromValue, toValue, attribute);
578 break; 580 break;
579 case AnimatedPath:
580 interpolation = PathSVGInterpolation::maybeCreate(fromValue, toValue, at tribute);
581 break;
582 case AnimatedPoints: 581 case AnimatedPoints:
583 interpolation = ListSVGInterpolation<PointSVGInterpolation>::maybeCreate (fromValue, toValue, attribute); 582 interpolation = ListSVGInterpolation<PointSVGInterpolation>::maybeCreate (fromValue, toValue, attribute);
584 break; 583 break;
585 case AnimatedRect: 584 case AnimatedRect:
586 return RectSVGInterpolation::create(fromValue, toValue, attribute); 585 return RectSVGInterpolation::create(fromValue, toValue, attribute);
587 case AnimatedTransformList: 586 case AnimatedTransformList:
588 interpolation = ListSVGInterpolation<TransformSVGInterpolation>::maybeCr eate(fromValue, toValue, attribute); 587 interpolation = ListSVGInterpolation<TransformSVGInterpolation>::maybeCr eate(fromValue, toValue, attribute);
589 break; 588 break;
590 589
591 // Handled by SVGInterpolationTypes. 590 // Handled by SVGInterpolationTypes.
591 case AnimatedPath:
592 case AnimatedInteger: 592 case AnimatedInteger:
593 case AnimatedNumber: 593 case AnimatedNumber:
594 ASSERT_NOT_REACHED(); 594 ASSERT_NOT_REACHED();
595 // Fallthrough. 595 // Fallthrough.
596 596
597 // TODO(ericwilligers): Support more animation types. 597 // TODO(ericwilligers): Support more animation types.
598 default: 598 default:
599 break; 599 break;
600 } 600 }
601 if (interpolation) 601 if (interpolation)
(...skipping 17 matching lines...) Expand all
619 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase( )->cloneForAnimation(m_value); 619 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase( )->cloneForAnimation(m_value);
620 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()- >cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); 620 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()- >cloneForAnimation(toSVGPropertySpecificKeyframe(end).value());
621 621
622 if (!fromValue || !toValue) 622 if (!fromValue || !toValue)
623 return nullptr; 623 return nullptr;
624 624
625 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get( )); 625 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get( ));
626 } 626 }
627 627
628 } // namespace blink 628 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698