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

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

Issue 2342913003: Replace narrowPrecisionToFloat with clampTo<float> (Closed)
Patch Set: Created 4 years, 3 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 15 matching lines...) Expand all
26 26
27 #include "bindings/core/v8/ExceptionState.h" 27 #include "bindings/core/v8/ExceptionState.h"
28 #include "core/CSSPropertyNames.h" 28 #include "core/CSSPropertyNames.h"
29 #include "core/SVGNames.h" 29 #include "core/SVGNames.h"
30 #include "core/css/CSSComputedStyleDeclaration.h" 30 #include "core/css/CSSComputedStyleDeclaration.h"
31 #include "core/css/parser/CSSParser.h" 31 #include "core/css/parser/CSSParser.h"
32 #include "core/frame/UseCounter.h" 32 #include "core/frame/UseCounter.h"
33 #include "core/svg/SVGAnimateElement.h" 33 #include "core/svg/SVGAnimateElement.h"
34 #include "core/svg/SVGElement.h" 34 #include "core/svg/SVGElement.h"
35 #include "core/svg/SVGParserUtilities.h" 35 #include "core/svg/SVGParserUtilities.h"
36 #include "platform/FloatConversion.h"
37 #include "wtf/MathExtras.h" 36 #include "wtf/MathExtras.h"
38 37
39 namespace blink { 38 namespace blink {
40 39
41 SVGAnimationElement::SVGAnimationElement(const QualifiedName& tagName, Document& document) 40 SVGAnimationElement::SVGAnimationElement(const QualifiedName& tagName, Document& document)
42 : SVGSMILElement(tagName, document) 41 : SVGSMILElement(tagName, document)
43 , m_fromPropertyValueType(RegularPropertyValue) 42 , m_fromPropertyValueType(RegularPropertyValue)
44 , m_toPropertyValueType(RegularPropertyValue) 43 , m_toPropertyValueType(RegularPropertyValue)
45 , m_animationValid(false) 44 , m_animationValid(false)
46 , m_attributeType(AttributeTypeAuto) 45 , m_attributeType(AttributeTypeAuto)
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 setInactive(); 236 setInactive();
238 } 237 }
239 238
240 float SVGAnimationElement::getStartTime(ExceptionState& exceptionState) const 239 float SVGAnimationElement::getStartTime(ExceptionState& exceptionState) const
241 { 240 {
242 SMILTime startTime = intervalBegin(); 241 SMILTime startTime = intervalBegin();
243 if (!startTime.isFinite()) { 242 if (!startTime.isFinite()) {
244 exceptionState.throwDOMException(InvalidStateError, "No current interval ."); 243 exceptionState.throwDOMException(InvalidStateError, "No current interval .");
245 return 0; 244 return 0;
246 } 245 }
247 return narrowPrecisionToFloat(startTime.value()); 246 return clampTo<float>(startTime.value());
248 } 247 }
249 248
250 float SVGAnimationElement::getCurrentTime() const 249 float SVGAnimationElement::getCurrentTime() const
251 { 250 {
252 return narrowPrecisionToFloat(elapsed().value()); 251 return clampTo<float>(elapsed().value());
253 } 252 }
254 253
255 float SVGAnimationElement::getSimpleDuration(ExceptionState& exceptionState) con st 254 float SVGAnimationElement::getSimpleDuration(ExceptionState& exceptionState) con st
256 { 255 {
257 SMILTime duration = simpleDuration(); 256 SMILTime duration = simpleDuration();
258 if (!duration.isFinite()) { 257 if (!duration.isFinite()) {
259 exceptionState.throwDOMException(NotSupportedError, "No simple duration defined."); 258 exceptionState.throwDOMException(NotSupportedError, "No simple duration defined.");
260 return 0; 259 return 0;
261 } 260 }
262 return narrowPrecisionToFloat(duration.value()); 261 return clampTo<float>(duration.value());
263 } 262 }
264 263
265 void SVGAnimationElement::beginElement() 264 void SVGAnimationElement::beginElement()
266 { 265 {
267 beginElementAt(0); 266 beginElementAt(0);
268 } 267 }
269 268
270 void SVGAnimationElement::beginElementAt(float offset) 269 void SVGAnimationElement::beginElementAt(float offset)
271 { 270 {
272 ASSERT(std::isfinite(offset)); 271 ASSERT(std::isfinite(offset));
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 } 451 }
453 452
454 float SVGAnimationElement::calculatePercentForSpline(float percent, unsigned spl ineIndex) const 453 float SVGAnimationElement::calculatePercentForSpline(float percent, unsigned spl ineIndex) const
455 { 454 {
456 ASSERT(getCalcMode() == CalcModeSpline); 455 ASSERT(getCalcMode() == CalcModeSpline);
457 ASSERT_WITH_SECURITY_IMPLICATION(splineIndex < m_keySplines.size()); 456 ASSERT_WITH_SECURITY_IMPLICATION(splineIndex < m_keySplines.size());
458 gfx::CubicBezier bezier = m_keySplines[splineIndex]; 457 gfx::CubicBezier bezier = m_keySplines[splineIndex];
459 SMILTime duration = simpleDuration(); 458 SMILTime duration = simpleDuration();
460 if (!duration.isFinite()) 459 if (!duration.isFinite())
461 duration = 100.0; 460 duration = 100.0;
462 return narrowPrecisionToFloat(bezier.SolveWithEpsilon(percent, solveEpsilon( duration.value()))); 461 return clampTo<float>(bezier.SolveWithEpsilon(percent, solveEpsilon(duration .value())));
463 } 462 }
464 463
465 float SVGAnimationElement::calculatePercentFromKeyPoints(float percent) const 464 float SVGAnimationElement::calculatePercentFromKeyPoints(float percent) const
466 { 465 {
467 ASSERT(!m_keyPoints.isEmpty()); 466 ASSERT(!m_keyPoints.isEmpty());
468 ASSERT(getCalcMode() != CalcModePaced); 467 ASSERT(getCalcMode() != CalcModePaced);
469 ASSERT(m_keyTimes.size() > 1); 468 ASSERT(m_keyTimes.size() > 1);
470 ASSERT(m_keyPoints.size() == m_keyTimes.size()); 469 ASSERT(m_keyPoints.size() == m_keyTimes.size());
471 470
472 if (percent == 1) 471 if (percent == 1)
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 if (!hasInvalidCSSAttributeType) 738 if (!hasInvalidCSSAttributeType)
740 schedule(); 739 schedule();
741 } 740 }
742 741
743 // Clear values that may depend on the previous target. 742 // Clear values that may depend on the previous target.
744 if (targetElement()) 743 if (targetElement())
745 clearAnimatedType(); 744 clearAnimatedType();
746 } 745 }
747 746
748 } // namespace blink 747 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/SVGPaintContext.cpp ('k') | third_party/WebKit/Source/core/svg/SVGSVGElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698