AX: isNativeCheckbox does not work as advertised
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Aug 2010 18:49:06 +0000 (18:49 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Aug 2010 18:49:06 +0000 (18:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=43872

Re-adding this patch after it was erroneously rolled out.

WebCore:

Test: platform/mac/accessibility/native-vs-nonnative-checkboxes.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::isInputImage):
(WebCore::AccessibilityRenderObject::isNativeCheckboxOrRadio):
* dom/InputElement.h:
* html/HTMLInputElement.h:
(WebCore::HTMLInputElement::isCheckbox):

LayoutTests:

* platform/mac/accessibility/native-vs-nonnative-checkboxes-expected.txt: Added.
* platform/mac/accessibility/native-vs-nonnative-checkboxes.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/native-vs-nonnative-checkboxes-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/native-vs-nonnative-checkboxes.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/accessibility/AccessibilityRenderObject.cpp
WebCore/dom/InputElement.h
WebCore/html/HTMLInputElement.h
WebCore/wml/WMLInputElement.h

index 3ed899d..39cbb7e 100644 (file)
@@ -1,3 +1,13 @@
+2010-08-13  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: isNativeCheckbox does not work as advertised
+        https://bugs.webkit.org/show_bug.cgi?id=43872
+
+        Re-adding this patch after it was erroneously rolled out.
+
+        * platform/mac/accessibility/native-vs-nonnative-checkboxes-expected.txt: Added.
+        * platform/mac/accessibility/native-vs-nonnative-checkboxes.html: Added.
+
 2010-08-11  Zhenyao Mo  <zmo@google.com>
 
         Reviewed by Dimitri Glazkov.
diff --git a/LayoutTests/platform/mac/accessibility/native-vs-nonnative-checkboxes-expected.txt b/LayoutTests/platform/mac/accessibility/native-vs-nonnative-checkboxes-expected.txt
new file mode 100644 (file)
index 0000000..55c57f4
--- /dev/null
@@ -0,0 +1,15 @@
+check1
+check2
+check2
+This tests that input types masquerading as checkboxes will use the aria-checked values for its value.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS accessibilityController.focusedElement.intValue is 1
+PASS accessibilityController.focusedElement.intValue is 0
+PASS accessibilityController.focusedElement.intValue is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/native-vs-nonnative-checkboxes.html b/LayoutTests/platform/mac/accessibility/native-vs-nonnative-checkboxes.html
new file mode 100644 (file)
index 0000000..e3b65ea
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<input type="image" role="checkbox" aria-checked="true" id="check1">check1<BR>
+<input type="image" role="checkbox" aria-checked="mixed" id="check2">check2<BR>
+<input type="image" role="checkbox" id="check3">check2<BR>
+
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that input types masquerading as checkboxes will use the aria-checked values for its value.");
+
+    if (window.accessibilityController) {
+
+          // aria-state=true
+          document.getElementById("check1").focus();
+          shouldBe("accessibilityController.focusedElement.intValue", "1");
+
+          // aria-state=false
+          document.getElementById("check3").focus();
+          shouldBe("accessibilityController.focusedElement.intValue", "0");
+
+          // aria-state=mixed
+          document.getElementById("check2").focus();
+          shouldBe("accessibilityController.focusedElement.intValue", "2");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 4f69af6..d299530 100644 (file)
@@ -1,3 +1,19 @@
+2010-08-13  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: isNativeCheckbox does not work as advertised
+        https://bugs.webkit.org/show_bug.cgi?id=43872
+
+        Re-adding this patch after it was erroneously rolled out.
+
+        Test: platform/mac/accessibility/native-vs-nonnative-checkboxes.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isInputImage):
+        (WebCore::AccessibilityRenderObject::isNativeCheckboxOrRadio):
+        * dom/InputElement.h:
+        * html/HTMLInputElement.h:
+        (WebCore::HTMLInputElement::isCheckbox):
+
 2010-08-13  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r65331.
index c4669cd..6b90b63 100644 (file)
@@ -508,8 +508,9 @@ bool AccessibilityRenderObject::isFileUploadButton() const
     
 bool AccessibilityRenderObject::isInputImage() const
 {
-    if (m_renderer && m_renderer->node() && m_renderer->node()->hasTagName(inputTag)) {
-        HTMLInputElement* input = static_cast<HTMLInputElement*>(m_renderer->node());
+    Node* elementNode = node();
+    if (roleValue() == ButtonRole && elementNode && elementNode->hasTagName(inputTag)) {
+        HTMLInputElement* input = static_cast<HTMLInputElement*>(elementNode);
         return input->inputType() == HTMLInputElement::IMAGE;
     }
     
@@ -591,8 +592,11 @@ bool AccessibilityRenderObject::isIndeterminate() const
 bool AccessibilityRenderObject::isNativeCheckboxOrRadio() const
 {
     Node* elementNode = node();
-    if (elementNode && elementNode->isElementNode())
-        return toInputElement(static_cast<Element*>(elementNode));
+    if (elementNode && elementNode->isElementNode()) {
+        InputElement* input = toInputElement(static_cast<Element*>(elementNode));
+        if (input)
+            return input->isCheckbox() || input->isRadioButton();
+    }
     
     return false;
 }
index 14cfda2..56fc99d 100644 (file)
@@ -43,6 +43,9 @@ public:
     virtual bool isPasswordField() const = 0;
     virtual bool isSearchField() const = 0;
     virtual bool isTextField() const = 0;
+    virtual bool isRadioButton() const = 0;
+    virtual bool isCheckbox() const = 0;
+    
     virtual bool supportsMaxLength() const = 0;
     virtual bool hasSpinButton() const { return false; }
 #if ENABLE(INPUT_SPEECH)
index 72ac589..18cbaa4 100644 (file)
@@ -101,6 +101,7 @@ public:
     virtual bool isSearchField() const { return m_type == SEARCH; }
     virtual bool isInputTypeHidden() const { return m_type == HIDDEN; }
     virtual bool isPasswordField() const { return m_type == PASSWORD; }
+    virtual bool isCheckbox() const { return m_type == CHECKBOX; }
     bool isTelephoneField() const { return m_type == TELEPHONE; }
     bool isNumberField() const { return m_type == NUMBER; }
     bool isEmailField() const { return m_type == EMAIL; }
index fe1ae89..329d869 100644 (file)
@@ -47,6 +47,7 @@ public:
     virtual bool isIndeterminate() const { return false; }
     virtual bool isTextFormControl() const { return true; }
     virtual bool isRadioButton() const { return false; }
+    virtual bool isCheckbox() const { return false; }
     virtual bool isTextField() const { return true; }
     virtual bool isSearchField() const { return false; }
     virtual bool isInputTypeHidden() const { return false; }