Commit 69754ad
Fix SVG length attributes to reset to defaults when removed
https://bugs.webkit.org/show_bug.cgi?id=307876
rdar://170360351
Reviewed by Brent Fulgham.
When removeAttribute() is called on SVG width/height attributes, Safari
was trying to parse an empty string instead of restoring the default
values (300 for width, 150 for height), causing an "Invalid value" error.
This occurred because SVGLengthValue::construct() only checked for null
strings, not empty strings. When an attribute is removed, an empty string
is passed, which should be treated the same as null, both indicate the
attribute should use its default value.
This patch fixes it by checking isEmpty() and using the fallback value
without attempting to parse, matching Firefox and Chrome behavior.
It is covered by existing tests, where earlier, we were throwing error
message incorrectly.
* Source/WebCore/svg/SVGLengthValue.cpp:
(WebCore::SVGLengthValue::construct):
> Rebaselines:
* LayoutTests/svg/custom/invalid-length-units-expected.txt:
* LayoutTests/svg/parser/whitespace-length-expected.txt:
* LayoutTests/svg/parser/whitespace-length-invalid-1-expected.txt:
* LayoutTests/svg/parser/whitespace-length-invalid-2-expected.txt:
* LayoutTests/svg/parser/whitespace-length-invalid-3-expected.txt:
* LayoutTests/svg/parser/whitespace-length-invalid-4-expected.txt:
Canonical link: https://commits.webkit.org/307585@main1 parent 16defb5 commit 69754ad
File tree
7 files changed
+10
-6145
lines changed- LayoutTests/svg
- custom
- parser
- Source/WebCore/svg
7 files changed
+10
-6145
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
Large diffs are not rendered by default.
Lines changed: 0 additions & 1000 deletions
Large diffs are not rendered by default.
Lines changed: 0 additions & 1000 deletions
Large diffs are not rendered by default.
Lines changed: 0 additions & 1000 deletions
Large diffs are not rendered by default.
Lines changed: 0 additions & 1000 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
123 | 131 | | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
127 | 135 | | |
128 | | - | |
129 | | - | |
| 136 | + | |
| 137 | + | |
130 | 138 | | |
131 | 139 | | |
132 | 140 | | |
| |||
0 commit comments