| OLD | NEW |
| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef ElementAnimation_h | 31 #ifndef ElementAnimation_h |
| 32 #define ElementAnimation_h | 32 #define ElementAnimation_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/EffectModelOrDictionarySequenceOrDictionary.h" | 34 #include "bindings/core/v8/DictionarySequenceOrDictionary.h" |
| 35 #include "core/animation/DocumentTimeline.h" | 35 #include "core/animation/DocumentTimeline.h" |
| 36 #include "core/animation/EffectInput.h" | 36 #include "core/animation/EffectInput.h" |
| 37 #include "core/animation/ElementAnimations.h" | 37 #include "core/animation/ElementAnimations.h" |
| 38 #include "core/animation/KeyframeEffect.h" | 38 #include "core/animation/KeyframeEffect.h" |
| 39 #include "core/animation/KeyframeEffectOptions.h" | 39 #include "core/animation/KeyframeEffectOptions.h" |
| 40 #include "core/animation/TimingInput.h" | 40 #include "core/animation/TimingInput.h" |
| 41 #include "core/dom/Document.h" | 41 #include "core/dom/Document.h" |
| 42 #include "core/dom/Element.h" | 42 #include "core/dom/Element.h" |
| 43 #include "platform/RuntimeEnabledFeatures.h" | 43 #include "platform/RuntimeEnabledFeatures.h" |
| 44 #include "wtf/Allocator.h" | 44 #include "wtf/Allocator.h" |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 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 DictionarySequenceOrDictionary& effectInput, double duration, Exceptio
nState& 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 nullptr; | 57 return nullptr; |
| 58 | 58 |
| 59 Timing timing; | 59 Timing timing; |
| 60 if (!TimingInput::convert(duration, timing, exceptionState)) | 60 if (!TimingInput::convert(duration, timing, exceptionState)) |
| 61 return nullptr; | 61 return nullptr; |
| 62 | 62 |
| 63 return animateInternal(element, effect, timing); | 63 return animateInternal(element, effect, timing); |
| 64 } | 64 } |
| 65 | 65 |
| 66 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 DictionarySequenceOrDictionary& effectInput, const KeyframeEffectOptio
ns& options, ExceptionState& exceptionState) |
| 67 { | 67 { |
| 68 EffectModel* effect = EffectInput::convert(&element, effectInput, execut
ionContext, exceptionState); | 68 EffectModel* effect = EffectInput::convert(&element, effectInput, execut
ionContext, exceptionState); |
| 69 if (exceptionState.hadException()) | 69 if (exceptionState.hadException()) |
| 70 return nullptr; | 70 return nullptr; |
| 71 | 71 |
| 72 Timing timing; | 72 Timing timing; |
| 73 if (!TimingInput::convert(options, timing, &element.document(), exceptio
nState)) | 73 if (!TimingInput::convert(options, timing, &element.document(), exceptio
nState)) |
| 74 return nullptr; | 74 return nullptr; |
| 75 | 75 |
| 76 Animation* animation = animateInternal(element, effect, timing); | 76 Animation* animation = animateInternal(element, effect, timing); |
| 77 animation->setId(options.id()); | 77 animation->setId(options.id()); |
| 78 return animation; | 78 return animation; |
| 79 } | 79 } |
| 80 | 80 |
| 81 static Animation* animate(ExecutionContext* executionContext, Element& eleme
nt, const EffectModelOrDictionarySequenceOrDictionary& effectInput, ExceptionSta
te& exceptionState) | 81 static Animation* animate(ExecutionContext* executionContext, Element& eleme
nt, const DictionarySequenceOrDictionary& effectInput, ExceptionState& exception
State) |
| 82 { | 82 { |
| 83 EffectModel* effect = EffectInput::convert(&element, effectInput, execut
ionContext, exceptionState); | 83 EffectModel* effect = EffectInput::convert(&element, effectInput, execut
ionContext, exceptionState); |
| 84 if (exceptionState.hadException()) | 84 if (exceptionState.hadException()) |
| 85 return nullptr; | 85 return nullptr; |
| 86 return animateInternal(element, effect, Timing()); | 86 return animateInternal(element, effect, Timing()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 static HeapVector<Member<Animation>> getAnimations(Element& element) | 89 static HeapVector<Member<Animation>> getAnimations(Element& element) |
| 90 { | 90 { |
| 91 HeapVector<Member<Animation>> animations; | 91 HeapVector<Member<Animation>> animations; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 105 static Animation* animateInternal(Element& element, EffectModel* effect, con
st Timing& timing) | 105 static Animation* animateInternal(Element& element, EffectModel* effect, con
st Timing& timing) |
| 106 { | 106 { |
| 107 KeyframeEffect* keyframeEffect = KeyframeEffect::create(&element, effect
, timing); | 107 KeyframeEffect* keyframeEffect = KeyframeEffect::create(&element, effect
, timing); |
| 108 return element.document().timeline().play(keyframeEffect); | 108 return element.document().timeline().play(keyframeEffect); |
| 109 } | 109 } |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace blink | 112 } // namespace blink |
| 113 | 113 |
| 114 #endif // ElementAnimation_h | 114 #endif // ElementAnimation_h |
| OLD | NEW |