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

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

Issue 195313003: [SVG2] Add getters and setters to SVG*List interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tryserver rebase 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
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
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<NewSVGPropertyBase> other, SVGElement* con textElement)
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 (numberOfItems() != otherList->numberOfItems()) 291 if (length() != otherList->length())
292 return; 292 return;
293 293
294 ASSERT(numberOfItems() == 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<NewSVGPropertyBase> from Value, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> to AtEndOfDurationValue, 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);
314 RefPtr<SVGTransformList> toAtEndOfDurationList = toSVGTransformList(toAtEndO fDurationValue); 314 RefPtr<SVGTransformList> toAtEndOfDurationList = toSVGTransformList(toAtEndO fDurationValue);
315 315
316 size_t fromListSize = fromList->numberOfItems(); 316 size_t fromListSize = fromList->length();
317 size_t toListSize = toList->numberOfItems(); 317 size_t toListSize = toList->length();
318 318
319 if (!toListSize) 319 if (!toListSize)
320 return; 320 return;
321 321
322 // Never resize the animatedTransformList to the toList size, instead either clear the list or append to it. 322 // Never resize the animatedTransformList to the toList size, instead either clear the list or append to it.
323 if (!isEmpty() && !animationElement->isAdditive()) 323 if (!isEmpty() && !animationElement->isAdditive())
324 clear(); 324 clear();
325 325
326 RefPtr<SVGTransform> toTransform = toList->at(0); 326 RefPtr<SVGTransform> toTransform = toList->at(0);
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<NewSVGPropertyBase> toValue , SVGElement*)
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() || numberOfItems() != toList->numberOfItems()) 343 if (isEmpty() || length() != toList->length())
344 return -1; 344 return -1;
345 345
346 ASSERT(numberOfItems() == 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

Powered by Google App Engine
This is Rietveld 408576698