Backed out 3 changesets (bug 1479569) for devtools/client/responsive.html failures. CLOSED TREE

Backed out changeset e123d0aa911c (bug 1479569)
Backed out changeset b828a58404e5 (bug 1479569)
Backed out changeset 97041ef8f311 (bug 1479569)
This commit is contained in:
Csoregi Natalia 2018-08-03 10:39:12 +03:00
Родитель 1d8637da03
Коммит 08c950712e
57 изменённых файлов: 266 добавлений и 167 удалений

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

@ -75,8 +75,10 @@ function FeedWriter() {
Services.telemetry.scalarAdd("browser.feeds.preview_loaded", 1);
XPCOMUtils.defineLazyGetter(this, "_mm",
() => this._window.docShell.messageManager);
XPCOMUtils.defineLazyGetter(this, "_mm", () =>
this._window.docShell.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIContentFrameMessageManager));
}
FeedWriter.prototype = {

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

@ -18,7 +18,10 @@ add_task(async function init() {
function frameScript() {
// Make send[A]syncMessage("SessionStore:update", ...) simulate OOM.
// Other operations are unaffected.
let mm = docShell.messageManager;
let mm = docShell.sameTypeRootTreeItem.
QueryInterface(Ci.nsIDocShell).
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIContentFrameMessageManager);
let wrap = function(original) {
return function(name, ...args) {

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

@ -266,7 +266,9 @@ let ProfileAutocomplete = {
},
_frameMMFromWindow(contentWindow) {
return contentWindow.docShell.messageManager;
return contentWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
},
_getSelectedIndex(contentWindow) {
@ -628,7 +630,9 @@ var FormAutofillContent = {
},
_messageManagerFromWindow(win) {
return win.docShell.messageManager;
return win.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
},
_onKeyDown(e) {

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

@ -412,7 +412,9 @@ class ChromeActions {
getLocalizedString(strings, "open_with_different_viewer"),
getLocalizedString(strings, "open_with_different_viewer", "accessKey"));
let winmm = domWindow.docShell.messageManager;
let winmm = domWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.addMessageListener("PDFJS:Child:fallbackDownload",
function fallbackDownload(msg) {
@ -437,7 +439,9 @@ class ChromeActions {
return;
}
var winmm = this.domWindow.docShell.messageManager;
var winmm = this.domWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.sendAsyncMessage("PDFJS:Parent:updateControlState", data);
}
@ -751,7 +755,9 @@ class RequestListener {
class FindEventManager {
constructor(contentWindow) {
this.contentWindow = contentWindow;
this.winmm = contentWindow.docShell.messageManager;
this.winmm = contentWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}
bind() {

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

@ -72,7 +72,9 @@ var PdfjsContentUtils = {
*/
displayWarning(aWindow, aMessage, aLabel, aAccessKey) {
// the child's dom frame mm associated with the window.
let winmm = aWindow.docShell.messageManager;
let winmm = aWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.sendAsyncMessage("PDFJS:Parent:displayWarning", {
message: aMessage,
label: aLabel,

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

@ -37,7 +37,18 @@ var gDecoderDoctorObserver = function(subject, topic, data) {
};
function getMessageManagerForWindow(aContentWindow) {
return aContentWindow.docShell.messageManager;
let ir = aContentWindow.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor);
try {
// If e10s is disabled, this throws NS_NOINTERFACE for closed tabs.
return ir.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
if (e.result == Cr.NS_NOINTERFACE) {
return null;
}
throw e;
}
}
Services.obs.addObserver(gEMEUIObserver, "mediakeys-request");

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

@ -425,5 +425,15 @@ function getMessageManagerForWindow(aContentWindow) {
return null;
}
return docShell.messageManager;
let ir = docShell.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor);
try {
// This throws NS_NOINTERFACE for closed tabs (only with e10s enabled).
return ir.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
if (e.result == Cr.NS_NOINTERFACE) {
return null;
}
throw e;
}
}

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

@ -36,7 +36,10 @@ FormSubmitObserver.prototype =
this._content = aWindow;
this._tab = aTabChildGlobal;
this._mm =
this._content.docShell.messageManager;
this._content.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
this._tab.addEventListener("pageshow", this);
this._tab.addEventListener("unload", this);

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

@ -51,5 +51,8 @@ var LightWeightThemeWebInstallListener = {
};
function getMessageManagerForContent(content) {
return content.docShell.messageManager;
return content.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}

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

@ -41,7 +41,10 @@ var LightweightThemeChildHelper = {
const windowEnumerator = Services.ww.getWindowEnumerator();
while (windowEnumerator.hasMoreElements()) {
const window = windowEnumerator.getNext().QueryInterface(Ci.nsIDOMWindow);
const tabChildGlobal = window.docShell.messageManager;
const tabChildGlobal = window.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
const {chromeOuterWindowID, content} = tabChildGlobal;
if (changedKeys.includes(`theme/${chromeOuterWindowID}`) &&
content && this.whitelist.has(content.document.documentURI)) {

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

@ -50,7 +50,9 @@ var PageStyleHandler = {
return;
}
let mm = win.docShell.messageManager;
let mm = win.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
this.sendStyleSheetInfo(mm);
},

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

@ -472,7 +472,8 @@ MessageManagerTunnel.prototype = {
// non-remote, so we're able to reach into its window and use the child
// side message manager there.
const docShell = this.outer[FRAME_LOADER].docShell;
return docShell.messageManager;
return docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
},
get inner() {

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

@ -314,7 +314,13 @@ const browsingContextTargetPrototype = {
* Getter for the nsIMessageManager associated to the browsing context.
*/
get messageManager() {
return this.docShell.messageManager;
try {
return this.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
return null;
}
},
/**

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

@ -42,7 +42,10 @@ function ContentProcessTargetActor(connection) {
const windowEnumerator = Services.ww.getWindowEnumerator();
while (windowEnumerator.hasMoreElements()) {
const window = windowEnumerator.getNext().QueryInterface(Ci.nsIDOMWindow);
const tabChildGlobal = window.docShell.messageManager;
const tabChildGlobal = window.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
tabs.push(tabChildGlobal);
}
return tabs;

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

@ -39,7 +39,6 @@
#include "mozilla/dom/ClientManager.h"
#include "mozilla/dom/ClientSource.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLAnchorElement.h"
@ -639,6 +638,17 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
} else if (aIID.Equals(NS_GET_IID(nsITabChild))) {
*aSink = GetTabChild().take();
return *aSink ? NS_OK : NS_ERROR_FAILURE;
} else if (aIID.Equals(NS_GET_IID(nsIContentFrameMessageManager))) {
RefPtr<TabChild> tabChild = TabChild::GetFrom(this);
nsCOMPtr<nsIContentFrameMessageManager> mm;
if (tabChild) {
mm = tabChild->GetMessageManager();
} else {
if (nsPIDOMWindowOuter* win = GetWindow()) {
mm = do_QueryInterface(win->GetParentTarget());
}
}
*aSink = mm.get();
} else {
return nsDocLoader::GetInterface(aIID, aSink);
}
@ -3966,19 +3976,6 @@ nsDocShell::GetDomWindow(mozIDOMWindowProxy** aWindow)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetMessageManager(ContentFrameMessageManager** aMessageManager)
{
RefPtr<ContentFrameMessageManager> mm;
if (RefPtr<TabChild> tabChild = TabChild::GetFrom(this)) {
mm = tabChild->GetMessageManager();
} else if (nsPIDOMWindowOuter* win = GetWindow()) {
mm = win->GetMessageManager();
}
mm.forget(aMessageManager);
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetDeviceSizeIsPageSize(bool aValue)
{

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

@ -65,7 +65,6 @@ interface nsILoadURIDelegate;
native TabChildRef(already_AddRefed<nsITabChild>);
native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
webidl ContentFrameMessageManager;
webidl EventTarget;
[scriptable, builtinclass, uuid(049234fe-da10-478b-bc5d-bc6f9a1ba63d)]
@ -1201,10 +1200,4 @@ interface nsIDocShell : nsIDocShellTreeItem
* Media queries only look at the value in the top-most docshell.
*/
attribute unsigned long displayMode;
/**
* The message manager for this docshell. This does not throw, but
* can return null if the docshell has no message manager.
*/
[infallible] readonly attribute ContentFrameMessageManager messageManager;
};

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

@ -6,7 +6,6 @@
#include "mozilla/dom/ChildSHistory.h"
#include "mozilla/dom/ChildSHistoryBinding.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "nsIMessageManager.h"
#include "nsComponentManagerUtils.h"
#include "nsSHistory.h"
@ -21,7 +20,6 @@ ChildSHistory::ChildSHistory(nsDocShell* aDocShell)
: mDocShell(aDocShell)
, mHistory(new nsSHistory())
{
MOZ_ASSERT(mDocShell);
mHistory->SetRootDocShell(mDocShell);
}
@ -133,13 +131,10 @@ nsISupports*
ChildSHistory::GetParentObject() const
{
// We want to get the TabChildGlobal, which is the
// messageManager on mDocShell.
RefPtr<ContentFrameMessageManager> mm;
if (mDocShell) {
mm = mDocShell->GetMessageManager();
}
// else we must be unlinked... can that happen here?
return ToSupports(mm);
// nsIContentFrameMessageManager on mDocShell.
nsCOMPtr<nsIContentFrameMessageManager> mm =
do_GetInterface(static_cast<nsIDocShell*>(mDocShell));
return mm;
}
} // namespace dom

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

@ -31,7 +31,6 @@
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/ChromeMessageBroadcaster.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ParentProcessMessageManager.h"
#include "mozilla/dom/ProcessGlobal.h"
@ -120,11 +119,11 @@ MarkChildMessageManagers(MessageBroadcaster* aMM)
mozilla::dom::ipc::MessageManagerCallback* cb = tabMM->GetCallback();
if (cb) {
nsFrameLoader* fl = static_cast<nsFrameLoader*>(cb);
nsInProcessTabChildGlobal* et = fl->GetTabChildGlobal();
EventTarget* et = fl->GetTabChildGlobalAsEventTarget();
if (!et) {
continue;
}
et->MarkForCC();
static_cast<nsInProcessTabChildGlobal*>(et)->MarkForCC();
EventListenerManager* elm = et->GetExistingListenerManager();
if (elm) {
elm->MarkForCC();
@ -509,13 +508,14 @@ mozilla::dom::TraceBlackJS(JSTracer* aTrc, bool aIsShutdownGC)
if (ds) {
nsCOMPtr<nsITabChild> tabChild = ds->GetTabChild();
if (tabChild) {
RefPtr<ContentFrameMessageManager> mm;
nsCOMPtr<nsISupports> mm;
tabChild->GetMessageManager(getter_AddRefs(mm));
if (mm) {
nsCOMPtr<EventTarget> et = do_QueryInterface(mm);
if (et) {
nsCOMPtr<nsISupports> tabChildAsSupports =
do_QueryInterface(tabChild);
mozilla::TraceScriptHolder(tabChildAsSupports, aTrc);
EventListenerManager* elm = mm->GetExistingListenerManager();
EventListenerManager* elm = et->GetExistingListenerManager();
if (elm) {
elm->TraceListeners(aTrc);
}

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

@ -121,7 +121,6 @@
#include "nsHtml5StringParser.h"
#include "nsHTMLDocument.h"
#include "nsHTMLTags.h"
#include "nsInProcessTabChildGlobal.h"
#include "nsIAddonPolicyService.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIAsyncVerifyRedirectCallback.h"
@ -11088,8 +11087,8 @@ nsContentUtils::ContentIsLink(nsIContent* aContent)
kNameSpaceID_XLink, nsGkAtoms::type, nsGkAtoms::simple, eCaseMatters);
}
/* static */ already_AddRefed<ContentFrameMessageManager>
nsContentUtils::TryGetTabChildGlobal(nsISupports* aFrom)
/* static */ already_AddRefed<EventTarget>
nsContentUtils::TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom)
{
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(aFrom);
if (!frameLoaderOwner) {
@ -11101,8 +11100,8 @@ nsContentUtils::TryGetTabChildGlobal(nsISupports* aFrom)
return nullptr;
}
RefPtr<ContentFrameMessageManager> manager = frameLoader->GetTabChildGlobal();
return manager.forget();
nsCOMPtr<EventTarget> target = frameLoader->GetTabChildGlobalAsEventTarget();
return target.forget();
}
/* static */ uint32_t

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

@ -124,7 +124,6 @@ class EventListenerManager;
class HTMLEditor;
namespace dom {
class ContentFrameMessageManager;
struct CustomElementDefinition;
class DocumentFragment;
class Element;
@ -3243,8 +3242,8 @@ public:
static bool ContentIsLink(nsIContent* aContent);
static already_AddRefed<mozilla::dom::ContentFrameMessageManager>
TryGetTabChildGlobal(nsISupports* aFrom);
static already_AddRefed<mozilla::dom::EventTarget>
TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom);
static PopupControlState
PushPopupControlState(PopupControlState aState, bool aForce)

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

@ -2820,7 +2820,8 @@ nsFrameLoader::DoLoadMessageManagerScript(const nsAString& aURL, bool aRunInGlob
if (tabParent) {
return tabParent->SendLoadRemoteScript(nsString(aURL), aRunInGlobalScope);
}
RefPtr<nsInProcessTabChildGlobal> tabChild = GetTabChildGlobal();
RefPtr<nsInProcessTabChildGlobal> tabChild =
static_cast<nsInProcessTabChildGlobal*>(GetTabChildGlobalAsEventTarget());
if (tabChild) {
tabChild->LoadFrameScript(aURL, aRunInGlobalScope);
}
@ -2978,6 +2979,12 @@ nsFrameLoader::ReallyLoadFrameScripts()
return NS_OK;
}
EventTarget*
nsFrameLoader::GetTabChildGlobalAsEventTarget()
{
return mChildMessageManager.get();
}
already_AddRefed<Element>
nsFrameLoader::GetOwnerElement()
{

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

@ -106,10 +106,7 @@ public:
void DestroyDocShell();
void DestroyComplete();
nsIDocShell* GetExistingDocShell() { return mDocShell; }
nsInProcessTabChildGlobal* GetTabChildGlobal() const
{
return mChildMessageManager;
}
mozilla::dom::EventTarget* GetTabChildGlobalAsEventTarget();
nsresult CreateStaticClone(nsFrameLoader* aDest);
nsresult UpdatePositionAndSize(nsSubDocumentFrame *aIFrame);

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

@ -145,7 +145,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentFrameMessageManager)
/* Message managers in child process implement nsIMessageSender.
Message managers in the chrome process are
@ -153,6 +153,9 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager)
managers) or they're simple message senders. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIMessageSender, !mChrome || !mIsBroadcaster)
/* nsIContentFrameMessageManager is accessible only in TabChildGlobal. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIContentFrameMessageManager,
!mChrome && !mIsProcessManager)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameMessageManager)

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

@ -161,7 +161,7 @@ private:
JS::Rooted<JSObject*> mObj;
};
class nsFrameMessageManager : public nsIMessageSender
class nsFrameMessageManager : public nsIContentFrameMessageManager
{
friend class mozilla::dom::MessageManagerReporter;
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
@ -180,7 +180,8 @@ public:
{}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsFrameMessageManager)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsFrameMessageManager,
nsIContentFrameMessageManager)
void MarkForCC();
@ -242,6 +243,7 @@ public:
mozilla::dom::ipc::WritableSharedMap* SharedData();
NS_DECL_NSIMESSAGESENDER
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
static mozilla::dom::ProcessMessageManager* NewProcessMessageManager(bool aIsRemote);

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

@ -18,7 +18,6 @@
#include "nsDOMNavigationTiming.h"
#include "nsIDOMStorageManager.h"
#include "mozilla/AutoplayPermissionManager.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/DOMJSProxyHandler.h"
#include "mozilla/dom/DOMPrefs.h"
#include "mozilla/dom/EventTarget.h"
@ -1911,18 +1910,20 @@ nsGlobalWindowInner::UpdateParentTarget()
nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal();
nsCOMPtr<EventTarget> eventTarget =
nsContentUtils::TryGetTabChildGlobal(frameElement);
nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement);
if (!eventTarget) {
nsGlobalWindowOuter* topWin = GetScriptableTopInternal();
if (topWin) {
frameElement = topWin->AsOuter()->GetFrameElementInternal();
eventTarget = nsContentUtils::TryGetTabChildGlobal(frameElement);
eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement);
}
}
if (!eventTarget) {
eventTarget = nsContentUtils::TryGetTabChildGlobal(mChromeEventHandler);
eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(mChromeEventHandler);
}
if (!eventTarget) {

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

@ -20,7 +20,6 @@
#include "nsISecureBrowserUI.h"
#include "nsIWebProgressListener.h"
#include "mozilla/AntiTrackingCommon.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/LocalStorage.h"
#include "mozilla/dom/Storage.h"
@ -1039,7 +1038,6 @@ nsGlobalWindowOuter::CleanUp()
}
mChromeEventHandler = nullptr; // Forces Release
mParentTarget = nullptr;
mMessageManager = nullptr;
mArguments = nullptr;
@ -1146,7 +1144,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindowOuter)
// Traverse stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessageManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOpenerForInitialContentBrowser)
@ -1173,7 +1170,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowOuter)
// Unlink stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessageManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOpenerForInitialContentBrowser)
@ -2240,10 +2236,9 @@ nsGlobalWindowOuter::SetOpenerWindow(nsPIDOMWindowOuter* aOpener,
void
nsGlobalWindowOuter::UpdateParentTarget()
{
// NOTE: This method is nearly identical to
// NOTE: This method is identical to
// nsGlobalWindowInner::UpdateParentTarget(). IF YOU UPDATE THIS METHOD,
// UPDATE THE OTHER ONE TOO! The one difference is that this method updates
// mMessageManager as well, which inner windows don't have.
// UPDATE THE OTHER ONE TOO!
// Try to get our frame element's tab child global (its in-process message
// manager). If that fails, fall back to the chrome event handler's tab
@ -2251,25 +2246,28 @@ nsGlobalWindowOuter::UpdateParentTarget()
// handler itself.
nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal();
mMessageManager = nsContentUtils::TryGetTabChildGlobal(frameElement);
nsCOMPtr<EventTarget> eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement);
if (!mMessageManager) {
if (!eventTarget) {
nsGlobalWindowOuter* topWin = GetScriptableTopInternal();
if (topWin) {
frameElement = topWin->GetFrameElementInternal();
mMessageManager = nsContentUtils::TryGetTabChildGlobal(frameElement);
eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement);
}
}
if (!mMessageManager) {
mMessageManager = nsContentUtils::TryGetTabChildGlobal(mChromeEventHandler);
if (!eventTarget) {
eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(mChromeEventHandler);
}
if (mMessageManager) {
mParentTarget = mMessageManager;
} else {
mParentTarget = mChromeEventHandler;
if (!eventTarget) {
eventTarget = mChromeEventHandler;
}
mParentTarget = eventTarget;
}
EventTarget*
@ -7629,19 +7627,6 @@ nsPIDOMWindowOuter::MaybeCreateDoc()
}
}
void
nsPIDOMWindowOuter::SetChromeEventHandlerInternal(EventTarget* aChromeEventHandler)
{
// Out-of-line so we don't need to include ContentFrameMessageManager.h in
// nsPIDOMWindow.h.
mChromeEventHandler = aChromeEventHandler;
// mParentTarget and mMessageManager will be set when the next event is
// dispatched or someone asks for our message manager.
mParentTarget = nullptr;
mMessageManager = nullptr;
}
mozilla::dom::DocGroup*
nsPIDOMWindowOuter::GetDocGroup() const
{

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

@ -13,8 +13,14 @@ interface nsIMessageSender : nsISupports
{
};
// NOTE: Only scriptable for Ci.nsIContentFrameMessageManager
[scriptable, builtinclass, uuid(694e367c-aa25-4446-8499-2c527c4bd838)]
interface nsIContentFrameMessageManager : nsIMessageSender
{
};
[uuid(b39a3324-b574-4f85-8cdb-274d04f807ef)]
interface nsIInProcessContentFrameMessageManager : nsIMessageSender
interface nsIInProcessContentFrameMessageManager : nsIContentFrameMessageManager
{
[notxpcom] nsIContent getOwnerContent();
};

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

@ -166,6 +166,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsInProcessTabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIInProcessContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
@ -294,7 +295,7 @@ nsInProcessTabChildGlobal::GetEventTargetParent(EventChainPreVisitor& aVisitor)
nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface(mOwner);
RefPtr<nsFrameLoader> fl = owner->GetFrameLoader();
if (fl) {
NS_ASSERTION(this == fl->GetTabChildGlobal(),
NS_ASSERTION(this == fl->GetTabChildGlobalAsEventTarget(),
"Wrong event target!");
NS_ASSERTION(fl->mMessageManager == mChromeMessageManager,
"Wrong message manager!");

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

@ -84,6 +84,7 @@ public:
virtual uint64_t ChromeOuterWindowID() override;
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER

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

@ -51,7 +51,6 @@ namespace dom {
class AudioContext;
class ClientInfo;
class ClientState;
class ContentFrameMessageManager;
class DocGroup;
class TabGroup;
class Element;
@ -873,15 +872,6 @@ public:
return mParentTarget;
}
mozilla::dom::ContentFrameMessageManager* GetMessageManager()
{
// We maintain our mMessageManager state alongside mParentTarget.
if (!mParentTarget) {
UpdateParentTarget();
}
return mMessageManager;
}
nsIDocument* GetExtantDoc() const
{
return mDoc;
@ -1170,7 +1160,11 @@ protected:
// we have what it takes to do so.
void MaybeCreateDoc();
void SetChromeEventHandlerInternal(mozilla::dom::EventTarget* aChromeEventHandler);
void SetChromeEventHandlerInternal(mozilla::dom::EventTarget* aChromeEventHandler) {
mChromeEventHandler = aChromeEventHandler;
// mParentTarget will be set when the next event is dispatched.
mParentTarget = nullptr;
}
virtual void UpdateParentTarget() = 0;
@ -1183,7 +1177,6 @@ protected:
nsCOMPtr<nsIURI> mDocumentURI; // strong
nsCOMPtr<mozilla::dom::EventTarget> mParentTarget; // strong
RefPtr<mozilla::dom::ContentFrameMessageManager> mMessageManager; // strong
nsCOMPtr<mozilla::dom::Element> mFrameElement;

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

@ -142,7 +142,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549682
var docShell = document.getElementById('ifr').contentWindow.docShell;
ok(docShell, "Should have docshell");
var cfmm = docShell.messageManager;
var cfmm = docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIContentFrameMessageManager);
ok(cfmm, "Should have content messageManager");
var didGetSyncMessage = false;

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

@ -30,7 +30,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1412775
b.addEventListener("foo", function(e) {
didCallChromeSide = true;
var path = e.composedPath();
var mm = d.defaultView.docShell.messageManager;
var mm = d.defaultView.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
is(path.length, 5, "Should have 5 items in composedPath in chrome.");
is(path[0], mm, "TabChildGlobal is the chrome handler.");
is(path[1], b, "browser element should be in the path.");

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

@ -8,15 +8,13 @@
interface nsIWebBrowserChrome3;
webidl ContentFrameMessageManager;
native CommandsArray(nsTArray<nsCString>);
[ref] native CommandsArrayRef(nsTArray<nsCString>);
[scriptable, uuid(1fb79c27-e760-4088-b19c-1ce3673ec24e)]
interface nsITabChild : nsISupports
{
readonly attribute ContentFrameMessageManager messageManager;
readonly attribute nsISupports messageManager;
attribute nsIWebBrowserChrome3 webBrowserChrome;

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

@ -2993,9 +2993,9 @@ TabChild::IsVisible()
}
NS_IMETHODIMP
TabChild::GetMessageManager(ContentFrameMessageManager** aResult)
TabChild::GetMessageManager(nsISupports** aResult)
{
RefPtr<ContentFrameMessageManager> mm(mTabChildGlobal);
nsCOMPtr<nsIContentFrameMessageManager> mm(mTabChildGlobal);
mm.forget(aResult);
return *aResult ? NS_OK : NS_ERROR_FAILURE;
}
@ -3551,6 +3551,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)

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

@ -80,7 +80,7 @@ class CoalescedMouseData;
class CoalescedWheelData;
class TabChildGlobal : public ContentFrameMessageManager,
public nsIMessageSender,
public nsIContentFrameMessageManager,
public nsIScriptObjectPrincipal,
public nsIGlobalObject,
public nsSupportsWeakReference
@ -108,6 +108,7 @@ public:
virtual uint64_t ChromeOuterWindowID() override;
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
void
GetEventTargetParent(EventChainPreVisitor& aVisitor) override

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

@ -21,8 +21,9 @@ addEventListener("click",
dump(e.target + "\n");
if (ChromeUtils.getClassName(e.target) === "HTMLAnchorElement" &&
dshell == docShell) {
var retval = docShell.messageManager
.sendSyncMessage("linkclick", { href: e.target.href });
var retval = docShell.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIContentFrameMessageManager).
sendSyncMessage("linkclick", { href: e.target.href });
dump(uneval(retval[0]) + "\n");
// Test here also that both retvals are the same
sendAsyncMessage("linkclick-reply-object", uneval(retval[0]) == uneval(retval[1]) ? retval[0] : "");

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

@ -196,9 +196,9 @@ this.FxAccountsWebChannel.prototype = {
switch (command) {
case COMMAND_LOADED:
// Note: we want the child side of the message manager here, not the
// parent, so get it from the docshell, not the browser.
let mm = sendingContext.browser.docShell.messageManager;
let mm = sendingContext.browser.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
mm.sendAsyncMessage(COMMAND_LOADED);
break;

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

@ -1754,14 +1754,14 @@ SpecialPowersAPI.prototype = {
aWindow.focus();
var mm = global;
if (aWindow) {
let windowMM = aWindow.docShell.messageManager;
if (windowMM) {
mm = windowMM;
try {
mm = aWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} catch (ex) {
/* Ignore exceptions for e.g. XUL chrome windows from mochitest-chrome
* which won't have a message manager */
}
/*
* Otherwise (e.g. XUL chrome windows from mochitest-chrome which won't
* have a message manager) just stick with "global".
*/
}
mm.sendAsyncMessage("SpecialPowers.Focus", {});
},

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

@ -4,7 +4,9 @@
function init() {
if (document.location.hash.indexOf("#auto") == 0) {
let mm = window.docShell.messageManager;
let mm = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
mm.addMessageListener("CPStartup:FinalResults", function onResults(msg) {
mm.removeMessageListener("CPStartup:FinalResults", onResults);

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

@ -4,7 +4,9 @@
function init() {
if (document.location.hash.indexOf("#auto") == 0) {
let mm = window.docShell.messageManager;
let mm = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
mm.addMessageListener("TabPaint:FinalResults", function onResults(msg) {
mm.removeMessageListener("TabPaint:FinalResults", onResults);

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

@ -52,7 +52,9 @@
let opened = parseInt(location.search.substring(1), 10);
let delta = presented - opened;
let mm = window.docShell.messageManager;
let mm = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
mm.sendAsyncMessage("TabPaint:Painted", { delta });
});

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

@ -371,7 +371,8 @@ class BaseContext {
let {document, docShell} = contentWindow;
this.innerWindowID = getInnerWindowID(contentWindow);
this.messageManager = docShell.messageManager;
this.messageManager = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
if (this.incognito == null) {
this.incognito = PrivateBrowsingUtils.isContentWindowPrivate(contentWindow);

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

@ -399,7 +399,9 @@ ExtensionPageChild = {
throw new Error("An extension context was already initialized for this frame");
}
let mm = contentWindow.docShell.messageManager;
let mm = contentWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
let {viewType, tabId, devtoolsToolboxInfo} = getFrameData(mm) || {};

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

@ -25,7 +25,7 @@
* A basic setup works something like this:
*
* A content script adds a message listener to its global
* ContentFrameMessageManager, with an appropriate set of filters:
* nsIContentFrameMessageManager, with an appropriate set of filters:
*
* {
* init(messageManager, window, extensionID) {

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

@ -88,6 +88,16 @@ var contentScripts = new DefaultWeakMap(matcher => {
matcher);
});
function getMessageManager(window) {
let docShell = window.docShell.QueryInterface(Ci.nsIInterfaceRequestor);
try {
return docShell.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
// Some windows don't support this interface (hidden window).
return null;
}
}
var DocumentManager;
var ExtensionManager;
@ -480,7 +490,7 @@ ExtensionProcessScript.prototype = {
},
initExtensionDocument(policy, doc) {
if (DocumentManager.globals.has(doc.defaultView.docShell.messageManager)) {
if (DocumentManager.globals.has(getMessageManager(doc.defaultView))) {
DocumentManager.loadInto(policy, doc.defaultView);
}
},
@ -497,7 +507,7 @@ ExtensionProcessScript.prototype = {
},
loadContentScript(contentScript, window) {
if (DocumentManager.globals.has(window.docShell.messageManager)) {
if (DocumentManager.globals.has(getMessageManager(window))) {
contentScripts.get(contentScript).injectInto(window);
}
},

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

@ -153,6 +153,12 @@ prefBranch.addObserver("", observer.onPrefChange);
observer.onPrefChange(); // read initial values
function messageManagerFromWindow(win) {
return win.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}
// This object maps to the "child" process (even in the single-process case).
var LoginManagerContent = {
__formFillService: null, // FormFillController, for username autocompleting
@ -295,7 +301,7 @@ var LoginManagerContent = {
}
let actionOrigin = LoginUtils._getActionOrigin(form);
let messageManager = win.docShell.messageManager;
let messageManager = messageManagerFromWindow(win);
// XXX Weak??
let requestData = { form };
@ -317,7 +323,7 @@ var LoginManagerContent = {
let formOrigin = LoginUtils._getPasswordOrigin(doc.documentURI);
let actionOrigin = LoginUtils._getActionOrigin(form);
let messageManager = win.docShell.messageManager;
let messageManager = messageManagerFromWindow(win);
let previousResult = aPreviousResult ?
{ searchString: aPreviousResult.searchString,
@ -438,7 +444,7 @@ var LoginManagerContent = {
const isPrivateWindow = PrivateBrowsingUtils.isContentWindowPrivate(window);
let messageManager = window.docShell.messageManager;
let messageManager = messageManagerFromWindow(window);
messageManager.sendAsyncMessage("LoginStats:LoginEncountered",
{
isPrivateWindow,
@ -501,7 +507,7 @@ var LoginManagerContent = {
frame => hasInsecureLoginForms(frame));
};
let messageManager = topWindow.docShell.messageManager;
let messageManager = messageManagerFromWindow(topWindow);
messageManager.sendAsyncMessage("RemoteLogins:insecureLoginFormPresent", {
hasInsecureLoginForms: hasInsecureLoginForms(topWindow),
});
@ -939,7 +945,7 @@ var LoginManagerContent = {
}
let formSubmitURL = LoginUtils._getActionOrigin(form);
let messageManager = win.docShell.messageManager;
let messageManager = messageManagerFromWindow(win);
let recipes = LoginRecipesContent.getRecipes(hostname, win);
@ -1257,7 +1263,7 @@ var LoginManagerContent = {
autofillResult = AUTOFILL_RESULT.FILLED;
let win = doc.defaultView;
let messageManager = win.docShell.messageManager;
let messageManager = messageManagerFromWindow(win);
messageManager.sendAsyncMessage("LoginStats:LoginFillSuccessful");
} finally {
if (autofillResult == -1) {

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

@ -234,7 +234,9 @@ var LoginRecipesContent = {
}
}
let mm = win.docShell.messageManager;
let mm = win.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
log.warn("getRecipes: falling back to a synchronous message for:", aHost);
recipes = mm.sendSyncMessage("RemoteLogins:findRecipes", { formOrigin: aHost })[0];

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

@ -359,7 +359,8 @@ function openTabPrompt(domWin, tabPrompt, args) {
let winUtils = domWin.windowUtils;
winUtils.enterModalState();
let frameMM = docShell.messageManager;
let frameMM = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
// We provide a callback so the prompt can close itself. We don't want to
// wait for this event loop to return... Otherwise the presence of other
@ -442,7 +443,7 @@ function openRemotePrompt(domWin, args, tabPrompt) {
winUtils.enterModalState();
let closed = false;
let frameMM = docShell.messageManager;
let frameMM = docShell.getInterface(Ci.nsIContentFrameMessageManager);
// It should be hard or impossible to cause a window to create multiple
// prompts, but just in case, give our prompt an ID.

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

@ -40,7 +40,11 @@ function isAutocompleteDisabled(aField) {
function FormHistoryClient({ formField, inputName }) {
if (formField && inputName != this.SEARCHBAR_ID) {
let window = formField.ownerGlobal;
this.mm = window.docShell.messageManager;
let topDocShell = window.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIDocShell);
this.mm = topDocShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} else {
if (inputName == this.SEARCHBAR_ID && formField) {
throw new Error("FormHistoryClient constructed with both a " +

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

@ -11,7 +11,13 @@ function nsSidebar() {
nsSidebar.prototype = {
init(window) {
this.window = window;
this.mm = window.docShell.messageManager;
try {
this.mm = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
Cu.reportError(e);
}
},
// This function implements window.external.AddSearchProvider().

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

@ -57,7 +57,9 @@ let ProcessObserver = {
// Get the frame message manager for this window so we can associate this
// page with a browser element
let messageManager = window.docShell.messageManager;
let messageManager = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
let { ChildMessagePort } =
ChromeUtils.import("resource://gre/modules/remotepagemanager/RemotePageManagerChild.jsm", {});

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

@ -306,8 +306,9 @@ var E10SUtils = {
redirectLoad(aDocShell, aURI, aReferrer, aTriggeringPrincipal, aFreshProcess, aFlags) {
// Retarget the load to the correct process
let messageManager = aDocShell.messageManager;
let sessionHistory = aDocShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
let messageManager = aDocShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
let sessionHistory = aDocShell.getInterface(Ci.nsIWebNavigation).sessionHistory;
messageManager.sendAsyncMessage("Browser:LoadURI", {
loadOptions: {

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

@ -12,7 +12,9 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
function getMessageManager(event) {
let window = Cu.getGlobalForObject(event.target);
return window.docShell.messageManager;
return window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}
var WebChannelContent = {

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

@ -165,9 +165,14 @@ var ContentPolicy = {
}
}
let windowMM = window.docShell.messageManager;
if (windowMM) {
mm = windowMM;
let ir = window.docShell.QueryInterface(Ci.nsIInterfaceRequestor);
try {
// If e10s is disabled, this throws NS_NOINTERFACE for closed tabs.
mm = ir.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
if (e.result != Cr.NS_NOINTERFACE) {
throw e;
}
}
}

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

@ -73,7 +73,9 @@ amContentHandler.prototype = {
}
// Fall back to sending through the message manager
let messageManager = window.docShell.messageManager;
let messageManager = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
messageManager.sendAsyncMessage(MSG_INSTALL_ADDON, install);
},

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

@ -37,7 +37,10 @@ function RemoteMediator(window) {
let utils = window.windowUtils;
this._windowID = utils.currentInnerWindowID;
this.mm = window.docShell.messageManager;
this.mm = window
.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
this.mm.addWeakMessageListener(MSG_INSTALL_CALLBACK, this);
this._lastCallbackID = 0;
@ -89,7 +92,9 @@ RemoteMediator.prototype = {
}
// Fall back to sending through the message manager
let messageManager = window.docShell.messageManager;
let messageManager = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
return messageManager.sendSyncMessage(MSG_INSTALL_ADDON, install)[0];
},

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

@ -203,7 +203,10 @@ class WebAPI extends APIObject {
}
init(window) {
let mm = window.docShell.messageManager;
let mm = window
.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
let broker = new APIBroker(mm);
super.init(window, broker, {});