Bug 1562821 - Propagate nsIWebProgress events to the <xul:browser> in responsive design mode r=Ehsan

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Barret Rennie 2019-07-23 16:43:20 +00:00
Родитель efab80cbeb
Коммит 2ce8272804
1 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -2582,8 +2582,23 @@ bool BrowserParent::GetWebProgressListener(
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;
}