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 296286 216a745230ddfb20fb292a2c212b5c1653657b12
parent 296285 ceadb2f312001085763d022231aa5d975cad0baa
child 296287 d9d25e8b20fa53c219c50c3d3f66a91527d664ab
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov, lizzard
bugs1210023
milestone43.0a2
Bug 1210023 - Fix accessibilityAttributeValue for NSAccessibilityIndexAttribute. r=surkov, a=lizzard
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())];