| 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 14 matching lines...) Expand all Loading... |
| 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/DictionarySequenceOrDictionary.h" | 34 #include "bindings/core/v8/DictionarySequenceOrDictionary.h" |
| 35 #include "bindings/core/v8/ScriptState.h" |
| 35 #include "core/animation/DocumentTimeline.h" | 36 #include "core/animation/DocumentTimeline.h" |
| 36 #include "core/animation/EffectInput.h" | 37 #include "core/animation/EffectInput.h" |
| 37 #include "core/animation/ElementAnimations.h" | 38 #include "core/animation/ElementAnimations.h" |
| 38 #include "core/animation/KeyframeEffect.h" | 39 #include "core/animation/KeyframeEffect.h" |
| 39 #include "core/animation/KeyframeEffectOptions.h" | 40 #include "core/animation/KeyframeEffectOptions.h" |
| 40 #include "core/animation/KeyframeEffectReadOnly.h" | 41 #include "core/animation/KeyframeEffectReadOnly.h" |
| 41 #include "core/animation/TimingInput.h" | 42 #include "core/animation/TimingInput.h" |
| 42 #include "core/dom/Document.h" | 43 #include "core/dom/Document.h" |
| 43 #include "core/dom/Element.h" | 44 #include "core/dom/Element.h" |
| 44 #include "platform/RuntimeEnabledFeatures.h" | 45 #include "platform/RuntimeEnabledFeatures.h" |
| 45 #include "wtf/Allocator.h" | 46 #include "wtf/Allocator.h" |
| 46 | 47 |
| 47 namespace blink { | 48 namespace blink { |
| 48 | 49 |
| 49 class ElementAnimation { | 50 class ElementAnimation { |
| 50 STATIC_ONLY(ElementAnimation); | 51 STATIC_ONLY(ElementAnimation); |
| 51 | 52 |
| 52 public: | 53 public: |
| 53 static Animation* animate(ExecutionContext* executionContext, | 54 static Animation* animate(ScriptState* scriptState, |
| 54 Element& element, | 55 Element& element, |
| 55 const DictionarySequenceOrDictionary& effectInput, | 56 const DictionarySequenceOrDictionary& effectInput, |
| 56 double duration, | 57 double duration, |
| 57 ExceptionState& exceptionState) { | 58 ExceptionState& exceptionState) { |
| 58 EffectModel* effect = EffectInput::convert( | 59 EffectModel* effect = EffectInput::convert( |
| 59 &element, effectInput, executionContext, exceptionState); | 60 &element, effectInput, scriptState->getExecutionContext(), |
| 61 exceptionState); |
| 60 if (exceptionState.hadException()) | 62 if (exceptionState.hadException()) |
| 61 return nullptr; | 63 return nullptr; |
| 62 | 64 |
| 63 Timing timing; | 65 Timing timing; |
| 64 if (!TimingInput::convert(duration, timing, exceptionState)) | 66 if (!TimingInput::convert(duration, timing, exceptionState)) |
| 65 return nullptr; | 67 return nullptr; |
| 66 | 68 |
| 67 return animateInternal(element, effect, timing); | 69 return animateInternal(element, effect, timing); |
| 68 } | 70 } |
| 69 | 71 |
| 70 static Animation* animate(ExecutionContext* executionContext, | 72 static Animation* animate(ScriptState* scriptState, |
| 71 Element& element, | 73 Element& element, |
| 72 const DictionarySequenceOrDictionary& effectInput, | 74 const DictionarySequenceOrDictionary& effectInput, |
| 73 const KeyframeEffectOptions& options, | 75 const KeyframeEffectOptions& options, |
| 74 ExceptionState& exceptionState) { | 76 ExceptionState& exceptionState) { |
| 75 EffectModel* effect = EffectInput::convert( | 77 EffectModel* effect = EffectInput::convert( |
| 76 &element, effectInput, executionContext, exceptionState); | 78 &element, effectInput, scriptState->getExecutionContext(), |
| 79 exceptionState); |
| 77 if (exceptionState.hadException()) | 80 if (exceptionState.hadException()) |
| 78 return nullptr; | 81 return nullptr; |
| 79 | 82 |
| 80 Timing timing; | 83 Timing timing; |
| 81 if (!TimingInput::convert(options, timing, &element.document(), | 84 if (!TimingInput::convert(options, timing, &element.document(), |
| 82 exceptionState)) | 85 exceptionState)) |
| 83 return nullptr; | 86 return nullptr; |
| 84 | 87 |
| 85 Animation* animation = animateInternal(element, effect, timing); | 88 Animation* animation = animateInternal(element, effect, timing); |
| 86 animation->setId(options.id()); | 89 animation->setId(options.id()); |
| 87 return animation; | 90 return animation; |
| 88 } | 91 } |
| 89 | 92 |
| 90 static Animation* animate(ExecutionContext* executionContext, | 93 static Animation* animate(ScriptState* scriptState, |
| 91 Element& element, | 94 Element& element, |
| 92 const DictionarySequenceOrDictionary& effectInput, | 95 const DictionarySequenceOrDictionary& effectInput, |
| 93 ExceptionState& exceptionState) { | 96 ExceptionState& exceptionState) { |
| 94 EffectModel* effect = EffectInput::convert( | 97 EffectModel* effect = EffectInput::convert( |
| 95 &element, effectInput, executionContext, exceptionState); | 98 &element, effectInput, scriptState->getExecutionContext(), |
| 99 exceptionState); |
| 96 if (exceptionState.hadException()) | 100 if (exceptionState.hadException()) |
| 97 return nullptr; | 101 return nullptr; |
| 98 return animateInternal(element, effect, Timing()); | 102 return animateInternal(element, effect, Timing()); |
| 99 } | 103 } |
| 100 | 104 |
| 101 static HeapVector<Member<Animation>> getAnimations(Element& element) { | 105 static HeapVector<Member<Animation>> getAnimations(Element& element) { |
| 102 HeapVector<Member<Animation>> animations; | 106 HeapVector<Member<Animation>> animations; |
| 103 | 107 |
| 104 if (!element.hasAnimations()) | 108 if (!element.hasAnimations()) |
| 105 return animations; | 109 return animations; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 121 const Timing& timing) { | 125 const Timing& timing) { |
| 122 KeyframeEffect* keyframeEffect = | 126 KeyframeEffect* keyframeEffect = |
| 123 KeyframeEffect::create(&element, effect, timing); | 127 KeyframeEffect::create(&element, effect, timing); |
| 124 return element.document().timeline().play(keyframeEffect); | 128 return element.document().timeline().play(keyframeEffect); |
| 125 } | 129 } |
| 126 }; | 130 }; |
| 127 | 131 |
| 128 } // namespace blink | 132 } // namespace blink |
| 129 | 133 |
| 130 #endif // ElementAnimation_h | 134 #endif // ElementAnimation_h |
| OLD | NEW |