From 6775220dafa5b704f40d55b84bbed5fea570e152 Mon Sep 17 00:00:00 2001 From: Aaron Klotz Date: Thu, 15 Sep 2016 13:37:04 -0600 Subject: [PATCH] Bug 1297549: Part 2 - Propagate changes in tab native window down to content for a11y; r=jimm MozReview-Commit-ID: LA5yLIGufEb --- dom/ipc/PBrowser.ipdl | 8 ++++++++ dom/ipc/TabChild.cpp | 14 ++++++++++++++ dom/ipc/TabChild.h | 11 +++++++++++ dom/ipc/TabParent.cpp | 11 +++++++++++ 4 files changed, 44 insertions(+) diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 3b4b78428c64..f0ad00793e3b 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -824,6 +824,14 @@ child: */ async Print(uint64_t aOuterWindowID, PrintData aPrintData); + /** + * Update the child with the tab's current top-level native window handle. + * This is used by a11y objects who must expose their native window. + * + * @param aNewHandle The native window handle of the tab's top-level window. + */ + async UpdateNativeWindowHandle(uintptr_t aNewHandle); + /* * FIXME: write protocol! diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 6cd90d50553d..950e30c006e5 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -546,6 +546,9 @@ TabChild::TabChild(nsIContentChild* aManager, , mDidSetRealShowInfo(false) , mDidLoadURLInit(false) , mAPZChild(nullptr) +#if defined(XP_WIN) && defined(ACCESSIBILITY) + , mNativeWindowHandle(0) +#endif { // In the general case having the TabParent tell us if APZ is enabled or not // doesn't really work because the TabParent itself may not have a reference @@ -2531,6 +2534,17 @@ TabChild::RecvPrint(const uint64_t& aOuterWindowID, const PrintData& aPrintData) return true; } +bool +TabChild::RecvUpdateNativeWindowHandle(const uintptr_t& aNewHandle) +{ +#if defined(XP_WIN) && defined(ACCESSIBILITY) + mNativeWindowHandle = aNewHandle; + return true; +#else + return false; +#endif +} + bool TabChild::RecvDestroy() { diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 2343da47bb8b..b52b8edb69ba 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -590,6 +590,8 @@ public: virtual bool RecvPrint(const uint64_t& aOuterWindowID, const PrintData& aPrintData) override; + virtual bool RecvUpdateNativeWindowHandle(const uintptr_t& aNewHandle) override; + /** * Native widget remoting protocol for use with windowed plugins with e10s. */ @@ -648,6 +650,10 @@ public: mAPZChild = aAPZChild; } +#if defined(XP_WIN) && defined(ACCESSIBILITY) + uintptr_t GetNativeWindowHandle() const { return mNativeWindowHandle; } +#endif + protected: virtual ~TabChild(); @@ -782,6 +788,11 @@ private: // dangling pointer. layers::APZChild* mAPZChild; +#if defined(XP_WIN) && defined(ACCESSIBILITY) + // The handle associated with the native window that contains this tab + uintptr_t mNativeWindowHandle; +#endif // defined(XP_WIN) + DISALLOW_EVIL_CONSTRUCTORS(TabChild); }; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 811142f84f05..f0cfd33f6ca4 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -398,6 +398,17 @@ TabParent::SetOwnerElement(Element* aElement) Unused << SendSetUseGlobalHistory(useGlobalHistory); } +#if defined(XP_WIN) && defined(ACCESSIBILITY) + if (!mIsDestroyed) { + uintptr_t newWindowHandle = 0; + if (nsCOMPtr widget = GetWidget()) { + newWindowHandle = + reinterpret_cast(widget->GetNativeData(NS_NATIVE_WINDOW)); + } + Unused << SendUpdateNativeWindowHandle(newWindowHandle); + } +#endif + AddWindowListeners(); TryCacheDPIAndScale(); }