1 | /* |
2 | * Copyright (C) 2007, 2008, 2012, 2016 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #include "CSSValue.h" |
29 | |
30 | namespace WebCore { |
31 | |
32 | class CSSCubicBezierTimingFunctionValue final : public CSSValue { |
33 | public: |
34 | static Ref<CSSCubicBezierTimingFunctionValue> create(double x1, double y1, double x2, double y2) |
35 | { |
36 | return adoptRef(*new CSSCubicBezierTimingFunctionValue(x1, y1, x2, y2)); |
37 | } |
38 | |
39 | String customCSSText() const; |
40 | |
41 | double x1() const { return m_x1; } |
42 | double y1() const { return m_y1; } |
43 | double x2() const { return m_x2; } |
44 | double y2() const { return m_y2; } |
45 | |
46 | bool equals(const CSSCubicBezierTimingFunctionValue&) const; |
47 | |
48 | private: |
49 | CSSCubicBezierTimingFunctionValue(double x1, double y1, double x2, double y2) |
50 | : CSSValue(CubicBezierTimingFunctionClass) |
51 | , m_x1(x1) |
52 | , m_y1(y1) |
53 | , m_x2(x2) |
54 | , m_y2(y2) |
55 | { |
56 | } |
57 | |
58 | double m_x1; |
59 | double m_y1; |
60 | double m_x2; |
61 | double m_y2; |
62 | }; |
63 | |
64 | class CSSStepsTimingFunctionValue final : public CSSValue { |
65 | public: |
66 | static Ref<CSSStepsTimingFunctionValue> create(int steps, bool stepAtStart) |
67 | { |
68 | return adoptRef(*new CSSStepsTimingFunctionValue(steps, stepAtStart)); |
69 | } |
70 | |
71 | int numberOfSteps() const { return m_steps; } |
72 | bool stepAtStart() const { return m_stepAtStart; } |
73 | |
74 | String customCSSText() const; |
75 | |
76 | bool equals(const CSSStepsTimingFunctionValue&) const; |
77 | |
78 | private: |
79 | CSSStepsTimingFunctionValue(int steps, bool stepAtStart) |
80 | : CSSValue(StepsTimingFunctionClass) |
81 | , m_steps(steps) |
82 | , m_stepAtStart(stepAtStart) |
83 | { |
84 | } |
85 | |
86 | int m_steps; |
87 | bool m_stepAtStart; |
88 | }; |
89 | |
90 | class CSSSpringTimingFunctionValue final : public CSSValue { |
91 | public: |
92 | static Ref<CSSSpringTimingFunctionValue> create(double mass, double stiffness, double damping, double initialVelocity) |
93 | { |
94 | return adoptRef(*new CSSSpringTimingFunctionValue(mass, stiffness, damping, initialVelocity)); |
95 | } |
96 | |
97 | double mass() const { return m_mass; } |
98 | double stiffness() const { return m_stiffness; } |
99 | double damping() const { return m_damping; } |
100 | double initialVelocity() const { return m_initialVelocity; } |
101 | |
102 | String customCSSText() const; |
103 | |
104 | bool equals(const CSSSpringTimingFunctionValue&) const; |
105 | |
106 | private: |
107 | CSSSpringTimingFunctionValue(double mass, double stiffness, double damping, double initialVelocity) |
108 | : CSSValue(SpringTimingFunctionClass) |
109 | , m_mass(mass) |
110 | , m_stiffness(stiffness) |
111 | , m_damping(damping) |
112 | , m_initialVelocity(initialVelocity) |
113 | { |
114 | } |
115 | |
116 | double m_mass; |
117 | double m_stiffness; |
118 | double m_damping; |
119 | double m_initialVelocity; |
120 | }; |
121 | |
122 | } // namespace WebCore |
123 | |
124 | SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSCubicBezierTimingFunctionValue, isCubicBezierTimingFunctionValue()) |
125 | SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSStepsTimingFunctionValue, isStepsTimingFunctionValue()) |
126 | SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSSpringTimingFunctionValue, isSpringTimingFunctionValue()) |
127 | |