Bug 1210023 - Fix accessibilityAttributeValue for NSAccessibilityIndexAttribute. r=surkov, a=lizzard
authorFrédéric Wang <fred.wang@free.fr>
Thu, 01 Oct 2015 08:40:35 +0200
changeset 291132 6fcef6bbbbc5c84260deb1dd88f40f89db86a96d
parent 291131 153e6e2572ec612895d2c62f7f0d195f11cec1c1
child 291133 9f5a6eb87f21b69449c9368c1afe1515d347e5b8
push id934
push userraliiev@mozilla.com
push dateMon, 26 Oct 2015 12:58:05 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov, lizzard
bugs1210023
milestone42.0
Bug 1210023 - Fix accessibilityAttributeValue for NSAccessibilityIndexAttribute. r=surkov, a=lizzard
accessible/mac/mozAccessible.mm
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -448,19 +448,22 @@ ConvertToNSArray(nsTArray<ProxyAccessibl
           }
         }
         return nativeArray;
       }
     } else if (accWrap->IsTableRow()) {
       if ([attribute isEqualToString:NSAccessibilityIndexAttribute]) {
         // Count the number of rows before that one to obtain the row index.
         uint32_t index = 0;
-        for (int32_t i = accWrap->IndexInParent() - 1; i >= 0; i--) {
-          if (accWrap->GetChildAt(i)->IsTableRow()) {
-            index++;
+        Accessible* parent = accWrap->Parent();
+        if (parent) {
+          for (int32_t i = accWrap->IndexInParent() - 1; i >= 0; i--) {
+            if (parent->GetChildAt(i)->IsTableRow()) {
+              index++;
+            }
           }
         }
         return [NSNumber numberWithUnsignedInteger:index];
       }
     } else if (accWrap->IsTableCell()) {
       TableCellAccessible* cell = accWrap->AsTableCell();
       if ([attribute isEqualToString:NSAccessibilityRowIndexRangeAttribute])
         return [NSValue valueWithRange:NSMakeRange(cell->RowIdx(),
@@ -498,19 +501,22 @@ ConvertToNSArray(nsTArray<ProxyAccessibl
           }
         }
         return nativeArray;
       }
     } else if (proxy->IsTableRow()) {
       if ([attribute isEqualToString:NSAccessibilityIndexAttribute]) {
         // Count the number of rows before that one to obtain the row index.
         uint32_t index = 0;
-        for (int32_t i = proxy->IndexInParent() - 1; i >= 0; i--) {
-          if (proxy->ChildAt(i)->IsTableRow()) {
-            index++;
+        ProxyAccessible* parent = proxy->Parent();
+        if (parent) {
+          for (int32_t i = proxy->IndexInParent() - 1; i >= 0; i--) {
+            if (parent->ChildAt(i)->IsTableRow()) {
+              index++;
+            }
           }
         }
         return [NSNumber numberWithUnsignedInteger:index];
       }
     } else if (proxy->IsTableCell()) {
       if ([attribute isEqualToString:NSAccessibilityRowIndexRangeAttribute])
         return [NSValue valueWithRange:NSMakeRange(proxy->RowIdx(),
                                                    proxy->RowExtent())];