Bug 805373 - don't expose explicit-name on unintentional empty name accessible, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 26 Oct 2012 21:38:29 +0900
changeset 111512 e8ed2b39b88c2adaa377572221ff46ea897a33fd
parent 111511 1c48b82bce7f99ef8593ae59c8ddae2f61001423
child 111513 97d5111dfb395b51870fd7e6c247a65d00c2da15
push id17102
push usersurkov.alexander@gmail.com
push dateFri, 26 Oct 2012 12:34:07 +0000
treeherdermozilla-inbound@e8ed2b39b88c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs805373
milestone19.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 805373 - don't expose explicit-name on unintentional empty name accessible, r=tbsaunde
accessible/src/base/nsTextEquivUtils.cpp
accessible/src/base/nsTextEquivUtils.h
accessible/src/generic/Accessible.cpp
accessible/tests/mochitest/name/markup.js
accessible/tests/mochitest/name/markuprules.xml
--- a/accessible/src/base/nsTextEquivUtils.cpp
+++ b/accessible/src/base/nsTextEquivUtils.cpp
@@ -27,17 +27,17 @@ nsTextEquivUtils::GetNameFromSubtree(Acc
                                      nsAString& aName)
 {
   aName.Truncate();
 
   if (gInitiatorAcc)
     return NS_OK;
 
   gInitiatorAcc = aAccessible;
-  if (IsNameFromSubtreeAllowed(aAccessible)) {
+  if (GetRoleRule(aAccessible->Role()) == eFromSubtree) {
     //XXX: is it necessary to care the accessible is not a document?
     if (aAccessible->IsContent()) {
       nsAutoString name;
       AppendFromAccessibleChildren(aAccessible, &name);
       name.CompressWhitespace();
       if (!IsWhitespaceString(name))
         aName = name;
     }
--- a/accessible/src/base/nsTextEquivUtils.h
+++ b/accessible/src/base/nsTextEquivUtils.h
@@ -84,24 +84,16 @@ public:
    * node or html:br) and appends it to the given string.
    *
    * @param aContent       [in] the text content
    * @param aString        [in, out] the string
    */
   static nsresult AppendTextEquivFromTextContent(nsIContent *aContent,
                                                  nsAString *aString);
 
-  /**
-   * Return true if the given accessible allows name from subtree.
-   */
-  static bool IsNameFromSubtreeAllowed(Accessible* aAccessible)
-  {
-    return GetRoleRule(aAccessible->Role()) == eFromSubtree;
-  }
-
 private:
   /**
    * Iterates accessible children and calculates text equivalent from each
    * child.
    */
   static nsresult AppendFromAccessibleChildren(Accessible* aAccessible,
                                                nsAString *aString);
   
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -1249,18 +1249,18 @@ Accessible::NativeAttributes()
 
   // Expose checkable object attribute if the accessible has checkable state
   if (State() & states::CHECKABLE) {
     nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable,
                            NS_LITERAL_STRING("true"));
   }
 
   // Expose 'explicit-name' attribute.
-  if (!nsTextEquivUtils::IsNameFromSubtreeAllowed(this) ||
-      Name(unused) != eNameFromSubtree) {
+  nsAutoString name;
+  if (Name(name) != eNameFromSubtree && !name.IsVoid()) {
     attributes->SetStringProperty(NS_LITERAL_CSTRING("explicit-name"),
                                   NS_LITERAL_STRING("true"), unused);
   }
 
   // Group attributes (level/setsize/posinset)
   GroupPos groupPos = GroupPosition();
   nsAccUtils::SetAccGroupAttrs(attributes, groupPos.level,
                                groupPos.setSize, groupPos.posInSet);
--- a/accessible/tests/mochitest/name/markup.js
+++ b/accessible/tests/mochitest/name/markup.js
@@ -53,16 +53,20 @@ var gTestIterator =
     if (this.markupIdx == -1) {
       this.markupIdx++;
       testNamesForMarkup(this.markupElms[this.markupIdx]);
       return;
     }
 
     this.ruleIdx++;
     if (this.ruleIdx == this.ruleElms.length) {
+      // When test is finished then name is empty and no explict-name.
+      testName(this.elm, null, "No name test. ");
+      testAbsentAttrs(this.elm, {"explicit-name" : "true"});
+
       this.markupIdx++;
       if (this.markupIdx == this.markupElms.length) {
         SimpleTest.finish();
         return;
       }
 
       this.ruleIdx = -1;
 
--- a/accessible/tests/mochitest/name/markuprules.xml
+++ b/accessible/tests/mochitest/name/markuprules.xml
@@ -197,17 +197,16 @@
                      aria-labelledby="l1 l2"
                      label="test4"
                      title="test5"
                      a11yname="option1">option1</html:option>
         <html:option>option2</html:option>
       </html:select>
     </markup>
 
-<!-- Temporarily disabled for causing bug 733848
     <markup ref="html:img" ruleset="htmlimage">
       <html:span id="l1" a11yname="test2">test2</html:span>
       <html:span id="l2" a11yname="test3">test3</html:span>
       <html:img id="img"
                 aria-label="Logo of Mozilla"
                 aria-labelledby="l1 l2"
                 alt="Mozilla logo"
                 title="This is a logo"
@@ -219,17 +218,16 @@
       <html:span id="l2" a11yname="test3">test3</html:span>
       <html:img id="img"
                  aria-label="Logo of Mozilla"
                  aria-labelledby="l1 l2"
                  title="This is a logo"
                  alt=""
                  src="../moz.png"/>
     </markup>
--->
 
     <markup ref="html:table/html:tr/html:td" ruleset="htmlelm"
             id="markup4test">
       <html:span id="l1" a11yname="test2">test2</html:span>
       <html:span id="l2" a11yname="test3">test3</html:span>
       <html:label for="tc" a11yname="test4">test4</html:label>
       <html:table>
         <html:tr>
@@ -285,11 +283,11 @@
                   summary="summary_tst6"
                   title="title_tst6">
         <html:caption a11yname="caption_tst6">caption_tst6</html:caption><html:tr>
           <html:td>cell1</html:td>
           <html:td>cell2</html:td>
         </html:tr>
       </html:table>
     </markup>
+
   </rulesample>
-
 </rules>