Bug 1171995 - Part 6: Handle proxies in mozAccessible accessibilityHitTest and accessibilityFocusedUIElement r=tbsaunde
authorLorien Hu <lorien@lorienhu.com>
Thu, 16 Jul 2015 17:34:52 -0400
changeset 253403 e27f10f740a22bd8e841c5822d0ec22fa5d7f4a2
parent 253402 73f2e7591ff02eecfc7de1961d2debac799a3941
child 253404 5a04fa687d3854c266d98cba3ce86d69f9707371
push id29065
push userryanvm@gmail.com
push dateFri, 17 Jul 2015 14:26:32 +0000
treeherdermozilla-central@911935404233 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1171995
milestone42.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 1171995 - Part 6: Handle proxies in mozAccessible accessibilityHitTest and accessibilityFocusedUIElement r=tbsaunde
accessible/mac/mozAccessible.mm
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -675,37 +675,44 @@ ConvertToNSArray(nsTArray<ProxyAccessibl
     [self focus];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (id)accessibilityHitTest:(NSPoint)point
 {
   AccessibleWrap* accWrap = [self getGeckoAccessible];
-  if (!accWrap)
+  ProxyAccessible* proxy = [self getProxyAccessible];
+  if (!accWrap && !proxy)
     return nil;
 
   // Convert the given screen-global point in the cocoa coordinate system (with
   // origin in the bottom-left corner of the screen) into point in the Gecko
   // coordinate system (with origin in a top-left screen point).
   NSScreen* mainView = [[NSScreen screens] objectAtIndex:0];
   NSPoint tmpPoint = NSMakePoint(point.x,
                                  [mainView frame].size.height - point.y);
   nsIntPoint geckoPoint = nsCocoaUtils::
     CocoaPointsToDevPixels(tmpPoint, nsCocoaUtils::GetBackingScaleFactor(mainView));
 
-  Accessible* child =
-    accWrap->ChildAtPoint(geckoPoint.x, geckoPoint.y,
-                          Accessible::eDeepestChild);
+  mozAccessible* nativeChild = nil;
+  if (accWrap) {
+    Accessible* child = accWrap->ChildAtPoint(geckoPoint.x, geckoPoint.y,
+                                  Accessible::eDeepestChild);
+    if (child)
+      nativeChild = GetNativeFromGeckoAccessible(child);
+  } else if (proxy) {
+    ProxyAccessible* child = proxy->ChildAtPoint(geckoPoint.x, geckoPoint.y,
+                                  Accessible::eDeepestChild);
+    if (child)
+      nativeChild = GetNativeFromProxy(child);
+  }
 
-  if (child) {
-    mozAccessible* nativeChild = GetNativeFromGeckoAccessible(child);
-    if (nativeChild)
-      return GetClosestInterestingAccessible(nativeChild);
-  }
+  if (nativeChild)
+    return GetClosestInterestingAccessible(nativeChild);
 
   // if we didn't find anything, return ourself (or the first unignored ancestor).
   return GetClosestInterestingAccessible(self);
 }
 
 - (NSArray*)accessibilityActionNames
 {
   return nil;
@@ -720,26 +727,34 @@ ConvertToNSArray(nsTArray<ProxyAccessibl
 
 - (void)accessibilityPerformAction:(NSString*)action
 {
 }
 
 - (id)accessibilityFocusedUIElement
 {
   AccessibleWrap* accWrap = [self getGeckoAccessible];
-  if (!accWrap)
+  ProxyAccessible* proxy = [self getProxyAccessible];
+  if (!accWrap && !proxy)
     return nil;
 
-  Accessible* focusedGeckoChild = accWrap->FocusedChild();
-  if (focusedGeckoChild) {
-    mozAccessible *focusedChild = GetNativeFromGeckoAccessible(focusedGeckoChild);
-    if (focusedChild)
-      return GetClosestInterestingAccessible(focusedChild);
+  mozAccessible* focusedChild = nil;
+  if (accWrap) {
+    Accessible* focusedGeckoChild = accWrap->FocusedChild();
+    if (focusedGeckoChild)
+      focusedChild = GetNativeFromGeckoAccessible(focusedGeckoChild);
+  } else if (proxy) {
+    ProxyAccessible* focusedGeckoChild = proxy->FocusedChild();
+    if (focusedGeckoChild)
+      focusedChild = GetNativeFromProxy(focusedGeckoChild);
   }
 
+  if (focusedChild)
+    return GetClosestInterestingAccessible(focusedChild);
+
   // return ourself if we can't get a native focused child.
   return GetClosestInterestingAccessible(self);
 }
 
 #pragma mark -
 
 - (id <mozAccessible>)parent
 {