Chromium Code Reviews| 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); |