| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 57 protected: | 57 protected: | 
| 58     TimingFunction(Type type) | 58     TimingFunction(Type type) | 
| 59         : m_type(type) | 59         : m_type(type) | 
| 60     { | 60     { | 
| 61     } | 61     } | 
| 62 | 62 | 
| 63 private: | 63 private: | 
| 64     Type m_type; | 64     Type m_type; | 
| 65 }; | 65 }; | 
| 66 | 66 | 
| 67 class LinearTimingFunction : public TimingFunction { | 67 class LinearTimingFunction FINAL : public TimingFunction { | 
| 68 public: | 68 public: | 
| 69     static PassRefPtr<LinearTimingFunction> create() | 69     static PassRefPtr<LinearTimingFunction> create() | 
| 70     { | 70     { | 
| 71         return adoptRef(new LinearTimingFunction); | 71         return adoptRef(new LinearTimingFunction); | 
| 72     } | 72     } | 
| 73 | 73 | 
| 74     ~LinearTimingFunction() { } | 74     virtual ~LinearTimingFunction() { } | 
| 75 | 75 | 
| 76     virtual double evaluate(double fraction, double) const | 76     virtual double evaluate(double fraction, double) const OVERRIDE | 
| 77     { | 77     { | 
| 78         ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >=
      0 && fraction <= 1)); | 78         ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >=
      0 && fraction <= 1)); | 
| 79         ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
     | (fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing 
     function behavior outside the range [0, 1] is not yet specified"); | 79         ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
     | (fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing 
     function behavior outside the range [0, 1] is not yet specified"); | 
| 80         return fraction; | 80         return fraction; | 
| 81     } | 81     } | 
| 82 | 82 | 
| 83 private: | 83 private: | 
| 84     LinearTimingFunction() | 84     LinearTimingFunction() | 
| 85         : TimingFunction(LinearFunction) | 85         : TimingFunction(LinearFunction) | 
| 86     { | 86     { | 
| 87     } | 87     } | 
| 88 }; | 88 }; | 
| 89 | 89 | 
| 90 | 90 | 
| 91 // Forward declare so we can friend it below. Don't use in production code! | 91 // Forward declare so we can friend it below. Don't use in production code! | 
| 92 class ChainedTimingFunctionTestHelper; | 92 class ChainedTimingFunctionTestHelper; | 
| 93 | 93 | 
| 94 class CubicBezierTimingFunction : public TimingFunction { | 94 class CubicBezierTimingFunction FINAL : public TimingFunction { | 
| 95 public: | 95 public: | 
| 96     enum SubType { | 96     enum SubType { | 
| 97         Ease, | 97         Ease, | 
| 98         EaseIn, | 98         EaseIn, | 
| 99         EaseOut, | 99         EaseOut, | 
| 100         EaseInOut, | 100         EaseInOut, | 
| 101         Custom | 101         Custom | 
| 102     }; | 102     }; | 
| 103 | 103 | 
| 104     static PassRefPtr<CubicBezierTimingFunction> create(double x1, double y1, do
     uble x2, double y2) | 104     static PassRefPtr<CubicBezierTimingFunction> create(double x1, double y1, do
     uble x2, double y2) | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 128             { | 128             { | 
| 129                 DEFINE_STATIC_REF(CubicBezierTimingFunction, easeInOut, (adoptRe
     f(new CubicBezierTimingFunction(EaseInOut, 0.42, 0.0, 0.58, 1.0)))); | 129                 DEFINE_STATIC_REF(CubicBezierTimingFunction, easeInOut, (adoptRe
     f(new CubicBezierTimingFunction(EaseInOut, 0.42, 0.0, 0.58, 1.0)))); | 
| 130                 return easeInOut; | 130                 return easeInOut; | 
| 131             } | 131             } | 
| 132         default: | 132         default: | 
| 133             ASSERT_NOT_REACHED(); | 133             ASSERT_NOT_REACHED(); | 
| 134             return 0; | 134             return 0; | 
| 135         } | 135         } | 
| 136     } | 136     } | 
| 137 | 137 | 
| 138     ~CubicBezierTimingFunction() { } | 138     virtual ~CubicBezierTimingFunction() { } | 
| 139 | 139 | 
| 140     virtual double evaluate(double fraction, double accuracy) const | 140     virtual double evaluate(double fraction, double accuracy) const OVERRIDE | 
| 141     { | 141     { | 
| 142         ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >=
      0 && fraction <= 1)); | 142         ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >=
      0 && fraction <= 1)); | 
| 143         ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
     | (fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing 
     function behavior outside the range [0, 1] is not yet specified"); | 143         ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
     | (fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing 
     function behavior outside the range [0, 1] is not yet specified"); | 
| 144         if (!m_bezier) | 144         if (!m_bezier) | 
| 145             m_bezier = adoptPtr(new UnitBezier(m_x1, m_y1, m_x2, m_y2)); | 145             m_bezier = adoptPtr(new UnitBezier(m_x1, m_y1, m_x2, m_y2)); | 
| 146         return m_bezier->solve(fraction, accuracy); | 146         return m_bezier->solve(fraction, accuracy); | 
| 147     } | 147     } | 
| 148 | 148 | 
| 149     double x1() const { return m_x1; } | 149     double x1() const { return m_x1; } | 
| 150     double y1() const { return m_y1; } | 150     double y1() const { return m_y1; } | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 165     } | 165     } | 
| 166 | 166 | 
| 167     double m_x1; | 167     double m_x1; | 
| 168     double m_y1; | 168     double m_y1; | 
| 169     double m_x2; | 169     double m_x2; | 
| 170     double m_y2; | 170     double m_y2; | 
| 171     SubType m_subType; | 171     SubType m_subType; | 
| 172     mutable OwnPtr<UnitBezier> m_bezier; | 172     mutable OwnPtr<UnitBezier> m_bezier; | 
| 173 }; | 173 }; | 
| 174 | 174 | 
| 175 class StepsTimingFunction : public TimingFunction { | 175 class StepsTimingFunction FINAL : public TimingFunction { | 
| 176 public: | 176 public: | 
| 177     enum SubType { | 177     enum SubType { | 
| 178         Start, | 178         Start, | 
| 179         End, | 179         End, | 
| 180         Custom | 180         Custom | 
| 181     }; | 181     }; | 
| 182 | 182 | 
| 183     static PassRefPtr<StepsTimingFunction> create(int steps, bool stepAtStart) | 183     static PassRefPtr<StepsTimingFunction> create(int steps, bool stepAtStart) | 
| 184     { | 184     { | 
| 185         return adoptRef(new StepsTimingFunction(Custom, steps, stepAtStart)); | 185         return adoptRef(new StepsTimingFunction(Custom, steps, stepAtStart)); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 198                 DEFINE_STATIC_REF(StepsTimingFunction, end, (adoptRef(new StepsT
     imingFunction(End, 1, false)))); | 198                 DEFINE_STATIC_REF(StepsTimingFunction, end, (adoptRef(new StepsT
     imingFunction(End, 1, false)))); | 
| 199                 return end; | 199                 return end; | 
| 200             } | 200             } | 
| 201         default: | 201         default: | 
| 202             ASSERT_NOT_REACHED(); | 202             ASSERT_NOT_REACHED(); | 
| 203             return 0; | 203             return 0; | 
| 204         } | 204         } | 
| 205     } | 205     } | 
| 206 | 206 | 
| 207 | 207 | 
| 208     ~StepsTimingFunction() { } | 208     virtual ~StepsTimingFunction() { } | 
| 209 | 209 | 
| 210     virtual double evaluate(double fraction, double) const | 210     virtual double evaluate(double fraction, double) const OVERRIDE | 
| 211     { | 211     { | 
| 212         ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >=
      0 && fraction <= 1)); | 212         ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >=
      0 && fraction <= 1)); | 
| 213         ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
     | (fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing 
     function behavior outside the range [0, 1] is not yet specified"); | 213         ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
     | (fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing 
     function behavior outside the range [0, 1] is not yet specified"); | 
| 214         return std::min(1.0, (floor(m_steps * fraction) + m_stepAtStart) / m_ste
     ps); | 214         return std::min(1.0, (floor(m_steps * fraction) + m_stepAtStart) / m_ste
     ps); | 
| 215     } | 215     } | 
| 216 | 216 | 
| 217     int numberOfSteps() const { return m_steps; } | 217     int numberOfSteps() const { return m_steps; } | 
| 218     bool stepAtStart() const { return m_stepAtStart; } | 218     bool stepAtStart() const { return m_stepAtStart; } | 
| 219 | 219 | 
| 220     SubType subType() const { return m_subType; } | 220     SubType subType() const { return m_subType; } | 
| 221 | 221 | 
| 222 private: | 222 private: | 
| 223     StepsTimingFunction(SubType subType, int steps, bool stepAtStart) | 223     StepsTimingFunction(SubType subType, int steps, bool stepAtStart) | 
| 224         : TimingFunction(StepsFunction) | 224         : TimingFunction(StepsFunction) | 
| 225         , m_steps(steps) | 225         , m_steps(steps) | 
| 226         , m_stepAtStart(stepAtStart) | 226         , m_stepAtStart(stepAtStart) | 
| 227         , m_subType(subType) | 227         , m_subType(subType) | 
| 228     { | 228     { | 
| 229     } | 229     } | 
| 230 | 230 | 
| 231     int m_steps; | 231     int m_steps; | 
| 232     bool m_stepAtStart; | 232     bool m_stepAtStart; | 
| 233     SubType m_subType; | 233     SubType m_subType; | 
| 234 }; | 234 }; | 
| 235 | 235 | 
| 236 class ChainedTimingFunction : public TimingFunction { | 236 class ChainedTimingFunction FINAL : public TimingFunction { | 
| 237 public: | 237 public: | 
| 238     static PassRefPtr<ChainedTimingFunction> create() | 238     static PassRefPtr<ChainedTimingFunction> create() | 
| 239     { | 239     { | 
| 240         return adoptRef(new ChainedTimingFunction); | 240         return adoptRef(new ChainedTimingFunction); | 
| 241     } | 241     } | 
| 242 | 242 | 
| 243     void appendSegment(double upperBound, TimingFunction* timingFunction) | 243     void appendSegment(double upperBound, TimingFunction* timingFunction) | 
| 244     { | 244     { | 
| 245         double max = m_segments.isEmpty() ? 0 : m_segments.last().max(); | 245         double max = m_segments.isEmpty() ? 0 : m_segments.last().max(); | 
| 246         ASSERT(upperBound > max); | 246         ASSERT(upperBound > max); | 
| 247         m_segments.append(Segment(max, upperBound, timingFunction)); | 247         m_segments.append(Segment(max, upperBound, timingFunction)); | 
| 248     } | 248     } | 
| 249     virtual double evaluate(double fraction, double accuracy) const | 249     virtual double evaluate(double fraction, double accuracy) const OVERRIDE | 
| 250     { | 250     { | 
| 251         ASSERT_WITH_MESSAGE(fraction >= 0 && fraction <= 1, "Web Animations not 
     yet implemented: Timing function behavior outside the range [0, 1] is not yet sp
     ecified"); | 251         ASSERT_WITH_MESSAGE(fraction >= 0 && fraction <= 1, "Web Animations not 
     yet implemented: Timing function behavior outside the range [0, 1] is not yet sp
     ecified"); | 
| 252         ASSERT(!m_segments.isEmpty()); | 252         ASSERT(!m_segments.isEmpty()); | 
| 253         ASSERT(m_segments.last().max() == 1); | 253         ASSERT(m_segments.last().max() == 1); | 
| 254         size_t i = 0; | 254         size_t i = 0; | 
| 255         const Segment* segment = &m_segments[i++]; | 255         const Segment* segment = &m_segments[i++]; | 
| 256         while (fraction >= segment->max() && i < m_segments.size()) { | 256         while (fraction >= segment->max() && i < m_segments.size()) { | 
| 257             segment = &m_segments[i++]; | 257             segment = &m_segments[i++]; | 
| 258         } | 258         } | 
| 259         return segment->evaluate(fraction, accuracy); | 259         return segment->evaluate(fraction, accuracy); | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 321         value.type() == TimingFunction::typeName##Function) | 321         value.type() == TimingFunction::typeName##Function) | 
| 322 | 322 | 
| 323 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Linear); | 323 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Linear); | 
| 324 DEFINE_TIMING_FUNCTION_TYPE_CASTS(CubicBezier); | 324 DEFINE_TIMING_FUNCTION_TYPE_CASTS(CubicBezier); | 
| 325 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Steps); | 325 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Steps); | 
| 326 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Chained); | 326 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Chained); | 
| 327 | 327 | 
| 328 } // namespace WebCore | 328 } // namespace WebCore | 
| 329 | 329 | 
| 330 #endif // TimingFunction_h | 330 #endif // TimingFunction_h | 
| OLD | NEW | 
|---|