2019-01-23 19:38:09 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2019-05-24 22:23:18 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
# include "mozilla/a11y/DocAccessibleParent.h"
|
|
|
|
#endif
|
2019-03-05 05:15:58 +03:00
|
|
|
#include "mozilla/dom/BrowserBridgeParent.h"
|
2019-05-07 19:07:47 +03:00
|
|
|
#include "mozilla/dom/BrowserParent.h"
|
2019-01-23 19:38:09 +03:00
|
|
|
#include "mozilla/dom/ContentParent.h"
|
|
|
|
#include "mozilla/dom/ContentProcessManager.h"
|
2019-03-14 21:50:45 +03:00
|
|
|
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
|
|
|
#include "mozilla/dom/BrowsingContextGroup.h"
|
2019-08-08 19:07:05 +03:00
|
|
|
#include "mozilla/dom/WindowGlobalParent.h"
|
2019-05-06 11:12:21 +03:00
|
|
|
#include "mozilla/layers/InputAPZContext.h"
|
2019-01-23 19:38:09 +03:00
|
|
|
|
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace mozilla::layout;
|
2019-03-05 05:15:58 +03:00
|
|
|
using namespace mozilla::hal;
|
2019-01-23 19:38:09 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2019-10-15 19:19:14 +03:00
|
|
|
BrowserBridgeParent::BrowserBridgeParent() {}
|
2019-01-23 19:38:09 +03:00
|
|
|
|
2019-04-17 03:52:53 +03:00
|
|
|
BrowserBridgeParent::~BrowserBridgeParent() { Destroy(); }
|
2019-01-23 19:38:09 +03:00
|
|
|
|
2019-10-15 19:19:16 +03:00
|
|
|
nsresult BrowserBridgeParent::InitWithProcess(
|
|
|
|
ContentParent* aContentParent, const nsString& aPresentationURL,
|
|
|
|
const WindowGlobalInit& aWindowInit, uint32_t aChromeFlags, TabId aTabId) {
|
2020-02-21 02:30:50 +03:00
|
|
|
if (aWindowInit.browsingContext().IsNullOrDiscarded()) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2019-08-08 19:07:05 +03:00
|
|
|
RefPtr<CanonicalBrowsingContext> browsingContext =
|
2020-02-21 02:30:50 +03:00
|
|
|
aWindowInit.browsingContext().get_canonical();
|
2019-08-08 19:07:05 +03:00
|
|
|
|
2019-07-19 22:00:31 +03:00
|
|
|
// We can inherit most TabContext fields for the new BrowserParent actor from
|
2019-10-24 11:51:06 +03:00
|
|
|
// our Manager BrowserParent. We also need to sync the first party domain if
|
|
|
|
// the content principal exists.
|
2019-01-23 19:40:08 +03:00
|
|
|
MutableTabContext tabContext;
|
2019-10-24 11:51:06 +03:00
|
|
|
OriginAttributes attrs;
|
|
|
|
attrs = Manager()->OriginAttributesRef();
|
|
|
|
RefPtr<nsIPrincipal> principal = Manager()->GetContentPrincipal();
|
|
|
|
if (principal) {
|
|
|
|
attrs.SetFirstPartyDomain(
|
|
|
|
true, principal->OriginAttributesRef().mFirstPartyDomain);
|
|
|
|
}
|
|
|
|
|
2019-07-19 22:00:31 +03:00
|
|
|
tabContext.SetTabContext(false, Manager()->ChromeOuterWindowID(),
|
2019-10-24 11:51:06 +03:00
|
|
|
Manager()->ShowFocusRings(), attrs, aPresentationURL,
|
2019-07-19 22:00:31 +03:00
|
|
|
Manager()->GetMaxTouchPoints());
|
2019-01-23 19:40:08 +03:00
|
|
|
|
2019-03-14 21:50:45 +03:00
|
|
|
// Ensure that our content process is subscribed to our newly created
|
|
|
|
// BrowsingContextGroup.
|
2019-10-15 19:19:16 +03:00
|
|
|
browsingContext->Group()->EnsureSubscribed(aContentParent);
|
|
|
|
browsingContext->SetOwnerProcessId(aContentParent->ChildID());
|
2019-03-14 21:50:45 +03:00
|
|
|
|
2019-04-10 00:38:15 +03:00
|
|
|
// Construct the BrowserParent object for our subframe.
|
2019-08-08 19:07:05 +03:00
|
|
|
auto browserParent = MakeRefPtr<BrowserParent>(
|
2019-10-15 19:19:16 +03:00
|
|
|
aContentParent, aTabId, tabContext, browsingContext, aChromeFlags);
|
2019-05-15 18:34:03 +03:00
|
|
|
browserParent->SetBrowserBridgeParent(this);
|
2019-01-23 19:40:08 +03:00
|
|
|
|
2019-08-08 19:46:24 +03:00
|
|
|
// Open a remote endpoint for our PBrowser actor.
|
2019-04-17 03:51:38 +03:00
|
|
|
ManagedEndpoint<PBrowserChild> childEp =
|
2019-10-15 19:19:16 +03:00
|
|
|
aContentParent->OpenPBrowserEndpoint(browserParent);
|
2019-04-17 03:51:38 +03:00
|
|
|
if (NS_WARN_IF(!childEp.IsValid())) {
|
|
|
|
MOZ_ASSERT(false, "Browser Open Endpoint Failed");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2019-08-08 19:07:26 +03:00
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
|
|
|
cpm->RegisterRemoteFrame(browserParent);
|
|
|
|
|
2019-08-08 19:07:05 +03:00
|
|
|
auto windowParent =
|
|
|
|
MakeRefPtr<WindowGlobalParent>(aWindowInit, /* inprocess */ false);
|
|
|
|
|
|
|
|
ManagedEndpoint<PWindowGlobalChild> windowChildEp =
|
2019-08-08 19:46:20 +03:00
|
|
|
browserParent->OpenPWindowGlobalEndpoint(windowParent);
|
2019-08-08 19:07:05 +03:00
|
|
|
if (NS_WARN_IF(!windowChildEp.IsValid())) {
|
|
|
|
MOZ_ASSERT(false, "WindowGlobal Open Endpoint Failed");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2019-04-17 03:51:38 +03:00
|
|
|
// Tell the content process to set up its PBrowserChild.
|
2019-10-15 19:19:16 +03:00
|
|
|
bool ok = aContentParent->SendConstructBrowser(
|
2019-08-08 19:07:05 +03:00
|
|
|
std::move(childEp), std::move(windowChildEp), aTabId, TabId(0),
|
|
|
|
tabContext.AsIPCTabContext(), aWindowInit, aChromeFlags,
|
2019-10-15 19:19:16 +03:00
|
|
|
aContentParent->ChildID(), aContentParent->IsForBrowser(),
|
2019-08-08 19:07:05 +03:00
|
|
|
/* aIsTopLevel */ false);
|
2019-04-17 03:51:38 +03:00
|
|
|
if (NS_WARN_IF(!ok)) {
|
2019-01-23 19:40:08 +03:00
|
|
|
MOZ_ASSERT(false, "Browser Constructor Failed");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2019-04-10 00:38:15 +03:00
|
|
|
// Set our BrowserParent object to the newly created browser.
|
2020-02-13 17:38:48 +03:00
|
|
|
mBrowserParent = std::move(browserParent);
|
2019-04-10 00:38:15 +03:00
|
|
|
mBrowserParent->SetOwnerElement(Manager()->GetOwnerElement());
|
|
|
|
mBrowserParent->InitRendering();
|
2019-01-23 19:40:08 +03:00
|
|
|
|
2019-08-08 19:07:05 +03:00
|
|
|
windowParent->Init(aWindowInit);
|
|
|
|
|
2019-01-23 20:04:26 +03:00
|
|
|
// Send the newly created layers ID back into content.
|
2019-06-01 00:00:57 +03:00
|
|
|
Unused << SendSetLayersId(mBrowserParent->GetLayersId());
|
2019-01-23 19:38:09 +03:00
|
|
|
return NS_OK;
|
2019-10-15 19:19:16 +03:00
|
|
|
}
|
|
|
|
|
2019-05-07 19:07:47 +03:00
|
|
|
CanonicalBrowsingContext* BrowserBridgeParent::GetBrowsingContext() {
|
|
|
|
return mBrowserParent->GetBrowsingContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
BrowserParent* BrowserBridgeParent::Manager() {
|
2019-10-15 19:19:14 +03:00
|
|
|
MOZ_ASSERT(CanSend());
|
2019-05-07 19:07:47 +03:00
|
|
|
return static_cast<BrowserParent*>(PBrowserBridgeParent::Manager());
|
|
|
|
}
|
|
|
|
|
2019-04-17 03:52:53 +03:00
|
|
|
void BrowserBridgeParent::Destroy() {
|
2019-04-10 00:38:15 +03:00
|
|
|
if (mBrowserParent) {
|
|
|
|
mBrowserParent->Destroy();
|
2019-07-07 19:02:11 +03:00
|
|
|
mBrowserParent->SetBrowserBridgeParent(nullptr);
|
2019-04-10 00:38:15 +03:00
|
|
|
mBrowserParent = nullptr;
|
2019-04-17 03:52:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-05 23:58:21 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvShow(const OwnerShowInfo& aOwnerInfo) {
|
2019-11-25 00:23:04 +03:00
|
|
|
mBrowserParent->AttachLayerManager();
|
2020-01-05 23:58:21 +03:00
|
|
|
Unused << mBrowserParent->SendShow(mBrowserParent->GetShowInfo(), aOwnerInfo);
|
2019-01-23 20:04:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-01-13 14:30:44 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvScrollbarPreferenceChanged(
|
|
|
|
ScrollbarPreference aPref) {
|
|
|
|
Unused << mBrowserParent->SendScrollbarPreferenceChanged(aPref);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvLoadURL(const nsCString& aUrl) {
|
2019-04-10 00:38:15 +03:00
|
|
|
Unused << mBrowserParent->SendLoadURL(aUrl, mBrowserParent->GetShowInfo());
|
2019-01-23 20:04:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-17 03:53:28 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvResumeLoad(uint64_t aPendingSwitchID) {
|
2019-04-10 00:38:15 +03:00
|
|
|
mBrowserParent->ResumeLoad(aPendingSwitchID);
|
2019-04-17 03:53:28 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvUpdateDimensions(
|
2020-02-14 01:30:56 +03:00
|
|
|
const nsIntRect& aRect, const ScreenIntSize& aSize) {
|
|
|
|
mBrowserParent->UpdateDimensions(aRect, aSize);
|
2019-01-23 20:04:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-15 23:26:25 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvUpdateEffects(const EffectsInfo& aEffects) {
|
|
|
|
Unused << mBrowserParent->SendUpdateEffects(aEffects);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvRenderLayers(
|
2019-09-27 01:11:17 +03:00
|
|
|
const bool& aEnabled, const layers::LayersObserverEpoch& aEpoch) {
|
|
|
|
Unused << mBrowserParent->SendRenderLayers(aEnabled, aEpoch);
|
2019-01-23 20:04:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvNavigateByKey(
|
2019-03-05 22:33:09 +03:00
|
|
|
const bool& aForward, const bool& aForDocumentNavigation) {
|
2019-04-10 00:38:15 +03:00
|
|
|
Unused << mBrowserParent->SendNavigateByKey(aForward, aForDocumentNavigation);
|
2019-03-05 22:33:09 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-06 11:12:21 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvDispatchSynthesizedMouseEvent(
|
|
|
|
const WidgetMouseEvent& aEvent) {
|
|
|
|
if (aEvent.mMessage != eMouseMove ||
|
|
|
|
aEvent.mReason != WidgetMouseEvent::eSynthesized) {
|
|
|
|
return IPC_FAIL(this, "Unexpected event type");
|
|
|
|
}
|
|
|
|
|
|
|
|
WidgetMouseEvent event = aEvent;
|
|
|
|
// Convert mRefPoint from the dispatching child process coordinate space
|
|
|
|
// to the parent coordinate space. The SendRealMouseEvent call will convert
|
|
|
|
// it into the dispatchee child process coordinate space
|
|
|
|
event.mRefPoint = Manager()->TransformChildToParent(event.mRefPoint);
|
|
|
|
// We need to set up an InputAPZContext on the stack because
|
|
|
|
// BrowserParent::SendRealMouseEvent requires one. But the only thing in
|
|
|
|
// that context that is actually used in this scenario is the layers id,
|
|
|
|
// and we already have that on the mouse event.
|
|
|
|
layers::InputAPZContext context(
|
|
|
|
layers::ScrollableLayerGuid(event.mLayersId, 0,
|
|
|
|
layers::ScrollableLayerGuid::NULL_SCROLL_ID),
|
|
|
|
0, nsEventStatus_eIgnore);
|
|
|
|
mBrowserParent->SendRealMouseEvent(event);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-02-06 22:07:56 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvWillChangeProcess() {
|
|
|
|
Unused << mBrowserParent->SendWillChangeProcess();
|
2019-04-04 01:40:28 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvActivate() {
|
2019-04-10 00:38:15 +03:00
|
|
|
mBrowserParent->Activate();
|
2019-03-05 22:33:52 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-06-14 10:02:18 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvDeactivate(const bool& aWindowLowering) {
|
|
|
|
mBrowserParent->Deactivate(aWindowLowering);
|
2019-03-14 19:00:32 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-13 04:49:07 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvSetIsUnderHiddenEmbedderElement(
|
|
|
|
const bool& aIsUnderHiddenEmbedderElement) {
|
|
|
|
Unused << mBrowserParent->SendSetIsUnderHiddenEmbedderElement(
|
|
|
|
aIsUnderHiddenEmbedderElement);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-12-02 09:25:40 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
2019-05-24 22:23:18 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvSetEmbedderAccessible(
|
|
|
|
PDocAccessibleParent* aDoc, uint64_t aID) {
|
|
|
|
mEmbedderAccessibleDoc = static_cast<a11y::DocAccessibleParent*>(aDoc);
|
|
|
|
mEmbedderAccessibleID = aID;
|
Bug 1581040: handle late creation/re-creation of OuterDocAccessible for OOP iframe. r=yzen,nika
1. When creating a DocAccessibleParent for an embedded document in an OOP iframe, it's possible that the embedder accessible hasn't been set yet.
This can occur if the iframe is initially hidden.
Previously, we incorrectly set the document up as a top level document (e.g. tab document) in this case.
Now, we set up the document as top level in its content process, set up the proxy, etc.
The document will be added to its child document later when the embedder is set.
2. When setting the embedder accessible for an OOP iframe, check if the embedded DocAccessibleParent already exists.
This can happen if an iframe is hidden and then shown or an iframe is reflowed by layout.
If it already exists, add the embedded (child) document to its embedder.
3. Mac's implementation of ProxyCreated requires that AddChildDoc be called *before* ProxyCreated so it can invalidate the native children of the parent.
Because it's possible for an OOP iframe document to be added to its embedder after the document is created, we can't satisfy this requirement for OOP iframe documents.
Therefore, we now allow a null parent in Mac's ProxyCreated and use the reorder event fired later to invalidate the native children.
Differential Revision: https://phabricator.services.mozilla.com/D51357
--HG--
extra : moz-landing-system : lando
2019-11-07 03:38:59 +03:00
|
|
|
if (auto embeddedBrowser = GetBrowserParent()) {
|
|
|
|
a11y::DocAccessibleParent* childDocAcc =
|
|
|
|
embeddedBrowser->GetTopLevelDocAccessible();
|
|
|
|
if (childDocAcc && !childDocAcc->IsShutdown()) {
|
|
|
|
// The embedded DocAccessibleParent has already been created. This can
|
|
|
|
// happen if, for example, an iframe is hidden and then shown or
|
|
|
|
// an iframe is reflowed by layout.
|
|
|
|
mEmbedderAccessibleDoc->AddChildDoc(childDocAcc, aID,
|
|
|
|
/* aCreating */ false);
|
|
|
|
}
|
|
|
|
}
|
2019-05-24 22:23:18 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
2019-12-02 09:25:40 +03:00
|
|
|
#endif
|
2019-05-24 22:23:18 +03:00
|
|
|
|
2019-10-15 19:19:14 +03:00
|
|
|
void BrowserBridgeParent::ActorDestroy(ActorDestroyReason aWhy) { Destroy(); }
|
2019-01-23 19:38:09 +03:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|