2010-12-07 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Dec 2010 22:01:58 +0000 (22:01 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Dec 2010 22:01:58 +0000 (22:01 +0000)
        Reviewed by Kent Tamura.

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

        * fast/forms/caret-rtl.html: Fixed a non-closed comment which added an "hidden" attribute.
        * fast/html/hidden-attr-expected.txt: Added.
        * fast/html/hidden-attr.html: Added. Test static and dynamic cases of hidden attribute.
2010-12-07  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Kent Tamura.

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

        Test: fast/html/hidden-attr.html

        * html/HTMLElement.cpp:
        (WebCore::HTMLElement::mapToEntry): Pick up hidden as a global mapped attribute.
        (WebCore::HTMLElement::parseMappedAttribute): Map hidden attribute to display: none.

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/caret-rtl.html
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 a059b26..47b674e 100644 (file)
@@ -1,3 +1,14 @@
+2010-12-07  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Kent Tamura.
+
+        Implement HTML5 hidden attribute
+        https://bugs.webkit.org/show_bug.cgi?id=40511
+        
+        * fast/forms/caret-rtl.html: Fixed a non-closed comment which added an "hidden" attribute.
+        * fast/html/hidden-attr-expected.txt: Added.
+        * fast/html/hidden-attr.html: Added. Test static and dynamic cases of hidden attribute.
+
 2010-12-07  Philippe Normand  <pnormand@igalia.com>
 
         Reviewed by Gustavo Noronha Silva.
index e523dc9..8bb4e85 100644 (file)
@@ -18,7 +18,7 @@ This tests that clicking in a contenteditable div will set the caret in the righ
 <p>
     Click in the div, the caret should be on the right edge of the div.
 </p>
-<div CONTENTEDITABLE id="test" style="direction: rtl; width:200px; font-size:2000%"; outline: solid thin; overflow: hidden></div> 
+<div CONTENTEDITABLE id="test" style="direction: rtl; width:200px; font-size:2000%; outline: solid thin"></div> 
 </body>
 <script> runTest(); </script>
 </html>
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..7f9af11
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>\r
+<meta charset=utf8>\r
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">\r
+<script src="../../fast/js/resources/js-test-pre.js"></script>\r
+\r
+<p id="description"></p>\r
+<div id="console">\r
+Tests that hidden in markup works:\r
+<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>\r
+\r
+Tests that dynamically adding/removing hidden works:\r
+<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>\r
+</div>\r
+<script>\r
+description('Various tests for the hidden attribute.');\r
+\r
+document.getElementById("test1").removeAttribute("hidden");\r
+document.getElementById("test2").setAttribute("hidden", "");\r
+\r
+var testParent = document.createElement('div');\r
+document.body.appendChild(testParent);\r
+\r
+debug('Dynamic changing of hidden and effects on style:');\r
+testParent.innerHTML="<div id=test3 hidden>a</div><div id=test4>b</div>"\r
+var test3 = document.getElementById("test3");\r
+var test4 = document.getElementById("test4");\r
+\r
+shouldBe('getComputedStyle(test3, false).display', '"none"');\r
+test3.removeAttribute("hidden");\r
+debug('test3.removeAttribute("hidden")');\r
+shouldBe('getComputedStyle(test3, false).display', '"block"');\r
+\r
+shouldBe('getComputedStyle(test4, false).display', '"block"');\r
+test4.setAttribute("hidden", "");\r
+debug('test4.setAttribute("hidden", "")');\r
+shouldBe('getComputedStyle(test4, false).display', '"none"');\r
+\r
+var successfullyParsed = true;\r
+\r
+</script>\r
+<script src="../../fast/js/resources/js-test-post.js"></script>\r
+</body>\r
+</html>\r
index fb95eb2..db93665 100644 (file)
@@ -1,3 +1,16 @@
+2010-12-07  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Kent Tamura.
+
+        Implement HTML5 hidden attribute
+        https://bugs.webkit.org/show_bug.cgi?id=40511
+
+        Test: fast/html/hidden-attr.html
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::mapToEntry): Pick up hidden as a global mapped attribute.
+        (WebCore::HTMLElement::parseMappedAttribute): Map hidden attribute to display: none.
+
 2010-12-07  Kenneth Russell  <kbr@google.com>
 
         Reviewed by David Levin.
index 4dcf998..d01a240 100644 (file)
@@ -116,8 +116,9 @@ bool HTMLElement::ieForbidsInsertHTML() 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;
     }
@@ -142,6 +143,8 @@ void HTMLElement::parseMappedAttribute(Attribute* attr)
             addCSSProperty(attr, CSSPropertyTextAlign, attr->value());
     } else if (attr->name() == contenteditableAttr) {
         setContentEditable(attr);
+    } else if (attr->name() == hiddenAttr) {
+        addCSSProperty(attr, CSSPropertyDisplay, CSSValueNone);
     } else if (attr->name() == tabindexAttr) {
         indexstring = getAttribute(tabindexAttr);
         int tabindex = 0;