Bug 1562821 - Propagate nsIWebProgress events to the <xul:browser> in responsive design mode. r=Ehsan, a=RyanVM
authorBarret Rennie <barret@brennie.ca>
Tue, 23 Jul 2019 16:43:20 +0000
changeset 544805 146120adc5c87fa572b9a4474346f8690d01891a
parent 544804 23d9c50ee55a5c0b99359a5218f648c0e4ac8198
child 544806 7374e601e0b6624451c0bec4c64a036aaddbba11
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan, RyanVM
bugs1562821, 1510569
milestone69.0
Bug 1562821 - Propagate nsIWebProgress events to the <xul:browser> in responsive design mode. r=Ehsan, a=RyanVM The work from bug 1510569 that has ported the majority of the `nsIWebProgress` event handlers from `WebProgressChild`/`RemoteWebProgress` to `BrowserChild`/`BrowserParent` was not properly propogating the events in the responsive design mode case. The `BrowserParent` assumed that its frame element was an `nsIBrowser`, but in RDM it is an `<iframe mozbrowser>` which does not implement `nsIBrowser`. In the RDM case we now walk up the document in the `BrowserParent` tree to find the `<xul:browser>` and call the event handlers on that instead. Differential Revision: https://phabricator.services.mozilla.com/D38916
dom/ipc/BrowserParent.cpp
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -2571,18 +2571,33 @@ mozilla::ipc::IPCResult BrowserParent::R
 
 bool BrowserParent::GetWebProgressListener(
     nsIBrowser** aOutBrowser, nsIWebProgress** aOutManager,
     nsIWebProgressListener** aOutListener) {
   MOZ_ASSERT(aOutBrowser);
   MOZ_ASSERT(aOutManager);
   MOZ_ASSERT(aOutListener);
 
-  nsCOMPtr<nsIBrowser> browser =
-      mFrameElement ? mFrameElement->AsBrowser() : nullptr;
+  nsCOMPtr<nsIBrowser> browser;
+  RefPtr<Element> currentElement = mFrameElement;
+
+  // In Responsive Design Mode, mFrameElement will be the <iframe mozbrowser>,
+  // but we want the <xul:browser> that it is embedded in.
+  while (currentElement) {
+    browser = currentElement->AsBrowser();
+    if (browser) {
+      break;
+    }
+
+    BrowsingContext* browsingContext =
+        currentElement->OwnerDoc()->GetBrowsingContext();
+    currentElement =
+        browsingContext ? browsingContext->GetEmbedderElement() : nullptr;
+  }
+
   if (!browser) {
     return false;
   }
 
   nsCOMPtr<nsIWebProgress> manager;
   nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
   if (NS_FAILED(rv)) {
     return false;