| 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 15 matching lines...) Expand all Loading... |
| 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 "bindings/core/v8/ScriptState.h" |
| 36 #include "bindings/core/v8/UnrestrictedDoubleOrKeyframeEffectOptions.h" |
| 36 #include "core/animation/DocumentTimeline.h" | 37 #include "core/animation/DocumentTimeline.h" |
| 37 #include "core/animation/EffectInput.h" | 38 #include "core/animation/EffectInput.h" |
| 38 #include "core/animation/ElementAnimations.h" | 39 #include "core/animation/ElementAnimations.h" |
| 39 #include "core/animation/KeyframeEffect.h" | 40 #include "core/animation/KeyframeEffect.h" |
| 40 #include "core/animation/KeyframeEffectOptions.h" | |
| 41 #include "core/animation/KeyframeEffectReadOnly.h" | 41 #include "core/animation/KeyframeEffectReadOnly.h" |
| 42 #include "core/animation/TimingInput.h" | 42 #include "core/animation/TimingInput.h" |
| 43 #include "core/dom/Document.h" | 43 #include "core/dom/Document.h" |
| 44 #include "core/dom/Element.h" | 44 #include "core/dom/Element.h" |
| 45 #include "core/dom/ExecutionContext.h" | 45 #include "core/dom/ExecutionContext.h" |
| 46 #include "platform/RuntimeEnabledFeatures.h" | 46 #include "platform/RuntimeEnabledFeatures.h" |
| 47 #include "platform/wtf/Allocator.h" | 47 #include "platform/wtf/Allocator.h" |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 class ElementAnimation { | 51 class ElementAnimation { |
| 52 STATIC_ONLY(ElementAnimation); | 52 STATIC_ONLY(ElementAnimation); |
| 53 | 53 |
| 54 public: | 54 public: |
| 55 static Animation* animate(ScriptState* script_state, | 55 static Animation* animate(ScriptState* script_state, |
| 56 Element& element, | 56 Element& element, |
| 57 const DictionarySequenceOrDictionary& effect_input, | 57 const DictionarySequenceOrDictionary& effect_input, |
| 58 double duration, | 58 UnrestrictedDoubleOrKeyframeEffectOptions options, |
| 59 ExceptionState& exception_state) { | 59 ExceptionState& exception_state) { |
| 60 EffectModel* effect = EffectInput::Convert( | 60 EffectModel* effect = EffectInput::Convert( |
| 61 &element, effect_input, ExecutionContext::From(script_state), | 61 &element, effect_input, ExecutionContext::From(script_state), |
| 62 exception_state); | |
| 63 if (exception_state.HadException()) | |
| 64 return nullptr; | |
| 65 | |
| 66 Timing timing; | |
| 67 if (!TimingInput::Convert(duration, timing, exception_state)) | |
| 68 return nullptr; | |
| 69 | |
| 70 return animate(element, effect, timing); | |
| 71 } | |
| 72 | |
| 73 static Animation* animate(ScriptState* script_state, | |
| 74 Element& element, | |
| 75 const DictionarySequenceOrDictionary& effect_input, | |
| 76 const KeyframeEffectOptions& options, | |
| 77 ExceptionState& exception_state) { | |
| 78 EffectModel* effect = EffectInput::Convert( | |
| 79 &element, effect_input, ExecutionContext::From(script_state), | |
| 80 exception_state); | 62 exception_state); |
| 81 if (exception_state.HadException()) | 63 if (exception_state.HadException()) |
| 82 return nullptr; | 64 return nullptr; |
| 83 | 65 |
| 84 Timing timing; | 66 Timing timing; |
| 85 if (!TimingInput::Convert(options, timing, &element.GetDocument(), | 67 if (!TimingInput::Convert(options, timing, &element.GetDocument(), |
| 86 exception_state)) | 68 exception_state)) |
| 87 return nullptr; | 69 return nullptr; |
| 88 | 70 |
| 89 Animation* animation = animate(element, effect, timing); | 71 if (options.isKeyframeEffectOptions()) { |
| 90 animation->setId(options.id()); | 72 Animation* animation = animate(element, effect, timing); |
| 91 return animation; | 73 animation->setId(options.getAsKeyframeEffectOptions().id()); |
| 74 return animation; |
| 75 } |
| 76 return animate(element, effect, timing); |
| 92 } | 77 } |
| 93 | 78 |
| 94 static Animation* animate(ScriptState* script_state, | 79 static Animation* animate(ScriptState* script_state, |
| 95 Element& element, | 80 Element& element, |
| 96 const DictionarySequenceOrDictionary& effect_input, | 81 const DictionarySequenceOrDictionary& effect_input, |
| 97 ExceptionState& exception_state) { | 82 ExceptionState& exception_state) { |
| 98 EffectModel* effect = EffectInput::Convert( | 83 EffectModel* effect = EffectInput::Convert( |
| 99 &element, effect_input, ExecutionContext::From(script_state), | 84 &element, effect_input, ExecutionContext::From(script_state), |
| 100 exception_state); | 85 exception_state); |
| 101 if (exception_state.HadException()) | 86 if (exception_state.HadException()) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 125 animation->effect()->IsInEffect())) | 110 animation->effect()->IsInEffect())) |
| 126 animations.push_back(animation); | 111 animations.push_back(animation); |
| 127 } | 112 } |
| 128 return animations; | 113 return animations; |
| 129 } | 114 } |
| 130 }; | 115 }; |
| 131 | 116 |
| 132 } // namespace blink | 117 } // namespace blink |
| 133 | 118 |
| 134 #endif // ElementAnimation_h | 119 #endif // ElementAnimation_h |
| OLD | NEW |