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 | #include "TimingFunction.h"
|
---|
30 |
|
---|
31 | namespace WebCore {
|
---|
32 |
|
---|
33 | class CSSCubicBezierTimingFunctionValue final : public CSSValue {
|
---|
34 | public:
|
---|
35 | static Ref<CSSCubicBezierTimingFunctionValue> create(double x1, double y1, double x2, double y2)
|
---|
36 | {
|
---|
37 | return adoptRef(*new CSSCubicBezierTimingFunctionValue(x1, y1, x2, y2));
|
---|
38 | }
|
---|
39 |
|
---|
40 | String customCSSText() const;
|
---|
41 |
|
---|
42 | double x1() const { return m_x1; }
|
---|
43 | double y1() const { return m_y1; }
|
---|
44 | double x2() const { return m_x2; }
|
---|
45 | double y2() const { return m_y2; }
|
---|
46 |
|
---|
47 | bool equals(const CSSCubicBezierTimingFunctionValue&) const;
|
---|
48 |
|
---|
49 | private:
|
---|
50 | CSSCubicBezierTimingFunctionValue(double x1, double y1, double x2, double y2)
|
---|
51 | : CSSValue(CubicBezierTimingFunctionClass)
|
---|
52 | , m_x1(x1)
|
---|
53 | , m_y1(y1)
|
---|
54 | , m_x2(x2)
|
---|
55 | , m_y2(y2)
|
---|
56 | {
|
---|
57 | }
|
---|
58 |
|
---|
59 | double m_x1;
|
---|
60 | double m_y1;
|
---|
61 | double m_x2;
|
---|
62 | double m_y2;
|
---|
63 | };
|
---|
64 |
|
---|
65 | class CSSStepsTimingFunctionValue final : public CSSValue {
|
---|
66 | public:
|
---|
67 | static Ref<CSSStepsTimingFunctionValue> create(int steps, std::optional<StepsTimingFunction::StepPosition> stepPosition)
|
---|
68 | {
|
---|
69 | return adoptRef(*new CSSStepsTimingFunctionValue(steps, stepPosition));
|
---|
70 | }
|
---|
71 |
|
---|
72 | int numberOfSteps() const { return m_steps; }
|
---|
73 | std::optional<StepsTimingFunction::StepPosition> stepPosition() const { return m_stepPosition; }
|
---|
74 |
|
---|
75 | String customCSSText() const;
|
---|
76 |
|
---|
77 | bool equals(const CSSStepsTimingFunctionValue&) const;
|
---|
78 |
|
---|
79 | private:
|
---|
80 | CSSStepsTimingFunctionValue(int steps, std::optional<StepsTimingFunction::StepPosition> stepPosition)
|
---|
81 | : CSSValue(StepsTimingFunctionClass)
|
---|
82 | , m_steps(steps)
|
---|
83 | , m_stepPosition(stepPosition)
|
---|
84 | {
|
---|
85 | }
|
---|
86 |
|
---|
87 | int m_steps;
|
---|
88 | std::optional<StepsTimingFunction::StepPosition> m_stepPosition;
|
---|
89 | };
|
---|
90 |
|
---|
91 | class CSSSpringTimingFunctionValue final : public CSSValue {
|
---|
92 | public:
|
---|
93 | static Ref<CSSSpringTimingFunctionValue> create(double mass, double stiffness, double damping, double initialVelocity)
|
---|
94 | {
|
---|
95 | return adoptRef(*new CSSSpringTimingFunctionValue(mass, stiffness, damping, initialVelocity));
|
---|
96 | }
|
---|
97 |
|
---|
98 | double mass() const { return m_mass; }
|
---|
99 | double stiffness() const { return m_stiffness; }
|
---|
100 | double damping() const { return m_damping; }
|
---|
101 | double initialVelocity() const { return m_initialVelocity; }
|
---|
102 |
|
---|
103 | String customCSSText() const;
|
---|
104 |
|
---|
105 | bool equals(const CSSSpringTimingFunctionValue&) const;
|
---|
106 |
|
---|
107 | private:
|
---|
108 | CSSSpringTimingFunctionValue(double mass, double stiffness, double damping, double initialVelocity)
|
---|
109 | : CSSValue(SpringTimingFunctionClass)
|
---|
110 | , m_mass(mass)
|
---|
111 | , m_stiffness(stiffness)
|
---|
112 | , m_damping(damping)
|
---|
113 | , m_initialVelocity(initialVelocity)
|
---|
114 | {
|
---|
115 | }
|
---|
116 |
|
---|
117 | double m_mass;
|
---|
118 | double m_stiffness;
|
---|
119 | double m_damping;
|
---|
120 | double m_initialVelocity;
|
---|
121 | };
|
---|
122 |
|
---|
123 | } // namespace WebCore
|
---|
124 |
|
---|
125 | SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSCubicBezierTimingFunctionValue, isCubicBezierTimingFunctionValue())
|
---|
126 | SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSStepsTimingFunctionValue, isStepsTimingFunctionValue())
|
---|
127 | SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSSpringTimingFunctionValue, isSpringTimingFunctionValue())
|
---|