Bug 25453: AX: fall back to PLACEHOLDER attr if form element is not labeled
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2009 19:37:09 +0000 (19:37 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Apr 2009 19:37:09 +0000 (19:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=25453

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

LayoutTests/ChangeLog
LayoutTests/accessibility/placeholder-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/placeholder.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/page/AccessibilityRenderObject.cpp

index fc37887..23c16b0 100644 (file)
@@ -1,5 +1,15 @@
 2009-04-28  Chris Fleizach  <cfleizach@apple.com>
 
+        Reviewed by Darin Alder.
+
+        Bug 25453: AX: fall back to PLACEHOLDER attr if form element is not labeled
+        https://bugs.webkit.org/show_bug.cgi?id=25453
+
+        * accessibility/placeholder-expected.txt: Added.
+        * accessibility/placeholder.html: Added.
+
+2009-04-28  Chris Fleizach  <cfleizach@apple.com>
+
         Reviewed by Darin Adler.
 
         Bug 25452: AX: Don't create addition space AXStaticText element for every bold or link tag
diff --git a/LayoutTests/accessibility/placeholder-expected.txt b/LayoutTests/accessibility/placeholder-expected.txt
new file mode 100644 (file)
index 0000000..942df1a
--- /dev/null
@@ -0,0 +1,3 @@
+
+Test passed
+
diff --git a/LayoutTests/accessibility/placeholder.html b/LayoutTests/accessibility/placeholder.html
new file mode 100644 (file)
index 0000000..88ca1e0
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+<body id="body">
+    <!-- This test makes sure that the AXTitle will fall back to placeholder text if nothing else is available -->
+    <input placeholder="search" type="text" name="q" size="15" maxlength="255" id="searchterm" />
+    
+    <div id="result"></div>
+
+     
+    <script>
+        if (window.accessibilityController) {
+            var result = document.getElementById("result");
+
+            var field = document.getElementById("searchterm");
+            field.focus();
+            var fieldElement = accessibilityController.focusedElement;
+            
+            var pattern = "AXTitle: search";
+            if (fieldElement.allAttributes().indexOf(pattern) != -1) {
+                result.innerText += "Test passed\n";
+            }
+            else {
+                 result.innerText += "Test failed\n";
+            }
+        }
+    </script>
+</body>
+</html>
index ec4e4d9..72ebf80 100644 (file)
@@ -2,6 +2,18 @@
 
         Reviewed by Darin Adler.
 
+        Bug 25453: AX: fall back to PLACEHOLDER attr if form element is not labeled
+        https://bugs.webkit.org/show_bug.cgi?id=25453
+
+        Test: accessibility/placeholder.html
+
+        * page/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::title):
+
+2009-04-28  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Darin Adler.
+
         Bug 25452: AX: Don't create addition space AXStaticText element for every bold or link tag
         https://bugs.webkit.org/show_bug.cgi?id=25452
 
index 5222563..5646999 100644 (file)
@@ -908,6 +908,10 @@ String AccessibilityRenderObject::title() const
         HTMLLabelElement* label = labelForElement(static_cast<Element*>(node));
         if (label && !titleUIElement())
             return label->innerText();
+        
+        const AtomicString& placeholder = getAttribute(placeholderAttr);
+        if (!placeholder.isEmpty())
+            return placeholder;
     }
     
     if (roleValue() == ButtonRole