2010-06-11 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Jun 2010 01:28:18 +0000 (01:28 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Jun 2010 01:28:18 +0000 (01:28 +0000)
        Reviewed by Ojan Vafai.

        Implement HTML5 hidden attribute
        https://bugs.webkit.org/show_bug.cgi?id=40511

        Test: fast/html/hidden-attr.html

        Note: I used the mapped attribute mechanism for this instead of a rule in the UA stylesheet
        to avoid a performance hit from adding a global attribute rule to the UA stylesheet.

        * html/HTMLElement.cpp:
        (WebCore::HTMLElement::mapToEntry): Pick up hidden as a global mapped attribute.
        (WebCore::HTMLElement::parseMappedAttribute): Map hidden attribute to display: none.
2010-06-11  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Ojan Vafai.

        Implement HTML5 hidden attribute
        https://bugs.webkit.org/show_bug.cgi?id=40511

        * fast/html/hidden-attr-expected.txt: Added.
        * fast/html/hidden-attr.html: Added. Test static and dynamic cases of hidden attribute.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@61052 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/html/hidden-attr-expected.txt [new file with mode: 0644]
LayoutTests/fast/html/hidden-attr.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLElement.cpp

index 7cffbd1de1895d2e8d1cc487d19cf2130f6f4189..dc9e87e4062490e34205eda5b4322064def84463 100644 (file)
@@ -1,3 +1,13 @@
+2010-06-11  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Ojan Vafai.
+
+        Implement HTML5 hidden attribute
+        https://bugs.webkit.org/show_bug.cgi?id=40511
+
+        * fast/html/hidden-attr-expected.txt: Added.
+        * fast/html/hidden-attr.html: Added. Test static and dynamic cases of hidden attribute.
+
 2010-06-11  Simon Fraser  <simon.fraser@apple.com>
 
         Add expected result missing from the previous commit.
diff --git a/LayoutTests/fast/html/hidden-attr-expected.txt b/LayoutTests/fast/html/hidden-attr-expected.txt
new file mode 100644 (file)
index 0000000..d6d12b5
--- /dev/null
@@ -0,0 +1,27 @@
+Various tests for the hidden attribute.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Tests that hidden in markup works:
+
+
+Tests that dynamically adding/removing hidden works:
+PASS - this line should appear
+
+Dynamic changing of hidden and effects on style:
+PASS getComputedStyle(test3, false).display is "none"
+test3.removeAttribute("hidden")
+PASS getComputedStyle(test3, false).display is "block"
+PASS getComputedStyle(test4, false).display is "block"
+test4.setAttribute("hidden", "")
+PASS getComputedStyle(test4, false).display is "none"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+a
diff --git a/LayoutTests/fast/html/hidden-attr.html b/LayoutTests/fast/html/hidden-attr.html
new file mode 100644 (file)
index 0000000..5177a3f
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<meta charset=utf8>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+
+<p id="description"></p>
+<div id="console">
+Tests that hidden in markup works:
+<div hidden><span class=fail>FAIL</span> - this line should not appear</div><div hidden=hidden><span class=fail>FAIL</span> - this line should not appear</div><div hidden=false><span class=fail>FAIL</span> - this line should not appear</div><p hidden><span class=fail>FAIL</span> - this line should not appear</p><span hidden><span class=fail>FAIL</span> - this line should not appear</span><img width=400px alt="FAIL - this should not appear" src="resources/xxx-missing.jpeg" hidden>
+
+Tests that dynamically adding/removing hidden works:
+<div hidden id=test1><span class=pass>PASS</span> - this line should appear<div id=test2><span class=fail>FAIL</span> - this line should not appear</div>
+</div>
+<script>
+description('Various tests for the hidden attribute.');
+
+document.getElementById("test1").removeAttribute("hidden");
+document.getElementById("test2").setAttribute("hidden", "");
+
+var testParent = document.createElement('div');
+document.body.appendChild(testParent);
+
+debug('Dynamic changing of hidden and effects on style:');
+testParent.innerHTML="<div id=test3 hidden>a</div><div id=test4>b</div>"
+var test3 = document.getElementById("test3");
+var test4 = document.getElementById("test4");
+
+shouldBe('getComputedStyle(test3, false).display', '"none"');
+test3.removeAttribute("hidden");
+debug('test3.removeAttribute("hidden")');
+shouldBe('getComputedStyle(test3, false).display', '"block"');
+
+shouldBe('getComputedStyle(test4, false).display', '"block"');
+test4.setAttribute("hidden", "");
+debug('test4.setAttribute("hidden", "")');
+shouldBe('getComputedStyle(test4, false).display', '"none"');
+
+var successfullyParsed = true;
+
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 372fb1915f2f8b577e3abbaef195f5e18bff08cb..5e37ce5189f8a67c648c3007890f924e30799c0a 100644 (file)
@@ -1,3 +1,19 @@
+2010-06-11  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Ojan Vafai.
+
+        Implement HTML5 hidden attribute
+        https://bugs.webkit.org/show_bug.cgi?id=40511
+
+        Test: fast/html/hidden-attr.html
+        
+        Note: I used the mapped attribute mechanism for this instead of a rule in the UA stylesheet
+        to avoid a performance hit from adding a global attribute rule to the UA stylesheet.
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::mapToEntry): Pick up hidden as a global mapped attribute.
+        (WebCore::HTMLElement::parseMappedAttribute): Map hidden attribute to display: none.
+
 2010-06-10  Abhishek Arya  <inferno@chromium.org>
 
         Reviewed by Dave Hyatt.
index d95a23654f3e47d4daa477077e3a279eac5eae23..fd22bc73bb3ac6e1708ab115caf3644d12841a1b 100644 (file)
@@ -129,8 +129,9 @@ int HTMLElement::tagPriority() const
 
 bool HTMLElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
 {
-    if (attrName == alignAttr ||
-        attrName == contenteditableAttr) {
+    if (attrName == alignAttr
+        || attrName == contenteditableAttr
+        || attrName == hiddenAttr) {
         result = eUniversal;
         return false;
     }
@@ -153,6 +154,8 @@ void HTMLElement::parseMappedAttribute(Attribute* attr)
             addCSSProperty(attr, CSSPropertyTextAlign, "center");
         else
             addCSSProperty(attr, CSSPropertyTextAlign, attr->value());
+    } else if (attr->name() == hiddenAttr) {
+        addCSSProperty(attr, CSSPropertyDisplay, CSSValueNone);
     } else if (attr->name() == contenteditableAttr) {
         setContentEditable(attr);
     } else if (attr->name() == tabindexAttr) {