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

Side by Side Diff: third_party/WebKit/Source/core/animation/ElementAnimation.h

Issue 1906463002: Web Animations: Throw TypeErrors for invalid timing parameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 4 years, 8 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 class Dictionary; 48 class Dictionary;
49 49
50 class ElementAnimation { 50 class ElementAnimation {
51 STATIC_ONLY(ElementAnimation); 51 STATIC_ONLY(ElementAnimation);
52 public: 52 public:
53 static Animation* animate(ExecutionContext* executionContext, Element& eleme nt, const EffectModelOrDictionarySequenceOrDictionary& effectInput, double durat ion, ExceptionState& exceptionState) 53 static Animation* animate(ExecutionContext* executionContext, Element& eleme nt, const EffectModelOrDictionarySequenceOrDictionary& effectInput, double durat ion, ExceptionState& exceptionState)
54 { 54 {
55 EffectModel* effect = EffectInput::convert(&element, effectInput, execut ionContext, exceptionState); 55 EffectModel* effect = EffectInput::convert(&element, effectInput, execut ionContext, exceptionState);
56 if (exceptionState.hadException()) 56 if (exceptionState.hadException())
57 return 0; 57 return nullptr;
58 return animateInternal(element, effect, TimingInput::convert(duration)); 58
59 Timing timing;
60 if (!TimingInput::convert(duration, timing, exceptionState))
61 return nullptr;
62
63 return animateInternal(element, effect, timing);
59 } 64 }
60 65
61 static Animation* animate(ExecutionContext* executionContext, Element& eleme nt, const EffectModelOrDictionarySequenceOrDictionary& effectInput, const Keyfra meEffectOptions& options, ExceptionState& exceptionState) 66 static Animation* animate(ExecutionContext* executionContext, Element& eleme nt, const EffectModelOrDictionarySequenceOrDictionary& effectInput, const Keyfra meEffectOptions& options, ExceptionState& exceptionState)
62 { 67 {
63 EffectModel* effect = EffectInput::convert(&element, effectInput, execut ionContext, exceptionState); 68 EffectModel* effect = EffectInput::convert(&element, effectInput, execut ionContext, exceptionState);
69 if (exceptionState.hadException())
70 return nullptr;
71
64 Timing timing; 72 Timing timing;
65 bool success = TimingInput::convert(options, timing, &element.document() , exceptionState); 73 if (!TimingInput::convert(options, timing, &element.document(), exceptio nState))
66 if (!success || exceptionState.hadException()) 74 return nullptr;
67 return 0;
68 75
69 Animation* animation = animateInternal(element, effect, timing); 76 Animation* animation = animateInternal(element, effect, timing);
70 animation->setId(options.id()); 77 animation->setId(options.id());
71 return animation; 78 return animation;
72 } 79 }
73 80
74 static Animation* animate(ExecutionContext* executionContext, Element& eleme nt, const EffectModelOrDictionarySequenceOrDictionary& effectInput, ExceptionSta te& exceptionState) 81 static Animation* animate(ExecutionContext* executionContext, Element& eleme nt, const EffectModelOrDictionarySequenceOrDictionary& effectInput, ExceptionSta te& exceptionState)
75 { 82 {
76 EffectModel* effect = EffectInput::convert(&element, effectInput, execut ionContext, exceptionState); 83 EffectModel* effect = EffectInput::convert(&element, effectInput, execut ionContext, exceptionState);
77 if (exceptionState.hadException()) 84 if (exceptionState.hadException())
78 return 0; 85 return nullptr;
79 return animateInternal(element, effect, Timing()); 86 return animateInternal(element, effect, Timing());
80 } 87 }
81 88
82 static HeapVector<Member<Animation>> getAnimations(Element& element) 89 static HeapVector<Member<Animation>> getAnimations(Element& element)
83 { 90 {
84 HeapVector<Member<Animation>> animations; 91 HeapVector<Member<Animation>> animations;
85 92
86 if (!element.hasAnimations()) 93 if (!element.hasAnimations())
87 return animations; 94 return animations;
88 95
89 for (const auto& animation : element.document().timeline().getAnimations ()) { 96 for (const auto& animation : element.document().timeline().getAnimations ()) {
90 ASSERT(animation->effect()); 97 ASSERT(animation->effect());
91 if (toKeyframeEffect(animation->effect())->target() == element && (a nimation->effect()->isCurrent() || animation->effect()->isInEffect())) 98 if (toKeyframeEffect(animation->effect())->target() == element && (a nimation->effect()->isCurrent() || animation->effect()->isInEffect()))
92 animations.append(animation); 99 animations.append(animation);
93 } 100 }
94 return animations; 101 return animations;
95 } 102 }
96 103
97 private: 104 private:
98 static Animation* animateInternal(Element& element, EffectModel* effect, con st Timing& timing) 105 static Animation* animateInternal(Element& element, EffectModel* effect, con st Timing& timing)
99 { 106 {
100 KeyframeEffect* keyframeEffect = KeyframeEffect::create(&element, effect , timing); 107 KeyframeEffect* keyframeEffect = KeyframeEffect::create(&element, effect , timing);
101 return element.document().timeline().play(keyframeEffect); 108 return element.document().timeline().play(keyframeEffect);
102 } 109 }
103 }; 110 };
104 111
105 } // namespace blink 112 } // namespace blink
106 113
107 #endif // ElementAnimation_h 114 #endif // ElementAnimation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698