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

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

Issue 672853002: Implement "auto -> angle" animation on <marker> orient attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « Source/core/svg/SVGAngle.h ('k') | no next file » | 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, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 { 364 {
365 RefPtr<SVGAngle> otherAngle = toSVGAngle(other); 365 RefPtr<SVGAngle> otherAngle = toSVGAngle(other);
366 366
367 // Only respect by animations, if from and by are both specified in angles ( and not eg. 'auto'). 367 // Only respect by animations, if from and by are both specified in angles ( and not eg. 'auto').
368 if (orientType()->enumValue() != SVGMarkerOrientAngle || otherAngle->orientT ype()->enumValue() != SVGMarkerOrientAngle) 368 if (orientType()->enumValue() != SVGMarkerOrientAngle || otherAngle->orientT ype()->enumValue() != SVGMarkerOrientAngle)
369 return; 369 return;
370 370
371 setValue(value() + otherAngle->value()); 371 setValue(value() + otherAngle->value());
372 } 372 }
373 373
374 void SVGAngle::assign(const SVGAngle& other)
375 {
376 SVGMarkerOrientType otherOrientType = other.orientType()->enumValue();
377 if (otherOrientType == SVGMarkerOrientAngle)
378 newValueSpecifiedUnits(other.unitType(), other.valueInSpecifiedUnits());
379 else
380 m_orientType->setEnumValue(otherOrientType);
381 }
382
374 void SVGAngle::calculateAnimatedValue(SVGAnimationElement* animationElement, flo at percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPt r<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDuration, SVGElement *) 383 void SVGAngle::calculateAnimatedValue(SVGAnimationElement* animationElement, flo at percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPt r<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDuration, SVGElement *)
375 { 384 {
376 ASSERT(animationElement); 385 ASSERT(animationElement);
377 bool isToAnimation = animationElement->animationMode() == ToAnimation; 386 bool isToAnimation = animationElement->animationMode() == ToAnimation;
378 387
379 RefPtr<SVGAngle> fromAngle = isToAnimation ? this : toSVGAngle(from); 388 RefPtr<SVGAngle> fromAngle = isToAnimation ? this : toSVGAngle(from);
380 RefPtr<SVGAngle> toAngle = toSVGAngle(to); 389 RefPtr<SVGAngle> toAngle = toSVGAngle(to);
381 RefPtr<SVGAngle> toAtEndOfDurationAngle = toSVGAngle(toAtEndOfDuration);
382
383 SVGMarkerOrientType fromOrientType = fromAngle->orientType()->enumValue(); 390 SVGMarkerOrientType fromOrientType = fromAngle->orientType()->enumValue();
384 SVGMarkerOrientType toOrientType = toAngle->orientType()->enumValue(); 391 SVGMarkerOrientType toOrientType = toAngle->orientType()->enumValue();
385 392
386 if (fromOrientType != toOrientType) { 393 if (fromOrientType != toOrientType) {
387 // Animating from eg. 90deg to auto. 394 // Fall back to discrete animation.
388 if (fromOrientType == SVGMarkerOrientAngle) { 395 assign(percentage < 0.5f ? *fromAngle : *toAngle);
389 // Animating from an angle value to eg. 'auto' - this disabled addit ive as 'auto' is a keyword..
390 if (toOrientType == SVGMarkerOrientAuto || toOrientType == SVGMarker OrientAutoStartReverse) {
391 if (percentage < 0.5f) {
392 newValueSpecifiedUnits(fromAngle->unitType(), fromAngle->val ueInSpecifiedUnits());
393 return;
394 }
395 orientType()->setEnumValue(toOrientType);
396 return;
397 }
398 m_valueInSpecifiedUnits = 0;
399 orientType()->setEnumValue(SVGMarkerOrientUnknown);
400 return;
401 } else if (toOrientType == SVGMarkerOrientAuto || toOrientType == SVGMar kerOrientAutoStartReverse) {
402 // Animating from e.g 'auto' to 'auto-start-reverse'
403 if (percentage >= 0.5f) {
404 m_valueInSpecifiedUnits = 0;
405 orientType()->setEnumValue(toOrientType);
406 return;
407 }
408 }
409 }
410
411 // From 'auto' to 'auto', or 'auto-start-reverse' to 'auto-start-reverse'
412 if (fromOrientType == SVGMarkerOrientAuto || fromOrientType == SVGMarkerOrie ntAutoStartReverse) {
413 m_valueInSpecifiedUnits = 0;
414 orientType()->setEnumValue(fromOrientType);
415 return; 396 return;
416 } 397 }
417 398
399 switch (fromOrientType) {
400 // From 'auto' to 'auto', or 'auto-start-reverse' to 'auto-start-reverse'
401 case SVGMarkerOrientAuto:
402 case SVGMarkerOrientAutoStartReverse:
403 orientType()->setEnumValue(fromOrientType);
404 return;
405
406 // Regular from angle to angle animation, with all features like additive et c.
407 case SVGMarkerOrientAngle:
408 {
409 float animatedValue = value();
410 RefPtr<SVGAngle> toAtEndOfDurationAngle = toSVGAngle(toAtEndOfDurati on);
411
412 animationElement->animateAdditiveNumber(percentage, repeatCount, fro mAngle->value(), toAngle->value(), toAtEndOfDurationAngle->value(), animatedValu e);
413 orientType()->setEnumValue(SVGMarkerOrientAngle);
414 setValue(animatedValue);
415 }
416 return;
417
418 // If the enumeration value is not angle or auto, its unknown. 418 // If the enumeration value is not angle or auto, its unknown.
419 if (fromOrientType != SVGMarkerOrientAngle) { 419 default:
420 m_valueInSpecifiedUnits = 0; 420 m_valueInSpecifiedUnits = 0;
421 orientType()->setEnumValue(SVGMarkerOrientUnknown); 421 orientType()->setEnumValue(SVGMarkerOrientUnknown);
422 return; 422 return;
423 } 423 }
424
425 // Regular from angle to angle animation, with all features like additive et c.
426 float animatedValue = value();
427 animationElement->animateAdditiveNumber(percentage, repeatCount, fromAngle-> value(), toAngle->value(), toAtEndOfDurationAngle->value(), animatedValue);
428 orientType()->setEnumValue(SVGMarkerOrientAngle);
429 setValue(animatedValue);
430 } 424 }
431 425
432 float SVGAngle::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElement* ) 426 float SVGAngle::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElement* )
433 { 427 {
434 return fabsf(value() - toSVGAngle(other)->value()); 428 return fabsf(value() - toSVGAngle(other)->value());
435 } 429 }
436 430
437 void SVGAngle::orientTypeChanged() 431 void SVGAngle::orientTypeChanged()
438 { 432 {
439 if (orientType()->enumValue() == SVGMarkerOrientAuto || orientType()->enumVa lue() == SVGMarkerOrientAutoStartReverse) { 433 if (orientType()->enumValue() == SVGMarkerOrientAuto || orientType()->enumVa lue() == SVGMarkerOrientAutoStartReverse) {
440 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; 434 m_unitType = SVG_ANGLETYPE_UNSPECIFIED;
441 m_valueInSpecifiedUnits = 0; 435 m_valueInSpecifiedUnits = 0;
442 } 436 }
443 } 437 }
444 438
445 } 439 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGAngle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698