From e8740b799a6ed75f93da320f38b748c3915927bc Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Wed, 19 Aug 2015 14:14:30 -0400 Subject: [PATCH] bug 1196372 - make GetHWNDFor() work with proxied accessibles r=surkov --- accessible/windows/msaa/AccessibleWrap.cpp | 69 ++++++++++++++-------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/accessible/windows/msaa/AccessibleWrap.cpp b/accessible/windows/msaa/AccessibleWrap.cpp index d076487bc79..10e8a743da0 100644 --- a/accessible/windows/msaa/AccessibleWrap.cpp +++ b/accessible/windows/msaa/AccessibleWrap.cpp @@ -1308,35 +1308,54 @@ AccessibleWrap::GetChildIDFor(Accessible* aAccessible) HWND AccessibleWrap::GetHWNDFor(Accessible* aAccessible) { - if (aAccessible) { - DocAccessible* document = aAccessible->Document(); - if(!document) - return nullptr; + if (!aAccessible) { + return nullptr; + } - // Popup lives in own windows, use its HWND until the popup window is - // hidden to make old JAWS versions work with collapsed comboboxes (see - // discussion in bug 379678). - nsIFrame* frame = aAccessible->GetFrame(); - if (frame) { - nsIWidget* widget = frame->GetNearestWidget(); - if (widget && widget->IsVisible()) { - nsIPresShell* shell = document->PresShell(); - nsViewManager* vm = shell->GetViewManager(); - if (vm) { - nsCOMPtr rootWidget; - vm->GetRootWidget(getter_AddRefs(rootWidget)); - // Make sure the accessible belongs to popup. If not then use - // document HWND (which might be different from root widget in the - // case of window emulation). - if (rootWidget != widget) - return static_cast(widget->GetNativeData(NS_NATIVE_WINDOW)); - } - } + // Accessibles in child processes are said to have the HWND of the window + // their tab is within. Popups are always in the parent process, and so + // never proxied, which means this is basically correct. + if (aAccessible->IsProxy()) { + ProxyAccessible* proxy = aAccessible->Proxy(); + if (!proxy) { + return nullptr; } - return static_cast(document->GetNativeWindow()); + Accessible* outerDoc = proxy->OuterDocOfRemoteBrowser(); + NS_ASSERTION(outerDoc, "no outer doc for accessible remote tab!"); + if (!outerDoc) { + return nullptr; + } + + return GetHWNDFor(outerDoc); } - return nullptr; + + DocAccessible* document = aAccessible->Document(); + if(!document) + return nullptr; + + // Popup lives in own windows, use its HWND until the popup window is + // hidden to make old JAWS versions work with collapsed comboboxes (see + // discussion in bug 379678). + nsIFrame* frame = aAccessible->GetFrame(); + if (frame) { + nsIWidget* widget = frame->GetNearestWidget(); + if (widget && widget->IsVisible()) { + nsIPresShell* shell = document->PresShell(); + nsViewManager* vm = shell->GetViewManager(); + if (vm) { + nsCOMPtr rootWidget; + vm->GetRootWidget(getter_AddRefs(rootWidget)); + // Make sure the accessible belongs to popup. If not then use + // document HWND (which might be different from root widget in the + // case of window emulation). + if (rootWidget != widget) + return static_cast(widget->GetNativeData(NS_NATIVE_WINDOW)); + } + } + } + + return static_cast(document->GetNativeWindow()); } IDispatch*