Skip to content

Commit ed7b1f5

Browse files
lukewarlowJarred-Sumner
authored andcommitted
Align SVGStyleElement's type and media attributes with HTML
https://bugs.webkit.org/show_bug.cgi?id=297909 Reviewed by Tim Nguyen. See w3c/svgwg#1001 This aligns SVGStyleElement type and media to use pure attribute reflection which matches how HTMLStyleElement works. This aligns WebKit with Firefox/Gecko. Canonical link: https://commits.webkit.org/299252@main
1 parent 3231ea3 commit ed7b1f5

File tree

9 files changed

+44
-34
lines changed

9 files changed

+44
-34
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
PASS media attribute on SVG <style> elements should reflect correctly
3+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<title>Media - SVG Style element</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
6+
<svg>
7+
<style id=style1></style>
8+
<style id=style2 media="foo"></style>
9+
</svg>
10+
11+
<script>
12+
test(() => {
13+
assert_equals(style1.media, "", "missing media reflects as empty string IDL attribute on the style element");
14+
assert_equals(style2.media, "foo", "media reflects correctly IDL attribute on the style element");
15+
}, "media attribute on SVG <style> elements should reflect correctly");
16+
</script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
PASS type attribute on SVG <style> elements should reflect correctly
3+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<title>Type - SVG Style element</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
6+
<svg>
7+
<style id=style1></style>
8+
<style id=style2 type="random/type"></style>
9+
</svg>
10+
11+
<script>
12+
test(() => {
13+
assert_equals(style1.type, "", "missing type reflects as empty string IDL attribute on the style element");
14+
assert_equals(style2.type, "random/type", "type reflects correctly IDL attribute on the style element");
15+
}, "type attribute on SVG <style> elements should reflect correctly");
16+
</script>

LayoutTests/svg/dom/style-reflect-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ This test checks that the type, media and title properties on an SVGStyleElement
33
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

55

6-
PASS style.type is "text/css"
7-
PASS style.media is "all"
6+
PASS style.type is ""
7+
PASS style.media is ""
88
PASS style.title is ""
99
PASS style.type is "text/x-something-else"
1010
PASS style.media is "print"

LayoutTests/svg/dom/style-reflect.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
var style = document.createElementNS("http://www.w3.org/2000/svg", "style");
1313

14-
shouldBeEqualToString("style.type", "text/css");
15-
shouldBeEqualToString("style.media", "all");
14+
shouldBeEqualToString("style.type", "");
15+
shouldBeEqualToString("style.media", "");
1616
shouldBeEqualToString("style.title", "");
1717

1818
style.type = "text/x-something-else";

Source/WebCore/svg/SVGStyleElement.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,6 @@ void SVGStyleElement::setDisabled(bool setDisabled)
6666
styleSheet->setDisabled(setDisabled);
6767
}
6868

69-
const AtomString& SVGStyleElement::type() const
70-
{
71-
auto& typeValue = getAttribute(SVGNames::typeAttr);
72-
return typeValue.isNull() ? cssContentTypeAtom() : typeValue;
73-
}
74-
75-
void SVGStyleElement::setType(const AtomString& type)
76-
{
77-
setAttribute(SVGNames::typeAttr, type);
78-
}
79-
80-
const AtomString& SVGStyleElement::media() const
81-
{
82-
auto& value = attributeWithoutSynchronization(SVGNames::mediaAttr);
83-
return value.isNull() ? allAtom() : value;
84-
}
85-
86-
void SVGStyleElement::setMedia(const AtomString& media)
87-
{
88-
setAttributeWithoutSynchronization(SVGNames::mediaAttr, media);
89-
}
90-
9169
String SVGStyleElement::title() const
9270
{
9371
return attributeWithoutSynchronization(SVGNames::titleAttr);

Source/WebCore/svg/SVGStyleElement.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ class SVGStyleElement final : public SVGElement {
3838

3939
bool disabled() const;
4040
void setDisabled(bool);
41-
42-
const AtomString& type() const;
43-
void setType(const AtomString&);
44-
45-
const AtomString& media() const;
46-
void setMedia(const AtomString&);
4741

4842
private:
4943
SVGStyleElement(const QualifiedName&, Document&, bool createdByParser);

Source/WebCore/svg/SVGStyleElement.idl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
Exposed=Window
2929
] interface SVGStyleElement : SVGElement {
3030
attribute boolean disabled;
31-
attribute [AtomString] DOMString type;
32-
attribute [AtomString] DOMString media;
31+
[Reflect] attribute DOMString type;
32+
[Reflect] attribute DOMString media;
3333
[Reflect] attribute DOMString title;
3434
};
3535

0 commit comments

Comments
 (0)