Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: Source/core/svg/SVGTransformList.cpp

Issue 208133002: [SVG] Remove "New" prefix from properties implementation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGTransformList.h ('k') | Source/core/svg/SVGTransformListTearOff.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 #include "SVGNames.h" 28 #include "SVGNames.h"
29 #include "core/svg/SVGAnimateTransformElement.h" 29 #include "core/svg/SVGAnimateTransformElement.h"
30 #include "core/svg/SVGAnimatedNumber.h" 30 #include "core/svg/SVGAnimatedNumber.h"
31 #include "core/svg/SVGParserUtilities.h" 31 #include "core/svg/SVGParserUtilities.h"
32 #include "core/svg/SVGTransformDistance.h" 32 #include "core/svg/SVGTransformDistance.h"
33 #include "wtf/text/StringBuilder.h" 33 #include "wtf/text/StringBuilder.h"
34 #include "wtf/text/WTFString.h" 34 #include "wtf/text/WTFString.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 inline PassRefPtr<SVGTransformList> toSVGTransformList(PassRefPtr<NewSVGProperty Base> passBase) 38 inline PassRefPtr<SVGTransformList> toSVGTransformList(PassRefPtr<SVGPropertyBas e> passBase)
39 { 39 {
40 RefPtr<NewSVGPropertyBase> base = passBase; 40 RefPtr<SVGPropertyBase> base = passBase;
41 ASSERT(base->type() == SVGTransformList::classType()); 41 ASSERT(base->type() == SVGTransformList::classType());
42 return static_pointer_cast<SVGTransformList>(base.release()); 42 return static_pointer_cast<SVGTransformList>(base.release());
43 } 43 }
44 44
45 SVGTransformList::SVGTransformList() 45 SVGTransformList::SVGTransformList()
46 { 46 {
47 } 47 }
48 48
49 SVGTransformList::~SVGTransformList() 49 SVGTransformList::~SVGTransformList()
50 { 50 {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 const UChar* end = ptr + value.length(); 249 const UChar* end = ptr + value.length();
250 valid = parse(ptr, end); 250 valid = parse(ptr, end);
251 } 251 }
252 252
253 if (!valid) { 253 if (!valid) {
254 clear(); 254 clear();
255 exceptionState.throwDOMException(SyntaxError, "Problem parsing transform list=\""+value+"\""); 255 exceptionState.throwDOMException(SyntaxError, "Problem parsing transform list=\""+value+"\"");
256 } 256 }
257 } 257 }
258 258
259 PassRefPtr<NewSVGPropertyBase> SVGTransformList::cloneForAnimation(const String& value) const 259 PassRefPtr<SVGPropertyBase> SVGTransformList::cloneForAnimation(const String& va lue) const
260 { 260 {
261 ASSERT_NOT_REACHED(); 261 ASSERT_NOT_REACHED();
262 return nullptr; 262 return nullptr;
263 } 263 }
264 264
265 PassRefPtr<SVGTransformList> SVGTransformList::create(SVGTransformType transform Type, const String& value) 265 PassRefPtr<SVGTransformList> SVGTransformList::create(SVGTransformType transform Type, const String& value)
266 { 266 {
267 RefPtr<SVGTransform> transform; 267 RefPtr<SVGTransform> transform;
268 if (value.isEmpty()) { 268 if (value.isEmpty()) {
269 } else if (value.is8Bit()) { 269 } else if (value.is8Bit()) {
270 const LChar* ptr = value.characters8(); 270 const LChar* ptr = value.characters8();
271 const LChar* end = ptr + value.length(); 271 const LChar* end = ptr + value.length();
272 transform = parseTransformOfType(transformType, ptr, end); 272 transform = parseTransformOfType(transformType, ptr, end);
273 } else { 273 } else {
274 const UChar* ptr = value.characters16(); 274 const UChar* ptr = value.characters16();
275 const UChar* end = ptr + value.length(); 275 const UChar* end = ptr + value.length();
276 transform = parseTransformOfType(transformType, ptr, end); 276 transform = parseTransformOfType(transformType, ptr, end);
277 } 277 }
278 278
279 RefPtr<SVGTransformList> svgTransformList = SVGTransformList::create(); 279 RefPtr<SVGTransformList> svgTransformList = SVGTransformList::create();
280 if (transform) 280 if (transform)
281 svgTransformList->append(transform); 281 svgTransformList->append(transform);
282 return svgTransformList.release(); 282 return svgTransformList.release();
283 } 283 }
284 284
285 void SVGTransformList::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* con textElement) 285 void SVGTransformList::add(PassRefPtr<SVGPropertyBase> other, SVGElement* contex tElement)
286 { 286 {
287 if (isEmpty()) 287 if (isEmpty())
288 return; 288 return;
289 289
290 RefPtr<SVGTransformList> otherList = toSVGTransformList(other); 290 RefPtr<SVGTransformList> otherList = toSVGTransformList(other);
291 if (length() != otherList->length()) 291 if (length() != otherList->length())
292 return; 292 return;
293 293
294 ASSERT(length() == 1); 294 ASSERT(length() == 1);
295 RefPtr<SVGTransform> fromTransform = at(0); 295 RefPtr<SVGTransform> fromTransform = at(0);
296 RefPtr<SVGTransform> toTransform = otherList->at(0); 296 RefPtr<SVGTransform> toTransform = otherList->at(0);
297 297
298 ASSERT(fromTransform->transformType() == toTransform->transformType()); 298 ASSERT(fromTransform->transformType() == toTransform->transformType());
299 clear(); 299 clear();
300 append(SVGTransformDistance::addSVGTransforms(fromTransform, toTransform)); 300 append(SVGTransformDistance::addSVGTransforms(fromTransform, toTransform));
301 } 301 }
302 302
303 void SVGTransformList::calculateAnimatedValue(SVGAnimationElement* animationElem ent, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> from Value, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> to AtEndOfDurationValue, SVGElement* contextElement) 303 void SVGTransformList::calculateAnimatedValue(SVGAnimationElement* animationElem ent, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromVal ue, PassRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDu rationValue, SVGElement* contextElement)
304 { 304 {
305 ASSERT(animationElement); 305 ASSERT(animationElement);
306 bool isToAnimation = animationElement->animationMode() == ToAnimation; 306 bool isToAnimation = animationElement->animationMode() == ToAnimation;
307 307
308 // Spec: To animations provide specific functionality to get a smooth change from the underlying value to the 308 // Spec: To animations provide specific functionality to get a smooth change from the underlying value to the
309 // ‘to’ attribute value, which conflicts mathematically with the requirement for additive transform animations 309 // ‘to’ attribute value, which conflicts mathematically with the requirement for additive transform animations
310 // to be post-multiplied. As a consequence, in SVG 1.1 the behavior of to an imations for ‘animateTransform’ is undefined 310 // to be post-multiplied. As a consequence, in SVG 1.1 the behavior of to an imations for ‘animateTransform’ is undefined
311 // FIXME: This is not taken into account yet. 311 // FIXME: This is not taken into account yet.
312 RefPtr<SVGTransformList> fromList = isToAnimation ? this : toSVGTransformLis t(fromValue); 312 RefPtr<SVGTransformList> fromList = isToAnimation ? this : toSVGTransformLis t(fromValue);
313 RefPtr<SVGTransformList> toList = toSVGTransformList(toValue); 313 RefPtr<SVGTransformList> toList = toSVGTransformList(toValue);
(...skipping 13 matching lines...) Expand all
327 RefPtr<SVGTransform> effectiveFrom = fromListSize ? fromList->at(0) : SVGTra nsform::create(toTransform->transformType(), SVGTransform::ConstructZeroTransfor m); 327 RefPtr<SVGTransform> effectiveFrom = fromListSize ? fromList->at(0) : SVGTra nsform::create(toTransform->transformType(), SVGTransform::ConstructZeroTransfor m);
328 RefPtr<SVGTransform> currentTransform = SVGTransformDistance(effectiveFrom, toTransform).scaledDistance(percentage).addToSVGTransform(effectiveFrom); 328 RefPtr<SVGTransform> currentTransform = SVGTransformDistance(effectiveFrom, toTransform).scaledDistance(percentage).addToSVGTransform(effectiveFrom);
329 if (animationElement->isAccumulated() && repeatCount) { 329 if (animationElement->isAccumulated() && repeatCount) {
330 RefPtr<SVGTransform> effectiveToAtEnd = !toAtEndOfDurationList->isEmpty( ) ? toAtEndOfDurationList->at(0) : SVGTransform::create(toTransform->transformTy pe(), SVGTransform::ConstructZeroTransform); 330 RefPtr<SVGTransform> effectiveToAtEnd = !toAtEndOfDurationList->isEmpty( ) ? toAtEndOfDurationList->at(0) : SVGTransform::create(toTransform->transformTy pe(), SVGTransform::ConstructZeroTransform);
331 append(SVGTransformDistance::addSVGTransforms(currentTransform, effectiv eToAtEnd, repeatCount)); 331 append(SVGTransformDistance::addSVGTransforms(currentTransform, effectiv eToAtEnd, repeatCount));
332 } else { 332 } else {
333 append(currentTransform); 333 append(currentTransform);
334 } 334 }
335 } 335 }
336 336
337 float SVGTransformList::calculateDistance(PassRefPtr<NewSVGPropertyBase> toValue , SVGElement*) 337 float SVGTransformList::calculateDistance(PassRefPtr<SVGPropertyBase> toValue, S VGElement*)
338 { 338 {
339 // FIXME: This is not correct in all cases. The spec demands that each compo nent (translate x and y for example) 339 // FIXME: This is not correct in all cases. The spec demands that each compo nent (translate x and y for example)
340 // is paced separately. To implement this we need to treat each component as individual animation everywhere. 340 // is paced separately. To implement this we need to treat each component as individual animation everywhere.
341 341
342 RefPtr<SVGTransformList> toList = toSVGTransformList(toValue); 342 RefPtr<SVGTransformList> toList = toSVGTransformList(toValue);
343 if (isEmpty() || length() != toList->length()) 343 if (isEmpty() || length() != toList->length())
344 return -1; 344 return -1;
345 345
346 ASSERT(length() == 1); 346 ASSERT(length() == 1);
347 if (at(0)->transformType() == toList->at(0)->transformType()) 347 if (at(0)->transformType() == toList->at(0)->transformType())
348 return -1; 348 return -1;
349 349
350 // Spec: http://www.w3.org/TR/SVG/animate.html#complexDistances 350 // Spec: http://www.w3.org/TR/SVG/animate.html#complexDistances
351 // Paced animations assume a notion of distance between the various animatio n values defined by the ‘to’, ‘from’, ‘by’ and ‘values’ attributes. 351 // Paced animations assume a notion of distance between the various animatio n values defined by the ‘to’, ‘from’, ‘by’ and ‘values’ attributes.
352 // Distance is defined only for scalar types (such as <length>), colors and the subset of transformation types that are supported by ‘animateTransform’. 352 // Distance is defined only for scalar types (such as <length>), colors and the subset of transformation types that are supported by ‘animateTransform’.
353 return SVGTransformDistance(at(0), toList->at(0)).distance(); 353 return SVGTransformDistance(at(0), toList->at(0)).distance();
354 } 354 }
355 355
356 } 356 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGTransformList.h ('k') | Source/core/svg/SVGTransformListTearOff.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698