Title: [106623] trunk
Revision
106623
Author
[email protected]
Date
2012-02-02 20:51:18 -0800 (Thu, 02 Feb 2012)

Log Message

Support 'disabled' attribute on SVGStyleElement
https://bugs.webkit.org/show_bug.cgi?id=52130

Source/WebCore:

Adding disabled property to SVGStyleElement, which
mirrors the functionality added to HTMLStyleElement
for DOM1. The disabled property reflects and sets
the disabled state of its style sheet.

Based off of patch for bug 25287

Patch by Bear Travis <[email protected]> on 2012-02-02
Reviewed by Dirk Schulze.

Test: svg/dom/SVGStyleElement/disable-svg-style-element.html

* svg/SVGStyleElement.cpp:
(WebCore::SVGStyleElement::disabled):
(WebCore):
(WebCore::SVGStyleElement::setDisabled):
* svg/SVGStyleElement.h:
(SVGStyleElement):
* svg/SVGStyleElement.idl:

LayoutTests:

Test the disabled property of an svg style element.
Based off of the patch for bug 25287.

Patch by Bear Travis <[email protected]> on 2012-02-02
Reviewed by Dirk Schulze.

* svg/dom/SVGStyleElement/disable-svg-style-element-expected.txt: Added.
* svg/dom/SVGStyleElement/disable-svg-style-element.html: Added.
* svg/dom/SVGStyleElement/script-tests/disable-svg-style-element.js: Added.
(createStyle):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106622 => 106623)


--- trunk/LayoutTests/ChangeLog	2012-02-03 04:37:07 UTC (rev 106622)
+++ trunk/LayoutTests/ChangeLog	2012-02-03 04:51:18 UTC (rev 106623)
@@ -1,3 +1,18 @@
+2012-02-02  Bear Travis  <[email protected]>
+
+        Support 'disabled' attribute on SVGStyleElement
+        https://bugs.webkit.org/show_bug.cgi?id=52130
+
+        Test the disabled property of an svg style element.
+        Based off of the patch for bug 25287.
+
+        Reviewed by Dirk Schulze.
+
+        * svg/dom/SVGStyleElement/disable-svg-style-element-expected.txt: Added.
+        * svg/dom/SVGStyleElement/disable-svg-style-element.html: Added.
+        * svg/dom/SVGStyleElement/script-tests/disable-svg-style-element.js: Added.
+        (createStyle):
+
 2012-02-02  Raymond Toy  <[email protected]>
 
         Check parameters to biquad filters

Added: trunk/LayoutTests/svg/dom/SVGStyleElement/disable-svg-style-element-expected.txt (0 => 106623)


--- trunk/LayoutTests/svg/dom/SVGStyleElement/disable-svg-style-element-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/dom/SVGStyleElement/disable-svg-style-element-expected.txt	2012-02-03 04:51:18 UTC (rev 106623)
@@ -0,0 +1,17 @@
+Test the disabled property on an svg style element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS styleElement.disabled is false
+PASS window.getComputedStyle(rect).fill is "#0000ff"
+PASS styleElement.disabled is true
+PASS window.getComputedStyle(rect).fill is "#ff0000"
+PASS newStyleElement.disabled is false
+PASS newStyleElement.disabled is false
+PASS otherStyleElement.disabled is false
+PASS otherStyleElement.disabled is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/dom/SVGStyleElement/disable-svg-style-element.html (0 => 106623)


--- trunk/LayoutTests/svg/dom/SVGStyleElement/disable-svg-style-element.html	                        (rev 0)
+++ trunk/LayoutTests/svg/dom/SVGStyleElement/disable-svg-style-element.html	2012-02-03 04:51:18 UTC (rev 106623)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+svg {
+    width: 200px;
+    height: 200px;
+}
+rect {
+    fill: #ff0000;
+}
+</style>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/svg/dom/SVGStyleElement/script-tests/disable-svg-style-element.js (0 => 106623)


--- trunk/LayoutTests/svg/dom/SVGStyleElement/script-tests/disable-svg-style-element.js	                        (rev 0)
+++ trunk/LayoutTests/svg/dom/SVGStyleElement/script-tests/disable-svg-style-element.js	2012-02-03 04:51:18 UTC (rev 106623)
@@ -0,0 +1,51 @@
+description('Test the disabled property on an svg style element.');
+
+var console = document.getElementById('console');
+
+// Setup
+function createStyle(ns, type, ruletext) {
+    var style = document.createElementNS(ns, "style");
+    var rules = document.createTextNode(ruletext);
+    style.appendChild(rules);
+    style.type = type;
+    return style;
+}
+
+var xmlns = "http://www.w3.org/2000/svg";
+var svg = document.createElementNS(xmlns, "svg");
+svg.style.display = "block";
+
+var defs = document.createElementNS(xmlns, "defs");
+var styleElement = createStyle(xmlns, "text/css", "rect { fill: #0000ff; }");
+var otherStyleElement = createStyle(xmlns, "foo/bar", "");
+defs.appendChild(styleElement);
+defs.appendChild(otherStyleElement);
+svg.appendChild(defs);
+
+var rect = document.createElementNS(xmlns, "rect");
+rect.setAttribute("width", 100);
+rect.setAttribute("height", 100);
+svg.appendChild(rect);
+
+document.body.appendChild(svg);
+
+// Simple case
+shouldBeFalse('styleElement.disabled');
+shouldBe('window.getComputedStyle(rect).fill', '"#0000ff"');
+
+styleElement.disabled = true
+shouldBeTrue('styleElement.disabled');
+shouldBe('window.getComputedStyle(rect).fill', '"#ff0000"');
+
+// Test disconnected element
+var newStyleElement = document.createElementNS(xmlns, 'style');
+shouldBeFalse('newStyleElement.disabled');
+newStyleElement.disabled = true
+shouldBeFalse('newStyleElement.disabled');
+
+// Test non-CSS element
+shouldBeFalse('otherStyleElement.disabled');
+otherStyleElement.disabled = true
+shouldBeFalse('otherStyleElement.disabled');
+
+document.body.removeChild(svg);
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (106622 => 106623)


--- trunk/Source/WebCore/ChangeLog	2012-02-03 04:37:07 UTC (rev 106622)
+++ trunk/Source/WebCore/ChangeLog	2012-02-03 04:51:18 UTC (rev 106623)
@@ -1,3 +1,27 @@
+2012-02-02  Bear Travis  <[email protected]>
+
+        Support 'disabled' attribute on SVGStyleElement
+        https://bugs.webkit.org/show_bug.cgi?id=52130
+
+        Adding disabled property to SVGStyleElement, which
+        mirrors the functionality added to HTMLStyleElement
+        for DOM1. The disabled property reflects and sets
+        the disabled state of its style sheet.
+
+        Based off of patch for bug 25287
+
+        Reviewed by Dirk Schulze.
+
+        Test: svg/dom/SVGStyleElement/disable-svg-style-element.html
+
+        * svg/SVGStyleElement.cpp:
+        (WebCore::SVGStyleElement::disabled):
+        (WebCore):
+        (WebCore::SVGStyleElement::setDisabled):
+        * svg/SVGStyleElement.h:
+        (SVGStyleElement):
+        * svg/SVGStyleElement.idl:
+
 2012-02-02  Hayato Ito  <[email protected]>
 
         Make ShadowRoot interface inherit DocumentFragment interface in IDL.

Modified: trunk/Source/WebCore/svg/SVGStyleElement.cpp (106622 => 106623)


--- trunk/Source/WebCore/svg/SVGStyleElement.cpp	2012-02-03 04:37:07 UTC (rev 106622)
+++ trunk/Source/WebCore/svg/SVGStyleElement.cpp	2012-02-03 04:51:18 UTC (rev 106623)
@@ -51,6 +51,20 @@
     return adoptRef(new SVGStyleElement(tagName, document, createdByParser));
 }
 
+bool SVGStyleElement::disabled() const
+{
+    if (!m_sheet)
+        return false;
+    
+    return m_sheet->disabled();
+}
+
+void SVGStyleElement::setDisabled(bool setDisabled)
+{
+    if (CSSStyleSheet* styleSheet = sheet())
+        styleSheet->setDisabled(setDisabled);
+}
+
 const AtomicString& SVGStyleElement::type() const
 {
     DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("text/css"));

Modified: trunk/Source/WebCore/svg/SVGStyleElement.h (106622 => 106623)


--- trunk/Source/WebCore/svg/SVGStyleElement.h	2012-02-03 04:37:07 UTC (rev 106622)
+++ trunk/Source/WebCore/svg/SVGStyleElement.h	2012-02-03 04:51:18 UTC (rev 106623)
@@ -37,6 +37,9 @@
 
     using StyleElement::sheet;
 
+    bool disabled() const;
+    void setDisabled(bool);
+                          
     virtual const AtomicString& type() const;
     void setType(const AtomicString&, ExceptionCode&);
 

Modified: trunk/Source/WebCore/svg/SVGStyleElement.idl (106622 => 106623)


--- trunk/Source/WebCore/svg/SVGStyleElement.idl	2012-02-03 04:37:07 UTC (rev 106622)
+++ trunk/Source/WebCore/svg/SVGStyleElement.idl	2012-02-03 04:51:18 UTC (rev 106623)
@@ -30,6 +30,7 @@
         Conditional=SVG
     ] SVGStyleElement : SVGElement,
                                                   SVGLangSpace {
+                 attribute boolean disabled;
                  attribute DOMString type
                      setter raises(DOMException);
                  attribute DOMString media
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to