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