From 45529b8d0b3f78596455d27a2670203f894e8f5c Mon Sep 17 00:00:00 2001 From: Yura Zenevich Date: Thu, 24 Oct 2013 23:21:24 -0400 Subject: [PATCH] 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(+) --- .../src/html/HTMLFormControlAccessible.cpp | 15 +++++++++++++++ accessible/src/html/HTMLFormControlAccessible.h | 1 + .../tests/mochitest/attributes/test_obj.html | 16 ++++++++++++++++ content/base/src/nsGkAtomList.h | 1 + 4 files changed, 33 insertions(+) diff --git a/accessible/src/html/HTMLFormControlAccessible.cpp b/accessible/src/html/HTMLFormControlAccessible.cpp index d694fd6964f..e5028da0d44 100644 --- a/accessible/src/html/HTMLFormControlAccessible.cpp +++ b/accessible/src/html/HTMLFormControlAccessible.cpp @@ -306,6 +306,21 @@ HTMLTextFieldAccessible::NativeRole() return roles::ENTRY; } +already_AddRefed +HTMLTextFieldAccessible::NativeAttributes() +{ + nsCOMPtr 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) { diff --git a/accessible/src/html/HTMLFormControlAccessible.h b/accessible/src/html/HTMLFormControlAccessible.h index e670c1a5e10..44fd50514a1 100644 --- a/accessible/src/html/HTMLFormControlAccessible.h +++ b/accessible/src/html/HTMLFormControlAccessible.h @@ -131,6 +131,7 @@ public: virtual void ApplyARIAState(uint64_t* aState) const; virtual mozilla::a11y::role NativeRole(); virtual uint64_t NativeState(); + virtual already_AddRefed NativeAttributes() MOZ_OVERRIDE; // ActionAccessible virtual uint8_t ActionCount(); diff --git a/accessible/tests/mochitest/attributes/test_obj.html b/accessible/tests/mochitest/attributes/test_obj.html index 9d2742d6668..31607903014 100644 --- a/accessible/tests/mochitest/attributes/test_obj.html +++ b/accessible/tests/mochitest/attributes/test_obj.html @@ -97,6 +97,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=558036 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); @@ -223,6 +232,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=558036 excuse
me
+ + + + + + + diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index fa8baf98799..17349707505 100644 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -2181,6 +2181,7 @@ 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")