Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d5668e13da64a23845ff1740e560274a7a4f8a15
https://github.com/WebKit/WebKit/commit/d5668e13da64a23845ff1740e560274a7a4f8a15
Author: Karl Dubost <[email protected]>
Date: 2026-08-13 (Thu, 13 Aug 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-initial-values-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-initial-values.html
A
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-invalid-values-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-invalid-values.html
A
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-keywords-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-keywords.html
R LayoutTests/svg/dom/SVGAnimatedEnumeration-case-sensitive-expected.txt
R LayoutTests/svg/dom/SVGAnimatedEnumeration-case-sensitive.html
M Source/WebCore/svg/SVGClipPathElement.cpp
M Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp
M Source/WebCore/svg/SVGFEBlendElement.cpp
M Source/WebCore/svg/SVGFEColorMatrixElement.cpp
M Source/WebCore/svg/SVGFECompositeElement.cpp
M Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp
M Source/WebCore/svg/SVGFEConvolveMatrixElement.h
M Source/WebCore/svg/SVGFEDisplacementMapElement.cpp
M Source/WebCore/svg/SVGFEGaussianBlurElement.cpp
M Source/WebCore/svg/SVGFEMorphologyElement.cpp
M Source/WebCore/svg/SVGFETurbulenceElement.cpp
M Source/WebCore/svg/SVGFilterElement.cpp
M Source/WebCore/svg/SVGGradientElement.cpp
M Source/WebCore/svg/SVGMarkerElement.cpp
M Source/WebCore/svg/SVGMaskElement.cpp
M Source/WebCore/svg/SVGPatternElement.cpp
M Source/WebCore/svg/SVGTextContentElement.cpp
M Source/WebCore/svg/SVGTextPathElement.cpp
M Source/WebCore/svg/properties/SVGAnimatedDecoratedProperty.h
Log Message:
-----------
SVG enumerated attributes should revert to their initial value when removed
or invalid
https://bugs.webkit.org/show_bug.cgi?id=321049
rdar://184076505
Reviewed by Nikolas Zimmermann.
Removing an SVG enumerated attribute, or setting it to something which is not
one of its keywords, left the DOM property reporting the previous value
instead of the initial one.
let e = document.createElementNS(svgNS, 'clipPath');
e.setAttribute('clipPathUnits', 'objectBoundingBox'); // baseVal is 2
e.removeAttribute('clipPathUnits'); // baseVal is still
2, expected 1
Every attributeChanged() wrote the property only when the value parsed to a
known keyword. SVGPropertyTraits::fromString() returns the unknown constant
both for a removed attribute and for an unrecognized one, so in both cases
nothing was written at all and the previous value survived. SVG 2 says an
attribute which fails to parse is treated as if the initial value had been
specified.
Fix by keeping the initial value in SVGAnimatedEnumeration, which already
receives it when the property is constructed but did not hold on to it, and
adding parseBaseVal() to parse and fall back to it. This replaces 24 copies of
the same guard, written three different ways.
parseBaseVal() treats a value above the highest keyword of the attribute's
grammar as unrecognized too, which is the test
SVGDecoratedEnumeration::setValue()
already applies to values arriving from the DOM. feBlend's mode needs it: the
shared BlendMode parser also accepts plus-darker and plus-lighter, and neither
is
one of the sixteen keywords of <blend-mode>, so both were stored above the range
of the attribute and read back as 0, a value the IDL setter refuses. They now
revert to normal.
https://drafts.csswg.org/filter-effects-1/#feBlendElement
https://drafts.csswg.org/compositing-1/#ltblendmodegt
marker's orient keeps its own code because one attribute drives two
properties. It had the opposite problem: it always wrote, so an unrecognized
value stored the unknown constant instead of the initial one.
feConvolveMatrix and feGaussianBlur still report an unrecognized edgeMode in
the console, and no longer report one when the attribute is merely removed.
svg/dom/SVGAnimatedEnumeration-case-sensitive.html asserted the old behaviour.
It also covered keyword parsing and case sensitivity, which the WPT tests did
not, so that coverage moves to SVGAnimatedEnumeration-keywords.html and the
local test is removed.
Tests:
imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-invalid-values.html
imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-keywords.html
*
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-initial-values-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-initial-values.html:
Adding feGaussianBlur edgeMode, whose initial value is none.
*
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-invalid-values-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-invalid-values.html:
Added.
Empty attribute values, the content attribute keeping what was specified, and
feBlend rejecting the two blend modes that are not in <blend-mode>.
*
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-keywords-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGAnimatedEnumeration-keywords.html:
Added.
Every keyword of every enumerated attribute, and its rejection in the wrong
case.
* LayoutTests/svg/dom/SVGAnimatedEnumeration-case-sensitive-expected.txt:
Removed.
* LayoutTests/svg/dom/SVGAnimatedEnumeration-case-sensitive.html: Removed.
* Source/WebCore/svg/SVGClipPathElement.cpp:
(WebCore::SVGClipPathElement::attributeChanged):
* Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp:
(WebCore::SVGComponentTransferFunctionElement::attributeChanged):
* Source/WebCore/svg/SVGFEBlendElement.cpp:
(WebCore::SVGFEBlendElement::attributeChanged):
* Source/WebCore/svg/SVGFEColorMatrixElement.cpp:
(WebCore::SVGFEColorMatrixElement::attributeChanged):
* Source/WebCore/svg/SVGFECompositeElement.cpp:
(WebCore::SVGFECompositeElement::attributeChanged):
* Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp:
(WebCore::SVGFEConvolveMatrixElement::attributeChanged):
* Source/WebCore/svg/SVGFEConvolveMatrixElement.h:
Removing SVGPropertyTraits<EdgeModeType>::initialValue(), which had no callers
and named none, while feConvolveMatrix starts at duplicate. The initial value
belongs to the attribute, not to the enumeration it is drawn from.
* Source/WebCore/svg/SVGFEDisplacementMapElement.cpp:
(WebCore::SVGFEDisplacementMapElement::attributeChanged):
* Source/WebCore/svg/SVGFEGaussianBlurElement.cpp:
(WebCore::SVGFEGaussianBlurElement::attributeChanged):
* Source/WebCore/svg/SVGFEMorphologyElement.cpp:
(WebCore::SVGFEMorphologyElement::attributeChanged):
* Source/WebCore/svg/SVGFETurbulenceElement.cpp:
(WebCore::SVGFETurbulenceElement::attributeChanged):
* Source/WebCore/svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::attributeChanged):
* Source/WebCore/svg/SVGGradientElement.cpp:
(WebCore::SVGGradientElement::attributeChanged):
* Source/WebCore/svg/SVGMarkerElement.cpp:
(WebCore::SVGMarkerElement::attributeChanged):
* Source/WebCore/svg/SVGMaskElement.cpp:
(WebCore::SVGMaskElement::attributeChanged):
* Source/WebCore/svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::attributeChanged):
* Source/WebCore/svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::attributeChanged):
* Source/WebCore/svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::attributeChanged):
* Source/WebCore/svg/properties/SVGAnimatedDecoratedProperty.h:
(WebCore::SVGAnimatedDecoratedProperty::create):
Dropping the overload which took no initial value. It had no callers, and a
property built through it would have restored 0, which is not a legal
enumeration value.
(WebCore::SVGAnimatedDecoratedProperty::SVGAnimatedDecoratedProperty):
(WebCore::SVGAnimatedDecoratedProperty::parseBaseVal):
Canonical link: https://commits.webkit.org/319093@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications