OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/animation/LengthListPropertyFunctions.h" | 5 #include "core/animation/LengthListPropertyFunctions.h" |
6 | 6 |
7 #include "core/style/ComputedStyle.h" | 7 #include "core/style/ComputedStyle.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 } // namespace | 77 } // namespace |
78 | 78 |
79 ValueRange LengthListPropertyFunctions::valueRange(CSSPropertyID property) | 79 ValueRange LengthListPropertyFunctions::valueRange(CSSPropertyID property) |
80 { | 80 { |
81 switch (property) { | 81 switch (property) { |
82 case CSSPropertyBackgroundPositionX: | 82 case CSSPropertyBackgroundPositionX: |
83 case CSSPropertyBackgroundPositionY: | 83 case CSSPropertyBackgroundPositionY: |
84 case CSSPropertyObjectPosition: | 84 case CSSPropertyObjectPosition: |
85 case CSSPropertyPerspectiveOrigin: | 85 case CSSPropertyPerspectiveOrigin: |
| 86 case CSSPropertyTransformOrigin: |
86 case CSSPropertyWebkitMaskPositionX: | 87 case CSSPropertyWebkitMaskPositionX: |
87 case CSSPropertyWebkitMaskPositionY: | 88 case CSSPropertyWebkitMaskPositionY: |
88 return ValueRangeAll; | 89 return ValueRangeAll; |
89 | 90 |
90 case CSSPropertyBorderBottomLeftRadius: | 91 case CSSPropertyBorderBottomLeftRadius: |
91 case CSSPropertyBorderBottomRightRadius: | 92 case CSSPropertyBorderBottomRightRadius: |
92 case CSSPropertyBorderTopLeftRadius: | 93 case CSSPropertyBorderTopLeftRadius: |
93 case CSSPropertyBorderTopRightRadius: | 94 case CSSPropertyBorderTopRightRadius: |
94 case CSSPropertyStrokeDasharray: | 95 case CSSPropertyStrokeDasharray: |
95 return ValueRangeNonNegative; | 96 return ValueRangeNonNegative; |
(...skipping 18 matching lines...) Expand all Loading... |
114 } | 115 } |
115 | 116 |
116 static Vector<Length> toVector(const LengthSize& size) | 117 static Vector<Length> toVector(const LengthSize& size) |
117 { | 118 { |
118 Vector<Length> result(2); | 119 Vector<Length> result(2); |
119 result[0] = size.width(); | 120 result[0] = size.width(); |
120 result[1] = size.height(); | 121 result[1] = size.height(); |
121 return result; | 122 return result; |
122 } | 123 } |
123 | 124 |
| 125 static Vector<Length> toVector(const TransformOrigin& transformOrigin) |
| 126 { |
| 127 Vector<Length> result(3); |
| 128 result[0] = transformOrigin.x(); |
| 129 result[1] = transformOrigin.y(); |
| 130 result[2] = Length(transformOrigin.z(), Fixed); |
| 131 return result; |
| 132 } |
| 133 |
124 Vector<Length> LengthListPropertyFunctions::getLengthList(CSSPropertyID property
, const ComputedStyle& style) | 134 Vector<Length> LengthListPropertyFunctions::getLengthList(CSSPropertyID property
, const ComputedStyle& style) |
125 { | 135 { |
126 switch (property) { | 136 switch (property) { |
127 case CSSPropertyStrokeDasharray: { | 137 case CSSPropertyStrokeDasharray: { |
128 if (style.strokeDashArray()) | 138 if (style.strokeDashArray()) |
129 return style.strokeDashArray()->vector(); | 139 return style.strokeDashArray()->vector(); |
130 return Vector<Length>(); | 140 return Vector<Length>(); |
131 } | 141 } |
132 case CSSPropertyObjectPosition: | 142 case CSSPropertyObjectPosition: |
133 return toVector(style.objectPosition()); | 143 return toVector(style.objectPosition()); |
134 case CSSPropertyPerspectiveOrigin: | 144 case CSSPropertyPerspectiveOrigin: |
135 return toVector(style.perspectiveOrigin()); | 145 return toVector(style.perspectiveOrigin()); |
136 case CSSPropertyBorderBottomLeftRadius: | 146 case CSSPropertyBorderBottomLeftRadius: |
137 return toVector(style.borderBottomLeftRadius()); | 147 return toVector(style.borderBottomLeftRadius()); |
138 case CSSPropertyBorderBottomRightRadius: | 148 case CSSPropertyBorderBottomRightRadius: |
139 return toVector(style.borderBottomRightRadius()); | 149 return toVector(style.borderBottomRightRadius()); |
140 case CSSPropertyBorderTopLeftRadius: | 150 case CSSPropertyBorderTopLeftRadius: |
141 return toVector(style.borderTopLeftRadius()); | 151 return toVector(style.borderTopLeftRadius()); |
142 case CSSPropertyBorderTopRightRadius: | 152 case CSSPropertyBorderTopRightRadius: |
143 return toVector(style.borderTopRightRadius()); | 153 return toVector(style.borderTopRightRadius()); |
| 154 case CSSPropertyTransformOrigin: |
| 155 return toVector(style.transformOrigin()); |
144 default: | 156 default: |
145 break; | 157 break; |
146 } | 158 } |
147 | 159 |
148 Vector<Length> result; | 160 Vector<Length> result; |
149 const FillLayer* fillLayer = getFillLayer(property, style); | 161 const FillLayer* fillLayer = getFillLayer(property, style); |
150 FillLayerMethods fillLayerMethods(property); | 162 FillLayerMethods fillLayerMethods(property); |
151 while (fillLayer && (fillLayer->*fillLayerMethods.isSet)()) { | 163 while (fillLayer && (fillLayer->*fillLayerMethods.isSet)()) { |
152 result.append((fillLayer->*fillLayerMethods.get)()); | 164 result.append((fillLayer->*fillLayerMethods.get)()); |
153 fillLayer = fillLayer->next(); | 165 fillLayer = fillLayer->next(); |
154 } | 166 } |
155 return result; | 167 return result; |
156 } | 168 } |
157 | 169 |
158 static LengthPoint pointFromVector(const Vector<Length>& list) | 170 static LengthPoint pointFromVector(const Vector<Length>& list) |
159 { | 171 { |
160 ASSERT(list.size() == 2); | 172 ASSERT(list.size() == 2); |
161 return LengthPoint(list[0], list[1]); | 173 return LengthPoint(list[0], list[1]); |
162 } | 174 } |
163 | 175 |
164 static LengthSize sizeFromVector(const Vector<Length>& list) | 176 static LengthSize sizeFromVector(const Vector<Length>& list) |
165 { | 177 { |
166 ASSERT(list.size() == 2); | 178 ASSERT(list.size() == 2); |
167 return LengthSize(list[0], list[1]); | 179 return LengthSize(list[0], list[1]); |
168 } | 180 } |
169 | 181 |
| 182 static TransformOrigin transformOriginFromVector(const Vector<Length>& list) |
| 183 { |
| 184 ASSERT(list.size() == 3); |
| 185 return TransformOrigin(list[0], list[1], list[2].pixels()); |
| 186 } |
| 187 |
170 void LengthListPropertyFunctions::setLengthList(CSSPropertyID property, Computed
Style& style, Vector<Length>&& lengthList) | 188 void LengthListPropertyFunctions::setLengthList(CSSPropertyID property, Computed
Style& style, Vector<Length>&& lengthList) |
171 { | 189 { |
172 switch (property) { | 190 switch (property) { |
173 case CSSPropertyStrokeDasharray: | 191 case CSSPropertyStrokeDasharray: |
174 style.setStrokeDashArray(lengthList.isEmpty() ? nullptr : RefVector<Leng
th>::create(std::move(lengthList))); | 192 style.setStrokeDashArray(lengthList.isEmpty() ? nullptr : RefVector<Leng
th>::create(std::move(lengthList))); |
175 return; | 193 return; |
176 case CSSPropertyObjectPosition: | 194 case CSSPropertyObjectPosition: |
177 style.setObjectPosition(pointFromVector(lengthList)); | 195 style.setObjectPosition(pointFromVector(lengthList)); |
178 return; | 196 return; |
179 case CSSPropertyPerspectiveOrigin: | 197 case CSSPropertyPerspectiveOrigin: |
180 style.setPerspectiveOrigin(pointFromVector(lengthList)); | 198 style.setPerspectiveOrigin(pointFromVector(lengthList)); |
181 return; | 199 return; |
182 case CSSPropertyBorderBottomLeftRadius: | 200 case CSSPropertyBorderBottomLeftRadius: |
183 style.setBorderBottomLeftRadius(sizeFromVector(lengthList)); | 201 style.setBorderBottomLeftRadius(sizeFromVector(lengthList)); |
184 return; | 202 return; |
185 case CSSPropertyBorderBottomRightRadius: | 203 case CSSPropertyBorderBottomRightRadius: |
186 style.setBorderBottomRightRadius(sizeFromVector(lengthList)); | 204 style.setBorderBottomRightRadius(sizeFromVector(lengthList)); |
187 return; | 205 return; |
188 case CSSPropertyBorderTopLeftRadius: | 206 case CSSPropertyBorderTopLeftRadius: |
189 style.setBorderTopLeftRadius(sizeFromVector(lengthList)); | 207 style.setBorderTopLeftRadius(sizeFromVector(lengthList)); |
190 return; | 208 return; |
191 case CSSPropertyBorderTopRightRadius: | 209 case CSSPropertyBorderTopRightRadius: |
192 style.setBorderTopRightRadius(sizeFromVector(lengthList)); | 210 style.setBorderTopRightRadius(sizeFromVector(lengthList)); |
193 return; | 211 return; |
| 212 case CSSPropertyTransformOrigin: |
| 213 style.setTransformOrigin(transformOriginFromVector(lengthList)); |
| 214 return; |
194 default: | 215 default: |
195 break; | 216 break; |
196 } | 217 } |
197 | 218 |
198 FillLayer* fillLayer = accessFillLayer(property, style); | 219 FillLayer* fillLayer = accessFillLayer(property, style); |
199 FillLayer* prev = nullptr; | 220 FillLayer* prev = nullptr; |
200 FillLayerMethods fillLayerMethods(property); | 221 FillLayerMethods fillLayerMethods(property); |
201 for (size_t i = 0; i < lengthList.size(); i++) { | 222 for (size_t i = 0; i < lengthList.size(); i++) { |
202 if (!fillLayer) | 223 if (!fillLayer) |
203 fillLayer = prev->ensureNext(); | 224 fillLayer = prev->ensureNext(); |
204 (fillLayer->*fillLayerMethods.set)(lengthList[i]); | 225 (fillLayer->*fillLayerMethods.set)(lengthList[i]); |
205 prev = fillLayer; | 226 prev = fillLayer; |
206 fillLayer = fillLayer->next(); | 227 fillLayer = fillLayer->next(); |
207 } | 228 } |
208 while (fillLayer) { | 229 while (fillLayer) { |
209 (fillLayer->*fillLayerMethods.clear)(); | 230 (fillLayer->*fillLayerMethods.clear)(); |
210 fillLayer = fillLayer->next(); | 231 fillLayer = fillLayer->next(); |
211 } | 232 } |
212 } | 233 } |
213 | 234 |
214 } // namespace blink | 235 } // namespace blink |
OLD | NEW |