Skip to content

Commit 7fa7cb0

Browse files
committed
Align SVGStyleElement's type and media attributes with HTML
https://bugs.webkit.org/show_bug.cgi?id=297909 Reviewed by NOBODY (OOPS!). 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. * LayoutTests/imported/w3c/web-platform-tests/svg/styling/attr-style-media-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/svg/styling/attr-style-media.html: Added. * LayoutTests/imported/w3c/web-platform-tests/svg/styling/attr-style-type-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/svg/styling/attr-style-type.html: Added. * Source/WebCore/svg/SVGStyleElement.cpp: (WebCore::SVGStyleElement::type const): Deleted. (WebCore::SVGStyleElement::setType): Deleted. (WebCore::SVGStyleElement::media const): Deleted. (WebCore::SVGStyleElement::setMedia): Deleted. * Source/WebCore/svg/SVGStyleElement.h: * Source/WebCore/svg/SVGStyleElement.idl:
1 parent 46a9586 commit 7fa7cb0

File tree

7 files changed

+40
-30
lines changed

7 files changed

+40
-30
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>

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)