Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(711)

Side by Side Diff: third_party/WebKit/Source/core/animation/TimingInput.cpp

Issue 2814523002: Web Animations: Coalesce constructors where possible. (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/animation/TimingInput.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/animation/TimingInput.h" 5 #include "core/animation/TimingInput.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/UnrestrictedDoubleOrKeyframeEffectOptions.h"
8 #include "core/animation/AnimationInputHelpers.h" 9 #include "core/animation/AnimationInputHelpers.h"
9 #include "core/animation/KeyframeEffectOptions.h" 10 #include "core/animation/KeyframeEffectOptions.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
13 void TimingInput::SetStartDelay(Timing& timing, double start_delay) { 14 void TimingInput::SetStartDelay(Timing& timing, double start_delay) {
14 if (std::isfinite(start_delay)) 15 if (std::isfinite(start_delay))
15 timing.start_delay = start_delay / 1000; 16 timing.start_delay = start_delay / 1000;
16 else 17 else
17 timing.start_delay = Timing::Defaults().start_delay; 18 timing.start_delay = Timing::Defaults().start_delay;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ExceptionState& exception_state) { 113 ExceptionState& exception_state) {
113 if (RefPtr<TimingFunction> timing_function = 114 if (RefPtr<TimingFunction> timing_function =
114 AnimationInputHelpers::ParseTimingFunction( 115 AnimationInputHelpers::ParseTimingFunction(
115 timing_function_string, document, exception_state)) { 116 timing_function_string, document, exception_state)) {
116 timing.timing_function = timing_function; 117 timing.timing_function = timing_function;
117 return true; 118 return true;
118 } 119 }
119 return false; 120 return false;
120 } 121 }
121 122
123 bool TimingInput::Convert(
124 const UnrestrictedDoubleOrKeyframeEffectOptions& options,
125 Timing& timing_output,
126 Document* document,
127 ExceptionState& exception_state) {
128 if (options.isKeyframeEffectOptions()) {
129 return Convert(options.getAsKeyframeEffectOptions(), timing_output,
130 document, exception_state);
131 } else if (options.isUnrestrictedDouble()) {
132 return Convert(options.getAsUnrestrictedDouble(), timing_output,
133 exception_state);
134 } else if (options.isNull()) {
135 return true;
136 }
137 NOTREACHED();
138 return false;
139 }
140
122 bool TimingInput::Convert(const KeyframeEffectOptions& timing_input, 141 bool TimingInput::Convert(const KeyframeEffectOptions& timing_input,
123 Timing& timing_output, 142 Timing& timing_output,
124 Document* document, 143 Document* document,
125 ExceptionState& exception_state) { 144 ExceptionState& exception_state) {
126 SetStartDelay(timing_output, timing_input.delay()); 145 SetStartDelay(timing_output, timing_input.delay());
127 SetEndDelay(timing_output, timing_input.endDelay()); 146 SetEndDelay(timing_output, timing_input.endDelay());
128 SetFillMode(timing_output, timing_input.fill()); 147 SetFillMode(timing_output, timing_input.fill());
129 148
130 if (!SetIterationStart(timing_output, timing_input.iterationStart(), 149 if (!SetIterationStart(timing_output, timing_input.iterationStart(),
131 exception_state)) 150 exception_state))
(...skipping 23 matching lines...) Expand all
155 Timing& timing_output, 174 Timing& timing_output,
156 ExceptionState& exception_state) { 175 ExceptionState& exception_state) {
157 DCHECK(timing_output == Timing::Defaults()); 176 DCHECK(timing_output == Timing::Defaults());
158 return SetIterationDuration( 177 return SetIterationDuration(
159 timing_output, 178 timing_output,
160 UnrestrictedDoubleOrString::fromUnrestrictedDouble(duration), 179 UnrestrictedDoubleOrString::fromUnrestrictedDouble(duration),
161 exception_state); 180 exception_state);
162 } 181 }
163 182
164 } // namespace blink 183 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/TimingInput.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698