OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2008 Apple Inc. All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2012. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2012. All rights reserved. |
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 28 matching lines...) Expand all Loading... |
39 SVGTransformList::~SVGTransformList() | 39 SVGTransformList::~SVGTransformList() |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 PassRefPtrWillBeRawPtr<SVGTransform> SVGTransformList::consolidate() | 43 PassRefPtrWillBeRawPtr<SVGTransform> SVGTransformList::consolidate() |
44 { | 44 { |
45 AffineTransform matrix; | 45 AffineTransform matrix; |
46 if (!concatenate(matrix)) | 46 if (!concatenate(matrix)) |
47 return SVGTransform::create(); | 47 return SVGTransform::create(); |
48 | 48 |
49 RefPtrWillBeRawPtr<SVGTransform> transform = SVGTransform::create(matrix); | 49 return initialize(SVGTransform::create(matrix)); |
50 clear(); | |
51 return appendItem(transform); | |
52 } | 50 } |
53 | 51 |
54 bool SVGTransformList::concatenate(AffineTransform& result) const | 52 bool SVGTransformList::concatenate(AffineTransform& result) const |
55 { | 53 { |
56 if (isEmpty()) | 54 if (isEmpty()) |
57 return false; | 55 return false; |
58 | 56 |
59 ConstIterator it = begin(); | 57 ConstIterator it = begin(); |
60 ConstIterator itEnd = end(); | 58 ConstIterator itEnd = end(); |
61 for (; it != itEnd; ++it) | 59 for (; it != itEnd; ++it) |
62 result *= it->matrix(); | 60 result *= it->matrix(); |
63 | 61 |
64 return true; | 62 return true; |
65 } | 63 } |
66 | 64 |
67 namespace { | 65 namespace { |
68 | 66 |
69 const LChar skewXDesc[] = {'s', 'k', 'e', 'w', 'X'}; | 67 const LChar skewXDesc[] = {'s', 'k', 'e', 'w', 'X'}; |
70 const LChar skewYDesc[] = {'s', 'k', 'e', 'w', 'Y'}; | 68 const LChar skewYDesc[] = {'s', 'k', 'e', 'w', 'Y'}; |
71 const LChar scaleDesc[] = {'s', 'c', 'a', 'l', 'e'}; | 69 const LChar scaleDesc[] = {'s', 'c', 'a', 'l', 'e'}; |
72 const LChar translateDesc[] = {'t', 'r', 'a', 'n', 's', 'l', 'a', 't', 'e'}; | 70 const LChar translateDesc[] = {'t', 'r', 'a', 'n', 's', 'l', 'a', 't', 'e'}; |
73 const LChar rotateDesc[] = {'r', 'o', 't', 'a', 't', 'e'}; | 71 const LChar rotateDesc[] = {'r', 'o', 't', 'a', 't', 'e'}; |
74 const LChar matrixDesc[] = {'m', 'a', 't', 'r', 'i', 'x'}; | 72 const LChar matrixDesc[] = {'m', 'a', 't', 'r', 'i', 'x'}; |
75 | 73 |
76 template<typename CharType> | 74 template<typename CharType> |
77 bool parseAndSkipTransformType(const CharType*& ptr, const CharType* end, SVGTra
nsformType& type) | 75 SVGTransformType parseAndSkipTransformType(const CharType*& ptr, const CharType*
end) |
78 { | 76 { |
79 if (ptr >= end) | 77 if (ptr >= end) |
80 return false; | 78 return SVG_TRANSFORM_UNKNOWN; |
81 | 79 |
82 if (*ptr == 's') { | 80 if (*ptr == 's') { |
83 if (skipString(ptr, end, skewXDesc, WTF_ARRAY_LENGTH(skewXDesc))) | 81 if (skipString(ptr, end, skewXDesc, WTF_ARRAY_LENGTH(skewXDesc))) |
84 type = SVG_TRANSFORM_SKEWX; | 82 return SVG_TRANSFORM_SKEWX; |
85 else if (skipString(ptr, end, skewYDesc, WTF_ARRAY_LENGTH(skewYDesc))) | 83 if (skipString(ptr, end, skewYDesc, WTF_ARRAY_LENGTH(skewYDesc))) |
86 type = SVG_TRANSFORM_SKEWY; | 84 return SVG_TRANSFORM_SKEWY; |
87 else if (skipString(ptr, end, scaleDesc, WTF_ARRAY_LENGTH(scaleDesc))) | 85 if (skipString(ptr, end, scaleDesc, WTF_ARRAY_LENGTH(scaleDesc))) |
88 type = SVG_TRANSFORM_SCALE; | 86 return SVG_TRANSFORM_SCALE; |
89 else | 87 |
90 return false; | 88 return SVG_TRANSFORM_UNKNOWN; |
91 } else if (skipString(ptr, end, translateDesc, WTF_ARRAY_LENGTH(translateDes
c))) { | |
92 type = SVG_TRANSFORM_TRANSLATE; | |
93 } else if (skipString(ptr, end, rotateDesc, WTF_ARRAY_LENGTH(rotateDesc))) { | |
94 type = SVG_TRANSFORM_ROTATE; | |
95 } else if (skipString(ptr, end, matrixDesc, WTF_ARRAY_LENGTH(matrixDesc))) { | |
96 type = SVG_TRANSFORM_MATRIX; | |
97 } else { | |
98 return false; | |
99 } | 89 } |
100 return true; | 90 if (skipString(ptr, end, translateDesc, WTF_ARRAY_LENGTH(translateDesc))) |
| 91 return SVG_TRANSFORM_TRANSLATE; |
| 92 if (skipString(ptr, end, rotateDesc, WTF_ARRAY_LENGTH(rotateDesc))) |
| 93 return SVG_TRANSFORM_ROTATE; |
| 94 if (skipString(ptr, end, matrixDesc, WTF_ARRAY_LENGTH(matrixDesc))) |
| 95 return SVG_TRANSFORM_MATRIX; |
| 96 |
| 97 return SVG_TRANSFORM_UNKNOWN; |
101 } | 98 } |
102 | 99 |
| 100 // These should be kept in sync with enum SVGTransformType |
| 101 const unsigned requiredValuesForType[] = {0, 6, 1, 1, 1, 1, 1}; |
| 102 const unsigned optionalValuesForType[] = {0, 0, 1, 1, 2, 0, 0}; |
| 103 static_assert(SVG_TRANSFORM_UNKNOWN == 0, "index of SVG_TRANSFORM_UNKNOWN has ch
anged"); |
| 104 static_assert(SVG_TRANSFORM_MATRIX == 1, "index of SVG_TRANSFORM_MATRIX has chan
ged"); |
| 105 static_assert(SVG_TRANSFORM_TRANSLATE == 2, "index of SVG_TRANSFORM_TRANSLATE ha
s changed"); |
| 106 static_assert(SVG_TRANSFORM_SCALE == 3, "index of SVG_TRANSFORM_SCALE has change
d"); |
| 107 static_assert(SVG_TRANSFORM_ROTATE == 4, "index of SVG_TRANSFORM_ROTATE has chan
ged"); |
| 108 static_assert(SVG_TRANSFORM_SKEWX == 5, "index of SVG_TRANSFORM_SKEWX has change
d"); |
| 109 static_assert(SVG_TRANSFORM_SKEWY == 6, "index of SVG_TRANSFORM_SKEWY has change
d"); |
| 110 static_assert(WTF_ARRAY_LENGTH(requiredValuesForType) - 1 == SVG_TRANSFORM_SKEWY
, "the number of transform types have changed"); |
| 111 static_assert(WTF_ARRAY_LENGTH(requiredValuesForType) == WTF_ARRAY_LENGTH(option
alValuesForType), "the arrays should have the same number of elements"); |
| 112 |
| 113 const unsigned kMaxTransformArguments = 6; |
| 114 |
| 115 using TransformArguments = Vector<float, kMaxTransformArguments>; |
| 116 |
103 template<typename CharType> | 117 template<typename CharType> |
104 int parseTransformParamList(const CharType*& ptr, const CharType* end, float* va
lues, int required, int optional) | 118 int parseTransformArgumentsForType( |
| 119 SVGTransformType type, |
| 120 const CharType*& ptr, const CharType* end, |
| 121 TransformArguments& arguments) |
105 { | 122 { |
106 int parsedParams = 0; | 123 const size_t required = requiredValuesForType[type]; |
107 int maxPossibleParams = required + optional; | 124 const size_t optional = optionalValuesForType[type]; |
| 125 const size_t maxPossibleParams = required + optional; |
| 126 ASSERT(maxPossibleParams <= kMaxTransformArguments); |
| 127 ASSERT(arguments.isEmpty()); |
108 | 128 |
109 bool trailingDelimiter = false; | 129 bool trailingDelimiter = false; |
110 | 130 |
111 skipOptionalSVGSpaces(ptr, end); | 131 while (arguments.size() < maxPossibleParams) { |
112 while (parsedParams < maxPossibleParams) { | 132 float argumentValue = 0; |
113 if (!parseNumber(ptr, end, values[parsedParams], DisallowWhitespace)) | 133 if (!parseNumber(ptr, end, argumentValue, AllowLeadingWhitespace)) |
114 break; | 134 break; |
115 | 135 |
116 ++parsedParams; | 136 arguments.append(argumentValue); |
| 137 trailingDelimiter = false; |
| 138 |
| 139 if (arguments.size() == maxPossibleParams) |
| 140 break; |
117 | 141 |
118 if (skipOptionalSVGSpaces(ptr, end) && *ptr == ',') { | 142 if (skipOptionalSVGSpaces(ptr, end) && *ptr == ',') { |
119 ++ptr; | 143 ++ptr; |
120 skipOptionalSVGSpaces(ptr, end); | |
121 | |
122 trailingDelimiter = true; | 144 trailingDelimiter = true; |
123 } else { | |
124 trailingDelimiter = false; | |
125 } | 145 } |
126 } | 146 } |
127 | 147 |
128 if (trailingDelimiter || !(parsedParams == required || parsedParams == maxPo
ssibleParams)) | 148 if (trailingDelimiter || !(arguments.size() == required || arguments.size()
== maxPossibleParams)) |
129 return -1; | 149 return -1; |
130 | 150 |
131 return parsedParams; | 151 return safeCast<int>(arguments.size()); |
132 } | 152 } |
133 | 153 |
134 // These should be kept in sync with enum SVGTransformType | 154 PassRefPtrWillBeRawPtr<SVGTransform> createTransformFromValues(SVGTransformType
type, const TransformArguments& arguments) |
135 const int requiredValuesForType[] = {0, 6, 1, 1, 1, 1, 1}; | |
136 const int optionalValuesForType[] = {0, 0, 1, 1, 2, 0, 0}; | |
137 | |
138 template<typename CharType> | |
139 PassRefPtrWillBeRawPtr<SVGTransform> parseTransformOfType(unsigned type, const C
harType*& ptr, const CharType* end) | |
140 { | 155 { |
141 if (type == SVG_TRANSFORM_UNKNOWN) | |
142 return nullptr; | |
143 | |
144 int valueCount = 0; | |
145 float values[] = {0, 0, 0, 0, 0, 0}; | |
146 if ((valueCount = parseTransformParamList(ptr, end, values, requiredValuesFo
rType[type], optionalValuesForType[type])) < 0) { | |
147 return nullptr; | |
148 } | |
149 | |
150 RefPtrWillBeRawPtr<SVGTransform> transform = SVGTransform::create(); | 156 RefPtrWillBeRawPtr<SVGTransform> transform = SVGTransform::create(); |
151 | |
152 switch (type) { | 157 switch (type) { |
153 case SVG_TRANSFORM_SKEWX: | 158 case SVG_TRANSFORM_SKEWX: |
154 transform->setSkewX(values[0]); | 159 transform->setSkewX(arguments[0]); |
155 break; | 160 break; |
156 case SVG_TRANSFORM_SKEWY: | 161 case SVG_TRANSFORM_SKEWY: |
157 transform->setSkewY(values[0]); | 162 transform->setSkewY(arguments[0]); |
158 break; | 163 break; |
159 case SVG_TRANSFORM_SCALE: | 164 case SVG_TRANSFORM_SCALE: |
160 if (valueCount == 1) // Spec: if only one param given, assume uniform sc
aling | 165 // Spec: if only one param given, assume uniform scaling. |
161 transform->setScale(values[0], values[0]); | 166 if (arguments.size() == 1) |
| 167 transform->setScale(arguments[0], arguments[0]); |
162 else | 168 else |
163 transform->setScale(values[0], values[1]); | 169 transform->setScale(arguments[0], arguments[1]); |
164 break; | 170 break; |
165 case SVG_TRANSFORM_TRANSLATE: | 171 case SVG_TRANSFORM_TRANSLATE: |
166 if (valueCount == 1) // Spec: if only one param given, assume 2nd param
to be 0 | 172 // Spec: if only one param given, assume 2nd param to be 0. |
167 transform->setTranslate(values[0], 0); | 173 if (arguments.size() == 1) |
| 174 transform->setTranslate(arguments[0], 0); |
168 else | 175 else |
169 transform->setTranslate(values[0], values[1]); | 176 transform->setTranslate(arguments[0], arguments[1]); |
170 break; | 177 break; |
171 case SVG_TRANSFORM_ROTATE: | 178 case SVG_TRANSFORM_ROTATE: |
172 if (valueCount == 1) | 179 if (arguments.size() == 1) |
173 transform->setRotate(values[0], 0, 0); | 180 transform->setRotate(arguments[0], 0, 0); |
174 else | 181 else |
175 transform->setRotate(values[0], values[1], values[2]); | 182 transform->setRotate(arguments[0], arguments[1], arguments[2]); |
176 break; | 183 break; |
177 case SVG_TRANSFORM_MATRIX: | 184 case SVG_TRANSFORM_MATRIX: |
178 transform->setMatrix(AffineTransform(values[0], values[1], values[2], va
lues[3], values[4], values[5])); | 185 transform->setMatrix(AffineTransform(arguments[0], arguments[1], argumen
ts[2], arguments[3], arguments[4], arguments[5])); |
| 186 break; |
| 187 case SVG_TRANSFORM_UNKNOWN: |
| 188 ASSERT_NOT_REACHED(); |
179 break; | 189 break; |
180 } | 190 } |
181 | |
182 return transform.release(); | 191 return transform.release(); |
183 } | 192 } |
184 | 193 |
185 } // namespace | 194 } // namespace |
186 | 195 |
187 template<typename CharType> | 196 template<typename CharType> |
188 bool SVGTransformList::parseInternal(const CharType*& ptr, const CharType* end) | 197 bool SVGTransformList::parseInternal(const CharType*& ptr, const CharType* end) |
189 { | 198 { |
190 clear(); | 199 clear(); |
191 | 200 |
192 bool delimParsed = false; | 201 bool delimParsed = false; |
193 while (ptr < end) { | 202 while (skipOptionalSVGSpaces(ptr, end)) { |
194 delimParsed = false; | 203 delimParsed = false; |
195 SVGTransformType transformType = SVG_TRANSFORM_UNKNOWN; | |
196 skipOptionalSVGSpaces(ptr, end); | |
197 | 204 |
198 if (!parseAndSkipTransformType(ptr, end, transformType)) | 205 SVGTransformType transformType = parseAndSkipTransformType(ptr, end); |
| 206 if (transformType == SVG_TRANSFORM_UNKNOWN) |
199 return false; | 207 return false; |
200 | 208 |
201 if (!skipOptionalSVGSpaces(ptr, end) || *ptr != '(') | 209 if (!skipOptionalSVGSpaces(ptr, end) || *ptr != '(') |
202 return false; | 210 return false; |
203 ptr++; | 211 ptr++; |
204 | 212 |
205 RefPtrWillBeRawPtr<SVGTransform> transform = parseTransformOfType(transf
ormType, ptr, end); | 213 TransformArguments arguments; |
206 if (!transform) | 214 int valueCount = parseTransformArgumentsForType(transformType, ptr, end,
arguments); |
| 215 if (valueCount < 0) |
207 return false; | 216 return false; |
| 217 ASSERT(static_cast<unsigned>(valueCount) >= requiredValuesForType[transf
ormType]); |
208 | 218 |
209 if (!skipOptionalSVGSpaces(ptr, end) || *ptr != ')') | 219 if (!skipOptionalSVGSpaces(ptr, end) || *ptr != ')') |
210 return false; | 220 return false; |
211 ptr++; | 221 ptr++; |
212 | 222 |
213 append(transform.release()); | 223 append(createTransformFromValues(transformType, arguments)); |
214 | 224 |
215 skipOptionalSVGSpaces(ptr, end); | 225 if (skipOptionalSVGSpaces(ptr, end) && *ptr == ',') { |
216 if (ptr < end && *ptr == ',') { | 226 ++ptr; |
217 delimParsed = true; | 227 delimParsed = true; |
218 ++ptr; | |
219 skipOptionalSVGSpaces(ptr, end); | |
220 } | 228 } |
221 } | 229 } |
222 | |
223 return !delimParsed; | 230 return !delimParsed; |
224 } | 231 } |
225 | 232 |
226 bool SVGTransformList::parse(const UChar*& ptr, const UChar* end) | 233 bool SVGTransformList::parse(const UChar*& ptr, const UChar* end) |
227 { | 234 { |
228 return parseInternal(ptr, end); | 235 return parseInternal(ptr, end); |
229 } | 236 } |
230 | 237 |
231 bool SVGTransformList::parse(const LChar*& ptr, const LChar* end) | 238 bool SVGTransformList::parse(const LChar*& ptr, const LChar* end) |
232 { | 239 { |
233 return parseInternal(ptr, end); | 240 return parseInternal(ptr, end); |
234 } | 241 } |
235 | 242 |
236 SVGTransformType parseTransformType(const String& string) | 243 SVGTransformType parseTransformType(const String& string) |
237 { | 244 { |
238 if (string.isEmpty()) | 245 if (string.isEmpty()) |
239 return SVG_TRANSFORM_UNKNOWN; | 246 return SVG_TRANSFORM_UNKNOWN; |
240 SVGTransformType type = SVG_TRANSFORM_UNKNOWN; | |
241 if (string.is8Bit()) { | 247 if (string.is8Bit()) { |
242 const LChar* ptr = string.characters8(); | 248 const LChar* ptr = string.characters8(); |
243 const LChar* end = ptr + string.length(); | 249 const LChar* end = ptr + string.length(); |
244 parseAndSkipTransformType(ptr, end, type); | 250 return parseAndSkipTransformType(ptr, end); |
245 } else { | |
246 const UChar* ptr = string.characters16(); | |
247 const UChar* end = ptr + string.length(); | |
248 parseAndSkipTransformType(ptr, end, type); | |
249 } | 251 } |
250 return type; | 252 const UChar* ptr = string.characters16(); |
| 253 const UChar* end = ptr + string.length(); |
| 254 return parseAndSkipTransformType(ptr, end); |
251 } | 255 } |
252 | 256 |
253 String SVGTransformList::valueAsString() const | 257 String SVGTransformList::valueAsString() const |
254 { | 258 { |
255 StringBuilder builder; | 259 StringBuilder builder; |
256 | 260 |
257 ConstIterator it = begin(); | 261 ConstIterator it = begin(); |
258 ConstIterator itEnd = end(); | 262 ConstIterator itEnd = end(); |
259 while (it != itEnd) { | 263 while (it != itEnd) { |
260 builder.append(it->valueAsString()); | 264 builder.append(it->valueAsString()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 297 } |
294 | 298 |
295 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGTransformList::cloneForAnimation(cons
t String& value) const | 299 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGTransformList::cloneForAnimation(cons
t String& value) const |
296 { | 300 { |
297 ASSERT(RuntimeEnabledFeatures::webAnimationsSVGEnabled()); | 301 ASSERT(RuntimeEnabledFeatures::webAnimationsSVGEnabled()); |
298 return SVGListPropertyHelper::cloneForAnimation(value); | 302 return SVGListPropertyHelper::cloneForAnimation(value); |
299 } | 303 } |
300 | 304 |
301 PassRefPtrWillBeRawPtr<SVGTransformList> SVGTransformList::create(SVGTransformTy
pe transformType, const String& value) | 305 PassRefPtrWillBeRawPtr<SVGTransformList> SVGTransformList::create(SVGTransformTy
pe transformType, const String& value) |
302 { | 306 { |
303 RefPtrWillBeRawPtr<SVGTransform> transform = nullptr; | 307 TransformArguments arguments; |
| 308 bool atEndOfValue = false; |
| 309 int valueCount = -1; |
304 if (value.isEmpty()) { | 310 if (value.isEmpty()) { |
305 } else if (value.is8Bit()) { | 311 } else if (value.is8Bit()) { |
306 const LChar* ptr = value.characters8(); | 312 const LChar* ptr = value.characters8(); |
307 const LChar* end = ptr + value.length(); | 313 const LChar* end = ptr + value.length(); |
308 transform = parseTransformOfType(transformType, ptr, end); | 314 valueCount = parseTransformArgumentsForType(transformType, ptr, end, arg
uments); |
| 315 atEndOfValue = !skipOptionalSVGSpaces(ptr, end); |
309 } else { | 316 } else { |
310 const UChar* ptr = value.characters16(); | 317 const UChar* ptr = value.characters16(); |
311 const UChar* end = ptr + value.length(); | 318 const UChar* end = ptr + value.length(); |
312 transform = parseTransformOfType(transformType, ptr, end); | 319 valueCount = parseTransformArgumentsForType(transformType, ptr, end, arg
uments); |
| 320 atEndOfValue = !skipOptionalSVGSpaces(ptr, end); |
313 } | 321 } |
314 | 322 |
315 RefPtrWillBeRawPtr<SVGTransformList> svgTransformList = SVGTransformList::cr
eate(); | 323 RefPtrWillBeRawPtr<SVGTransformList> svgTransformList = SVGTransformList::cr
eate(); |
316 if (transform) | 324 if (atEndOfValue && valueCount > 0) |
317 svgTransformList->append(transform); | 325 svgTransformList->append(createTransformFromValues(transformType, argume
nts)); |
318 return svgTransformList.release(); | 326 return svgTransformList.release(); |
319 } | 327 } |
320 | 328 |
321 void SVGTransformList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGEle
ment* contextElement) | 329 void SVGTransformList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGEle
ment* contextElement) |
322 { | 330 { |
323 if (isEmpty()) | 331 if (isEmpty()) |
324 return; | 332 return; |
325 | 333 |
326 RefPtrWillBeRawPtr<SVGTransformList> otherList = toSVGTransformList(other); | 334 RefPtrWillBeRawPtr<SVGTransformList> otherList = toSVGTransformList(other); |
327 if (length() != otherList->length()) | 335 if (length() != otherList->length()) |
328 return; | 336 return; |
329 | 337 |
330 ASSERT(length() == 1); | 338 ASSERT(length() == 1); |
331 RefPtrWillBeRawPtr<SVGTransform> fromTransform = at(0); | 339 RefPtrWillBeRawPtr<SVGTransform> fromTransform = at(0); |
332 RefPtrWillBeRawPtr<SVGTransform> toTransform = otherList->at(0); | 340 RefPtrWillBeRawPtr<SVGTransform> toTransform = otherList->at(0); |
333 | 341 |
334 ASSERT(fromTransform->transformType() == toTransform->transformType()); | 342 ASSERT(fromTransform->transformType() == toTransform->transformType()); |
335 clear(); | 343 initialize(SVGTransformDistance::addSVGTransforms(fromTransform, toTransform
)); |
336 append(SVGTransformDistance::addSVGTransforms(fromTransform, toTransform)); | |
337 } | 344 } |
338 | 345 |
339 void SVGTransformList::calculateAnimatedValue(SVGAnimationElement* animationElem
ent, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyB
ase> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillB
eRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) | 346 void SVGTransformList::calculateAnimatedValue(SVGAnimationElement* animationElem
ent, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyB
ase> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillB
eRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) |
340 { | 347 { |
341 ASSERT(animationElement); | 348 ASSERT(animationElement); |
342 bool isToAnimation = animationElement->animationMode() == ToAnimation; | 349 bool isToAnimation = animationElement->animationMode() == ToAnimation; |
343 | 350 |
344 // Spec: To animations provide specific functionality to get a smooth change
from the underlying value to the | 351 // Spec: To animations provide specific functionality to get a smooth change
from the underlying value to the |
345 // 'to' attribute value, which conflicts mathematically with the requirement
for additive transform animations | 352 // 'to' attribute value, which conflicts mathematically with the requirement
for additive transform animations |
346 // to be post-multiplied. As a consequence, in SVG 1.1 the behavior of to an
imations for 'animateTransform' is undefined | 353 // to be post-multiplied. As a consequence, in SVG 1.1 the behavior of to an
imations for 'animateTransform' is undefined |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 if (at(0)->transformType() == toList->at(0)->transformType()) | 395 if (at(0)->transformType() == toList->at(0)->transformType()) |
389 return -1; | 396 return -1; |
390 | 397 |
391 // Spec: http://www.w3.org/TR/SVG/animate.html#complexDistances | 398 // Spec: http://www.w3.org/TR/SVG/animate.html#complexDistances |
392 // Paced animations assume a notion of distance between the various animatio
n values defined by the 'to', 'from', 'by' and 'values' attributes. | 399 // Paced animations assume a notion of distance between the various animatio
n values defined by the 'to', 'from', 'by' and 'values' attributes. |
393 // Distance is defined only for scalar types (such as <length>), colors and
the subset of transformation types that are supported by 'animateTransform'. | 400 // Distance is defined only for scalar types (such as <length>), colors and
the subset of transformation types that are supported by 'animateTransform'. |
394 return SVGTransformDistance(at(0), toList->at(0)).distance(); | 401 return SVGTransformDistance(at(0), toList->at(0)).distance(); |
395 } | 402 } |
396 | 403 |
397 } // namespace blink | 404 } // namespace blink |
OLD | NEW |