Bug 1210023 - Fix accessibilityAttributeValue for NSAccessibilityIndexAttribute. r=surkov
authorFrédéric Wang <fred.wang@free.fr>
Thu, 01 Oct 2015 08:40:35 +0200
changeset 265572 860c5decce249dfb052b79990417bd95a0c9f94a
parent 265571 2c3e1c2fc632be77211c3a58431cc58484441e72
child 265573 c37cbf6f62969b69747e9a8b56bf4aba27007ac6
push id15472
push usercbook@mozilla.com
push dateFri, 02 Oct 2015 11:51:34 +0000
treeherderfx-team@2c33ef6b27e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1210023
milestone44.0a1
Bug 1210023 - Fix accessibilityAttributeValue for NSAccessibilityIndexAttribute. r=surkov
accessible/mac/mozAccessible.mm
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -445,19 +445,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(),
@@ -495,19 +498,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())];