Verified Commit 02322e29 authored by James Teh's avatar James Teh Committed by ma1
Browse files

Bug 2056767: Shut down DocAccessibleParents before we shut down platform accessibility. a=pascalc

parent 614f7848
Loading
Loading
Loading
Loading
+16 −0
Changes for accessible/base/DocManager.cpp: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@
#include "nsCoreUtils.h"
#include "xpcAccessibleDocument.h"

#if defined(ANDROID)
#  include "mozilla/Monitor.h"
#endif

using namespace mozilla;
using namespace mozilla::a11y;
using namespace mozilla::dom;
@@ -195,6 +199,18 @@ void DocManager::Shutdown() {
  }

  ClearDocCache();
  // Even though remote documents aren't strictly managed by this DocManager
  // instance, destroy them now because they might depend on platform specific
  // state which is about to be torn down by PlatformShutdown. Iterate the array
  // backwards because destroying the document removes it from this array.
  if (sRemoteDocuments) {
#if defined(ANDROID)
    MonitorAutoLock mal(nsAccessibilityService::GetAndroidMonitor());
#endif
    for (size_t i = sRemoteDocuments->Length(); i-- > 0;) {
      (*sRemoteDocuments)[i]->Destroy();
    }
  }
}

////////////////////////////////////////////////////////////////////////////////
+6 −6
Changes for accessible/ipc/DocAccessibleParent.cpp: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -1241,14 +1241,13 @@ void DocAccessibleParent::MaybeInitWindowEmulation() {
    isActive = browserParent->GetDocShellIsActive();
  }

  // onCreate is guaranteed to be called synchronously by
  // nsWinUtils::CreateNativeWindow, so this reference isn't really necessary.
  // However, static analysis complains without it.
  RefPtr<DocAccessibleParent> thisRef = this;
  nsWinUtils::NativeWindowCreateProc onCreate([thisRef](HWND aHwnd) -> void {
    ::SetPropW(aHwnd, kPropNameDocAccParent,
               reinterpret_cast<HANDLE>(thisRef.get()));
  nsWinUtils::NativeWindowCreateProc onCreate(
      [thisRef](HWND aHwnd) mutable -> void {
        thisRef->SetEmulatedWindowHandle(aHwnd);
        HANDLE val;
        thisRef.forget(&val);  // Release in SetEmulatedWindowHandle.
        ::SetPropW(aHwnd, kPropNameDocAccParent, val);
      });

  HWND parentWnd = reinterpret_cast<HWND>(rootDocument->GetNativeWindow());
@@ -1261,6 +1260,7 @@ void DocAccessibleParent::MaybeInitWindowEmulation() {
void DocAccessibleParent::SetEmulatedWindowHandle(HWND aWindowHandle) {
  if (!aWindowHandle && mEmulatedWindowHandle && IsTopLevel()) {
    ::DestroyWindow(mEmulatedWindowHandle);
    Release();  // AddRef in MaybeInitWindowEmulation.
  }
  mEmulatedWindowHandle = aWindowHandle;
}