Bug 1543313 part 3: For out-of-process iframes on Windows, send the embedder accessible COM proxy to be used as the parent of the embedded document. r=eeejay
☠☠ backed out by 523d45768463 ☠ ☠
authorJames Teh <jteh@mozilla.com>
Fri, 24 May 2019 06:14:24 +0000
changeset 476307 15f3e6bb3ba913aa9d67687edd59899873b671ae
parent 476306 30b106088985198cfdc755e09173bd663ca657c7
child 476308 1a8bea02205d138e7881bcf63aff985ae1f2d64d
push id36092
push userarchaeopteryx@coole-files.de
push dateFri, 31 May 2019 17:03:46 +0000
treeherdermozilla-central@8384972e1f6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay
bugs1543313
milestone69.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 1543313 part 3: For out-of-process iframes on Windows, send the embedder accessible COM proxy to be used as the parent of the embedded document. r=eeejay Aside from the parent being needed by the client, this is also important because events from the embedded document are deferred until the parent COM proxy is received. Differential Revision: https://phabricator.services.mozilla.com/D32284
accessible/generic/OuterDocAccessible.cpp
accessible/ipc/DocAccessibleParent.cpp
accessible/ipc/DocAccessibleParent.h
dom/ipc/BrowserParent.cpp
--- a/accessible/generic/OuterDocAccessible.cpp
+++ b/accessible/generic/OuterDocAccessible.cpp
@@ -31,17 +31,17 @@ using namespace mozilla::a11y;
 
 OuterDocAccessible::OuterDocAccessible(nsIContent* aContent,
                                        DocAccessible* aDoc)
     : AccessibleWrap(aContent, aDoc) {
   mType = eOuterDocType;
 
 #ifdef XP_WIN
   if (DocAccessibleParent* remoteDoc = RemoteChildDoc()) {
-    remoteDoc->SendParentCOMProxy();
+    remoteDoc->SendParentCOMProxy(this);
   }
 #endif
 
   if (IPCAccessibilityActive()) {
     auto bridge = dom::BrowserBridgeChild::GetFrom(aContent);
     if (bridge) {
       // This is an iframe which will be rendered in another process. Tell the
       // parent process the iframe accessible so it can link the
--- a/accessible/ipc/DocAccessibleParent.cpp
+++ b/accessible/ipc/DocAccessibleParent.cpp
@@ -552,16 +552,20 @@ ipc::IPCResult DocAccessibleParent::AddC
     IDispatchHolder::COMPtrType docPtr(
         mscom::ToProxyUniquePtr(std::move(docWrapped)));
     IDispatchHolder docHolder(std::move(docPtr));
     if (bridge->SendSetEmbeddedDocAccessibleCOMProxy(docHolder)) {
 #  if defined(MOZ_SANDBOX)
       mDocProxyStream = docHolder.GetPreservedStream();
 #  endif  // defined(MOZ_SANDBOX)
     }
+    // Send a COM proxy for the embedder OuterDocAccessible to the embedded
+    // document process. This will be returned as the parent of the
+    // embedded document.
+    aChildDoc->SendParentCOMProxy(WrapperFor(outerDoc));
   }
 #endif  // defined(XP_WIN)
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult DocAccessibleParent::RecvShutdown() {
   Destroy();
@@ -729,34 +733,26 @@ void DocAccessibleParent::MaybeInitWindo
 
   HWND parentWnd = reinterpret_cast<HWND>(rootDocument->GetNativeWindow());
   DebugOnly<HWND> hWnd = nsWinUtils::CreateNativeWindow(
       kClassNameTabContent, parentWnd, rect.X(), rect.Y(), rect.Width(),
       rect.Height(), isActive, &onCreate);
   MOZ_ASSERT(hWnd);
 }
 
-/**
- * @param aCOMProxy COM Proxy to the document in the content process.
- */
-void DocAccessibleParent::SendParentCOMProxy() {
+void DocAccessibleParent::SendParentCOMProxy(Accessible* aOuterDoc) {
   // Make sure that we're not racing with a tab shutdown
   auto tab = static_cast<dom::BrowserParent*>(Manager());
   MOZ_ASSERT(tab);
   if (tab->IsDestroyed()) {
     return;
   }
 
-  Accessible* outerDoc = OuterDocOfRemoteBrowser();
-  if (!outerDoc) {
-    return;
-  }
-
   RefPtr<IAccessible> nativeAcc;
-  outerDoc->GetNativeInterface(getter_AddRefs(nativeAcc));
+  aOuterDoc->GetNativeInterface(getter_AddRefs(nativeAcc));
   MOZ_ASSERT(nativeAcc);
 
   RefPtr<IDispatch> wrapped(
       mscom::PassthruProxy::Wrap<IDispatch>(WrapNotNull(nativeAcc)));
 
   IDispatchHolder::COMPtrType ptr(mscom::ToProxyUniquePtr(std::move(wrapped)));
   IDispatchHolder holder(std::move(ptr));
   if (!PDocAccessibleParent::SendParentCOMProxy(holder)) {
--- a/accessible/ipc/DocAccessibleParent.h
+++ b/accessible/ipc/DocAccessibleParent.h
@@ -211,17 +211,23 @@ class DocAccessibleParent : public Proxy
     return const_cast<DocAccessibleParent*>(this)->ChildDocAt(aIdx);
   }
   DocAccessibleParent* ChildDocAt(size_t aIdx) {
     return LiveDocs().Get(mChildDocs[aIdx]);
   }
 
 #if defined(XP_WIN)
   void MaybeInitWindowEmulation();
-  void SendParentCOMProxy();
+
+  /**
+   * @param aOuterDoc The OuterDocAccessible to be returned as the parent of
+   *        this document. Only GetNativeInterface() is called on this, so it
+   *        may be a ProxyAccessibleWrap or similar.
+   */
+  void SendParentCOMProxy(Accessible* aOuterDoc);
 
   virtual mozilla::ipc::IPCResult RecvGetWindowedPluginIAccessible(
       const WindowsHandle& aHwnd, IAccessibleHolder* aPluginCOMProxy) override;
 
   /**
    * Set emulated native window handle for a document.
    * @param aWindowHandle emulated native window handle
    */
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -1163,17 +1163,19 @@ mozilla::ipc::IPCResult BrowserParent::R
     a11y::DocManager::RemoteDocAdded(doc);
 #  ifdef XP_WIN
     a11y::WrapperFor(doc)->SetID(aMsaaID);
     MOZ_ASSERT(!aDocCOMProxy.IsNull());
 
     RefPtr<IAccessible> proxy(aDocCOMProxy.Get());
     doc->SetCOMInterface(proxy);
     doc->MaybeInitWindowEmulation();
-    doc->SendParentCOMProxy();
+    if (a11y::Accessible* outerDoc = doc->OuterDocOfRemoteBrowser()) {
+      doc->SendParentCOMProxy(outerDoc);
+    }
 #  endif
   }
 #endif
   return IPC_OK();
 }
 
 PFilePickerParent* BrowserParent::AllocPFilePickerParent(const nsString& aTitle,
                                                          const int16_t& aMode) {