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

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

Issue 910713002: Restrict floats over SVGSVGElement to finite values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update svg/animations/animate-setcurrenttime.html Created 5 years, 10 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, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2014 Google, Inc. 5 * Copyright (C) 2014 Google, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 const FrameTree& frameTree = frame->tree(); 146 const FrameTree& frameTree = frame->tree();
147 147
148 // The behaviour of currentScale() is undefined, when we're dealing with non -standalone SVG documents. 148 // The behaviour of currentScale() is undefined, when we're dealing with non -standalone SVG documents.
149 // If the svg is embedded, the scaling is handled by the host renderer, so w hen asking from inside 149 // If the svg is embedded, the scaling is handled by the host renderer, so w hen asking from inside
150 // the SVG document, a scale value of 1 seems reasonable, as it doesn't know anything about the parent scale. 150 // the SVG document, a scale value of 1 seems reasonable, as it doesn't know anything about the parent scale.
151 return frameTree.parent() ? 1 : frame->pageZoomFactor(); 151 return frameTree.parent() ? 1 : frame->pageZoomFactor();
152 } 152 }
153 153
154 void SVGSVGElement::setCurrentScale(float scale) 154 void SVGSVGElement::setCurrentScale(float scale)
155 { 155 {
156 ASSERT(std::isfinite(scale));
156 if (!inDocument() || !isOutermostSVGSVGElement()) 157 if (!inDocument() || !isOutermostSVGSVGElement())
157 return; 158 return;
158 159
159 LocalFrame* frame = document().frame(); 160 LocalFrame* frame = document().frame();
160 if (!frame) 161 if (!frame)
161 return; 162 return;
162 163
163 const FrameTree& frameTree = frame->tree(); 164 const FrameTree& frameTree = frame->tree();
164 165
165 // The behaviour of setCurrentScale() is undefined, when we're dealing with non-standalone SVG documents. 166 // The behaviour of setCurrentScale() is undefined, when we're dealing with non-standalone SVG documents.
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 return m_timeContainer->isPaused(); 572 return m_timeContainer->isPaused();
572 } 573 }
573 574
574 float SVGSVGElement::getCurrentTime() const 575 float SVGSVGElement::getCurrentTime() const
575 { 576 {
576 return narrowPrecisionToFloat(m_timeContainer->elapsed().value()); 577 return narrowPrecisionToFloat(m_timeContainer->elapsed().value());
577 } 578 }
578 579
579 void SVGSVGElement::setCurrentTime(float seconds) 580 void SVGSVGElement::setCurrentTime(float seconds)
580 { 581 {
581 if (std::isnan(seconds)) 582 ASSERT(std::isfinite(seconds));
582 return;
583 seconds = max(seconds, 0.0f); 583 seconds = max(seconds, 0.0f);
584 m_timeContainer->setElapsed(seconds); 584 m_timeContainer->setElapsed(seconds);
585 } 585 }
586 586
587 bool SVGSVGElement::selfHasRelativeLengths() const 587 bool SVGSVGElement::selfHasRelativeLengths() const
588 { 588 {
589 return m_x->currentValue()->isRelative() 589 return m_x->currentValue()->isRelative()
590 || m_y->currentValue()->isRelative() 590 || m_y->currentValue()->isRelative()
591 || m_width->currentValue()->isRelative() 591 || m_width->currentValue()->isRelative()
592 || m_height->currentValue()->isRelative() 592 || m_height->currentValue()->isRelative()
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 visitor->trace(m_width); 771 visitor->trace(m_width);
772 visitor->trace(m_height); 772 visitor->trace(m_height);
773 visitor->trace(m_translation); 773 visitor->trace(m_translation);
774 visitor->trace(m_timeContainer); 774 visitor->trace(m_timeContainer);
775 visitor->trace(m_viewSpec); 775 visitor->trace(m_viewSpec);
776 SVGGraphicsElement::trace(visitor); 776 SVGGraphicsElement::trace(visitor);
777 SVGFitToViewBox::trace(visitor); 777 SVGFitToViewBox::trace(visitor);
778 } 778 }
779 779
780 } // namespace blink 780 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/svg/dom/SVGSVGElement-currentTime-expected.txt ('k') | Source/core/svg/SVGSVGElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698