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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGAnimationElement.cpp

Issue 2712343004: Tidy up instance time handling in SVGSMILElement (Closed)
Patch Set: Created 3 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 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005 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) 2009 Cameron McCormack <cam@mcc.id.au> 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 ExceptionState& exceptionState) const { 246 ExceptionState& exceptionState) const {
247 SMILTime duration = simpleDuration(); 247 SMILTime duration = simpleDuration();
248 if (!duration.isFinite()) { 248 if (!duration.isFinite()) {
249 exceptionState.throwDOMException(NotSupportedError, 249 exceptionState.throwDOMException(NotSupportedError,
250 "No simple duration defined."); 250 "No simple duration defined.");
251 return 0; 251 return 0;
252 } 252 }
253 return clampTo<float>(duration.value()); 253 return clampTo<float>(duration.value());
254 } 254 }
255 255
256 void SVGAnimationElement::beginElement() {
257 beginElementAt(0);
258 }
259
260 void SVGAnimationElement::beginElementAt(float offset) { 256 void SVGAnimationElement::beginElementAt(float offset) {
261 ASSERT(std::isfinite(offset)); 257 DCHECK(std::isfinite(offset));
262 SMILTime elapsed = this->elapsed(); 258 addInstanceTime(Begin, elapsed() + offset, SMILTimeWithOrigin::ScriptOrigin);
263 addBeginTime(elapsed, elapsed + offset, SMILTimeWithOrigin::ScriptOrigin);
264 }
265
266 void SVGAnimationElement::endElement() {
267 endElementAt(0);
268 } 259 }
269 260
270 void SVGAnimationElement::endElementAt(float offset) { 261 void SVGAnimationElement::endElementAt(float offset) {
271 ASSERT(std::isfinite(offset)); 262 DCHECK(std::isfinite(offset));
272 SMILTime elapsed = this->elapsed(); 263 addInstanceTime(End, elapsed() + offset, SMILTimeWithOrigin::ScriptOrigin);
273 addEndTime(elapsed, elapsed + offset, SMILTimeWithOrigin::ScriptOrigin);
274 } 264 }
275 265
276 void SVGAnimationElement::updateAnimationMode() { 266 void SVGAnimationElement::updateAnimationMode() {
277 // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues 267 // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
278 if (hasAttribute(SVGNames::valuesAttr)) 268 if (hasAttribute(SVGNames::valuesAttr))
279 setAnimationMode(ValuesAnimation); 269 setAnimationMode(ValuesAnimation);
280 else if (!toValue().isEmpty()) 270 else if (!toValue().isEmpty())
281 setAnimationMode(fromValue().isEmpty() ? ToAnimation : FromToAnimation); 271 setAnimationMode(fromValue().isEmpty() ? ToAnimation : FromToAnimation);
282 else if (!byValue().isEmpty()) 272 else if (!byValue().isEmpty())
283 setAnimationMode(fromValue().isEmpty() ? ByAnimation : FromByAnimation); 273 setAnimationMode(fromValue().isEmpty() ? ByAnimation : FromByAnimation);
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 calculatePercentForSpline(percent, calculateKeyTimesIndex(percent)); 611 calculatePercentForSpline(percent, calculateKeyTimesIndex(percent));
622 else if (animationMode == FromToAnimation || animationMode == ToAnimation) 612 else if (animationMode == FromToAnimation || animationMode == ToAnimation)
623 effectivePercent = calculatePercentForFromTo(percent); 613 effectivePercent = calculatePercentForFromTo(percent);
624 else 614 else
625 effectivePercent = percent; 615 effectivePercent = percent;
626 616
627 calculateAnimatedValue(effectivePercent, repeatCount, resultElement); 617 calculateAnimatedValue(effectivePercent, repeatCount, resultElement);
628 } 618 }
629 619
630 } // namespace blink 620 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698