Bug 924896 - exposing the text input type in the accessible's attributes. r=surkov
authorYura Zenevich <yura.zenevich@gmail.com>
Thu, 24 Oct 2013 23:21:24 -0400
changeset 166821 87a32e0b05ba73fe8a9826e420a03887108ac53d
parent 166820 2fd66c1fac2361392c84cc3bbfdfcc112f615462
child 166822 53746157d20f6fbd9d88edc77e858b9294d5feac
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs924896
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 924896 - exposing the text input type in the accessible's attributes. r=surkov --- accessible/src/html/HTMLFormControlAccessible.cpp | 15 +++++++++++++++ accessible/src/html/HTMLFormControlAccessible.h | 1 + accessible/tests/mochitest/attributes/test_obj.html | 16 ++++++++++++++++ content/base/src/nsGkAtomList.h | 1 + 4 files changed, 33 insertions(+)
accessible/src/html/HTMLFormControlAccessible.cpp
accessible/src/html/HTMLFormControlAccessible.h
accessible/tests/mochitest/attributes/test_obj.html
content/base/src/nsGkAtomList.h
--- a/accessible/src/html/HTMLFormControlAccessible.cpp
+++ b/accessible/src/html/HTMLFormControlAccessible.cpp
@@ -301,16 +301,31 @@ HTMLTextFieldAccessible::NativeRole()
   if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
                             nsGkAtoms::password, eIgnoreCase)) {
     return roles::PASSWORD_TEXT;
   }
   
   return roles::ENTRY;
 }
 
+already_AddRefed<nsIPersistentProperties>
+HTMLTextFieldAccessible::NativeAttributes()
+{
+  nsCOMPtr<nsIPersistentProperties> attributes =
+    HyperTextAccessibleWrap::NativeAttributes();
+
+  // Expose type for text input elements as it gives some useful context,
+  // especially for mobile.
+  nsAutoString type;
+  if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type))
+    nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType, type);
+
+  return attributes.forget();
+}
+
 ENameValueFlag
 HTMLTextFieldAccessible::NativeName(nsString& aName)
 {
   ENameValueFlag nameFlag = Accessible::NativeName(aName);
   if (!aName.IsEmpty())
     return nameFlag;
 
   if (mContent->GetBindingParent()) {
--- a/accessible/src/html/HTMLFormControlAccessible.h
+++ b/accessible/src/html/HTMLFormControlAccessible.h
@@ -126,16 +126,17 @@ public:
   // HyperTextAccessible
   virtual already_AddRefed<nsIEditor> GetEditor() const;
 
   // Accessible
   virtual void Value(nsString& aValue);
   virtual void ApplyARIAState(uint64_t* aState) const;
   virtual mozilla::a11y::role NativeRole();
   virtual uint64_t NativeState();
+  virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
 
   // ActionAccessible
   virtual uint8_t ActionCount();
 
   // Widgets
   virtual bool IsWidget() const;
   virtual Accessible* ContainerWidget() const;
 
--- a/accessible/tests/mochitest/attributes/test_obj.html
+++ b/accessible/tests/mochitest/attributes/test_obj.html
@@ -92,16 +92,25 @@ https://bugzilla.mozilla.org/show_bug.cg
       testAbsentAttrs("labelledby", {"labelledby" : "label"});
 
       // container that has no default live attribute
       testAttrs("liveGroup", {"live" : "polite"}, true);
       testAttrs("liveGroupChild", {"container-live" : "polite"}, true);
       testAttrs("liveGroup", {"container-live-role" : "group"}, true);
       testAttrs("liveGroupChild", {"container-live-role" : "group"}, true);
 
+      // text input type
+      testAbsentAttrs("button", { "text-input-type": "button"});
+      testAbsentAttrs("checkbox", { "text-input-type": "checkbox"});
+      testAbsentAttrs("radio", { "text-input-type": "radio"});
+      testAttrs("email", {"text-input-type" : "email"}, true);
+      testAttrs("search", {"text-input-type" : "search"}, true);
+      testAttrs("tel", {"text-input-type" : "tel"}, true);
+      testAttrs("url", {"text-input-type" : "url"}, true);
+
       // html
       testAttrs("radio", {"checkable" : "true"}, true); 
       testAttrs("checkbox", {"checkable" : "true"}, true); 
       testAttrs("draggable", {"draggable" : "true"}, true);
       testAttrs("th1", { "abbr": "SS#" }, true);
       testAttrs("th2", { "abbr": "SS#" }, true);
       testAttrs("th2", { "axis": "social" }, true);
 
@@ -218,16 +227,23 @@ https://bugzilla.mozilla.org/show_bug.cg
   <div id="label" role="checkbox" aria-label="foo"></div>
   <div id="labelledby" role="checkbox" aria-labelledby="label"></div>
 
   <!-- unusual live case -->
   <div id="liveGroup" role="group" aria-live="polite">
     excuse <div id="liveGroupChild">me</div>
   </div>
 
+  <!-- text input type -->
+  <input id="button" type="button"/>
+  <input id="email" type="email"/>
+  <input id="search" type="search"/>
+  <input id="tel" type="tel"/>
+  <input id="url" type="url"/>
+
   <!-- html -->
   <input id="radio" type="radio"/>
   <input id="checkbox" type="checkbox"/>
   <div id="draggable" draggable="true">Draggable div</div>
   <table>
     <tr>
       <th id="th1"><abbr title="Social Security Number">SS#</abbr></th>
       <th id="th2" abbr="SS#" axis="social">Social Security Number</th>
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -2176,16 +2176,17 @@ GK_ATOM(select1, "select1")
 GK_ATOM(setsize, "setsize")
 GK_ATOM(spelling, "spelling")
 GK_ATOM(spinbutton, "spinbutton")
 GK_ATOM(status, "status")
 GK_ATOM(tableCellIndex, "table-cell-index")
 GK_ATOM(tablist, "tablist")
 GK_ATOM(textAlign, "text-align")
 GK_ATOM(textIndent, "text-indent")
+GK_ATOM(textInputType, "text-input-type")
 GK_ATOM(textLineThroughColor, "text-line-through-color")
 GK_ATOM(textLineThroughStyle, "text-line-through-style")
 GK_ATOM(textPosition, "text-position")
 GK_ATOM(textUnderlineColor, "text-underline-color")
 GK_ATOM(textUnderlineStyle, "text-underline-style")
 GK_ATOM(timer, "timer")
 GK_ATOM(toolbarname, "toolbarname")
 GK_ATOM(toolbarseparator, "toolbarseparator")