зеркало из https://github.com/mozilla/gecko-dev.git
Bug 888600 - Move ContentFrameMessageManager to WebIDL. Part 5: Convert MessageManager globals to WebIDL. r=bz.
The change in browser_net_view-source-debugger.js is needed because we now use WebIDL callbacks for MessageListener, and they add async creation stack frames. --HG-- extra : rebase_source : 0adb349b40a0c51bb3d8f4b9b7d98106a3929cbd extra : source : a88d94ec010a12c1d829708aaf59a85609478477
This commit is contained in:
Родитель
5ad9618d7c
Коммит
e673e5f508
|
@ -15,6 +15,9 @@ add_task(async function() {
|
|||
// Set a higher panel height in order to get full CodeMirror content
|
||||
await pushPref("devtools.toolbox.footer.height", 400);
|
||||
|
||||
// Async stacks aren't on by default in all builds
|
||||
await pushPref("javascript.options.asyncstack", true);
|
||||
|
||||
let { tab, monitor, toolbox } = await initNetMonitor(POST_DATA_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
|
@ -28,7 +31,7 @@ add_task(async function() {
|
|||
await waitForContentRequests;
|
||||
|
||||
info("Clicking stack-trace tab and waiting for stack-trace panel to open");
|
||||
let wait = waitForDOM(document, "#stack-trace-panel .frame-link", 4);
|
||||
let wait = waitForDOM(document, "#stack-trace-panel .frame-link", 5);
|
||||
// Click on the first request
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelector(".request-list-item"));
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_ContentFrameMessageManager_h
|
||||
#define mozilla_dom_ContentFrameMessageManager_h
|
||||
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/MessageManagerGlobal.h"
|
||||
#include "mozilla/dom/ResolveSystemBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/**
|
||||
* Base class for implementing the WebIDL ContentFrameMessageManager class.
|
||||
*/
|
||||
class ContentFrameMessageManager : public DOMEventTargetHelper,
|
||||
public MessageManagerGlobal
|
||||
{
|
||||
public:
|
||||
using DOMEventTargetHelper::AddRef;
|
||||
using DOMEventTargetHelper::Release;
|
||||
|
||||
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> aDesc)
|
||||
{
|
||||
bool found;
|
||||
if (!SystemGlobalResolve(aCx, aObj, aId, &found)) {
|
||||
return false;
|
||||
}
|
||||
if (found) {
|
||||
FillPropertyDescriptor(aDesc, aObj, JS::UndefinedValue(), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static bool MayResolve(jsid aId)
|
||||
{
|
||||
return MayResolveAsSystemBindingName(aId);
|
||||
}
|
||||
void GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
|
||||
bool aEnumerableOnly, mozilla::ErrorResult& aRv)
|
||||
{
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapper());
|
||||
GetSystemBindingNames(aCx, thisObj, aNames, aEnumerableOnly, aRv);
|
||||
}
|
||||
|
||||
nsresult AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture)
|
||||
{
|
||||
// By default add listeners only for trusted events!
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture, false, 2);
|
||||
}
|
||||
using DOMEventTargetHelper::AddEventListener;
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture, bool aWantsUntrusted,
|
||||
uint8_t optional_argc) override
|
||||
{
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture,
|
||||
aWantsUntrusted,
|
||||
optional_argc);
|
||||
}
|
||||
|
||||
virtual already_AddRefed<nsPIDOMWindowOuter> GetContent(ErrorResult& aError) = 0;
|
||||
virtual already_AddRefed<nsIDocShell> GetDocShell(ErrorResult& aError) = 0;
|
||||
virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() = 0;
|
||||
|
||||
nsFrameMessageManager* GetMessageManager()
|
||||
{
|
||||
return mMessageManager;
|
||||
}
|
||||
void DisconnectMessageManager()
|
||||
{
|
||||
mMessageManager->Disconnect();
|
||||
mMessageManager = nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit ContentFrameMessageManager(nsFrameMessageManager* aMessageManager)
|
||||
: MessageManagerGlobal(aMessageManager)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ContentFrameMessageManager_h
|
|
@ -0,0 +1,181 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_MessageManagerGlobal_h
|
||||
#define mozilla_dom_MessageManagerGlobal_h
|
||||
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/**
|
||||
* Base class for implementing the WebIDL MessageManagerGlobal class.
|
||||
*/
|
||||
class MessageManagerGlobal
|
||||
{
|
||||
public:
|
||||
// MessageListenerManager
|
||||
void AddMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
bool aListenWhenClosed,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->AddMessageListener(aMessageName, aListener,
|
||||
aListenWhenClosed, aError);
|
||||
}
|
||||
void RemoveMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->RemoveMessageListener(aMessageName, aListener, aError);
|
||||
}
|
||||
void AddWeakMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->AddWeakMessageListener(aMessageName, aListener, aError);
|
||||
}
|
||||
void RemoveWeakMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->RemoveWeakMessageListener(aMessageName, aListener, aError);
|
||||
}
|
||||
|
||||
// MessageSender
|
||||
void SendAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JS::Handle<JS::Value> aTransfers,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->SendAsyncMessage(aCx, aMessageName, aObj, aObjects,
|
||||
aPrincipal, aTransfers, aError);
|
||||
}
|
||||
already_AddRefed<nsIMessageSender> GetProcessMessageManager(mozilla::ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return nullptr;
|
||||
}
|
||||
return mMessageManager->GetProcessMessageManager(aError);
|
||||
}
|
||||
|
||||
void GetRemoteType(nsAString& aRemoteType, mozilla::ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->GetRemoteType(aRemoteType, aError);
|
||||
}
|
||||
|
||||
// SyncMessageSender
|
||||
void SendSyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->SendSyncMessage(aCx, aMessageName, aObj, aObjects,
|
||||
aPrincipal, aResult, aError);
|
||||
}
|
||||
void SendRpcMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->SendRpcMessage(aCx, aMessageName, aObj, aObjects,
|
||||
aPrincipal, aResult, aError);
|
||||
}
|
||||
|
||||
// MessageManagerGlobal
|
||||
void Dump(const nsAString& aStr, ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->Dump(aStr);
|
||||
}
|
||||
void PrivateNoteIntentionalCrash(ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->PrivateNoteIntentionalCrash();
|
||||
}
|
||||
void Atob(const nsAString& aAsciiString, nsAString& aBase64Data,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->Atob(aAsciiString, aBase64Data);
|
||||
}
|
||||
void Btoa(const nsAString& aBase64Data, nsAString& aAsciiString,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->Btoa(aBase64Data, aAsciiString);
|
||||
}
|
||||
|
||||
bool MarkForCC()
|
||||
{
|
||||
return mMessageManager && mMessageManager->MarkForCC();
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit MessageManagerGlobal(nsFrameMessageManager* aMessageManager)
|
||||
: mMessageManager(aMessageManager)
|
||||
{}
|
||||
|
||||
RefPtr<nsFrameMessageManager> mMessageManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MessageManagerGlobal_h
|
|
@ -7,17 +7,16 @@
|
|||
#include "ProcessGlobal.h"
|
||||
|
||||
#include "nsContentCID.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
#include "mozilla/dom/ResolveSystemBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
ProcessGlobal::ProcessGlobal(nsFrameMessageManager* aMessageManager)
|
||||
: mInitialized(false),
|
||||
mMessageManager(aMessageManager)
|
||||
: MessageManagerGlobal(aMessageManager),
|
||||
mInitialized(false)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
|
@ -27,6 +26,36 @@ ProcessGlobal::~ProcessGlobal()
|
|||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessGlobal::DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> aDesc)
|
||||
{
|
||||
bool found;
|
||||
if (!SystemGlobalResolve(aCx, aObj, aId, &found)) {
|
||||
return false;
|
||||
}
|
||||
if (found) {
|
||||
FillPropertyDescriptor(aDesc, aObj, JS::UndefinedValue(), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
ProcessGlobal::MayResolve(jsid aId)
|
||||
{
|
||||
return MayResolveAsSystemBindingName(aId);
|
||||
}
|
||||
|
||||
void
|
||||
ProcessGlobal::GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
|
||||
bool aEnumerableOnly, ErrorResult& aRv)
|
||||
{
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapper());
|
||||
GetSystemBindingNames(aCx, thisObj, aNames, aEnumerableOnly, aRv);
|
||||
}
|
||||
|
||||
ProcessGlobal*
|
||||
ProcessGlobal::Get()
|
||||
{
|
||||
|
@ -43,7 +72,7 @@ NS_IMETHODIMP_(bool)
|
|||
ProcessGlobal::MarkForCC()
|
||||
{
|
||||
MarkScopesForCC();
|
||||
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
||||
return MessageManagerGlobal::MarkForCC();
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(ProcessGlobal)
|
||||
|
@ -75,7 +104,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ProcessGlobal)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentProcessMessageManager)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(ProcessGlobal)
|
||||
|
@ -89,15 +117,30 @@ ProcessGlobal::Init()
|
|||
}
|
||||
mInitialized = true;
|
||||
|
||||
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(nsIContentProcessMessageManager*, this);
|
||||
return InitChildGlobalInternal(scopeSupports, NS_LITERAL_CSTRING("processChildGlobal"));
|
||||
return InitChildGlobalInternal(NS_LITERAL_CSTRING("processChildGlobal"));
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessGlobal::WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector)
|
||||
{
|
||||
bool ok = ContentProcessMessageManagerBinding::Wrap(aCx, this, this, aOptions,
|
||||
nsJSPrincipals::get(mPrincipal),
|
||||
true, aReflector);
|
||||
if (ok) {
|
||||
// Since we can't rewrap we have to preserve the global's wrapper here.
|
||||
PreserveWrapper(ToSupports(this));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void
|
||||
ProcessGlobal::LoadScript(const nsAString& aURL)
|
||||
{
|
||||
Init();
|
||||
LoadScriptInternal(aURL, false);
|
||||
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper());
|
||||
LoadScriptInternal(global, aURL, false);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define mozilla_dom_ProcessGlobal_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/MessageManagerGlobal.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -25,18 +26,26 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
class ProcessGlobal :
|
||||
public nsMessageManagerScriptExecutor,
|
||||
public nsIContentProcessMessageManager,
|
||||
public nsMessageManagerScriptExecutor,
|
||||
public nsIGlobalObject,
|
||||
public nsIScriptObjectPrincipal,
|
||||
public nsSupportsWeakReference,
|
||||
public mozilla::dom::ipc::MessageManagerCallback,
|
||||
public ipc::MessageManagerCallback,
|
||||
public MessageManagerGlobal,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
explicit ProcessGlobal(nsFrameMessageManager* aMessageManager);
|
||||
|
||||
using mozilla::dom::ipc::MessageManagerCallback::GetProcessMessageManager;
|
||||
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> aDesc);
|
||||
static bool MayResolve(jsid aId);
|
||||
void GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
|
||||
bool aEnumerableOnly, ErrorResult& aRv);
|
||||
|
||||
using ipc::MessageManagerCallback::GetProcessMessageManager;
|
||||
|
||||
bool Init();
|
||||
|
||||
|
@ -45,6 +54,41 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(ProcessGlobal, nsIContentProcessMessageManager)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("We should never get here!");
|
||||
}
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) override;
|
||||
|
||||
using MessageManagerGlobal::AddMessageListener;
|
||||
using MessageManagerGlobal::RemoveMessageListener;
|
||||
using MessageManagerGlobal::AddWeakMessageListener;
|
||||
using MessageManagerGlobal::RemoveWeakMessageListener;
|
||||
using MessageManagerGlobal::SendAsyncMessage;
|
||||
using MessageManagerGlobal::GetProcessMessageManager;
|
||||
using MessageManagerGlobal::GetRemoteType;
|
||||
using MessageManagerGlobal::SendSyncMessage;
|
||||
using MessageManagerGlobal::SendRpcMessage;
|
||||
using MessageManagerGlobal::Dump;
|
||||
using MessageManagerGlobal::PrivateNoteIntentionalCrash;
|
||||
using MessageManagerGlobal::Atob;
|
||||
using MessageManagerGlobal::Btoa;
|
||||
|
||||
// ContentProcessMessageManager
|
||||
void GetInitialProcessData(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aInitialProcessData,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->GetInitialProcessData(aCx, aInitialProcessData, aError);
|
||||
}
|
||||
|
||||
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager)
|
||||
|
@ -55,15 +99,10 @@ public:
|
|||
|
||||
virtual JSObject* GetGlobalJSObject() override
|
||||
{
|
||||
return mGlobal;
|
||||
return GetWrapper();
|
||||
}
|
||||
virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("ProcessGlobal doesn't use DOM bindings!");
|
||||
}
|
||||
|
||||
void SetInitialProcessData(JS::HandleValue aInitialData);
|
||||
|
||||
protected:
|
||||
|
@ -71,7 +110,6 @@ protected:
|
|||
|
||||
private:
|
||||
bool mInitialized;
|
||||
RefPtr<nsFrameMessageManager> mMessageManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -161,6 +161,7 @@ EXPORTS.mozilla.dom += [
|
|||
'ChromeNodeList.h',
|
||||
'ChromeUtils.h',
|
||||
'Comment.h',
|
||||
'ContentFrameMessageManager.h',
|
||||
'CustomElementRegistry.h',
|
||||
'DirectionalityUtils.h',
|
||||
'DispatcherTrait.h',
|
||||
|
@ -198,6 +199,7 @@ EXPORTS.mozilla.dom += [
|
|||
'Link.h',
|
||||
'Location.h',
|
||||
'MessageListenerManager.h',
|
||||
'MessageManagerGlobal.h',
|
||||
'MessageSender.h',
|
||||
'NameSpaceConstants.h',
|
||||
'Navigator.h',
|
||||
|
|
|
@ -71,7 +71,6 @@
|
|||
// includes needed for the prototype chain interfaces
|
||||
|
||||
#include "nsIEventListenerService.h"
|
||||
#include "nsIMessageManager.h"
|
||||
|
||||
#include "mozilla/dom/TouchEvent.h"
|
||||
|
||||
|
@ -129,9 +128,6 @@ using namespace mozilla::dom;
|
|||
#define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, false, false)
|
||||
|
||||
#define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, false)
|
||||
|
||||
#define NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, true)
|
||||
|
||||
|
@ -166,16 +162,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
|
||||
// Misc Core related classes
|
||||
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager,
|
||||
nsMessageManagerSH<nsEventTargetSH>,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
XPC_SCRIPTABLE_WANT_ENUMERATE |
|
||||
XPC_SCRIPTABLE_IS_GLOBAL_OBJECT)
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentProcessMessageManager,
|
||||
nsMessageManagerSH<nsDOMGenericSH>,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
XPC_SCRIPTABLE_WANT_ENUMERATE |
|
||||
XPC_SCRIPTABLE_IS_GLOBAL_OBJECT)
|
||||
};
|
||||
|
||||
nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
|
||||
|
@ -409,21 +395,6 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIContentFrameMessageManager)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentProcessMessageManager, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIContentProcessMessageManager)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
static_assert(MOZ_ARRAY_LENGTH(sClassInfoData) == eDOMClassInfoIDCount,
|
||||
"The number of items in sClassInfoData doesn't match the "
|
||||
"number of nsIDOMClassInfo ID's, this is bad! Fix it!");
|
||||
|
@ -1875,41 +1846,3 @@ nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
return wrapped->HasInstance(wrapper, cx, obj, val, bp, _retval);
|
||||
}
|
||||
|
||||
// nsContentFrameMessageManagerSH
|
||||
|
||||
template<typename Super>
|
||||
NS_IMETHODIMP
|
||||
nsMessageManagerSH<Super>::Resolve(nsIXPConnectWrappedNative* wrapper,
|
||||
JSContext* cx, JSObject* obj_,
|
||||
jsid id_, bool* resolvedp,
|
||||
bool* _retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, obj_);
|
||||
JS::Rooted<jsid> id(cx, id_);
|
||||
|
||||
*_retval = SystemGlobalResolve(cx, obj, id, resolvedp);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
if (*resolvedp) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return Super::Resolve(wrapper, cx, obj, id, resolvedp, _retval);
|
||||
}
|
||||
|
||||
template<typename Super>
|
||||
NS_IMETHODIMP
|
||||
nsMessageManagerSH<Super>::Enumerate(nsIXPConnectWrappedNative* wrapper,
|
||||
JSContext* cx, JSObject* obj_,
|
||||
bool* _retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, obj_);
|
||||
|
||||
*_retval = SystemGlobalEnumerate(cx, obj);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
// Don't call up to our superclass, since neither nsDOMGenericSH nor
|
||||
// nsEventTargetSH have WANT_ENUMERATE.
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -212,29 +212,4 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
class nsMessageManagerSH : public Super
|
||||
{
|
||||
protected:
|
||||
explicit nsMessageManagerSH(nsDOMClassInfoData* aData)
|
||||
: Super(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsMessageManagerSH()
|
||||
{
|
||||
}
|
||||
public:
|
||||
NS_IMETHOD Resolve(nsIXPConnectWrappedNative* wrapper, JSContext* cx,
|
||||
JSObject* obj_, jsid id_, bool* resolvedp,
|
||||
bool* _retval) override;
|
||||
NS_IMETHOD Enumerate(nsIXPConnectWrappedNative* wrapper, JSContext* cx,
|
||||
JSObject* obj_, bool* _retval) override;
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsMessageManagerSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* nsDOMClassInfo_h___ */
|
||||
|
|
|
@ -19,9 +19,6 @@ enum nsDOMClassInfoID
|
|||
eDOMClassInfo_DOMPrototype_id,
|
||||
eDOMClassInfo_DOMConstructor_id,
|
||||
|
||||
eDOMClassInfo_ContentFrameMessageManager_id,
|
||||
eDOMClassInfo_ContentProcessMessageManager_id,
|
||||
|
||||
// This one better be the last one in this list
|
||||
eDOMClassInfoIDCount
|
||||
};
|
||||
|
|
|
@ -1643,14 +1643,12 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
|||
RefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
|
||||
// Swap pointers in child message managers.
|
||||
if (mChildMessageManager) {
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
|
||||
nsInProcessTabChildGlobal* tabChild = mChildMessageManager;
|
||||
tabChild->SetOwner(otherContent);
|
||||
tabChild->SetChromeMessageManager(otherMessageManager);
|
||||
}
|
||||
if (aOther->mChildMessageManager) {
|
||||
nsInProcessTabChildGlobal* otherTabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(aOther->mChildMessageManager.get());
|
||||
nsInProcessTabChildGlobal* otherTabChild = aOther->mChildMessageManager;
|
||||
otherTabChild->SetOwner(ourContent);
|
||||
otherTabChild->SetChromeMessageManager(ourMessageManager);
|
||||
}
|
||||
|
@ -1885,7 +1883,7 @@ nsFrameLoader::DestroyDocShell()
|
|||
|
||||
// Fire the "unload" event if we're in-process.
|
||||
if (mChildMessageManager) {
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->FireUnloadEvent();
|
||||
mChildMessageManager->FireUnloadEvent();
|
||||
}
|
||||
|
||||
// Destroy the docshell.
|
||||
|
@ -1897,7 +1895,7 @@ nsFrameLoader::DestroyDocShell()
|
|||
|
||||
if (mChildMessageManager) {
|
||||
// Stop handling events in the in-process frame script.
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->DisconnectEventListeners();
|
||||
mChildMessageManager->DisconnectEventListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1932,7 +1930,7 @@ nsFrameLoader::DestroyComplete()
|
|||
}
|
||||
|
||||
if (mChildMessageManager) {
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->Disconnect();
|
||||
mChildMessageManager->Disconnect();
|
||||
}
|
||||
|
||||
mMessageManager = nullptr;
|
||||
|
@ -2988,12 +2986,11 @@ public:
|
|||
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mFrameLoader->mChildMessageManager.get());
|
||||
nsInProcessTabChildGlobal* tabChild = mFrameLoader->mChildMessageManager;
|
||||
// Since bug 1126089, messages can arrive even when the docShell is destroyed.
|
||||
// Here we make sure that those messages are not delivered.
|
||||
if (tabChild && tabChild->GetInnerManager() && mFrameLoader->GetExistingDocShell()) {
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), tabChild->GetGlobal());
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), tabChild->GetWrapper());
|
||||
ReceiveMessage(static_cast<EventTarget*>(tabChild), mFrameLoader,
|
||||
tabChild->GetInnerManager());
|
||||
}
|
||||
|
@ -3141,7 +3138,7 @@ nsFrameLoader::ReallyLoadFrameScripts()
|
|||
EventTarget*
|
||||
nsFrameLoader::GetTabChildGlobalAsEventTarget()
|
||||
{
|
||||
return static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
|
||||
return mChildMessageManager.get();
|
||||
}
|
||||
|
||||
already_AddRefed<Element>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
class nsIURI;
|
||||
class nsSubDocumentFrame;
|
||||
class nsView;
|
||||
class nsIInProcessContentFrameMessageManager;
|
||||
class nsInProcessTabChildGlobal;
|
||||
class AutoResetInShow;
|
||||
class AutoResetInFrameSwap;
|
||||
class nsITabParent;
|
||||
|
@ -321,7 +321,7 @@ public:
|
|||
|
||||
// public because a callback needs these.
|
||||
RefPtr<mozilla::dom::ChromeMessageSender> mMessageManager;
|
||||
nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
|
||||
RefPtr<nsInProcessTabChildGlobal> mChildMessageManager;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "mozilla/dom/ProcessGlobal.h"
|
||||
#include "mozilla/dom/ResolveSystemBinding.h"
|
||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
|
@ -1619,7 +1620,6 @@ StaticRefPtr<nsScriptCacheCleaner> nsMessageManagerScriptExecutor::sScriptCacheC
|
|||
void
|
||||
nsMessageManagerScriptExecutor::DidCreateGlobal()
|
||||
{
|
||||
NS_ASSERTION(mGlobal, "Should have mGlobal!");
|
||||
if (!sCachedScripts) {
|
||||
sCachedScripts =
|
||||
new nsDataHashtable<nsStringHashKey, nsMessageManagerScriptHolder*>;
|
||||
|
@ -1654,13 +1654,14 @@ nsMessageManagerScriptExecutor::Shutdown()
|
|||
}
|
||||
|
||||
void
|
||||
nsMessageManagerScriptExecutor::LoadScriptInternal(const nsAString& aURL,
|
||||
nsMessageManagerScriptExecutor::LoadScriptInternal(JS::Handle<JSObject*> aGlobal,
|
||||
const nsAString& aURL,
|
||||
bool aRunInGlobalScope)
|
||||
{
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
|
||||
"nsMessageManagerScriptExecutor::LoadScriptInternal", OTHER, aURL);
|
||||
|
||||
if (!mGlobal || !sCachedScripts) {
|
||||
if (!sCachedScripts) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1678,21 +1679,18 @@ nsMessageManagerScriptExecutor::LoadScriptInternal(const nsAString& aURL,
|
|||
shouldCache, &script);
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> global(rcx, mGlobal);
|
||||
if (global) {
|
||||
AutoEntryScript aes(global, "message manager script load");
|
||||
JSContext* cx = aes.cx();
|
||||
if (script) {
|
||||
if (aRunInGlobalScope) {
|
||||
JS::RootedValue rval(cx);
|
||||
JS::CloneAndExecuteScript(cx, script, &rval);
|
||||
} else {
|
||||
JS::Rooted<JSObject*> scope(cx);
|
||||
bool ok = js::ExecuteInGlobalAndReturnScope(cx, global, script, &scope);
|
||||
if (ok) {
|
||||
// Force the scope to stay alive.
|
||||
mAnonymousGlobalScopes.AppendElement(scope);
|
||||
}
|
||||
AutoEntryScript aes(aGlobal, "message manager script load");
|
||||
JSContext* cx = aes.cx();
|
||||
if (script) {
|
||||
if (aRunInGlobalScope) {
|
||||
JS::RootedValue rval(cx);
|
||||
JS::CloneAndExecuteScript(cx, script, &rval);
|
||||
} else {
|
||||
JS::Rooted<JSObject*> scope(cx);
|
||||
bool ok = js::ExecuteInGlobalAndReturnScope(cx, aGlobal, script, &scope);
|
||||
if (ok) {
|
||||
// Force the scope to stay alive.
|
||||
mAnonymousGlobalScopes.AppendElement(scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1813,45 +1811,38 @@ nsMessageManagerScriptExecutor::Trace(const TraceCallbacks& aCallbacks, void* aC
|
|||
for (size_t i = 0, length = mAnonymousGlobalScopes.Length(); i < length; ++i) {
|
||||
aCallbacks.Trace(&mAnonymousGlobalScopes[i], "mAnonymousGlobalScopes[i]", aClosure);
|
||||
}
|
||||
aCallbacks.Trace(&mGlobal, "mGlobal", aClosure);
|
||||
}
|
||||
|
||||
void
|
||||
nsMessageManagerScriptExecutor::Unlink()
|
||||
{
|
||||
ImplCycleCollectionUnlink(mAnonymousGlobalScopes);
|
||||
mGlobal = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
nsMessageManagerScriptExecutor::InitChildGlobalInternal(
|
||||
nsISupports* aScope,
|
||||
const nsACString& aID)
|
||||
nsMessageManagerScriptExecutor::InitChildGlobalInternal(const nsACString& aID)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
|
||||
if (!SystemBindingInitIds(cx)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint32_t flags = xpc::INIT_JS_STANDARD_CLASSES;
|
||||
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
|
||||
|
||||
JS::CompartmentOptions options;
|
||||
options.creationOptions().setSystemZone();
|
||||
|
||||
if (xpc::SharedMemoryEnabled()) {
|
||||
options.creationOptions().setSharedMemoryAndAtomicsEnabled(true);
|
||||
xpc::InitGlobalObjectOptions(options, mPrincipal);
|
||||
JS::Rooted<JSObject*> global(cx);
|
||||
if (!WrapGlobalObject(cx, options, &global)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> global(cx);
|
||||
nsresult rv = xpc::InitClassesWithNewWrappedGlobal(cx, aScope, mPrincipal,
|
||||
flags, options,
|
||||
&global);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
mGlobal = global;
|
||||
NS_ENSURE_TRUE(mGlobal, false);
|
||||
xpc::InitGlobalObject(cx, global, 0);
|
||||
|
||||
// Set the location information for the new global, so that tools like
|
||||
// about:memory may use that information.
|
||||
xpc::SetLocationForGlobal(mGlobal, aID);
|
||||
xpc::SetLocationForGlobal(global, aID);
|
||||
|
||||
DidCreateGlobal();
|
||||
return true;
|
||||
|
|
|
@ -476,10 +476,6 @@ class nsMessageManagerScriptExecutor
|
|||
public:
|
||||
static void PurgeCache();
|
||||
static void Shutdown();
|
||||
JSObject* GetGlobal()
|
||||
{
|
||||
return mGlobal;
|
||||
}
|
||||
|
||||
void MarkScopesForCC();
|
||||
protected:
|
||||
|
@ -488,17 +484,20 @@ protected:
|
|||
~nsMessageManagerScriptExecutor() { MOZ_COUNT_DTOR(nsMessageManagerScriptExecutor); }
|
||||
|
||||
void DidCreateGlobal();
|
||||
void LoadScriptInternal(const nsAString& aURL, bool aRunInGlobalScope);
|
||||
void LoadScriptInternal(JS::Handle<JSObject*> aGlobal, const nsAString& aURL,
|
||||
bool aRunInGlobalScope);
|
||||
void TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
bool aRunInGlobalScope,
|
||||
bool aShouldCache,
|
||||
JS::MutableHandle<JSScript*> aScriptp);
|
||||
void TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
bool aRunInGlobalScope);
|
||||
bool InitChildGlobalInternal(nsISupports* aScope, const nsACString& aID);
|
||||
bool InitChildGlobalInternal(const nsACString& aID);
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) = 0;
|
||||
void Trace(const TraceCallbacks& aCallbacks, void* aClosure);
|
||||
void Unlink();
|
||||
JS::TenuredHeap<JSObject*> mGlobal;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
AutoTArray<JS::Heap<JSObject*>, 2> mAnonymousGlobalScopes;
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
#include "nsFrameLoader.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsIMozBrowserFrame.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
|
||||
|
@ -89,11 +90,11 @@ nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
|
|||
nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
|
||||
nsIContent* aOwner,
|
||||
nsFrameMessageManager* aChrome)
|
||||
: mDocShell(aShell), mInitialized(false), mLoadingScript(false),
|
||||
: ContentFrameMessageManager(aChrome),
|
||||
mDocShell(aShell), mInitialized(false), mLoadingScript(false),
|
||||
mPreventEventsEscaping(false),
|
||||
mOwner(aOwner), mChromeMessageManager(aChrome)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
||||
// If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our
|
||||
|
@ -119,7 +120,7 @@ NS_IMETHODIMP_(bool)
|
|||
nsInProcessTabChildGlobal::MarkForCC()
|
||||
{
|
||||
MarkScopesForCC();
|
||||
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
||||
return MessageManagerGlobal::MarkForCC();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -167,43 +168,69 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsInProcessTabChildGlobal)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
|
||||
|
||||
bool
|
||||
nsInProcessTabChildGlobal::WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector)
|
||||
{
|
||||
bool ok = ContentFrameMessageManagerBinding::Wrap(aCx, this, this, aOptions,
|
||||
nsJSPrincipals::get(mPrincipal),
|
||||
true, aReflector);
|
||||
if (ok) {
|
||||
// Since we can't rewrap we have to preserve the global's wrapper here.
|
||||
PreserveWrapper(ToSupports(this));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void
|
||||
nsInProcessTabChildGlobal::CacheFrameLoader(nsIFrameLoader* aFrameLoader)
|
||||
{
|
||||
mFrameLoader = aFrameLoader;
|
||||
}
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter>
|
||||
nsInProcessTabChildGlobal::GetContent(ErrorResult& aError)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindowOuter> content;
|
||||
if (mDocShell) {
|
||||
content = mDocShell->GetWindow();
|
||||
}
|
||||
return content.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetContent(mozIDOMWindowProxy** aContent)
|
||||
{
|
||||
*aContent = nullptr;
|
||||
if (!mDocShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = mDocShell->GetWindow();
|
||||
window.forget(aContent);
|
||||
return NS_OK;
|
||||
ErrorResult rv;
|
||||
*aContent = GetContent(rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
|
||||
{
|
||||
NS_IF_ADDREF(*aDocShell = mDocShell);
|
||||
return NS_OK;
|
||||
ErrorResult rv;
|
||||
*aDocShell = GetDocShell(rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
nsInProcessTabChildGlobal::GetTabEventTarget()
|
||||
{
|
||||
nsCOMPtr<nsIEventTarget> target = GetMainThreadEventTarget();
|
||||
return target.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetTabEventTarget(nsIEventTarget** aTarget)
|
||||
{
|
||||
nsCOMPtr<nsIEventTarget> target = GetMainThreadEventTarget();
|
||||
target.forget(aTarget);
|
||||
*aTarget = GetTabEventTarget().take();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -310,8 +337,7 @@ nsInProcessTabChildGlobal::InitTabChildGlobal()
|
|||
id.AppendLiteral("?ownedBy=");
|
||||
id.Append(u);
|
||||
}
|
||||
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, this);
|
||||
NS_ENSURE_STATE(InitChildGlobalInternal(scopeSupports, id));
|
||||
NS_ENSURE_STATE(InitChildGlobalInternal(id));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -351,7 +377,8 @@ nsInProcessTabChildGlobal::LoadFrameScript(const nsAString& aURL, bool aRunInGlo
|
|||
}
|
||||
bool tmp = mLoadingScript;
|
||||
mLoadingScript = true;
|
||||
LoadScriptInternal(aURL, aRunInGlobalScope);
|
||||
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper());
|
||||
LoadScriptInternal(global, aURL, aRunInGlobalScope);
|
||||
mLoadingScript = tmp;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/ContentFrameMessageManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -27,7 +28,7 @@ namespace mozilla {
|
|||
class EventChainPreVisitor;
|
||||
} // namespace mozilla
|
||||
|
||||
class nsInProcessTabChildGlobal : public mozilla::DOMEventTargetHelper,
|
||||
class nsInProcessTabChildGlobal : public mozilla::dom::ContentFrameMessageManager,
|
||||
public nsMessageManagerScriptExecutor,
|
||||
public nsIInProcessContentFrameMessageManager,
|
||||
public nsIGlobalObject,
|
||||
|
@ -46,38 +47,30 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsInProcessTabChildGlobal,
|
||||
mozilla::DOMEventTargetHelper)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("We should never get here!");
|
||||
}
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) override;
|
||||
|
||||
virtual already_AddRefed<nsPIDOMWindowOuter>
|
||||
GetContent(mozilla::ErrorResult& aError) override;
|
||||
virtual already_AddRefed<nsIDocShell>
|
||||
GetDocShell(mozilla::ErrorResult& aError) override
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell(mDocShell);
|
||||
return docShell.forget();
|
||||
}
|
||||
virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() override;
|
||||
|
||||
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager);
|
||||
NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(mMessageManager)
|
||||
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD GetContent(mozIDOMWindowProxy** aContent) override;
|
||||
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) override;
|
||||
NS_IMETHOD GetTabEventTarget(nsIEventTarget** aTarget) override;
|
||||
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
|
||||
|
||||
NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER
|
||||
|
||||
|
@ -99,26 +92,6 @@ public:
|
|||
|
||||
virtual nsresult GetEventTargetParent(
|
||||
mozilla::EventChainPreVisitor& aVisitor) override;
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture)
|
||||
{
|
||||
// By default add listeners only for trusted events!
|
||||
return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture, false,
|
||||
2);
|
||||
}
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture, bool aWantsUntrusted,
|
||||
uint8_t optional_argc) override
|
||||
{
|
||||
return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture,
|
||||
aWantsUntrusted,
|
||||
optional_argc);
|
||||
}
|
||||
using mozilla::DOMEventTargetHelper::AddEventListener;
|
||||
|
||||
virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
|
||||
void LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope);
|
||||
|
@ -143,12 +116,9 @@ public:
|
|||
mChromeMessageManager = aParent;
|
||||
}
|
||||
|
||||
virtual JSObject* GetGlobalJSObject() override {
|
||||
return mGlobal;
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
|
||||
virtual JSObject* GetGlobalJSObject() override
|
||||
{
|
||||
MOZ_CRASH("nsInProcessTabChildGlobal doesn't use DOM bindings!");
|
||||
return GetWrapper();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIFrameLoader> GetFrameLoader();
|
||||
|
@ -158,7 +128,6 @@ protected:
|
|||
|
||||
nsresult Init();
|
||||
nsresult InitTabChildGlobal();
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
bool mInitialized;
|
||||
bool mLoadingScript;
|
||||
|
|
|
@ -344,11 +344,7 @@ private:
|
|||
// Friend declarations for things that need to be able to call
|
||||
// SetIsNotDOMBinding(). The goal is to get rid of all of these, and
|
||||
// SetIsNotDOMBinding() too.
|
||||
friend class mozilla::dom::TabChildGlobal;
|
||||
friend class mozilla::dom::ProcessGlobal;
|
||||
friend class SandboxPrivate;
|
||||
friend class nsInProcessTabChildGlobal;
|
||||
friend class nsWindowRoot;
|
||||
void SetIsNotDOMBinding()
|
||||
{
|
||||
MOZ_ASSERT(!mWrapper && !(GetWrapperFlags() & ~WRAPPER_IS_NOT_DOM_BINDING),
|
||||
|
|
|
@ -3127,11 +3127,22 @@ ConvertExceptionToPromise(JSContext* cx,
|
|||
|
||||
/* static */
|
||||
void
|
||||
CreateGlobalOptions<nsGlobalWindowInner>::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
|
||||
CreateGlobalOptionsWithXPConnect::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
|
||||
{
|
||||
xpc::TraceXPCGlobal(aTrc, aObj);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
CreateGlobalOptionsWithXPConnect::PostCreateGlobal(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGlobal)
|
||||
{
|
||||
// Invoking the XPCWrappedNativeScope constructor automatically hooks it
|
||||
// up to the compartment of aGlobal.
|
||||
(void) new XPCWrappedNativeScope(aCx, aGlobal);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool sRegisteredDOMNames = false;
|
||||
|
||||
nsresult
|
||||
|
@ -3165,10 +3176,7 @@ CreateGlobalOptions<nsGlobalWindowInner>::PostCreateGlobal(JSContext* aCx,
|
|||
return Throw(aCx, rv);
|
||||
}
|
||||
|
||||
// Invoking the XPCWrappedNativeScope constructor automatically hooks it
|
||||
// up to the compartment of aGlobal.
|
||||
(void) new XPCWrappedNativeScope(aCx, aGlobal);
|
||||
return true;
|
||||
return CreateGlobalOptionsWithXPConnect::PostCreateGlobal(aCx, aGlobal);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -50,6 +50,7 @@ enum UseCounter : int16_t;
|
|||
|
||||
namespace dom {
|
||||
class CustomElementReactionsStack;
|
||||
class MessageManagerGlobal;
|
||||
template<typename KeyType, typename ValueType> class Record;
|
||||
|
||||
nsresult
|
||||
|
@ -3100,11 +3101,9 @@ bool
|
|||
EnumerateGlobal(JSContext* aCx, JS::HandleObject aObj,
|
||||
JS::AutoIdVector& aProperties, bool aEnumerableOnly);
|
||||
|
||||
template <class T>
|
||||
struct CreateGlobalOptions
|
||||
|
||||
struct CreateGlobalOptionsGeneric
|
||||
{
|
||||
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
|
||||
ProtoAndIfaceCache::NonWindowLike;
|
||||
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj)
|
||||
{
|
||||
mozilla::dom::TraceProtoAndIfaceCache(aTrc, aObj);
|
||||
|
@ -3117,12 +3116,34 @@ struct CreateGlobalOptions
|
|||
}
|
||||
};
|
||||
|
||||
struct CreateGlobalOptionsWithXPConnect
|
||||
{
|
||||
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj);
|
||||
static bool PostCreateGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
using IsGlobalWithXPConnect =
|
||||
IntegralConstant<bool,
|
||||
IsBaseOf<nsGlobalWindowInner, T>::value ||
|
||||
IsBaseOf<MessageManagerGlobal, T>::value>;
|
||||
|
||||
template <class T>
|
||||
struct CreateGlobalOptions
|
||||
: Conditional<IsGlobalWithXPConnect<T>::value,
|
||||
CreateGlobalOptionsWithXPConnect,
|
||||
CreateGlobalOptionsGeneric>::Type
|
||||
{
|
||||
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
|
||||
ProtoAndIfaceCache::NonWindowLike;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CreateGlobalOptions<nsGlobalWindowInner>
|
||||
: public CreateGlobalOptionsWithXPConnect
|
||||
{
|
||||
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
|
||||
ProtoAndIfaceCache::WindowLike;
|
||||
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj);
|
||||
static bool PostCreateGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
};
|
||||
|
||||
|
|
|
@ -151,6 +151,10 @@ DOMInterfaces = {
|
|||
'implicitJSContext': ['clear', 'count', 'groupEnd', 'time', 'timeEnd'],
|
||||
},
|
||||
|
||||
'ContentProcessMessageManager': {
|
||||
'nativeType': 'mozilla::dom::ProcessGlobal'
|
||||
},
|
||||
|
||||
'ConvolverNode': {
|
||||
'implicitJSContext': [ 'buffer' ],
|
||||
},
|
||||
|
@ -1725,6 +1729,7 @@ addExternalIface('MozTreeView', nativeType='nsITreeView',
|
|||
addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')
|
||||
addExternalIface('nsIBrowserDOMWindow', nativeType='nsIBrowserDOMWindow',
|
||||
notflattened=True)
|
||||
addExternalIface('nsIEventTarget', nativeType='nsIEventTarget', notflattened=True)
|
||||
addExternalIface('nsIFile', nativeType='nsIFile', notflattened=True)
|
||||
addExternalIface('nsILoadGroup', nativeType='nsILoadGroup',
|
||||
headerFile='nsILoadGroup.h', notflattened=True)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
interface MozFrameLoader;
|
||||
interface nsIEventTarget;
|
||||
interface Principal;
|
||||
|
||||
dictionary ReceiveMessageArgument
|
||||
|
@ -194,6 +195,31 @@ interface ChildProcessMessageManager : SyncMessageSender
|
|||
{
|
||||
};
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface MessageManagerGlobal : SyncMessageSender
|
||||
{
|
||||
/**
|
||||
* Print a string to stdout.
|
||||
*/
|
||||
[Throws]
|
||||
void dump(DOMString str);
|
||||
|
||||
/**
|
||||
* If leak detection is enabled, print a note to the leak log that this
|
||||
* process will intentionally crash.
|
||||
*/
|
||||
[Throws]
|
||||
void privateNoteIntentionalCrash();
|
||||
|
||||
/**
|
||||
* Ascii base64 data to binary data and vice versa
|
||||
*/
|
||||
[Throws]
|
||||
DOMString atob(DOMString asciiString);
|
||||
[Throws]
|
||||
DOMString btoa(DOMString base64Data);
|
||||
};
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface FrameScriptLoader
|
||||
{
|
||||
|
@ -268,6 +294,47 @@ interface GlobalProcessScriptLoader : ProcessScriptLoader
|
|||
readonly attribute any initialProcessData;
|
||||
};
|
||||
|
||||
[ChromeOnly, Global, NeedResolve]
|
||||
interface ContentFrameMessageManager : EventTarget
|
||||
{
|
||||
/**
|
||||
* The current top level window in the frame or null.
|
||||
*/
|
||||
[Throws]
|
||||
readonly attribute WindowProxy? content;
|
||||
|
||||
/**
|
||||
* The top level docshell or null.
|
||||
*/
|
||||
[Throws]
|
||||
readonly attribute nsIDocShell? docShell;
|
||||
|
||||
/**
|
||||
* Returns the SchedulerEventTarget corresponding to the TabGroup
|
||||
* for this frame.
|
||||
*/
|
||||
readonly attribute nsIEventTarget? tabEventTarget;
|
||||
};
|
||||
// MessageManagerGlobal inherits from SyncMessageSender, which is a real interface, not a
|
||||
// mixin. This will need to change when we implement mixins according to the current
|
||||
// WebIDL spec.
|
||||
ContentFrameMessageManager implements MessageManagerGlobal;
|
||||
|
||||
[ChromeOnly, Global, NeedResolve]
|
||||
interface ContentProcessMessageManager
|
||||
{
|
||||
/**
|
||||
* Read out a copy of the object that was initialized in the parent
|
||||
* process via ProcessScriptLoader.initialProcessData.
|
||||
*/
|
||||
[Throws]
|
||||
readonly attribute any initialProcessData;
|
||||
};
|
||||
// MessageManagerGlobal inherits from SyncMessageSender, which is a real interface, not a
|
||||
// mixin. This will need to change when we implement mixins according to the current
|
||||
// WebIDL spec.
|
||||
ContentProcessMessageManager implements MessageManagerGlobal;
|
||||
|
||||
[ChromeOnly]
|
||||
interface ChromeMessageBroadcaster : MessageListenerManager
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/dom/DataTransfer.h"
|
||||
#include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
#include "mozilla/dom/MouseEventBinding.h"
|
||||
#include "mozilla/dom/PaymentRequestChild.h"
|
||||
#include "mozilla/dom/TelemetryScrollProbe.h"
|
||||
|
@ -105,7 +106,6 @@
|
|||
#include "UnitTransforms.h"
|
||||
#include "ClientLayerManager.h"
|
||||
#include "LayersLogging.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsColorPickerProxy.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
@ -237,11 +237,10 @@ TabChildBase::DispatchMessageManagerMessage(const nsAString& aMessageName,
|
|||
}
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(cx, GetGlobal());
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(cx, mTabChildGlobal->GetWrapper());
|
||||
// Let the BrowserElementScrolling helper (if it exists) for this
|
||||
// content manipulate the frame state.
|
||||
RefPtr<nsFrameMessageManager> mm =
|
||||
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
||||
RefPtr<nsFrameMessageManager> mm = mTabChildGlobal->GetMessageManager();
|
||||
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
|
||||
aMessageName, false, &data, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
@ -273,7 +272,7 @@ TabChildBase::UpdateFrameHandler(const FrameMetrics& aFrameMetrics)
|
|||
void
|
||||
TabChildBase::ProcessUpdateFrame(const FrameMetrics& aFrameMetrics)
|
||||
{
|
||||
if (!mGlobal || !mTabChildGlobal) {
|
||||
if (!mTabChildGlobal) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1110,13 +1109,11 @@ TabChild::ActorDestroy(ActorDestroyReason why)
|
|||
// We should have a message manager if the global is alive, but it
|
||||
// seems sometimes we don't. Assert in aurora/nightly, but don't
|
||||
// crash in release builds.
|
||||
MOZ_DIAGNOSTIC_ASSERT(mTabChildGlobal->mMessageManager);
|
||||
if (mTabChildGlobal->mMessageManager) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mTabChildGlobal->GetMessageManager());
|
||||
if (mTabChildGlobal->GetMessageManager()) {
|
||||
// The messageManager relays messages via the TabChild which
|
||||
// no longer exists.
|
||||
static_cast<nsFrameMessageManager*>
|
||||
(mTabChildGlobal->mMessageManager.get())->Disconnect();
|
||||
mTabChildGlobal->mMessageManager = nullptr;
|
||||
mTabChildGlobal->DisconnectMessageManager();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1363,9 +1360,11 @@ TabChild::HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
|
|||
const ScrollableLayerGuid& aGuid)
|
||||
{
|
||||
TABC_LOG("Handling double tap at %s with %p %p\n",
|
||||
Stringify(aPoint).c_str(), mGlobal.get(), mTabChildGlobal.get());
|
||||
Stringify(aPoint).c_str(),
|
||||
mTabChildGlobal ? mTabChildGlobal->GetWrapper() : nullptr,
|
||||
mTabChildGlobal.get());
|
||||
|
||||
if (!mGlobal || !mTabChildGlobal) {
|
||||
if (!mTabChildGlobal || !mTabChildGlobal->GetWrapper()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1406,7 +1405,7 @@ TabChild::RecvHandleTap(const GeckoContentController::TapType& aType,
|
|||
|
||||
switch (aType) {
|
||||
case GeckoContentController::TapType::eSingleTap:
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
if (mTabChildGlobal) {
|
||||
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, aGuid, 1);
|
||||
}
|
||||
break;
|
||||
|
@ -1414,18 +1413,18 @@ TabChild::RecvHandleTap(const GeckoContentController::TapType& aType,
|
|||
HandleDoubleTap(point, aModifiers, aGuid);
|
||||
break;
|
||||
case GeckoContentController::TapType::eSecondTap:
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
if (mTabChildGlobal) {
|
||||
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, aGuid, 2);
|
||||
}
|
||||
break;
|
||||
case GeckoContentController::TapType::eLongTap:
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
if (mTabChildGlobal) {
|
||||
mAPZEventState->ProcessLongTap(presShell, point, scale, aModifiers, aGuid,
|
||||
aInputBlockId);
|
||||
}
|
||||
break;
|
||||
case GeckoContentController::TapType::eLongTapUp:
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
if (mTabChildGlobal) {
|
||||
mAPZEventState->ProcessLongTapUp(presShell, point, scale, aModifiers);
|
||||
}
|
||||
break;
|
||||
|
@ -2278,12 +2277,18 @@ TabChild::RecvActivateFrameEvent(const nsString& aType, const bool& capture)
|
|||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvLoadRemoteScript(const nsString& aURL, const bool& aRunInGlobalScope)
|
||||
{
|
||||
if (!mGlobal && !InitTabChildGlobal())
|
||||
if (!InitTabChildGlobal())
|
||||
// This can happen if we're half-destroyed. It's not a fatal
|
||||
// error.
|
||||
return IPC_OK();
|
||||
|
||||
LoadScriptInternal(aURL, aRunInGlobalScope);
|
||||
JS::Rooted<JSObject*> global(RootingCx(), mTabChildGlobal->GetWrapper());
|
||||
if (!global) {
|
||||
// This can happen if we're half-destroyed. It's not a fatal error.
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
LoadScriptInternal(global, aURL, aRunInGlobalScope);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -2301,19 +2306,19 @@ TabChild::RecvAsyncMessage(const nsString& aMessage,
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
RefPtr<nsFrameMessageManager> mm = mTabChildGlobal->GetMessageManager();
|
||||
|
||||
// We should have a message manager if the global is alive, but it
|
||||
// seems sometimes we don't. Assert in aurora/nightly, but don't
|
||||
// crash in release builds.
|
||||
MOZ_DIAGNOSTIC_ASSERT(mTabChildGlobal->mMessageManager);
|
||||
if (!mTabChildGlobal->mMessageManager) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mm);
|
||||
if (!mm) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), GetGlobal());
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), mTabChildGlobal->GetWrapper());
|
||||
StructuredCloneData data;
|
||||
UnpackClonedMessageDataForChild(aData, data);
|
||||
RefPtr<nsFrameMessageManager> mm =
|
||||
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
||||
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
|
||||
aMessage, false, &data, &cpows, aPrincipal, nullptr);
|
||||
return IPC_OK();
|
||||
|
@ -2723,27 +2728,29 @@ TabChild::DeallocPRenderFrameChild(PRenderFrameChild* aFrame)
|
|||
bool
|
||||
TabChild::InitTabChildGlobal()
|
||||
{
|
||||
if (!mGlobal && !mTabChildGlobal) {
|
||||
if (!mTabChildGlobal) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
||||
NS_ENSURE_TRUE(window, false);
|
||||
nsCOMPtr<EventTarget> chromeHandler =
|
||||
do_QueryInterface(window->GetChromeEventHandler());
|
||||
NS_ENSURE_TRUE(chromeHandler, false);
|
||||
|
||||
RefPtr<TabChildGlobal> scope = new TabChildGlobal(this);
|
||||
|
||||
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, scope);
|
||||
RefPtr<TabChildGlobal> scope = mTabChildGlobal = new TabChildGlobal(this);
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(globalId, "outOfProcessTabChildGlobal");
|
||||
NS_ENSURE_TRUE(InitChildGlobalInternal(scopeSupports, globalId), false);
|
||||
if (NS_WARN_IF(!InitChildGlobalInternal(globalId))) {
|
||||
mTabChildGlobal = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
scope->Init();
|
||||
|
||||
nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler);
|
||||
NS_ENSURE_TRUE(root, false);
|
||||
if (NS_WARN_IF(!root)) {
|
||||
mTabChildGlobal = nullptr;
|
||||
return false;
|
||||
}
|
||||
root->SetParentTarget(scope);
|
||||
|
||||
mTabChildGlobal = scope.forget();;
|
||||
}
|
||||
|
||||
if (!mTriedBrowserInit) {
|
||||
|
@ -3479,9 +3486,9 @@ TabChild::TabGroup()
|
|||
}
|
||||
|
||||
TabChildGlobal::TabChildGlobal(TabChild* aTabChild)
|
||||
: mTabChild(aTabChild)
|
||||
: ContentFrameMessageManager(new nsFrameMessageManager(aTabChild)),
|
||||
mTabChild(aTabChild)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
}
|
||||
|
||||
TabChildGlobal::~TabChildGlobal()
|
||||
|
@ -3491,9 +3498,6 @@ TabChildGlobal::~TabChildGlobal()
|
|||
void
|
||||
TabChildGlobal::Init()
|
||||
{
|
||||
NS_ASSERTION(!mMessageManager, "Re-initializing?!?");
|
||||
mMessageManager = new nsFrameMessageManager(mTabChild);
|
||||
|
||||
TelemetryScrollProbe::Create(this);
|
||||
}
|
||||
|
||||
|
@ -3521,12 +3525,26 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabChildGlobal)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
||||
|
||||
bool
|
||||
TabChildGlobal::WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector)
|
||||
{
|
||||
bool ok = ContentFrameMessageManagerBinding::Wrap(aCx, this, this, aOptions,
|
||||
nsJSPrincipals::get(mTabChild->GetPrincipal()),
|
||||
true, aReflector);
|
||||
if (ok) {
|
||||
// Since we can't rewrap we have to preserve the global's wrapper here.
|
||||
PreserveWrapper(ToSupports(this));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
// This method isn't automatically forwarded safely because it's notxpcom, so
|
||||
// the IDL binding doesn't know what value to return.
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
@ -3539,36 +3557,59 @@ TabChildGlobal::MarkForCC()
|
|||
if (elm) {
|
||||
elm->MarkForCC();
|
||||
}
|
||||
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
||||
return MessageManagerGlobal::MarkForCC();
|
||||
}
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter>
|
||||
TabChildGlobal::GetContent(ErrorResult& aError)
|
||||
{
|
||||
if (!mTabChild) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window =
|
||||
do_GetInterface(mTabChild->WebNavigation());
|
||||
return window.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabChildGlobal::GetContent(mozIDOMWindowProxy** aContent)
|
||||
{
|
||||
*aContent = nullptr;
|
||||
if (!mTabChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(mTabChild->WebNavigation());
|
||||
window.forget(aContent);
|
||||
return NS_OK;
|
||||
ErrorResult rv;
|
||||
*aContent = GetContent(rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDocShell>
|
||||
TabChildGlobal::GetDocShell(ErrorResult& aError)
|
||||
{
|
||||
if (!mTabChild) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<nsIDocShell> window = do_GetInterface(mTabChild->WebNavigation());
|
||||
return window.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
|
||||
{
|
||||
*aDocShell = nullptr;
|
||||
if (!mTabChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mTabChild->WebNavigation());
|
||||
docShell.swap(*aDocShell);
|
||||
return NS_OK;
|
||||
ErrorResult rv;
|
||||
*aDocShell = GetDocShell(rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
TabChildGlobal::GetTabEventTarget()
|
||||
{
|
||||
nsCOMPtr<nsIEventTarget> target = EventTargetFor(TaskCategory::Other);
|
||||
return target.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabChildGlobal::GetTabEventTarget(nsIEventTarget** aTarget)
|
||||
{
|
||||
nsCOMPtr<nsIEventTarget> target = EventTargetFor(TaskCategory::Other);
|
||||
target.forget(aTarget);
|
||||
*aTarget = GetTabEventTarget().take();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3584,7 +3625,7 @@ JSObject*
|
|||
TabChildGlobal::GetGlobalJSObject()
|
||||
{
|
||||
NS_ENSURE_TRUE(mTabChild, nullptr);
|
||||
return mTabChild->GetGlobal();
|
||||
return GetWrapper();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef mozilla_dom_TabChild_h
|
||||
#define mozilla_dom_TabChild_h
|
||||
|
||||
#include "mozilla/dom/ContentFrameMessageManager.h"
|
||||
#include "mozilla/dom/PBrowserChild.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -78,7 +79,7 @@ class ClonedMessageData;
|
|||
class CoalescedMouseData;
|
||||
class CoalescedWheelData;
|
||||
|
||||
class TabChildGlobal : public DOMEventTargetHelper,
|
||||
class TabChildGlobal : public ContentFrameMessageManager,
|
||||
public nsIContentFrameMessageManager,
|
||||
public nsIScriptObjectPrincipal,
|
||||
public nsIGlobalObject,
|
||||
|
@ -89,58 +90,25 @@ public:
|
|||
void Init();
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("We should never get here!");
|
||||
}
|
||||
bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector);
|
||||
|
||||
virtual already_AddRefed<nsPIDOMWindowOuter> GetContent(ErrorResult& aError) override;
|
||||
virtual already_AddRefed<nsIDocShell> GetDocShell(ErrorResult& aError) override;
|
||||
virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() override;
|
||||
|
||||
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager);
|
||||
NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(mMessageManager)
|
||||
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD GetContent(mozIDOMWindowProxy** aContent) override;
|
||||
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) override;
|
||||
NS_IMETHOD GetTabEventTarget(nsIEventTarget** aTarget) override;
|
||||
|
||||
nsresult AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture)
|
||||
{
|
||||
// By default add listeners only for trusted events!
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture, false, 2);
|
||||
}
|
||||
using DOMEventTargetHelper::AddEventListener;
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture, bool aWantsUntrusted,
|
||||
uint8_t optional_argc) override
|
||||
{
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture,
|
||||
aWantsUntrusted,
|
||||
optional_argc);
|
||||
}
|
||||
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
|
||||
|
||||
nsresult
|
||||
GetEventTargetParent(EventChainPreVisitor& aVisitor) override
|
||||
|
@ -152,11 +120,6 @@ public:
|
|||
virtual nsIPrincipal* GetPrincipal() override;
|
||||
virtual JSObject* GetGlobalJSObject() override;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("TabChildGlobal doesn't use DOM bindings!");
|
||||
}
|
||||
|
||||
// Dispatch a runnable related to the global.
|
||||
virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
|
||||
already_AddRefed<nsIRunnable>&& aRunnable) override;
|
||||
|
@ -167,7 +130,6 @@ public:
|
|||
virtual AbstractThread*
|
||||
AbstractMainThreadFor(mozilla::TaskCategory aCategory) override;
|
||||
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
|
||||
RefPtr<TabChild> mTabChild;
|
||||
|
||||
protected:
|
||||
|
@ -202,6 +164,13 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TabChildBase)
|
||||
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) override
|
||||
{
|
||||
return mTabChildGlobal->WrapGlobalObject(aCx, aOptions, aReflector);
|
||||
}
|
||||
|
||||
virtual nsIWebNavigation* WebNavigation() const = 0;
|
||||
virtual PuppetWidget* WebWidget() = 0;
|
||||
nsIPrincipal* GetPrincipal() { return mPrincipal; }
|
||||
|
|
|
@ -26,6 +26,8 @@ ChildProcessMessageManager implements LegacyQueryInterface;
|
|||
ChromeMessageBroadcaster implements LegacyQueryInterface;
|
||||
ChromeMessageSender implements LegacyQueryInterface;
|
||||
Comment implements LegacyQueryInterface;
|
||||
ContentFrameMessageManager implements LegacyQueryInterface;
|
||||
ContentProcessMessageManager implements LegacyQueryInterface;
|
||||
Crypto implements LegacyQueryInterface;
|
||||
CSSMozDocumentRule implements LegacyQueryInterface;
|
||||
CSSPrimitiveValue implements LegacyQueryInterface;
|
||||
|
|
Загрузка…
Ссылка в новой задаче