1 | /* |
2 | * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
3 | * Copyright (C) 2004-2017 Apple Inc. All rights reserved. |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public License |
16 | * along with this library; see the file COPYING.LIB. If not, write to |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | * |
20 | */ |
21 | |
22 | #include "config.h" |
23 | #include "Animation.h" |
24 | |
25 | #include <wtf/NeverDestroyed.h> |
26 | |
27 | namespace WebCore { |
28 | |
29 | Animation::Animation() |
30 | : m_name(initialName()) |
31 | , m_iterationCount(initialIterationCount()) |
32 | , m_delay(initialDelay()) |
33 | , m_duration(initialDuration()) |
34 | , m_timingFunction(initialTimingFunction()) |
35 | , m_mode(AnimateAll) |
36 | , m_direction(initialDirection()) |
37 | , m_fillMode(static_cast<unsigned>(initialFillMode())) |
38 | , m_playState(static_cast<unsigned>(initialPlayState())) |
39 | , m_delaySet(false) |
40 | , m_directionSet(false) |
41 | , m_durationSet(false) |
42 | , m_fillModeSet(false) |
43 | , m_iterationCountSet(false) |
44 | , m_nameSet(false) |
45 | , m_playStateSet(false) |
46 | , m_propertySet(false) |
47 | , m_timingFunctionSet(false) |
48 | , m_isNone(false) |
49 | { |
50 | } |
51 | |
52 | Animation::Animation(const Animation& o) |
53 | : RefCounted<Animation>() |
54 | , m_property(o.m_property) |
55 | , m_name(o.m_name) |
56 | , m_iterationCount(o.m_iterationCount) |
57 | , m_delay(o.m_delay) |
58 | , m_duration(o.m_duration) |
59 | , m_timingFunction(o.m_timingFunction) |
60 | , m_nameStyleScopeOrdinal(o.m_nameStyleScopeOrdinal) |
61 | , m_mode(o.m_mode) |
62 | , m_direction(o.m_direction) |
63 | , m_fillMode(o.m_fillMode) |
64 | , m_playState(o.m_playState) |
65 | , m_delaySet(o.m_delaySet) |
66 | , m_directionSet(o.m_directionSet) |
67 | , m_durationSet(o.m_durationSet) |
68 | , m_fillModeSet(o.m_fillModeSet) |
69 | , m_iterationCountSet(o.m_iterationCountSet) |
70 | , m_nameSet(o.m_nameSet) |
71 | , m_playStateSet(o.m_playStateSet) |
72 | , m_propertySet(o.m_propertySet) |
73 | , m_timingFunctionSet(o.m_timingFunctionSet) |
74 | , m_isNone(o.m_isNone) |
75 | { |
76 | } |
77 | |
78 | Animation& Animation::operator=(const Animation& o) |
79 | { |
80 | m_name = o.m_name; |
81 | m_iterationCount = o.m_iterationCount; |
82 | m_delay = o.m_delay; |
83 | m_duration = o.m_duration; |
84 | m_timingFunction = o.m_timingFunction; |
85 | m_nameStyleScopeOrdinal = o.m_nameStyleScopeOrdinal; |
86 | m_property = o.m_property; |
87 | m_mode = o.m_mode; |
88 | m_direction = o.m_direction; |
89 | m_fillMode = o.m_fillMode; |
90 | m_playState = o.m_playState; |
91 | |
92 | m_delaySet = o.m_delaySet; |
93 | m_directionSet = o.m_directionSet; |
94 | m_durationSet = o.m_durationSet; |
95 | m_fillModeSet = o.m_fillModeSet; |
96 | m_iterationCountSet = o.m_iterationCountSet; |
97 | m_nameSet = o.m_nameSet; |
98 | m_playStateSet = o.m_playStateSet; |
99 | m_propertySet = o.m_propertySet; |
100 | m_timingFunctionSet = o.m_timingFunctionSet; |
101 | m_isNone = o.m_isNone; |
102 | |
103 | return *this; |
104 | } |
105 | |
106 | Animation::~Animation() = default; |
107 | |
108 | bool Animation::animationsMatch(const Animation& other, bool matchProperties) const |
109 | { |
110 | bool result = m_name == other.m_name |
111 | && m_playState == other.m_playState |
112 | && m_playStateSet == other.m_playStateSet |
113 | && m_iterationCount == other.m_iterationCount |
114 | && m_delay == other.m_delay |
115 | && m_duration == other.m_duration |
116 | && *(m_timingFunction.get()) == *(other.m_timingFunction.get()) |
117 | && m_nameStyleScopeOrdinal == other.m_nameStyleScopeOrdinal |
118 | && m_direction == other.m_direction |
119 | && m_fillMode == other.m_fillMode |
120 | && m_delaySet == other.m_delaySet |
121 | && m_directionSet == other.m_directionSet |
122 | && m_durationSet == other.m_durationSet |
123 | && m_fillModeSet == other.m_fillModeSet |
124 | && m_iterationCountSet == other.m_iterationCountSet |
125 | && m_nameSet == other.m_nameSet |
126 | && m_timingFunctionSet == other.m_timingFunctionSet |
127 | && m_isNone == other.m_isNone; |
128 | |
129 | if (!result) |
130 | return false; |
131 | |
132 | return !matchProperties || (m_mode == other.m_mode && m_property == other.m_property && m_propertySet == other.m_propertySet); |
133 | } |
134 | |
135 | const String& Animation::initialName() |
136 | { |
137 | static NeverDestroyed<String> initialValue(MAKE_STATIC_STRING_IMPL("none" )); |
138 | return initialValue; |
139 | } |
140 | |
141 | } // namespace WebCore |
142 | |