OLD | NEW |
---|---|
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 17 matching lines...) Expand all Loading... | |
28 #include "RuntimeEnabledFeatures.h" | 28 #include "RuntimeEnabledFeatures.h" |
29 #include "platform/animation/AnimationUtilities.h" // For blend() | 29 #include "platform/animation/AnimationUtilities.h" // For blend() |
30 #include "platform/animation/UnitBezier.h" | 30 #include "platform/animation/UnitBezier.h" |
31 #include "wtf/OwnPtr.h" | 31 #include "wtf/OwnPtr.h" |
32 #include "wtf/PassOwnPtr.h" | 32 #include "wtf/PassOwnPtr.h" |
33 #include "wtf/PassRefPtr.h" | 33 #include "wtf/PassRefPtr.h" |
34 #include "wtf/RefCounted.h" | 34 #include "wtf/RefCounted.h" |
35 #include "wtf/Vector.h" | 35 #include "wtf/Vector.h" |
36 #include <algorithm> | 36 #include <algorithm> |
37 | 37 |
38 | |
38 namespace WebCore { | 39 namespace WebCore { |
39 | 40 |
40 class TimingFunction : public RefCounted<TimingFunction> { | 41 class TimingFunction : public RefCounted<TimingFunction> { |
41 public: | 42 public: |
42 | 43 |
43 enum Type { | 44 enum Type { |
44 LinearFunction, CubicBezierFunction, StepsFunction, ChainedFunction | 45 LinearFunction, CubicBezierFunction, StepsFunction, ChainedFunction |
45 }; | 46 }; |
46 | 47 |
47 virtual ~TimingFunction() { } | 48 virtual ~TimingFunction() { } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 return other.type() == LinearFunction; | 85 return other.type() == LinearFunction; |
85 } | 86 } |
86 | 87 |
87 private: | 88 private: |
88 LinearTimingFunction() | 89 LinearTimingFunction() |
89 : TimingFunction(LinearFunction) | 90 : TimingFunction(LinearFunction) |
90 { | 91 { |
91 } | 92 } |
92 }; | 93 }; |
93 | 94 |
95 | |
96 // Forward declare so we can friend it below. Don't used in production code! | |
Steve Block
2013/11/04 23:05:02
s/used/use
mithro-old
2013/11/05 01:53:09
Done.
| |
97 class ChainedTimingFunctionPrintTo; | |
98 | |
94 class CubicBezierTimingFunction : public TimingFunction { | 99 class CubicBezierTimingFunction : public TimingFunction { |
95 public: | 100 public: |
96 enum SubType { | 101 enum SubType { |
97 Ease, | 102 Ease, |
98 EaseIn, | 103 EaseIn, |
99 EaseOut, | 104 EaseOut, |
100 EaseInOut, | 105 EaseInOut, |
101 Custom | 106 Custom |
102 }; | 107 }; |
103 | 108 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 return scaleFromLocal(m_timingFunction->evaluate(scaleToLocal(fracti on), accuracy)); | 309 return scaleFromLocal(m_timingFunction->evaluate(scaleToLocal(fracti on), accuracy)); |
305 } | 310 } |
306 | 311 |
307 private: | 312 private: |
308 double scaleToLocal(double x) const { return (x - m_min) / (m_max - m_mi n); } | 313 double scaleToLocal(double x) const { return (x - m_min) / (m_max - m_mi n); } |
309 double scaleFromLocal(double x) const { return blend(m_min, m_max, x); } | 314 double scaleFromLocal(double x) const { return blend(m_min, m_max, x); } |
310 | 315 |
311 double m_min; | 316 double m_min; |
312 double m_max; | 317 double m_max; |
313 RefPtr<TimingFunction> m_timingFunction; | 318 RefPtr<TimingFunction> m_timingFunction; |
319 | |
320 // Allow printing of our segments. Can be removed once | |
321 // ChainedTimingFunction has a public API for segments. | |
322 friend class ChainedTimingFunctionPrintTo; | |
314 }; | 323 }; |
315 | 324 |
316 ChainedTimingFunction() | 325 ChainedTimingFunction() |
317 : TimingFunction(ChainedFunction) | 326 : TimingFunction(ChainedFunction) |
318 { | 327 { |
319 ASSERT(RuntimeEnabledFeatures::webAnimationsEnabled()); | 328 ASSERT(RuntimeEnabledFeatures::webAnimationsEnabled()); |
320 } | 329 } |
321 | 330 |
322 Vector<Segment> m_segments; | 331 Vector<Segment> m_segments; |
332 | |
333 // Allow printing of our segments. Can be removed once | |
334 // ChainedTimingFunction has a public API for segments. | |
335 friend class ChainedTimingFunctionPrintTo; | |
323 }; | 336 }; |
324 | 337 |
325 } // namespace WebCore | 338 } // namespace WebCore |
326 | 339 |
327 #endif // TimingFunction_h | 340 #endif // TimingFunction_h |
OLD | NEW |