Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 201fa368edc55f7bbb649ec457fc491534e21353
https://github.com/WebKit/WebKit/commit/201fa368edc55f7bbb649ec457fc491534e21353
Author: Karl Dubost <[email protected]>
Date: 2026-09-01 (Tue, 01 Sep 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedNumber-initial-values-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedNumber-invalid-values-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedNumber-invalid-values.html
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp
M Source/WebCore/svg/SVGComponentTransferFunctionElement.h
M Source/WebCore/svg/SVGFECompositeElement.cpp
M Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp
M Source/WebCore/svg/SVGFEConvolveMatrixElement.h
M Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp
M Source/WebCore/svg/SVGFEDiffuseLightingElement.h
M Source/WebCore/svg/SVGFEDisplacementMapElement.cpp
M Source/WebCore/svg/SVGFEDropShadowElement.cpp
M Source/WebCore/svg/SVGFEDropShadowElement.h
M Source/WebCore/svg/SVGFEGaussianBlurElement.cpp
M Source/WebCore/svg/SVGFELightElement.cpp
M Source/WebCore/svg/SVGFELightElement.h
M Source/WebCore/svg/SVGFEMorphologyElement.cpp
M Source/WebCore/svg/SVGFEOffsetElement.cpp
M Source/WebCore/svg/SVGFESpecularLightingElement.cpp
M Source/WebCore/svg/SVGFESpecularLightingElement.h
M Source/WebCore/svg/SVGFETurbulenceElement.cpp
M Source/WebCore/svg/SVGGeometryElement.cpp
M Source/WebCore/svg/SVGParserUtilities.cpp
M Source/WebCore/svg/SVGStopElement.cpp
M Source/WebCore/svg/properties/SVGAnimatedPrimitiveProperty.h
A Source/WebCore/svg/properties/SVGAnimatedPrimitivePropertyAccessor.h
M Source/WebCore/svg/properties/SVGAnimatedPropertyAccessorImpl.h
M Source/WebCore/svg/properties/SVGAnimatedPropertyBase.cpp
M Source/WebCore/svg/properties/SVGAnimatedPropertyBase.h
M Source/WebCore/svg/properties/SVGAnimatedPropertyPairAccessor.h
M Source/WebCore/svg/properties/SVGAnimatedPropertyPairAccessorImpl.h
M Source/WebCore/svg/properties/SVGMemberAccessor.h
M Source/WebCore/svg/properties/SVGPropertyOwnerRegistry.h
M Source/WebCore/svg/properties/SVGPropertyRegistry.h
Log Message:
-----------
SVG number attributes should revert to their initial value when removed or
invalid
https://bugs.webkit.org/show_bug.cgi?id=303073
rdar://165378154
Reviewed by Said Abou-Hallawa.
Removing an SVG number attribute, or setting it to something that is not a
number, left the DOM property reporting 0 or the previous value instead of the
value the attribute starts life with.
let e = document.createElementNS(svgNS, 'feFuncA');
e.setAttribute('slope', '42'); // baseVal is 42
e.removeAttribute('slope'); // baseVal is 0, expected 1
String::toFloat() cannot report failure, so most attributes landed on 0. The
five
<number-optional-number> attributes wrote only when parsing succeeded, so a bad
value wrote nothing and the old value stayed. SVG 2 says an attribute that fails
to parse is assumed to have been specified as its initial value.
https://w3c.github.io/svgwg/svg2-draft/types.html#syntax
Fix by letting the property notice the failure instead of the caller.
setBaseValInternal() now takes an optional, and when it is empty the property
asks
its owner's registry to put the initial value back. The initial value is stored
on
the accessor, which exists once per attribute rather than once per element, so
no
element grows by a byte. The registry finds the right accessor by identity,
using
the same matches() call animatedPropertyAttributeName() already uses, so a
caller
does not have to name itself. Parsing an attribute is now one line:
m_dx->setBaseValInternal(parseNumber(newValue));
The five <number-optional-number> attributes keep an explicit if/else, because
one
content attribute drives two properties and each half needs its own parsed
value,
so there is nothing for a single call to return. Their failure branch resets
both
halves rather than one: a pair accessor matches either half and would restore
both
from a single call, but saying it once per property keeps each line true on its
own
and survives the pair being split into two accessors later. The cost is one
redundant reset on a path that only runs when parsing failed.
parseNumber() also skips whitespace around the value now, as SVG 2 requires and
both other engines do. Without it slope=" 5 " would have regressed.
Tests:
imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedNumber-invalid-values.html
*
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedNumber-initial-values-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedNumber-invalid-values-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedNumber-invalid-values.html:
Added.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp:
(WebCore::SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement):
(WebCore::SVGComponentTransferFunctionElement::attributeChanged):
* Source/WebCore/svg/SVGComponentTransferFunctionElement.h:
* Source/WebCore/svg/SVGFECompositeElement.cpp:
(WebCore::SVGFECompositeElement::attributeChanged):
* Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp:
(WebCore::SVGFEConvolveMatrixElement::attributeChanged):
* Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp:
(WebCore::SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement):
(WebCore::SVGFEDiffuseLightingElement::attributeChanged):
* Source/WebCore/svg/SVGFEDiffuseLightingElement.h:
* Source/WebCore/svg/SVGFEDisplacementMapElement.cpp:
(WebCore::SVGFEDisplacementMapElement::attributeChanged):
* Source/WebCore/svg/SVGFEDropShadowElement.cpp:
(WebCore::SVGFEDropShadowElement::SVGFEDropShadowElement):
(WebCore::SVGFEDropShadowElement::attributeChanged):
* Source/WebCore/svg/SVGFEDropShadowElement.h:
* Source/WebCore/svg/SVGFEGaussianBlurElement.cpp:
(WebCore::SVGFEGaussianBlurElement::attributeChanged):
* Source/WebCore/svg/SVGFELightElement.cpp:
(WebCore::SVGFELightElement::SVGFELightElement):
(WebCore::SVGFELightElement::attributeChanged):
* Source/WebCore/svg/SVGFELightElement.h:
* Source/WebCore/svg/SVGFEMorphologyElement.cpp:
(WebCore::SVGFEMorphologyElement::attributeChanged):
* Source/WebCore/svg/SVGFEOffsetElement.cpp:
(WebCore::SVGFEOffsetElement::attributeChanged):
* Source/WebCore/svg/SVGFESpecularLightingElement.cpp:
(WebCore::SVGFESpecularLightingElement::SVGFESpecularLightingElement):
(WebCore::SVGFESpecularLightingElement::attributeChanged):
* Source/WebCore/svg/SVGFESpecularLightingElement.h:
* Source/WebCore/svg/SVGFETurbulenceElement.cpp:
(WebCore::SVGFETurbulenceElement::SVGFETurbulenceElement):
(WebCore::SVGFETurbulenceElement::attributeChanged):
* Source/WebCore/svg/SVGGeometryElement.cpp:
(WebCore::SVGGeometryElement::attributeChanged):
* Source/WebCore/svg/SVGParserUtilities.cpp:
(WebCore::parseNumber):
(WebCore::parseNumberOptionalNumber):
* Source/WebCore/svg/SVGStopElement.cpp:
(WebCore::SVGStopElement::attributeChanged):
* Source/WebCore/svg/properties/SVGAnimatedPrimitiveProperty.h:
(WebCore::SVGAnimatedPrimitiveProperty::setBaseValInternal):
* Source/WebCore/svg/properties/SVGAnimatedPrimitivePropertyAccessor.h: Added.
(WebCore::SVGAnimatedPrimitivePropertyAccessor::SVGAnimatedPrimitivePropertyAccessor):
(WebCore::SVGAnimatedPrimitivePropertyAccessor::resetBaseVal):
(WebCore::SVGAnimatedPrimitivePropertyAccessor::singleton):
* Source/WebCore/svg/properties/SVGAnimatedPropertyAccessorImpl.h:
* Source/WebCore/svg/properties/SVGAnimatedPropertyBase.cpp:
(WebCore::SVGAnimatedPropertyBase::resetBaseValToInitialValue):
Out of line for the same reason commitPropertyChange() is: SVGElement is
incomplete in the header.
* Source/WebCore/svg/properties/SVGAnimatedPropertyBase.h:
* Source/WebCore/svg/properties/SVGAnimatedPropertyPairAccessor.h:
(WebCore::SVGAnimatedPropertyPairAccessor::SVGAnimatedPropertyPairAccessor):
(WebCore::SVGAnimatedPropertyPairAccessor::singleton):
(WebCore::SVGAnimatedPropertyPairAccessor::resetBaseVal):
* Source/WebCore/svg/properties/SVGAnimatedPropertyPairAccessorImpl.h:
* Source/WebCore/svg/properties/SVGMemberAccessor.h:
(WebCore::SVGMemberAccessor::resetBaseVal):
Asserting rather than doing nothing, so that asking to reset an attribute
family
that has no initial value yet does not fail the same way the bug being fixed
does.
* Source/WebCore/svg/properties/SVGPropertyOwnerRegistry.h:
(WebCore::SVGPropertyOwnerRegistry::registerProperty):
(WebCore::SVGPropertyOwnerRegistry::resetAnimatedPropertyBaseVal):
* Source/WebCore/svg/properties/SVGPropertyRegistry.h:
Canonical link: https://commits.webkit.org/320226@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications