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

Side by Side Diff: Source/platform/animation/TimingFunction.h

Issue 149363002: Web Animations API: Implement step-middle and steps(x, middle) timing functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix TimingFunctionTestHelperTest Created 6 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 double m_y2; 165 double m_y2;
166 SubType m_subType; 166 SubType m_subType;
167 mutable OwnPtr<UnitBezier> m_bezier; 167 mutable OwnPtr<UnitBezier> m_bezier;
168 }; 168 };
169 169
170 class PLATFORM_EXPORT StepsTimingFunction FINAL : public TimingFunction { 170 class PLATFORM_EXPORT StepsTimingFunction FINAL : public TimingFunction {
171 public: 171 public:
172 enum SubType { 172 enum SubType {
173 Start, 173 Start,
174 End, 174 End,
175 Middle,
175 Custom 176 Custom
176 }; 177 };
177 178
178 static PassRefPtr<StepsTimingFunction> create(int steps, bool stepAtStart) 179 enum StepAtPosition {
180 StepAtStart,
181 StepAtMiddle,
182 StepAtEnd
183 };
184
185 static PassRefPtr<StepsTimingFunction> create(int steps, StepAtPosition step AtPosition)
179 { 186 {
180 return adoptRef(new StepsTimingFunction(Custom, steps, stepAtStart)); 187 return adoptRef(new StepsTimingFunction(Custom, steps, stepAtPosition));
181 } 188 }
182 189
183 static StepsTimingFunction* preset(SubType subType) 190 static StepsTimingFunction* preset(SubType subType)
184 { 191 {
185 switch (subType) { 192 switch (subType) {
186 case Start: 193 case Start:
187 { 194 {
188 DEFINE_STATIC_REF(StepsTimingFunction, start, (adoptRef(new Step sTimingFunction(Start, 1, true)))); 195 DEFINE_STATIC_REF(StepsTimingFunction, start, (adoptRef(new Step sTimingFunction(Start, 1, StepAtStart))));
189 return start; 196 return start;
190 } 197 }
198 case Middle:
199 {
200 DEFINE_STATIC_REF(StepsTimingFunction, middle, (adoptRef(new Ste psTimingFunction(Middle, 1, StepAtMiddle))));
201 return middle;
202 }
191 case End: 203 case End:
192 { 204 {
193 DEFINE_STATIC_REF(StepsTimingFunction, end, (adoptRef(new StepsT imingFunction(End, 1, false)))); 205 DEFINE_STATIC_REF(StepsTimingFunction, end, (adoptRef(new StepsT imingFunction(End, 1, StepAtEnd))));
194 return end; 206 return end;
195 } 207 }
196 default: 208 default:
197 ASSERT_NOT_REACHED(); 209 ASSERT_NOT_REACHED();
198 return 0; 210 return 0;
199 } 211 }
200 } 212 }
201 213
202 214
203 virtual ~StepsTimingFunction() { } 215 virtual ~StepsTimingFunction() { }
204 216
205 virtual String toString() const OVERRIDE; 217 virtual String toString() const OVERRIDE;
206 218
207 virtual double evaluate(double fraction, double) const OVERRIDE; 219 virtual double evaluate(double fraction, double) const OVERRIDE;
208 220
209 int numberOfSteps() const { return m_steps; } 221 int numberOfSteps() const { return m_steps; }
210 bool stepAtStart() const { return m_stepAtStart; } 222 StepAtPosition stepAtPosition() const { return m_stepAtPosition; }
211 223
212 SubType subType() const { return m_subType; } 224 SubType subType() const { return m_subType; }
213 225
214 private: 226 private:
215 StepsTimingFunction(SubType subType, int steps, bool stepAtStart) 227 StepsTimingFunction(SubType subType, int steps, StepAtPosition stepAtPositio n)
216 : TimingFunction(StepsFunction) 228 : TimingFunction(StepsFunction)
217 , m_steps(steps) 229 , m_steps(steps)
218 , m_stepAtStart(stepAtStart) 230 , m_stepAtPosition(stepAtPosition)
219 , m_subType(subType) 231 , m_subType(subType)
220 { 232 {
221 } 233 }
222 234
223 int m_steps; 235 int m_steps;
224 bool m_stepAtStart; 236 StepAtPosition m_stepAtPosition;
225 SubType m_subType; 237 SubType m_subType;
226 }; 238 };
227 239
228 class PLATFORM_EXPORT ChainedTimingFunction FINAL : public TimingFunction { 240 class PLATFORM_EXPORT ChainedTimingFunction FINAL : public TimingFunction {
229 public: 241 public:
230 static PassRefPtr<ChainedTimingFunction> create() 242 static PassRefPtr<ChainedTimingFunction> create()
231 { 243 {
232 return adoptRef(new ChainedTimingFunction); 244 return adoptRef(new ChainedTimingFunction);
233 } 245 }
234 246
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 value.type() == TimingFunction::typeName##Function) 317 value.type() == TimingFunction::typeName##Function)
306 318
307 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Linear); 319 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Linear);
308 DEFINE_TIMING_FUNCTION_TYPE_CASTS(CubicBezier); 320 DEFINE_TIMING_FUNCTION_TYPE_CASTS(CubicBezier);
309 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Steps); 321 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Steps);
310 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Chained); 322 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Chained);
311 323
312 } // namespace WebCore 324 } // namespace WebCore
313 325
314 #endif // TimingFunction_h 326 #endif // TimingFunction_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698