Bug 835666 - ARIA combobox selected value is not a part of name computation, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 15 Feb 2013 18:54:06 +0900
changeset 122022 eec9adfe786f4833c562ab4810ae834052a49e1e
parent 122021 bcf070a2b4231797ce1b78eb6eaa862623708150
child 122023 42e87860c1570ff8d9bcc86f1cc2b8403a444d3a
push id24314
push userryanvm@gmail.com
push dateFri, 15 Feb 2013 14:39:46 +0000
treeherdermozilla-central@326c5e4868fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs835666
milestone21.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 835666 - ARIA combobox selected value is not a part of name computation, r=tbsaunde
accessible/src/base/nsTextEquivUtils.cpp
accessible/src/base/nsTextEquivUtils.h
accessible/src/generic/Accessible.cpp
accessible/tests/mochitest/name/test_general.html
--- a/accessible/src/base/nsTextEquivUtils.cpp
+++ b/accessible/src/base/nsTextEquivUtils.cpp
@@ -43,16 +43,29 @@ nsTextEquivUtils::GetNameFromSubtree(Acc
     }
   }
 
   gInitiatorAcc = nullptr;
 
   return NS_OK;
 }
 
+void
+nsTextEquivUtils::GetTextEquivFromSubtree(Accessible* aAccessible,
+                                          nsString& aTextEquiv)
+{
+  aTextEquiv.Truncate();
+
+  uint32_t nameRule = GetRoleRule(aAccessible->Role());
+  if (nameRule & eNameFromSubtreeIfReqRule) {
+    AppendFromAccessibleChildren(aAccessible, &aTextEquiv);
+    aTextEquiv.CompressWhitespace();
+  }
+}
+
 nsresult
 nsTextEquivUtils::GetTextEquivFromIDRefs(Accessible* aAccessible,
                                          nsIAtom *aIDRefsAttr,
                                          nsAString& aTextEquiv)
 {
   aTextEquiv.Truncate();
 
   nsIContent* content = aAccessible->GetContent();
--- a/accessible/src/base/nsTextEquivUtils.h
+++ b/accessible/src/base/nsTextEquivUtils.h
@@ -49,16 +49,24 @@ public:
    *
    * @param aAccessible [in] the given accessible
    * @param aName       [out] accessible name
    */
   static nsresult GetNameFromSubtree(Accessible* aAccessible,
                                      nsAString& aName);
 
   /**
+   * Calculates text equivalent from the subtree. Similar to GetNameFromSubtree.
+   * The difference it returns not empty result for things like HTML p, i.e.
+   * if the role has eNameFromSubtreeIfReq rule.
+   */
+  static void GetTextEquivFromSubtree(Accessible* aAccessible,
+                                      nsString& aTextEquiv);
+
+  /**
    * Calculates text equivalent for the given accessible from its IDRefs
    * attribute (like aria-labelledby or aria-describedby).
    *
    * @param aAccessible  [in] the accessible text equivalent is computed for
    * @param aIDRefsAttr  [in] IDRefs attribute on DOM node of the accessible
    * @param aTextEquiv   [out] result text equivalent
    */
   static nsresult GetTextEquivFromIDRefs(Accessible* aAccessible,
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -1665,17 +1665,17 @@ Accessible::Value(nsString& aValue)
         }
       }
 
       if (listbox)
         option = listbox->GetSelectedItem(0);
     }
 
     if (option)
-      nsTextEquivUtils::GetNameFromSubtree(option, aValue);
+      nsTextEquivUtils::GetTextEquivFromSubtree(option, aValue);
   }
 }
 
 // nsIAccessibleValue
 NS_IMETHODIMP
 Accessible::GetMaximumValue(double *aMaximumValue)
 {
   return GetAttrValue(nsGkAtoms::aria_valuemax, aMaximumValue);
--- a/accessible/tests/mochitest/name/test_general.html
+++ b/accessible/tests/mochitest/name/test_general.html
@@ -166,16 +166,17 @@
 
       //////////////////////////////////////////////////////////////////////////
       // controls having a value used as a part of computed name
 
       testName("ctrlvalue_progressbar:input", "foo 5 baz");
       testName("ctrlvalue_scrollbar:input", "foo 5 baz");
       testName("ctrlvalue_slider:input", "foo 5 baz");
       testName("ctrlvalue_spinbutton:input", "foo 5 baz");
+      testName("ctrlvalue_combobox:input", "foo 5 baz");
 
 
       /////////////////////////////////////////////////////////////////////////
       // label with nested combobox (test for 'f' item of name computation guide)
 
       testName("comboinstart", "One day(s).");
       testName("combo3", "day(s).");
 
@@ -265,16 +266,21 @@
      title="ARIA slider and spinbutton don't provide a value for name computation">
     Bug 812041
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=823927"
      title="Text is jammed with control's text in name computation">
     Bug 823927
   </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=835666"
+     title="ARIA combobox selected value is not a part of name computation">
+    Bug 835666
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <!-- aria-label, simple label -->
   <span id="btn_simple_aria_label" role="button" aria-label="I am a button"/>
   <br/>
@@ -500,16 +506,30 @@
   <label for="ctrlvalue_spinbutton:input">
     foo <input role="spinbutton" type="number"
                value="5" min="1" max="10"
                aria-valuenow="5" aria-valuemin="1"
                aria-valuemax="10">
     baz
   </label>
 
+  <input type="checkbox" id="ctrlvalue_combobox:input">
+  <label for="ctrlvalue_combobox:input">
+    foo
+    <div role="combobox">
+      <div role="textbox"></div>
+      <ul role="listbox" style="list-style-type: none;">
+        <li role="option">1</li>
+        <li role="option" aria-selected="true">5</li>
+        <li role="option">3</li>
+      </ul>
+    </div>
+    baz
+  </label>
+
   <!-- a label with a nested control in the start, middle and end -->
   <form>
     <!-- at the start (without and with whitespaces) -->
     <label id="comboinstart"><select id="combo3">
         <option>One</option>
         <option>Two</option>
       </select>
       day(s).