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

Unified Diff: Source/core/svg/SVGFitToViewBox.cpp

Issue 664433002: [SVG] Move negative viewBox width/height reporting to SVGAnimatedViewBoxRect (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: no need for manual rebaseline 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGFitToViewBox.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGFitToViewBox.cpp
diff --git a/Source/core/svg/SVGFitToViewBox.cpp b/Source/core/svg/SVGFitToViewBox.cpp
index 53ecdd16f24418966082a380b4ee7d41a149045e..d67c2f6c46bfc6550f2df667a80a3f811c16584e 100644
--- a/Source/core/svg/SVGFitToViewBox.cpp
+++ b/Source/core/svg/SVGFitToViewBox.cpp
@@ -33,8 +33,47 @@
namespace blink {
+class SVGAnimatedViewBoxRect : public SVGAnimatedRect {
+public:
+ static PassRefPtr<SVGAnimatedRect> create(SVGElement* contextElement)
+ {
+ return adoptRef(new SVGAnimatedViewBoxRect(contextElement));
+ }
+
+ void setBaseValueAsString(const String&, SVGParsingError&) override;
+
+protected:
+ SVGAnimatedViewBoxRect(SVGElement* contextElement)
+ : SVGAnimatedRect(contextElement, SVGNames::viewBoxAttr)
+ {
+ }
+};
+
+void SVGAnimatedViewBoxRect::setBaseValueAsString(const String& value, SVGParsingError& parseError)
+{
+ TrackExceptionState es;
+
+ baseValue()->setValueAsString(value, es);
+
+ if (es.hadException()) {
+ parseError = ParsingAttributeFailedError;
+ return;
+ }
+
+ if (baseValue()->width() < 0.0f) {
fs 2014/10/16 08:11:55 Nit: I don't mind personally, but I think that cod
+ parseError = NegativeValueForbiddenError;
+ baseValue()->setInvalid();
+ return;
+ }
+ if (baseValue()->height() < 0.0f) {
+ parseError = NegativeValueForbiddenError;
+ baseValue()->setInvalid();
+ return;
+ }
+}
+
SVGFitToViewBox::SVGFitToViewBox(SVGElement* element, PropertyMapPolicy propertyMapPolicy)
- : m_viewBox(SVGAnimatedRect::create(element, SVGNames::viewBoxAttr))
+ : m_viewBox(SVGAnimatedViewBoxRect::create(element))
, m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(element, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()))
{
ASSERT(element);
« no previous file with comments | « Source/core/svg/SVGFitToViewBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698