mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1516240 - Part 3: Directly pass BrowsingContext over IPC when possible, r=farre
This patch changes the logic such that we use the new direct BrowsingContext ParamTraits implementation when possible, and avoids doing manual lookups. Depends on D19178 Differential Revision: https://phabricator.services.mozilla.com/D19179 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
34cef5cb0d
commit
330d9fd3a2
@ -64,8 +64,7 @@ static void Sync(BrowsingContext* aBrowsingContext) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(cc);
|
||||
RefPtr<BrowsingContext> parent = aBrowsingContext->GetParent();
|
||||
BrowsingContext* opener = aBrowsingContext->GetOpener();
|
||||
cc->SendAttachBrowsingContext(BrowsingContextId(parent ? parent->Id() : 0),
|
||||
BrowsingContextId(opener ? opener->Id() : 0),
|
||||
cc->SendAttachBrowsingContext(parent, opener,
|
||||
BrowsingContextId(aBrowsingContext->Id()),
|
||||
aBrowsingContext->Name());
|
||||
}
|
||||
@ -103,6 +102,10 @@ BrowsingContext* BrowsingContext::TopLevelBrowsingContext() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CanonicalBrowsingContext* BrowsingContext::Canonical() {
|
||||
return CanonicalBrowsingContext::Cast(this);
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<BrowsingContext> BrowsingContext::Create(
|
||||
BrowsingContext* aParent, BrowsingContext* aOpener, const nsAString& aName,
|
||||
Type aType) {
|
||||
@ -238,8 +241,7 @@ void BrowsingContext::Detach() {
|
||||
|
||||
auto cc = ContentChild::GetSingleton();
|
||||
MOZ_DIAGNOSTIC_ASSERT(cc);
|
||||
cc->SendDetachBrowsingContext(BrowsingContextId(Id()),
|
||||
false /* aMoveToBFCache */);
|
||||
cc->SendDetachBrowsingContext(this, false /* aMoveToBFCache */);
|
||||
}
|
||||
|
||||
void BrowsingContext::CacheChildren() {
|
||||
@ -264,8 +266,7 @@ void BrowsingContext::CacheChildren() {
|
||||
|
||||
auto cc = ContentChild::GetSingleton();
|
||||
MOZ_DIAGNOSTIC_ASSERT(cc);
|
||||
cc->SendDetachBrowsingContext(BrowsingContextId(Id()),
|
||||
true /* aMoveToBFCache */);
|
||||
cc->SendDetachBrowsingContext(this, true /* aMoveToBFCache */);
|
||||
}
|
||||
|
||||
bool BrowsingContext::IsCached() { return sCachedBrowsingContexts->has(Id()); }
|
||||
@ -288,8 +289,7 @@ void BrowsingContext::SetOpener(BrowsingContext* aOpener) {
|
||||
|
||||
auto cc = ContentChild::GetSingleton();
|
||||
MOZ_DIAGNOSTIC_ASSERT(cc);
|
||||
cc->SendSetOpenerBrowsingContext(
|
||||
BrowsingContextId(Id()), BrowsingContextId(aOpener ? aOpener->Id() : 0));
|
||||
cc->SendSetOpenerBrowsingContext(this, aOpener);
|
||||
}
|
||||
|
||||
BrowsingContext::~BrowsingContext() {
|
||||
@ -326,7 +326,7 @@ void BrowsingContext::NotifyUserGestureActivation() {
|
||||
}
|
||||
auto cc = ContentChild::GetSingleton();
|
||||
MOZ_ASSERT(cc);
|
||||
cc->SendSetUserGestureActivation(BrowsingContextId(topLevelBC->Id()), true);
|
||||
cc->SendSetUserGestureActivation(topLevelBC, true);
|
||||
}
|
||||
|
||||
void BrowsingContext::NotifyResetUserGestureActivation() {
|
||||
@ -343,7 +343,7 @@ void BrowsingContext::NotifyResetUserGestureActivation() {
|
||||
}
|
||||
auto cc = ContentChild::GetSingleton();
|
||||
MOZ_ASSERT(cc);
|
||||
cc->SendSetUserGestureActivation(BrowsingContextId(topLevelBC->Id()), false);
|
||||
cc->SendSetUserGestureActivation(topLevelBC, false);
|
||||
}
|
||||
|
||||
void BrowsingContext::SetUserGestureActivation() {
|
||||
@ -397,18 +397,17 @@ void BrowsingContext::Close(CallerType aCallerType, ErrorResult& aError) {
|
||||
// document for this browsing context is loaded).
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1516343.
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
cc->SendWindowClose(BrowsingContextId(mBrowsingContextId),
|
||||
aCallerType == CallerType::System);
|
||||
cc->SendWindowClose(this, aCallerType == CallerType::System);
|
||||
}
|
||||
|
||||
void BrowsingContext::Focus(ErrorResult& aError) {
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
cc->SendWindowFocus(BrowsingContextId(mBrowsingContextId));
|
||||
cc->SendWindowFocus(this);
|
||||
}
|
||||
|
||||
void BrowsingContext::Blur(ErrorResult& aError) {
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
cc->SendWindowBlur(BrowsingContextId(mBrowsingContextId));
|
||||
cc->SendWindowBlur(this);
|
||||
}
|
||||
|
||||
Nullable<WindowProxyHolder> BrowsingContext::GetTop(ErrorResult& aError) {
|
||||
@ -460,7 +459,7 @@ void BrowsingContext::PostMessageMoz(JSContext* aCx,
|
||||
getter_AddRefs(data.callerDocumentURI()), aError)) {
|
||||
return;
|
||||
}
|
||||
data.source() = BrowsingContextId(sourceBc->Id());
|
||||
data.source() = sourceBc;
|
||||
data.isFromPrivateWindow() =
|
||||
callerInnerWindow &&
|
||||
nsScriptErrorBase::ComputeIsFromPrivateWindow(callerInnerWindow);
|
||||
@ -485,8 +484,7 @@ void BrowsingContext::PostMessageMoz(JSContext* aCx,
|
||||
return;
|
||||
}
|
||||
|
||||
cc->SendWindowPostMessage(BrowsingContextId(mBrowsingContextId), messageData,
|
||||
data);
|
||||
cc->SendWindowPostMessage(this, messageData, data);
|
||||
}
|
||||
|
||||
void BrowsingContext::PostMessageMoz(JSContext* aCx,
|
||||
|
@ -42,6 +42,7 @@ struct IPDLParamTraits;
|
||||
namespace dom {
|
||||
|
||||
class BrowsingContextGroup;
|
||||
class CanonicalBrowsingContext;
|
||||
class ContentParent;
|
||||
template <typename>
|
||||
struct Nullable;
|
||||
@ -93,6 +94,9 @@ class BrowsingContext : public nsWrapperCache,
|
||||
BrowsingContext* aParent, BrowsingContext* aOpener,
|
||||
const nsAString& aName, uint64_t aId, ContentParent* aOriginProcess);
|
||||
|
||||
// Cast this object to a canonical browsing context, and return it.
|
||||
CanonicalBrowsingContext* Canonical();
|
||||
|
||||
// Get the DocShell for this BrowsingContext if it is in-process, or
|
||||
// null if it's not.
|
||||
nsIDocShell* GetDocShell() { return mDocShell; }
|
||||
|
@ -3590,67 +3590,54 @@ PContentChild::Result ContentChild::OnMessageReceived(const Message& aMsg,
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvWindowClose(
|
||||
const BrowsingContextId& aContextId, const bool& aTrustedCaller) {
|
||||
RefPtr<BrowsingContext> bc = BrowsingContext::Get(aContextId);
|
||||
if (!bc) {
|
||||
BrowsingContext* aContext, bool aTrustedCaller) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ChildIPC: Trying to send a message to dead or detached context "
|
||||
"0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
("ChildIPC: Trying to send a message to dead or detached context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = bc->GetDOMWindow();
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = aContext->GetDOMWindow();
|
||||
nsGlobalWindowOuter::Cast(window)->CloseOuter(aTrustedCaller);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvWindowFocus(
|
||||
const BrowsingContextId& aContextId) {
|
||||
RefPtr<BrowsingContext> bc = BrowsingContext::Get(aContextId);
|
||||
if (!bc) {
|
||||
mozilla::ipc::IPCResult ContentChild::RecvWindowFocus(BrowsingContext* aContext) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ChildIPC: Trying to send a message to dead or detached context "
|
||||
"0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
("ChildIPC: Trying to send a message to dead or detached context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = bc->GetDOMWindow();
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = aContext->GetDOMWindow();
|
||||
nsGlobalWindowOuter::Cast(window)->FocusOuter();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvWindowBlur(
|
||||
const BrowsingContextId& aContextId) {
|
||||
RefPtr<BrowsingContext> bc = BrowsingContext::Get(aContextId);
|
||||
if (!bc) {
|
||||
BrowsingContext* aContext) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ChildIPC: Trying to send a message to dead or detached context "
|
||||
"0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
("ChildIPC: Trying to send a message to dead or detached context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = bc->GetDOMWindow();
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = aContext->GetDOMWindow();
|
||||
nsGlobalWindowOuter::Cast(window)->BlurOuter();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvWindowPostMessage(
|
||||
const BrowsingContextId& aContextId, const ClonedMessageData& aMessage,
|
||||
BrowsingContext* aContext, const ClonedMessageData& aMessage,
|
||||
const PostMessageData& aData) {
|
||||
RefPtr<BrowsingContext> bc = BrowsingContext::Get(aContextId);
|
||||
if (!bc) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ChildIPC: Trying to send a message to dead or detached context "
|
||||
"0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
("ChildIPC: Trying to send a message to dead or detached context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
RefPtr<nsGlobalWindowOuter> window =
|
||||
nsGlobalWindowOuter::Cast(bc->GetDOMWindow());
|
||||
nsGlobalWindowOuter::Cast(aContext->GetDOMWindow());
|
||||
nsCOMPtr<nsIPrincipal> providedPrincipal;
|
||||
if (!window->GetPrincipalForPostMessage(
|
||||
aData.targetOrigin(), aData.targetOriginURI(),
|
||||
@ -3659,11 +3646,10 @@ mozilla::ipc::IPCResult ContentChild::RecvWindowPostMessage(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
RefPtr<BrowsingContext> sourceBc = BrowsingContext::Get(aData.source());
|
||||
RefPtr<BrowsingContext> sourceBc = aData.source();
|
||||
if (!sourceBc) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ChildIPC: Trying to use a dead or detached context 0x%08" PRIx64,
|
||||
(uint64_t)aData.source()));
|
||||
("ChildIPC: Trying to use a dead or detached context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -714,12 +714,12 @@ class ContentChild final : public PContentChild,
|
||||
|
||||
virtual void OnChannelReceivedMessage(const Message& aMsg) override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvWindowClose(const BrowsingContextId& aContextId,
|
||||
const bool& aTrustedCaller);
|
||||
mozilla::ipc::IPCResult RecvWindowFocus(const BrowsingContextId& aContextId);
|
||||
mozilla::ipc::IPCResult RecvWindowBlur(const BrowsingContextId& aContextId);
|
||||
mozilla::ipc::IPCResult RecvWindowClose(BrowsingContext* aContext,
|
||||
bool aTrustedCaller);
|
||||
mozilla::ipc::IPCResult RecvWindowFocus(BrowsingContext* aContext);
|
||||
mozilla::ipc::IPCResult RecvWindowBlur(BrowsingContext* aContext);
|
||||
mozilla::ipc::IPCResult RecvWindowPostMessage(
|
||||
const BrowsingContextId& aContextId, const ClonedMessageData& aMessage,
|
||||
BrowsingContext* aContext, const ClonedMessageData& aMessage,
|
||||
const PostMessageData& aData);
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
|
@ -5609,31 +5609,9 @@ mozilla::ipc::IPCResult ContentParent::RecvStoreUserInteractionAsPermission(
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvAttachBrowsingContext(
|
||||
const BrowsingContextId& aParentId, const BrowsingContextId& aOpenerId,
|
||||
const BrowsingContextId& aChildId, const nsString& aName) {
|
||||
RefPtr<CanonicalBrowsingContext> parent =
|
||||
CanonicalBrowsingContext::Get(aParentId);
|
||||
if (aParentId && !parent) {
|
||||
// Unless 'aParentId' is 0 (which it is when the child is a root
|
||||
// BrowsingContext) there should always be a corresponding
|
||||
// 'parent'. The only reason for there not beeing one is if the
|
||||
// parent has already been detached, in which case the
|
||||
// BrowsingContext that tries to attach itself to the context with
|
||||
// 'aParentId' is surely doomed and we can safely do nothing.
|
||||
|
||||
// TODO(farre): When we start syncing/moving BrowsingContexts to
|
||||
// other child processes is it possible to get into races where
|
||||
// constructive operations on already detached BrowsingContexts
|
||||
// are requested? This needs to be answered/handled, but for now
|
||||
// return early. [Bug 1471598]
|
||||
MOZ_LOG(
|
||||
BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to attach to already detached parent 0x%08" PRIx64,
|
||||
(uint64_t)aParentId));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (parent && !parent->IsOwnedByProcess(ChildID())) {
|
||||
BrowsingContext* aParent, BrowsingContext* aOpener,
|
||||
BrowsingContextId aChildId, const nsString& aName) {
|
||||
if (aParent && !aParent->Canonical()->IsOwnedByProcess(ChildID())) {
|
||||
// Where trying attach a child BrowsingContext to a parent
|
||||
// BrowsingContext in another process. This is illegal since the
|
||||
// only thing that could create that child BrowsingContext is a
|
||||
@ -5648,7 +5626,7 @@ mozilla::ipc::IPCResult ContentParent::RecvAttachBrowsingContext(
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Warning,
|
||||
("ParentIPC: Trying to attach to out of process parent context "
|
||||
"0x%08" PRIx64,
|
||||
parent->Id()));
|
||||
aParent->Id()));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@ -5663,13 +5641,12 @@ mozilla::ipc::IPCResult ContentParent::RecvAttachBrowsingContext(
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Warning,
|
||||
("ParentIPC: Trying to attach already attached 0x%08" PRIx64
|
||||
" to 0x%08" PRIx64,
|
||||
child->Id(), (uint64_t)aParentId));
|
||||
child->Id(), aParent ? aParent->Id() : 0));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (!child) {
|
||||
RefPtr<BrowsingContext> opener = BrowsingContext::Get(aOpenerId);
|
||||
child = BrowsingContext::CreateFromIPC(parent, opener, aName,
|
||||
child = BrowsingContext::CreateFromIPC(aParent, aOpener, aName,
|
||||
(uint64_t)aChildId, this);
|
||||
}
|
||||
|
||||
@ -5677,18 +5654,14 @@ mozilla::ipc::IPCResult ContentParent::RecvAttachBrowsingContext(
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvDetachBrowsingContext(
|
||||
const BrowsingContextId& aContextId, const bool& aMoveToBFCache) {
|
||||
RefPtr<CanonicalBrowsingContext> context =
|
||||
CanonicalBrowsingContext::Get(aContextId);
|
||||
|
||||
if (!context) {
|
||||
BrowsingContext* aContext, bool aMoveToBFCache) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to detach already detached 0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
("ParentIPC: Trying to detach already detached"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (!context->IsOwnedByProcess(ChildID())) {
|
||||
if (!aContext->Canonical()->IsOwnedByProcess(ChildID())) {
|
||||
// Where trying to detach a child BrowsingContext in another child
|
||||
// process. This is illegal since the owner of the BrowsingContext
|
||||
// is the proccess with the in-process docshell, which is tracked
|
||||
@ -5698,33 +5671,28 @@ mozilla::ipc::IPCResult ContentParent::RecvDetachBrowsingContext(
|
||||
// above TODO. [Bug 1471598]
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Warning,
|
||||
("ParentIPC: Trying to detach out of process context 0x%08" PRIx64,
|
||||
context->Id()));
|
||||
aContext->Id()));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (aMoveToBFCache) {
|
||||
context->CacheChildren();
|
||||
aContext->CacheChildren();
|
||||
} else {
|
||||
context->Detach();
|
||||
aContext->Detach();
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvSetOpenerBrowsingContext(
|
||||
const BrowsingContextId& aContextId,
|
||||
const BrowsingContextId& aOpenerContextId) {
|
||||
RefPtr<CanonicalBrowsingContext> context =
|
||||
CanonicalBrowsingContext::Get(aContextId);
|
||||
|
||||
if (!context) {
|
||||
BrowsingContext* aContext, BrowsingContext* aOpener) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to set opener already detached 0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
("ParentIPC: Trying to set opener already detached"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (!context->IsOwnedByProcess(ChildID())) {
|
||||
if (!aContext->Canonical()->IsOwnedByProcess(ChildID())) {
|
||||
// Where trying to set opener on a child BrowsingContext in
|
||||
// another child process. This is illegal since the owner of the
|
||||
// BrowsingContext is the proccess with the in-process docshell,
|
||||
@ -5735,29 +5703,24 @@ mozilla::ipc::IPCResult ContentParent::RecvSetOpenerBrowsingContext(
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Warning,
|
||||
("ParentIPC: Trying to set opener on out of process context "
|
||||
"0x%08" PRIx64,
|
||||
context->Id()));
|
||||
aContext->Id()));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
RefPtr<BrowsingContext> opener = BrowsingContext::Get(aOpenerContextId);
|
||||
context->SetOpener(opener);
|
||||
aContext->SetOpener(aOpener);
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvSetUserGestureActivation(
|
||||
const BrowsingContextId& aContextId, const bool& aNewValue) {
|
||||
RefPtr<CanonicalBrowsingContext> context =
|
||||
CanonicalBrowsingContext::Get(aContextId);
|
||||
|
||||
if (!context) {
|
||||
BrowsingContext* aContext, bool aNewValue) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to activate wrong context 0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
("ParentIPC: Trying to activate wrong context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
context->NotifySetUserGestureActivationFromIPC(aNewValue);
|
||||
aContext->Canonical()->NotifySetUserGestureActivationFromIPC(aNewValue);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@ -5782,14 +5745,11 @@ void ContentParent::UnregisterRemoveWorkerActor() {
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvWindowClose(
|
||||
const BrowsingContextId& aContextId, const bool& aTrustedCaller) {
|
||||
RefPtr<CanonicalBrowsingContext> bc =
|
||||
CanonicalBrowsingContext::Get(aContextId);
|
||||
if (!bc) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to send a message to dead or detached context "
|
||||
"0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
BrowsingContext* aContext, bool aTrustedCaller) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(
|
||||
BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to send a message to dead or detached context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@ -5798,66 +5758,57 @@ mozilla::ipc::IPCResult ContentParent::RecvWindowClose(
|
||||
// browsing contexts of bc.
|
||||
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
ContentParent* cp =
|
||||
cpm->GetContentProcessById(ContentParentId(bc->OwnerProcessId()));
|
||||
Unused << cp->SendWindowClose(aContextId, aTrustedCaller);
|
||||
ContentParent* cp = cpm->GetContentProcessById(
|
||||
ContentParentId(aContext->Canonical()->OwnerProcessId()));
|
||||
Unused << cp->SendWindowClose(aContext, aTrustedCaller);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvWindowFocus(
|
||||
const BrowsingContextId& aContextId) {
|
||||
RefPtr<CanonicalBrowsingContext> bc =
|
||||
CanonicalBrowsingContext::Get(aContextId);
|
||||
if (!bc) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to send a message to dead or detached context "
|
||||
"0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
BrowsingContext* aContext) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(
|
||||
BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to send a message to dead or detached context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
ContentParent* cp =
|
||||
cpm->GetContentProcessById(ContentParentId(bc->OwnerProcessId()));
|
||||
Unused << cp->SendWindowFocus(aContextId);
|
||||
ContentParent* cp = cpm->GetContentProcessById(
|
||||
ContentParentId(aContext->Canonical()->OwnerProcessId()));
|
||||
Unused << cp->SendWindowFocus(aContext);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvWindowBlur(
|
||||
const BrowsingContextId& aContextId) {
|
||||
RefPtr<CanonicalBrowsingContext> bc =
|
||||
CanonicalBrowsingContext::Get(aContextId);
|
||||
if (!bc) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to send a message to dead or detached context "
|
||||
"0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
BrowsingContext* aContext) {
|
||||
if (!aContext) {
|
||||
MOZ_LOG(
|
||||
BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to send a message to dead or detached context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
ContentParent* cp =
|
||||
cpm->GetContentProcessById(ContentParentId(bc->OwnerProcessId()));
|
||||
Unused << cp->SendWindowBlur(aContextId);
|
||||
ContentParent* cp = cpm->GetContentProcessById(
|
||||
ContentParentId(aContext->Canonical()->OwnerProcessId()));
|
||||
Unused << cp->SendWindowBlur(aContext);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvWindowPostMessage(
|
||||
const BrowsingContextId& aContextId, const ClonedMessageData& aMessage,
|
||||
BrowsingContext* aContext, const ClonedMessageData& aMessage,
|
||||
const PostMessageData& aData) {
|
||||
RefPtr<CanonicalBrowsingContext> bc =
|
||||
CanonicalBrowsingContext::Get(aContextId);
|
||||
if (!bc) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to send a message to dead or detached context "
|
||||
"0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
if (!aContext) {
|
||||
MOZ_LOG(
|
||||
BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ParentIPC: Trying to send a message to dead or detached context"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
ContentParent* cp =
|
||||
cpm->GetContentProcessById(ContentParentId(bc->OwnerProcessId()));
|
||||
ContentParent* cp = cpm->GetContentProcessById(
|
||||
ContentParentId(aContext->Canonical()->OwnerProcessId()));
|
||||
StructuredCloneData messageFromChild;
|
||||
UnpackClonedMessageDataForParent(aMessage, messageFromChild);
|
||||
ClonedMessageData message;
|
||||
@ -5865,7 +5816,7 @@ mozilla::ipc::IPCResult ContentParent::RecvWindowPostMessage(
|
||||
// FIXME Logging?
|
||||
return IPC_OK();
|
||||
}
|
||||
Unused << cp->SendWindowPostMessage(aContextId, message, aData);
|
||||
Unused << cp->SendWindowPostMessage(aContext, message, aData);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -618,27 +618,25 @@ class ContentParent final : public PContentParent,
|
||||
static bool IsInputEventQueueSupported();
|
||||
|
||||
mozilla::ipc::IPCResult RecvAttachBrowsingContext(
|
||||
const BrowsingContextId& aParentContextId,
|
||||
const BrowsingContextId& aOpenerId, const BrowsingContextId& aContextId,
|
||||
const nsString& aName);
|
||||
BrowsingContext* aParentContext, BrowsingContext* aOpener,
|
||||
BrowsingContextId aContextId, const nsString& aName);
|
||||
|
||||
mozilla::ipc::IPCResult RecvDetachBrowsingContext(
|
||||
const BrowsingContextId& aContextId, const bool& aMoveToBFCache);
|
||||
mozilla::ipc::IPCResult RecvDetachBrowsingContext(BrowsingContext* aContext,
|
||||
bool aMoveToBFCache);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetOpenerBrowsingContext(
|
||||
const BrowsingContextId& aContextId,
|
||||
const BrowsingContextId& aOpenerContextId);
|
||||
BrowsingContext* aContext, BrowsingContext* aOpener);
|
||||
|
||||
mozilla::ipc::IPCResult RecvWindowClose(const BrowsingContextId& aContextId,
|
||||
const bool& aTrustedCaller);
|
||||
mozilla::ipc::IPCResult RecvWindowFocus(const BrowsingContextId& aContextId);
|
||||
mozilla::ipc::IPCResult RecvWindowBlur(const BrowsingContextId& aContextId);
|
||||
mozilla::ipc::IPCResult RecvWindowClose(BrowsingContext* aContext,
|
||||
bool aTrustedCaller);
|
||||
mozilla::ipc::IPCResult RecvWindowFocus(BrowsingContext* aContext);
|
||||
mozilla::ipc::IPCResult RecvWindowBlur(BrowsingContext* aContext);
|
||||
mozilla::ipc::IPCResult RecvWindowPostMessage(
|
||||
const BrowsingContextId& aContextId, const ClonedMessageData& aMessage,
|
||||
BrowsingContext* aContext, const ClonedMessageData& aMessage,
|
||||
const PostMessageData& aData);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetUserGestureActivation(
|
||||
const BrowsingContextId& aContextId, const bool& aNewValue);
|
||||
BrowsingContext* aContext, bool aNewValue);
|
||||
|
||||
protected:
|
||||
void OnChannelConnected(int32_t pid) override;
|
||||
|
@ -27,7 +27,7 @@ using mozilla::LayoutDeviceIntPoint from "Units.h";
|
||||
using hal::ScreenOrientation from "mozilla/HalScreenConfiguration.h";
|
||||
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
|
||||
using refcounted class nsIPrincipal from "mozilla/dom/PermissionMessageUtils.h";
|
||||
using mozilla::dom::BrowsingContextId from "mozilla/dom/ipc/IdType.h";
|
||||
using refcounted class mozilla::dom::BrowsingContext from "mozilla/dom/BrowsingContext.h";
|
||||
using refcounted class nsIURI from "mozilla/ipc/URIUtils.h";
|
||||
|
||||
namespace mozilla {
|
||||
@ -189,7 +189,7 @@ struct PerformanceInfo
|
||||
struct WindowGlobalInit
|
||||
{
|
||||
nsIPrincipal principal;
|
||||
BrowsingContextId browsingContextId;
|
||||
BrowsingContext browsingContext;
|
||||
uint64_t innerWindowId;
|
||||
uint64_t outerWindowId;
|
||||
};
|
||||
|
@ -88,7 +88,7 @@ using class mozilla::NativeEventData from "ipc/nsGUIEventIPC.h";
|
||||
using mozilla::FontRange from "ipc/nsGUIEventIPC.h";
|
||||
using mozilla::a11y::IAccessibleHolder from "mozilla/a11y/IPCTypes.h";
|
||||
using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
|
||||
using mozilla::dom::BrowsingContextId from "mozilla/dom/ipc/IdType.h";
|
||||
using refcounted class mozilla::dom::BrowsingContext from "mozilla/dom/BrowsingContext.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -621,7 +621,7 @@ parent:
|
||||
sync SetPrefersReducedMotionOverrideForTest(bool aValue);
|
||||
sync ResetPrefersReducedMotionOverrideForTest();
|
||||
|
||||
async RootBrowsingContext(BrowsingContextId aId);
|
||||
async RootBrowsingContext(BrowsingContext aContext);
|
||||
|
||||
child:
|
||||
/**
|
||||
|
@ -102,6 +102,7 @@ using mozilla::Telemetry::ChildEventData from "mozilla/TelemetryComms.h";
|
||||
using mozilla::Telemetry::DiscardedData from "mozilla/TelemetryComms.h";
|
||||
using mozilla::CrossProcessMutexHandle from "mozilla/ipc/CrossProcessMutex.h";
|
||||
using refcounted class nsIInputStream from "mozilla/ipc/IPCStreamUtils.h";
|
||||
using refcounted class mozilla::dom::BrowsingContext from "mozilla/dom/BrowsingContext.h";
|
||||
using mozilla::dom::BrowsingContextId from "mozilla/dom/ipc/IdType.h";
|
||||
|
||||
union ChromeRegistryItem
|
||||
@ -308,7 +309,7 @@ struct NotificationEventData
|
||||
|
||||
struct PostMessageData
|
||||
{
|
||||
BrowsingContextId source;
|
||||
BrowsingContext source;
|
||||
nsString origin;
|
||||
nsString targetOrigin;
|
||||
nsIURI targetOriginURI;
|
||||
@ -1219,47 +1220,44 @@ parent:
|
||||
async StoreUserInteractionAsPermission(Principal aPrincipal);
|
||||
|
||||
/**
|
||||
* Sync the BrowsingContext with id 'aContextId' and name 'aName'
|
||||
* to the parent, and attach it to the BrowsingContext with id
|
||||
* 'aParentContextId'. If 'aParentContextId' is '0' the
|
||||
* BrowsingContext is a root in the BrowsingContext
|
||||
* tree. AttachBrowsingContext must only be called at most once
|
||||
* for any child BrowsingContext, and only for BrowsingContexts
|
||||
* where the parent and the child context contains their
|
||||
* nsDocShell.
|
||||
* Sync the BrowsingContext with id 'aContextId' and name 'aName' to the
|
||||
* parent, and attach it to the BrowsingContext 'aParentContext'. If
|
||||
* 'aParentContext' is 'nullptr' the BrowsingContext is a root in the
|
||||
* BrowsingContext tree. AttachBrowsingContext must only be called at most
|
||||
* once for any child BrowsingContext, and only for BrowsingContexts where
|
||||
* the parent and the child context contains their nsDocShell.
|
||||
*/
|
||||
async AttachBrowsingContext(BrowsingContextId aParentContextId,
|
||||
BrowsingContextId aOpenerId,
|
||||
async AttachBrowsingContext(BrowsingContext aParentContext,
|
||||
BrowsingContext aOpener,
|
||||
BrowsingContextId aContextId,
|
||||
nsString aName);
|
||||
|
||||
/**
|
||||
* Remove the synced BrowsingContext with id 'aContextId' from the
|
||||
* parent. DetachBrowsingContext is only needed to be called once
|
||||
* for any BrowsingContext, since detaching a node in the
|
||||
* BrowsingContext detaches the entire sub-tree rooted at that
|
||||
* node. Calling DetachBrowsingContext with an already detached
|
||||
* BrowsingContext effectively does nothing. Note that it is not
|
||||
* an error to call DetachBrowsingContext on a BrowsingContext
|
||||
* belonging to an already detached subtree. The 'aMoveToBFCache'
|
||||
* paramater controls if detaching a BrowsingContext should move
|
||||
* it to the bfcache allowing it to be re-attached if navigated
|
||||
* Remove the synced BrowsingContext 'aContext' from the parent.
|
||||
* DetachBrowsingContext is only needed to be called once for any
|
||||
* BrowsingContext, since detaching a node in the BrowsingContext detaches
|
||||
* the entire sub-tree rooted at that node. Calling DetachBrowsingContext
|
||||
* with an already detached BrowsingContext effectively does nothing. Note
|
||||
* that it is not an error to call DetachBrowsingContext on a
|
||||
* BrowsingContext belonging to an already detached subtree. The
|
||||
* 'aMoveToBFCache' paramater controls if detaching a BrowsingContext
|
||||
* should move it to the bfcache allowing it to be re-attached if navigated
|
||||
* to.
|
||||
*/
|
||||
async DetachBrowsingContext(BrowsingContextId aContextId,
|
||||
async DetachBrowsingContext(BrowsingContext aContext,
|
||||
bool aMoveToBFCache);
|
||||
|
||||
/**
|
||||
* Set the opener of browsing context with id 'aContextId' to the
|
||||
* browsing context with id 'aOpenerId'.
|
||||
* Set the opener of browsing context 'aContext' to the browsing context
|
||||
* with id 'aOpenerId'.
|
||||
*/
|
||||
async SetOpenerBrowsingContext(BrowsingContextId aContextId,
|
||||
BrowsingContextId aOpenerContextId);
|
||||
async SetOpenerBrowsingContext(BrowsingContext aContext,
|
||||
BrowsingContext aOpenerContext);
|
||||
|
||||
/**
|
||||
* Notify parent to update user gesture activation flag.
|
||||
*/
|
||||
async SetUserGestureActivation(BrowsingContextId aContextId,
|
||||
async SetUserGestureActivation(BrowsingContext aContext,
|
||||
bool aNewValue);
|
||||
|
||||
both:
|
||||
@ -1279,11 +1277,10 @@ both:
|
||||
async PushError(nsCString scope, Principal principal, nsString message,
|
||||
uint32_t flags);
|
||||
|
||||
async WindowClose(BrowsingContextId aContextId,
|
||||
bool aTrustedCaller);
|
||||
async WindowFocus(BrowsingContextId aContextId);
|
||||
async WindowBlur(BrowsingContextId aContextId);
|
||||
async WindowPostMessage(BrowsingContextId aContextId, ClonedMessageData aMessage,
|
||||
async WindowClose(BrowsingContext aContext, bool aTrustedCaller);
|
||||
async WindowFocus(BrowsingContext aContext);
|
||||
async WindowBlur(BrowsingContext aContext);
|
||||
async WindowPostMessage(BrowsingContext aContext, ClonedMessageData aMessage,
|
||||
PostMessageData aData);
|
||||
};
|
||||
|
||||
|
@ -554,7 +554,7 @@ nsresult TabChild::Init(mozIDOMWindowProxy* aParent) {
|
||||
// Send our browsing context to the parent process.
|
||||
RefPtr<BrowsingContext> browsingContext =
|
||||
nsDocShell::Cast(docShell)->GetBrowsingContext();
|
||||
SendRootBrowsingContext(BrowsingContextId(browsingContext->Id()));
|
||||
SendRootBrowsingContext(browsingContext);
|
||||
|
||||
// Few lines before, baseWindow->Create() will end up creating a new
|
||||
// window root in nsGlobalWindow::SetDocShell.
|
||||
|
@ -3444,9 +3444,9 @@ mozilla::ipc::IPCResult TabParent::RecvGetSystemFont(nsCString* aFontName) {
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult TabParent::RecvRootBrowsingContext(
|
||||
const BrowsingContextId& aId) {
|
||||
BrowsingContext* aBrowsingContext) {
|
||||
MOZ_ASSERT(!mBrowsingContext, "May only set browsing context once!");
|
||||
mBrowsingContext = CanonicalBrowsingContext::Get(aId);
|
||||
mBrowsingContext = CanonicalBrowsingContext::Cast(aBrowsingContext);
|
||||
MOZ_ASSERT(mBrowsingContext, "Invalid ID!");
|
||||
return IPC_OK();
|
||||
}
|
||||
|
@ -257,11 +257,10 @@ class TabParent final : public PBrowserParent,
|
||||
const nsCursor& aValue, const bool& aHasCustomCursor,
|
||||
const nsCString& aUri, const uint32_t& aWidth, const uint32_t& aHeight,
|
||||
const uint32_t& aStride, const gfx::SurfaceFormat& aFormat,
|
||||
const uint32_t& aHotspotX, const uint32_t& aHotspotY,
|
||||
const bool& aForce);
|
||||
const uint32_t& aHotspotX, const uint32_t& aHotspotY, const bool& aForce);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetStatus(
|
||||
const uint32_t& aType, const nsString& aStatus);
|
||||
mozilla::ipc::IPCResult RecvSetStatus(const uint32_t& aType,
|
||||
const nsString& aStatus);
|
||||
|
||||
mozilla::ipc::IPCResult RecvShowTooltip(const uint32_t& aX,
|
||||
const uint32_t& aY,
|
||||
@ -595,7 +594,7 @@ class TabParent final : public PBrowserParent,
|
||||
mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(
|
||||
const nsCString& aFirstPartyURI, const bool& aHideDoorHanger);
|
||||
|
||||
mozilla::ipc::IPCResult RecvRootBrowsingContext(const BrowsingContextId& aId);
|
||||
mozilla::ipc::IPCResult RecvRootBrowsingContext(BrowsingContext* aContext);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetSystemFont(const nsCString& aFontName);
|
||||
mozilla::ipc::IPCResult RecvGetSystemFont(nsCString* aFontName);
|
||||
|
@ -39,9 +39,8 @@ already_AddRefed<WindowGlobalChild> WindowGlobalChild::Create(
|
||||
RefPtr<dom::BrowsingContext> bc = docshell->GetBrowsingContext();
|
||||
RefPtr<WindowGlobalChild> wgc = new WindowGlobalChild(aWindow, bc);
|
||||
|
||||
WindowGlobalInit init(principal,
|
||||
BrowsingContextId(wgc->BrowsingContext()->Id()),
|
||||
wgc->mInnerWindowId, wgc->mOuterWindowId);
|
||||
WindowGlobalInit init(principal, bc, wgc->mInnerWindowId,
|
||||
wgc->mOuterWindowId);
|
||||
|
||||
// Send the link constructor over PInProcessChild or PBrowser.
|
||||
if (XRE_IsParentProcess()) {
|
||||
|
@ -37,7 +37,7 @@ WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit,
|
||||
MOZ_RELEASE_ASSERT(mDocumentPrincipal, "Must have a valid principal");
|
||||
|
||||
// NOTE: mBrowsingContext initialized in Init()
|
||||
MOZ_RELEASE_ASSERT(aInit.browsingContextId() != 0,
|
||||
MOZ_RELEASE_ASSERT(aInit.browsingContext(),
|
||||
"Must be made in BrowsingContext");
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ void WindowGlobalParent::Init(const WindowGlobalInit& aInit) {
|
||||
processId = static_cast<ContentParent*>(Manager()->Manager())->ChildID();
|
||||
}
|
||||
|
||||
mBrowsingContext = CanonicalBrowsingContext::Get(aInit.browsingContextId());
|
||||
mBrowsingContext = CanonicalBrowsingContext::Cast(aInit.browsingContext());
|
||||
MOZ_ASSERT(mBrowsingContext);
|
||||
|
||||
// XXX(nika): This won't be the case soon, but for now this is a good
|
||||
|
Loading…
Reference in New Issue
Block a user