Reviewed by Sam.
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Jan 2008 08:13:43 +0000 (08:13 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Jan 2008 08:13:43 +0000 (08:13 +0000)
        Fix :checked matching type='text' and add test case
        http://bugs.webkit.org/show_bug.cgi?id=16750

        Test: fast/dom/HTMLInputElement/checked-pseudo-selector.html

        * html/HTMLInputElement.h: isChecked() can only be true for RADIO or CHECKBOX

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLInputElement/checked-pseudo-selector-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLInputElement/checked-pseudo-selector.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLInputElement/resources/TEMPLATE.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLInputElement/resources/checked-pseudo-selector.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLInputElement.h

index 5f491764bde200dc3677963057f39483b38b4f37..ce7f57cbd64fa9be80377a32da2ec619491f9bea 100644 (file)
@@ -1,3 +1,15 @@
+2008-01-06  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Sam.
+
+        Fix :checked matching type='text' and add test case
+        http://bugs.webkit.org/show_bug.cgi?id=16750
+
+        * fast/dom/HTMLInputElement/checked-pseudo-selector-expected.txt: Added.
+        * fast/dom/HTMLInputElement/checked-pseudo-selector.html: Added.
+        * fast/dom/HTMLInputElement/resources/TEMPLATE.html: Added.
+        * fast/dom/HTMLInputElement/resources/checked-pseudo-selector.js: Added.
+
 2008-01-05  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Eric Seidel.
diff --git a/LayoutTests/fast/dom/HTMLInputElement/checked-pseudo-selector-expected.txt b/LayoutTests/fast/dom/HTMLInputElement/checked-pseudo-selector-expected.txt
new file mode 100644 (file)
index 0000000..1af42d2
--- /dev/null
@@ -0,0 +1,6 @@
+PASS view.getComputedStyle(input1, '').getPropertyValue('color') is "rgb(0, 128, 0)"
+PASS input1.checked is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLInputElement/checked-pseudo-selector.html b/LayoutTests/fast/dom/HTMLInputElement/checked-pseudo-selector.html
new file mode 100644 (file)
index 0000000..20dc8c5
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/checked-pseudo-selector.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLInputElement/resources/TEMPLATE.html b/LayoutTests/fast/dom/HTMLInputElement/resources/TEMPLATE.html
new file mode 100644 (file)
index 0000000..1951c43
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="YOUR_JS_FILE_HERE"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLInputElement/resources/checked-pseudo-selector.js b/LayoutTests/fast/dom/HTMLInputElement/resources/checked-pseudo-selector.js
new file mode 100644 (file)
index 0000000..7336683
--- /dev/null
@@ -0,0 +1,19 @@
+var style = document.createElement('style');
+style.appendChild(document.createTextNode("input { color: green; }"));
+style.appendChild(document.createTextNode("input:checked { color: red; }"));
+document.documentElement.firstChild.appendChild(style);
+
+var input1 = document.createElement('input');
+input1.type = 'radio';
+document.body.appendChild(input1);
+input1.checked = true;
+input1.type = "text";
+
+var view = document.defaultView;
+shouldBeEqualToString("view.getComputedStyle(input1, '').getPropertyValue('color')", "rgb(0, 128, 0)");
+shouldBeTrue("input1.checked");
+
+// cleanup
+document.body.removeChild(input1);
+
+var successfullyParsed = true;
index bdaec7f8b7767187bb8777ff960f962fe2282be3..d70fe5d84aae3fff85319a73df8c245bd1461fcb 100644 (file)
@@ -1,3 +1,14 @@
+2008-01-06  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Sam.
+
+        Fix :checked matching type='text' and add test case
+        http://bugs.webkit.org/show_bug.cgi?id=16750
+
+        Test: fast/dom/HTMLInputElement/checked-pseudo-selector.html
+
+        * html/HTMLInputElement.h: isChecked() can only be true for RADIO or CHECKBOX
+
 2008-01-05  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Eric Seidel.
index 55515113c514488077c0ae1ca67b19c24de31cd7..410f2e137e7323f4d0ca3b4f67588905f0ef94ed 100644 (file)
@@ -70,7 +70,8 @@ public:
 
     bool autoComplete() const { return m_autocomplete; }
 
-    virtual bool isChecked() const { return checked(); }
+    // isChecked is used by the rendering tree/CSS while checked() is used by JS to determine checked state
+    virtual bool isChecked() const { return checked() && (inputType() == CHECKBOX || inputType() == RADIO); }
     virtual bool isIndeterminate() const { return indeterminate(); }
     
     bool readOnly() const { return isReadOnlyControl(); }