Bug 1620657 - Add `CanonicalBrowsingContext::GetParentProcessWidgetContaining()` r=nika,tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D67683

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Willcox 2020-03-25 23:47:40 +00:00
Родитель c248943491
Коммит 1f15cc4c1e
2 изменённых файлов: 26 добавлений и 0 удалений

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

@ -16,6 +16,8 @@
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/NullPrincipal.h"
#include "nsGlobalWindowOuter.h"
using namespace mozilla::ipc;
extern mozilla::LazyLogModule gAutoplayPermissionLog;
@ -122,6 +124,28 @@ WindowGlobalParent* CanonicalBrowsingContext::GetCurrentWindowGlobal() const {
return static_cast<WindowGlobalParent*>(GetCurrentWindowContext());
}
already_AddRefed<nsIWidget>
CanonicalBrowsingContext::GetParentProcessWidgetContaining() {
// If our document is loaded in-process, such as chrome documents, get the
// widget directly from our outer window. Otherwise, try to get the widget
// from the toplevel content's browser's element.
nsCOMPtr<nsIWidget> widget;
if (nsGlobalWindowOuter* window = nsGlobalWindowOuter::Cast(GetDOMWindow())) {
widget = window->GetNearestWidget();
} else if (Element* topEmbedder = Top()->GetEmbedderElement()) {
widget = nsContentUtils::WidgetForContent(topEmbedder);
if (!widget) {
widget = nsContentUtils::WidgetForDocument(topEmbedder->OwnerDoc());
}
}
if (widget) {
widget = widget->GetTopLevelWidget();
}
return widget.forget();
}
already_AddRefed<WindowGlobalParent>
CanonicalBrowsingContext::GetEmbedderWindowGlobal() const {
uint64_t windowId = GetEmbedderInnerWindowId();

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

@ -61,6 +61,8 @@ class CanonicalBrowsingContext final : public BrowsingContext {
// The current active WindowGlobal.
WindowGlobalParent* GetCurrentWindowGlobal() const;
already_AddRefed<nsIWidget> GetParentProcessWidgetContaining();
already_AddRefed<WindowGlobalParent> GetEmbedderWindowGlobal() const;
nsISHistory* GetSessionHistory();