OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
6 #include "sky/engine/core/animation/TimingInput.h" | 6 #include "sky/engine/core/animation/TimingInput.h" |
7 | 7 |
8 #include "sky/engine/bindings/core/v8/Dictionary.h" | |
9 #include "sky/engine/core/css/parser/BisonCSSParser.h" | 8 #include "sky/engine/core/css/parser/BisonCSSParser.h" |
10 #include "sky/engine/core/css/resolver/CSSToStyleMap.h" | 9 #include "sky/engine/core/css/resolver/CSSToStyleMap.h" |
11 | 10 |
12 namespace blink { | 11 namespace blink { |
13 | 12 |
14 void TimingInput::setStartDelay(Timing& timing, double startDelay) | 13 void TimingInput::setStartDelay(Timing& timing, double startDelay) |
15 { | 14 { |
16 if (std::isfinite(startDelay)) | 15 if (std::isfinite(startDelay)) |
17 timing.startDelay = startDelay / 1000; | 16 timing.startDelay = startDelay / 1000; |
18 else | 17 else |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 87 } |
89 | 88 |
90 void TimingInput::setTimingFunction(Timing& timing, const String& timingFunction
String) | 89 void TimingInput::setTimingFunction(Timing& timing, const String& timingFunction
String) |
91 { | 90 { |
92 if (RefPtr<CSSValue> timingFunctionValue = BisonCSSParser::parseAnimationTim
ingFunctionValue(timingFunctionString)) | 91 if (RefPtr<CSSValue> timingFunctionValue = BisonCSSParser::parseAnimationTim
ingFunctionValue(timingFunctionString)) |
93 timing.timingFunction = CSSToStyleMap::mapAnimationTimingFunction(timing
FunctionValue.get(), true); | 92 timing.timingFunction = CSSToStyleMap::mapAnimationTimingFunction(timing
FunctionValue.get(), true); |
94 else | 93 else |
95 timing.timingFunction = Timing::defaults().timingFunction; | 94 timing.timingFunction = Timing::defaults().timingFunction; |
96 } | 95 } |
97 | 96 |
98 Timing TimingInput::convert(const Dictionary& timingInputDictionary) | |
99 { | |
100 Timing result; | |
101 | |
102 // FIXME: This method needs to be refactored to handle invalid | |
103 // null, NaN, Infinity values better. | |
104 // See: http://www.w3.org/TR/WebIDL/#es-double | |
105 double startDelay = Timing::defaults().startDelay; | |
106 DictionaryHelper::get(timingInputDictionary, "delay", startDelay); | |
107 setStartDelay(result, startDelay); | |
108 | |
109 double endDelay = Timing::defaults().endDelay; | |
110 DictionaryHelper::get(timingInputDictionary, "endDelay", endDelay); | |
111 setEndDelay(result, endDelay); | |
112 | |
113 String fillMode; | |
114 DictionaryHelper::get(timingInputDictionary, "fill", fillMode); | |
115 setFillMode(result, fillMode); | |
116 | |
117 double iterationStart = Timing::defaults().iterationStart; | |
118 DictionaryHelper::get(timingInputDictionary, "iterationStart", iterationStar
t); | |
119 setIterationStart(result, iterationStart); | |
120 | |
121 double iterationCount = Timing::defaults().iterationCount; | |
122 DictionaryHelper::get(timingInputDictionary, "iterations", iterationCount); | |
123 setIterationCount(result, iterationCount); | |
124 | |
125 double iterationDuration = 0; | |
126 if (DictionaryHelper::get(timingInputDictionary, "duration", iterationDurati
on)) { | |
127 setIterationDuration(result, iterationDuration); | |
128 } | |
129 | |
130 double playbackRate = Timing::defaults().playbackRate; | |
131 DictionaryHelper::get(timingInputDictionary, "playbackRate", playbackRate); | |
132 setPlaybackRate(result, playbackRate); | |
133 | |
134 String direction; | |
135 DictionaryHelper::get(timingInputDictionary, "direction", direction); | |
136 setPlaybackDirection(result, direction); | |
137 | |
138 String timingFunctionString; | |
139 DictionaryHelper::get(timingInputDictionary, "easing", timingFunctionString)
; | |
140 setTimingFunction(result, timingFunctionString); | |
141 | |
142 result.assertValid(); | |
143 | |
144 return result; | |
145 } | |
146 | |
147 Timing TimingInput::convert(double duration) | 97 Timing TimingInput::convert(double duration) |
148 { | 98 { |
149 Timing result; | 99 Timing result; |
150 setIterationDuration(result, duration); | 100 setIterationDuration(result, duration); |
151 return result; | 101 return result; |
152 } | 102 } |
153 | 103 |
154 } // namespace blink | 104 } // namespace blink |
OLD | NEW |