Skip to content

Commit

Permalink
Bug 1522052 - remove nsIDOMChromeWindow. r=dom-core,webdriver-reviewe…
Browse files Browse the repository at this point in the history
…rs,devtools-reviewers,whimboo,mccr8

Differential Revision: https://phabricator.services.mozilla.com/D34310
  • Loading branch information
petervanderbeken committed Jun 23, 2023
1 parent c8f966a commit b52a207
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 118 deletions.
2 changes: 1 addition & 1 deletion browser/components/extensions/parent/ext-sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const createSession = async function createSession(
);
}
let sessionObj = { lastModified: Date.now() };
if (restored instanceof Ci.nsIDOMChromeWindow) {
if (restored.isChromeWindow) {
await promiseObserved(
"sessionstore-single-window-restored",
subject => subject == restored
Expand Down
5 changes: 1 addition & 4 deletions devtools/server/actors/accessibility/walker.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,7 @@ class AccessibleWalkerActor extends Actor {
* Check is event handling is allowed.
*/
_isEventAllowed({ view }) {
return (
this.rootWin instanceof Ci.nsIDOMChromeWindow ||
isWindowIncluded(this.rootWin, view)
);
return this.rootWin.isChromeWindow || isWindowIncluded(this.rootWin, view);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion devtools/server/actors/inspector/node-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class NodePicker {
_isEventAllowed({ view }) {
// Allow "non multiprocess" browser toolbox to inspect documents loaded in the parent
// process (e.g. about:robots)
if (this._targetActor.window instanceof Ci.nsIDOMChromeWindow) {
if (this._targetActor.window.isChromeWindow) {
return true;
}

Expand Down
10 changes: 4 additions & 6 deletions docshell/base/CanonicalBrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,10 @@ CanonicalBrowsingContext::GetParentProcessWidgetContaining() {
already_AddRefed<nsIBrowserDOMWindow>
CanonicalBrowsingContext::GetBrowserDOMWindow() {
RefPtr<CanonicalBrowsingContext> chromeTop = TopCrossChromeBoundary();
if (nsCOMPtr<nsIDOMChromeWindow> chromeWin =
do_QueryInterface(chromeTop->GetDOMWindow())) {
nsCOMPtr<nsIBrowserDOMWindow> bdw;
if (NS_SUCCEEDED(chromeWin->GetBrowserDOMWindow(getter_AddRefs(bdw)))) {
return bdw.forget();
}
nsGlobalWindowOuter* topWin;
if ((topWin = nsGlobalWindowOuter::Cast(chromeTop->GetDOMWindow())) &&
topWin->IsChromeWindow()) {
return do_AddRef(topWin->GetBrowserDOMWindow());
}
return nullptr;
}
Expand Down
11 changes: 4 additions & 7 deletions dom/base/nsFrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@

#include "nsThreadUtils.h"

#include "nsIDOMChromeWindow.h"
#include "InProcessBrowserChildMessageManager.h"

#include "ContentParent.h"
Expand Down Expand Up @@ -2757,13 +2756,11 @@ bool nsFrameLoader::TryRemoteBrowserInternal() {

nsCOMPtr<nsIDocShellTreeItem> rootItem;
parentDocShell->GetInProcessRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsPIDOMWindowOuter> rootWin = rootItem->GetWindow();
nsCOMPtr<nsIDOMChromeWindow> rootChromeWin = do_QueryInterface(rootWin);
RefPtr<nsGlobalWindowOuter> rootWin =
nsGlobalWindowOuter::Cast(rootItem->GetWindow());

if (rootChromeWin) {
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
browserParent->SetBrowserDOMWindow(browserDOMWin);
if (rootWin && rootWin->IsChromeWindow()) {
browserParent->SetBrowserDOMWindow(rootWin->GetBrowserDOMWindow());
}

// For xul:browsers, update some settings based on attributes:
Expand Down
12 changes: 1 addition & 11 deletions dom/base/nsGlobalWindowInner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindowInner)
NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
NS_INTERFACE_MAP_ENTRY(nsPIDOMWindowInner)
NS_INTERFACE_MAP_ENTRY(mozIDOMWindow)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMChromeWindow, IsChromeWindow())
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_END
Expand Down Expand Up @@ -7185,18 +7184,9 @@ void nsGlobalWindowInner::SetCursor(const nsACString& aCursor,
FORWARD_TO_OUTER_OR_THROW(SetCursorOuter, (aCursor, aError), aError, );
}

NS_IMETHODIMP
nsGlobalWindowInner::GetBrowserDOMWindow(nsIBrowserDOMWindow** aBrowserWindow) {
MOZ_RELEASE_ASSERT(IsChromeWindow());

ErrorResult rv;
NS_IF_ADDREF(*aBrowserWindow = GetBrowserDOMWindow(rv));
return rv.StealNSResult();
}

nsIBrowserDOMWindow* nsGlobalWindowInner::GetBrowserDOMWindow(
ErrorResult& aError) {
FORWARD_TO_OUTER_OR_THROW(GetBrowserDOMWindowOuter, (), aError, nullptr);
FORWARD_TO_OUTER_OR_THROW(GetBrowserDOMWindow, (), aError, nullptr);
}

void nsGlobalWindowInner::SetBrowserDOMWindow(
Expand Down
10 changes: 1 addition & 9 deletions dom/base/nsGlobalWindowInner.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// Interfaces Needed
#include "nsIBrowserDOMWindow.h"
#include "nsIInterfaceRequestor.h"
#include "nsIDOMChromeWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectPrincipal.h"
#include "mozilla/EventListenerManager.h"
Expand Down Expand Up @@ -169,11 +168,7 @@ extern const JSClass OuterWindowProxyClass;

class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
public nsPIDOMWindowInner,
private nsIDOMWindow
// NOTE: This interface is private, as it's only
// implemented on chrome windows.
,
private nsIDOMChromeWindow,
private nsIDOMWindow,
public nsIScriptGlobalObject,
public nsIScriptObjectPrincipal,
public nsSupportsWeakReference,
Expand Down Expand Up @@ -286,9 +281,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
// nsIDOMWindow
NS_DECL_NSIDOMWINDOW

// nsIDOMChromeWindow (only implemented on chrome windows)
NS_DECL_NSIDOMCHROMEWINDOW

void CaptureEvents();
void ReleaseEvents();
void Dump(const nsAString& aStr);
Expand Down
23 changes: 6 additions & 17 deletions dom/base/nsGlobalWindowOuter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindowOuter)
NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
NS_INTERFACE_MAP_ENTRY(nsPIDOMWindowOuter)
NS_INTERFACE_MAP_ENTRY(mozIDOMWindowProxy)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMChromeWindow, IsChromeWindow())
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_END
Expand Down Expand Up @@ -5879,8 +5878,7 @@ class nsCloseEvent : public Runnable {

bool nsGlobalWindowOuter::CanClose() {
if (mIsChrome) {
nsCOMPtr<nsIBrowserDOMWindow> bwin;
GetBrowserDOMWindow(getter_AddRefs(bwin));
nsCOMPtr<nsIBrowserDOMWindow> bwin = GetBrowserDOMWindow();

bool canClose = true;
if (bwin && NS_SUCCEEDED(bwin->CanClose(&canClose))) {
Expand Down Expand Up @@ -6893,9 +6891,8 @@ nsresult nsGlobalWindowOuter::OpenInternal(
}

if (domReturn && aDoJSFixups) {
nsCOMPtr<nsIDOMChromeWindow> chrome_win(
do_QueryInterface(domReturn->GetDOMWindow()));
if (!chrome_win) {
nsPIDOMWindowOuter* outer = domReturn->GetDOMWindow();
if (outer && !nsGlobalWindowOuter::Cast(outer)->IsChromeWindow()) {
// A new non-chrome window was created from a call to
// window.open() from JavaScript, make sure there's a document in
// the new window. We do this by simply asking the new window for
Expand All @@ -6904,10 +6901,8 @@ nsresult nsGlobalWindowOuter::OpenInternal(
// XXXbz should this just use EnsureInnerWindow()?

// Force document creation.
if (nsPIDOMWindowOuter* win = domReturn->GetDOMWindow()) {
nsCOMPtr<Document> doc = win->GetDoc();
Unused << doc;
}
nsCOMPtr<Document> doc = outer->GetDoc();
Unused << doc;
}
}

Expand Down Expand Up @@ -7194,14 +7189,8 @@ void nsGlobalWindowOuter::SetCursorOuter(const nsACString& aCursor,
}
}

NS_IMETHODIMP
nsGlobalWindowOuter::GetBrowserDOMWindow(nsIBrowserDOMWindow** aBrowserWindow) {
nsIBrowserDOMWindow* nsGlobalWindowOuter::GetBrowserDOMWindow() {
MOZ_RELEASE_ASSERT(IsChromeWindow());
FORWARD_TO_INNER(GetBrowserDOMWindow, (aBrowserWindow), NS_ERROR_UNEXPECTED);
}

nsIBrowserDOMWindow* nsGlobalWindowOuter::GetBrowserDOMWindowOuter() {
MOZ_ASSERT(IsChromeWindow());
return mChromeFields.mBrowserDOMWindow;
}

Expand Down
12 changes: 2 additions & 10 deletions dom/base/nsGlobalWindowOuter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
// Interfaces Needed
#include "nsIBrowserDOMWindow.h"
#include "nsIInterfaceRequestor.h"
#include "nsIDOMChromeWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectPrincipal.h"
#include "mozilla/EventListenerManager.h"
Expand Down Expand Up @@ -155,11 +154,7 @@ extern const JSClass OuterWindowProxyClass;

class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
public nsPIDOMWindowOuter,
private nsIDOMWindow
// NOTE: This interface is private, as it's only
// implemented on chrome windows.
,
private nsIDOMChromeWindow,
private nsIDOMWindow,
public nsIScriptGlobalObject,
public nsIScriptObjectPrincipal,
public nsSupportsWeakReference,
Expand Down Expand Up @@ -263,9 +258,6 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
// nsIDOMWindow
NS_DECL_NSIDOMWINDOW

// nsIDOMChromeWindow (only implemented on chrome windows)
NS_DECL_NSIDOMCHROMEWINDOW

mozilla::dom::ChromeMessageBroadcaster* GetMessageManager();
mozilla::dom::ChromeMessageBroadcaster* GetGroupMessageManager(
const nsAString& aGroup);
Expand Down Expand Up @@ -658,7 +650,7 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,

// ChromeWindow bits. Do NOT call these unless your window is in
// fact chrome.
nsIBrowserDOMWindow* GetBrowserDOMWindowOuter();
nsIBrowserDOMWindow* GetBrowserDOMWindow();
void SetBrowserDOMWindowOuter(nsIBrowserDOMWindow* aBrowserWindow);
void SetCursorOuter(const nsACString& aCursor, mozilla::ErrorResult& aError);

Expand Down
9 changes: 4 additions & 5 deletions dom/clients/manager/ClientOpenWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include "nsDocShell.h"
#include "nsDocShellLoadState.h"
#include "nsFocusManager.h"
#include "nsGlobalWindowOuter.h"
#include "nsIBrowserDOMWindow.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIDOMChromeWindow.h"
#include "nsIURI.h"
#include "nsIBrowser.h"
#include "nsIWebProgress.h"
Expand Down Expand Up @@ -222,15 +222,14 @@ void OpenWindow(const ClientOpenWindowArgsParsed& aArgsValidated,
return;
}

nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(browserWindow);
if (NS_WARN_IF(!chromeWin)) {
if (NS_WARN_IF(!nsGlobalWindowOuter::Cast(browserWindow)->IsChromeWindow())) {
// XXXbz Can this actually happen? Seems unlikely.
aRv.ThrowTypeError("Unable to open window");
return;
}

nsCOMPtr<nsIBrowserDOMWindow> bwin;
chromeWin->GetBrowserDOMWindow(getter_AddRefs(bwin));
nsCOMPtr<nsIBrowserDOMWindow> bwin =
nsGlobalWindowOuter::Cast(browserWindow)->GetBrowserDOMWindow();

if (NS_WARN_IF(!bwin)) {
aRv.ThrowTypeError("Unable to open window");
Expand Down
1 change: 0 additions & 1 deletion dom/interfaces/base/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ XPIDL_SOURCES += [
"nsIContentPermissionPrompt.idl",
"nsIContentPrefService2.idl",
"nsIContentProcess.idl",
"nsIDOMChromeWindow.idl",
"nsIDOMGlobalPropertyInitializer.idl",
"nsIDOMWindow.idl",
"nsIDOMWindowUtils.idl",
Expand Down
22 changes: 0 additions & 22 deletions dom/interfaces/base/nsIDOMChromeWindow.idl

This file was deleted.

8 changes: 4 additions & 4 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
#include "nsFocusManager.h"
#include "nsFrameLoader.h"
#include "nsFrameMessageManager.h"
#include "nsGlobalWindowOuter.h"
#include "nsHashPropertyBag.h"
#include "nsHyphenationManager.h"
#include "nsIAlertsService.h"
Expand All @@ -200,7 +201,6 @@
#include "nsICookie.h"
#include "nsICrashService.h"
#include "nsICycleCollectorListener.h"
#include "nsIDOMChromeWindow.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIDragService.h"
Expand Down Expand Up @@ -5630,9 +5630,9 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
return IPC_OK();
}

nsCOMPtr<nsIDOMChromeWindow> rootChromeWin = do_QueryInterface(outerWin);
if (rootChromeWin) {
rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
if (nsGlobalWindowOuter::Cast(outerWin)->IsChromeWindow()) {
browserDOMWin =
nsGlobalWindowOuter::Cast(outerWin)->GetBrowserDOMWindow();
}
}

Expand Down
2 changes: 0 additions & 2 deletions dom/webidl/Window.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ partial interface Window {
*/
[Throws, ChromeOnly] undefined sizeToContentConstrained(optional SizeToContentConstraints constraints = {});

// XXX Shouldn't this be in nsIDOMChromeWindow?
[ChromeOnly, Replaceable, Throws] readonly attribute XULControllers controllers;

[ChromeOnly, Throws] readonly attribute Element? realFrameElement;
Expand Down Expand Up @@ -462,7 +461,6 @@ partial interface Window {

[Throws] attribute boolean fullScreen;

// XXX Should this be in nsIDOMChromeWindow?
undefined updateCommands(DOMString action,
optional Selection? sel = null,
optional short reason = 0);
Expand Down
6 changes: 3 additions & 3 deletions layout/base/PresShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
#include "mozilla/dom/ImageTracker.h"
#include "nsIDocShellTreeOwner.h"
#include "nsClassHashtable.h"
#include "nsGlobalWindowOuter.h"
#include "nsHashKeys.h"
#include "ScrollSnap.h"
#include "VisualViewport.h"
Expand Down Expand Up @@ -9196,9 +9197,8 @@ void PresShell::DidPaintWindow() {
nsCOMPtr<nsIObserverService> obsvc = services::GetObserverService();
if (obsvc && mDocument) {
nsPIDOMWindowOuter* window = mDocument->GetWindow();
nsCOMPtr<nsIDOMChromeWindow> chromeWin(do_QueryInterface(window));
if (chromeWin) {
obsvc->NotifyObservers(chromeWin, "widget-first-paint", nullptr);
if (window && nsGlobalWindowOuter::Cast(window)->IsChromeWindow()) {
obsvc->NotifyObservers(window, "widget-first-paint", nullptr);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions remote/marionette/browser.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ export const WindowState = {
Fullscreen: "fullscreen",

/**
* Converts {@link nsIDOMChromeWindow.windowState} to WindowState.
* Converts {@link Window.windowState} to WindowState.
*
* @param {number} windowState
* Attribute from {@link nsIDOMChromeWindow.windowState}.
* Attribute from {@link Window.windowState}.
*
* @returns {WindowState}
* JSON representation.
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/prompts/test/PromptTestUtils.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export let PromptTestUtils = {
// Parent is browser
parentBrowser = parent;
parentWindow = parentBrowser.ownerGlobal;
} else if (parent instanceof Ci.nsIDOMChromeWindow) {
} else if (parent.isChromeWindow) {
// Parent is window
parentWindow = parent;
parentBrowser = parentWindow.gBrowser?.selectedBrowser;
Expand Down
4 changes: 1 addition & 3 deletions toolkit/components/windowwatcher/nsWindowWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "mozilla/dom/Document.h"
#include "mozilla/dom/DocumentInlines.h"
#include "nsIDragService.h"
#include "nsIDOMChromeWindow.h"
#include "nsIPrompt.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIScreen.h"
Expand Down Expand Up @@ -2299,8 +2298,7 @@ static void SizeOpenedWindow(nsIDocShellTreeOwner* aTreeOwner,
if (aIsCallerChrome) {
// Only enable special privileges for chrome when chrome calls
// open() on a chrome window
nsCOMPtr<nsIDOMChromeWindow> chromeWin(do_QueryInterface(aParent));
enabled = !aParent || chromeWin;
enabled = !aParent || nsGlobalWindowOuter::Cast(aParent)->IsChromeWindow();
}

const CSSIntCoord extraWidth = sizeChromeWidth ? CSSIntCoord(0) : chromeWidth;
Expand Down
Loading

0 comments on commit b52a207

Please sign in to comment.