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

Unified Diff: third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp

Issue 1901673003: Improve default value handling for SVGSVGElement.width/height (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak old test. Created 4 years, 8 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
Index: third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp b/third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp
index ddbb866d35e3ba6436d344f6f96faee2078ffdd4..991ddd45e211b6d66862acb0a684b5891cd068a0 100644
--- a/third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp
@@ -34,6 +34,11 @@
namespace blink {
+void SVGAnimatedLength::setDefaultValue()
+{
+ setDefaultValueAsString(m_defaultValue);
+}
+
void SVGAnimatedLength::setDefaultValueAsString(const String& value)
{
baseValue()->setValueAsString(value);
@@ -41,10 +46,15 @@ void SVGAnimatedLength::setDefaultValueAsString(const String& value)
SVGParsingError SVGAnimatedLength::setBaseValueAsString(const String& value)
{
+ if (value.isNull()) {
+ setDefaultValue();
+ return SVGParseStatus::NoError;
+ }
+
SVGParsingError parseStatus = baseValue()->setValueAsString(value);
if (parseStatus != SVGParseStatus::NoError)
- baseValue()->newValueSpecifiedUnits(CSSPrimitiveValue::UnitType::UserUnits, 0);
+ setDefaultValue();
else if (SVGLength::negativeValuesForbiddenForAnimatedLengthAttribute(attributeName()) && baseValue()->valueInSpecifiedUnits() < 0)
parseStatus = SVGParseStatus::NegativeValue;

Powered by Google App Engine
This is Rietveld 408576698