AX: Implement AutoFill Available attribute for a text field
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Mar 2016 16:38:56 +0000 (16:38 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Mar 2016 16:38:56 +0000 (16:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155567

Reviewed by Darin Adler.

Source/WebCore:

Expose the auto fill buttons to the AX hierarchy.
Add an attribute for the textfield to inform when the auto fill button is available.

Test: accessibility/auto-fill-types.html

* English.lproj/Localizable.strings:
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::element):
(WebCore::AccessibilityObject::isValueAutofillAvailable):
(WebCore::AccessibilityObject::isValueAutofilled):
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::passwordFieldValue):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::addTextFieldChildren):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
* html/TextFieldInputType.cpp:
(WebCore::limitLength):
(WebCore::autoFillButtonTypeToAccessibilityLabel):
(WebCore::autoFillButtonTypeToAutoFillButtonPseudoClassName):
(WebCore::TextFieldInputType::createAutoFillButton):
(WebCore::TextFieldInputType::updateAutoFillButton):
* platform/LocalizedStrings.cpp:
(WebCore::AXListItemActionVerb):
(WebCore::AXAutoFillCredentialsLabel):
(WebCore::AXAutoFillContactsLabel):
(WebCore::AXARIAContentGroupText):
* platform/LocalizedStrings.h:

LayoutTests:

* accessibility/auto-fill-types-expected.txt: Added.
* accessibility/auto-fill-types.html: Added.

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/auto-fill-types-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/auto-fill-types.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/Localizable.strings
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/platform/efl/LocalizedStringsEfl.cpp
Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp

index 63d6c71..3905e4f 100644 (file)
@@ -1,3 +1,13 @@
+2016-03-16  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Implement AutoFill Available attribute for a text field
+        https://bugs.webkit.org/show_bug.cgi?id=155567
+
+        Reviewed by Darin Adler.
+
+        * accessibility/auto-fill-types-expected.txt: Added.
+        * accessibility/auto-fill-types.html: Added.
+
 2016-03-17  Mark Lam  <mark.lam@apple.com>
 
         Method names should not appear in the lexical scope of the method's body.
diff --git a/LayoutTests/accessibility/auto-fill-types-expected.txt b/LayoutTests/accessibility/auto-fill-types-expected.txt
new file mode 100644 (file)
index 0000000..2bfd7bd
--- /dev/null
@@ -0,0 +1,16 @@
+
+This tests that the auto-filled buttons show up.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Initial auto-fill available: false
+Contact button role: AXRole: AXButton
+Contact button label: AXDescription: contact info auto fill
+Credentials button role: AXRole: AXButton
+Credentials button label: AXDescription: password auto fill
+Post auto-fill available: true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/auto-fill-types.html b/LayoutTests/accessibility/auto-fill-types.html
new file mode 100644 (file)
index 0000000..1639ffe
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<input type="text" value="hello" id="textfield">
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that the auto-filled buttons show up.");
+
+    if (window.accessibilityController) {
+        var textField = document.getElementById("textfield");
+        var axTextField = accessibilityController.accessibleElementById("textfield");
+        debug("Initial auto-fill available: " + axTextField.boolAttributeValue("AXValueAutofillAvailable"));
+
+        window.internals.setShowAutoFillButton(document.getElementById("textfield"), "AutoFillButtonTypeContacts");
+        var contactsButton = axTextField.childAtIndex(1);
+        debug("Contact button role: " + contactsButton.role);
+        debug("Contact button label: " + contactsButton.description);
+
+        window.internals.setShowAutoFillButton(document.getElementById("textfield"), "AutoFillButtonTypeCredentials");
+        var credentialsButton = axTextField.childAtIndex(1);
+        debug("Credentials button role: " + credentialsButton.role);
+        debug("Credentials button label: " + credentialsButton.description);
+
+        debug("Post auto-fill available: " + axTextField.boolAttributeValue("AXValueAutofillAvailable"));
+    }
+
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
index 22a5c6d..59798a6 100644 (file)
@@ -1,3 +1,39 @@
+2016-03-16  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Implement AutoFill Available attribute for a text field
+        https://bugs.webkit.org/show_bug.cgi?id=155567
+
+        Reviewed by Darin Adler.
+
+        Expose the auto fill buttons to the AX hierarchy.
+        Add an attribute for the textfield to inform when the auto fill button is available.
+
+        Test: accessibility/auto-fill-types.html
+
+        * English.lproj/Localizable.strings:
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::element):
+        (WebCore::AccessibilityObject::isValueAutofillAvailable):
+        (WebCore::AccessibilityObject::isValueAutofilled):
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::passwordFieldValue):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::addTextFieldChildren):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        * html/TextFieldInputType.cpp:
+        (WebCore::limitLength):
+        (WebCore::autoFillButtonTypeToAccessibilityLabel):
+        (WebCore::autoFillButtonTypeToAutoFillButtonPseudoClassName):
+        (WebCore::TextFieldInputType::createAutoFillButton):
+        (WebCore::TextFieldInputType::updateAutoFillButton):
+        * platform/LocalizedStrings.cpp:
+        (WebCore::AXListItemActionVerb):
+        (WebCore::AXAutoFillCredentialsLabel):
+        (WebCore::AXAutoFillContactsLabel):
+        (WebCore::AXARIAContentGroupText):
+        * platform/LocalizedStrings.h:
+
 2016-03-17  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Mac][cmake] Unreviewed speculative buildfix after r198179. Just for fun.
index 9da8ee1..71d231b 100644 (file)
 /* HTTP result code string */
 "conflict" = "conflict";
 
+/* Label for the auto fill contacts button inside a text field. */
+"contact info auto fill" = "contact info auto fill";
+
 /* An ARIA accessibility group that contains content. */
 "content information" = "content information";
 
 /* HTTP result code string */
 "partial content" = "partial content";
 
+/* Label for the auto fill credentials button inside a text field. */
+"password auto fill" = "password auto fill";
+
 /* Validation message for input form controls requiring a constrained value according to pattern */
 "pattern mismatch" = "pattern mismatch";
 
index f355c66..d4cf035 100644 (file)
@@ -2197,13 +2197,25 @@ Element* AccessibilityObject::element() const
     return nullptr;
 }
     
+bool AccessibilityObject::isValueAutofillAvailable() const
+{
+    if (!isNativeTextControl())
+        return false;
+    
+    Node* node = this->node();
+    if (!is<HTMLInputElement>(node))
+        return false;
+    
+    return downcast<HTMLInputElement>(*node).autoFillButtonType() != AutoFillButtonType::None;
+}
+    
 bool AccessibilityObject::isValueAutofilled() const
 {
     if (!isNativeTextControl())
         return false;
     
     Node* node = this->node();
-    if (!node || !is<HTMLInputElement>(*node))
+    if (!is<HTMLInputElement>(node))
         return false;
     
     return downcast<HTMLInputElement>(*node).isAutoFilled();
index f48a688..814f4f5 100644 (file)
@@ -891,6 +891,7 @@ public:
 
     virtual String passwordFieldValue() const { return String(); }
     bool isValueAutofilled() const;
+    bool isValueAutofillAvailable() const;
     
     // Used by an ARIA tree to get all its rows.
     void ariaTreeRows(AccessibilityChildrenVector&);
index f040ff6..93cfe31 100644 (file)
@@ -156,6 +156,10 @@ using namespace HTMLNames;
 #define NSAccessibilityValueAutofilledAttribute @"AXValueAutofilled"
 #endif
 
+#ifndef NSAccessibilityValueAutofillAvailableAttribute
+#define NSAccessibilityValueAutofillAvailableAttribute @"AXValueAutofillAvailable"
+#endif
+
 #ifndef NSAccessibilityLanguageAttribute
 #define NSAccessibilityLanguageAttribute @"AXLanguage"
 #endif
@@ -3196,6 +3200,9 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if ([attributeName isEqualToString:NSAccessibilityPlaceholderValueAttribute])
         return m_object->placeholderValue();
 
+    if ([attributeName isEqualToString:NSAccessibilityValueAutofillAvailableAttribute])
+        return @(m_object->isValueAutofillAvailable());
+    
     if ([attributeName isEqualToString:NSAccessibilityValueAutofilledAttribute])
         return @(m_object->isValueAutofilled());
 
index a21b1b3..3b7fb92 100644 (file)
@@ -42,6 +42,7 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "KeyboardEvent.h"
+#include "LocalizedStrings.h"
 #include "NodeRenderStyle.h"
 #include "Page.h"
 #include "PlatformKeyboardEvent.h"
@@ -399,6 +400,20 @@ static String limitLength(const String& string, int maxLength)
     return string.left(newLength);
 }
 
+static String autoFillButtonTypeToAccessibilityLabel(AutoFillButtonType autoFillButtonType)
+{
+    switch (autoFillButtonType) {
+    case AutoFillButtonType::Contacts:
+        return AXAutoFillContactsLabel();
+    case AutoFillButtonType::Credentials:
+        return AXAutoFillCredentialsLabel();
+    default:
+    case AutoFillButtonType::None:
+        ASSERT_NOT_REACHED();
+        return AtomicString();
+    }
+}
+    
 static AtomicString autoFillButtonTypeToAutoFillButtonPseudoClassName(AutoFillButtonType autoFillButtonType)
 {
     AtomicString pseudoClassName;
@@ -648,6 +663,8 @@ void TextFieldInputType::createAutoFillButton(AutoFillButtonType autoFillButtonT
 
     m_autoFillButton = AutoFillButtonElement::create(element().document(), *this);
     m_autoFillButton->setPseudo(autoFillButtonTypeToAutoFillButtonPseudoClassName(autoFillButtonType));
+    m_autoFillButton->setAttribute(roleAttr, "button");
+    m_autoFillButton->setAttribute(aria_labelAttr, autoFillButtonTypeToAccessibilityLabel(autoFillButtonType));
     m_container->appendChild(*m_autoFillButton, IGNORE_EXCEPTION);
 }
 
@@ -662,9 +679,10 @@ void TextFieldInputType::updateAutoFillButton()
 
         const AtomicString& attribute = m_autoFillButton->fastGetAttribute(pseudoAttr);
         bool shouldUpdateAutoFillButtonType = isAutoFillButtonTypeChanged(attribute, element().autoFillButtonType());
-        if (shouldUpdateAutoFillButtonType)
+        if (shouldUpdateAutoFillButtonType) {
             m_autoFillButton->setPseudo(autoFillButtonTypeToAutoFillButtonPseudoClassName(element().autoFillButtonType()));
-
+            m_autoFillButton->setAttribute(aria_labelAttr, autoFillButtonTypeToAccessibilityLabel(element().autoFillButtonType()));
+        }
         m_autoFillButton->setInlineStyleProperty(CSSPropertyDisplay, CSSValueBlock, true);
         return;
     }
index 1032e01..155eb58 100644 (file)
@@ -654,6 +654,16 @@ String AXListItemActionVerb()
 }
 #endif // !PLATFORM(IOS)
 
+String AXAutoFillCredentialsLabel()
+{
+    return WEB_UI_STRING("password auto fill", "Label for the auto fill credentials button inside a text field.");
+}
+
+String AXAutoFillContactsLabel()
+{
+    return WEB_UI_STRING("contact info auto fill", "Label for the auto fill contacts button inside a text field.");
+}
+    
 #if PLATFORM(COCOA)
 String AXARIAContentGroupText(const String& ariaType)
 {
index e7ace90..058d943 100644 (file)
@@ -183,6 +183,9 @@ namespace WebCore {
     String AXARIAContentGroupText(const String& ariaType);
     String AXHorizontalRuleDescriptionText();
 #endif
+    
+    String AXAutoFillCredentialsLabel();
+    String AXAutoFillContactsLabel();
 
     String missingPluginText();
     String crashedPluginText();
index c2196a2..c97a2af 100644 (file)
@@ -407,6 +407,16 @@ String AXSearchFieldCancelButtonText()
 {
     return String::fromUTF8("cancel");
 }
+    
+String AXAutoFillCredentialsLabel()
+{
+    return String::fromUTF8("password auto fill");
+}
+
+String AXAutoFillContactsLabel()
+{
+    return String::fromUTF8("contact info auto fill");
+}
 
 String AXButtonActionVerb()
 {
index 0cfd514..1cf92fb 100644 (file)
@@ -456,6 +456,16 @@ String AXSearchFieldCancelButtonText()
     return String::fromUTF8(_("cancel"));
 }
 
+String AXAutoFillCredentialsLabel()
+{
+    return String::fromUTF8(_("password auto fill"));
+}
+
+String AXAutoFillContactsLabel()
+{
+    return String::fromUTF8(_("contact info auto fill"));
+}
+    
 String AXButtonActionVerb()
 {
     return String::fromUTF8(_("press"));