Bug 1216401: Eviscerate nsIDOMWindow, move still needed methods to nsPIDOMWindow. r=bz

This commit is contained in:
Kyle Huey 2015-10-26 14:37:32 -07:00
Родитель 8bb8104d86
Коммит c7d3c4e21a
83 изменённых файлов: 725 добавлений и 2107 удалений

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

@ -190,11 +190,11 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
aWebProgress->GetDOMWindow(getter_AddRefs(DOMWindow));
NS_ENSURE_STATE(DOMWindow);
nsCOMPtr<nsIDOMDocument> DOMDocument;
DOMWindow->GetDocument(getter_AddRefs(DOMDocument));
NS_ENSURE_STATE(DOMDocument);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(DOMWindow);
MOZ_ASSERT(piWindow);
nsCOMPtr<nsIDocument> document(do_QueryInterface(DOMDocument));
nsCOMPtr<nsIDocument> document = piWindow->GetDoc();
NS_ENSURE_STATE(document);
// Document was loaded.
if (aStateFlags & STATE_STOP) {

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

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* 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
@ -193,12 +193,10 @@ ApplicationAccessible::CacheChildren()
while (hasMore) {
nsCOMPtr<nsISupports> window;
windowEnumerator->GetNext(getter_AddRefs(window));
nsCOMPtr<nsIDOMWindow> DOMWindow = do_QueryInterface(window);
nsCOMPtr<nsPIDOMWindow> DOMWindow = do_QueryInterface(window);
if (DOMWindow) {
nsCOMPtr<nsIDOMDocument> DOMDocument;
DOMWindow->GetDocument(getter_AddRefs(DOMDocument));
if (DOMDocument) {
nsCOMPtr<nsIDocument> docNode(do_QueryInterface(DOMDocument));
nsCOMPtr<nsIDocument> docNode = DOMWindow->GetDoc();
if (docNode) {
GetAccService()->GetDocAccessible(docNode); // ensure creation
}
}

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

@ -133,13 +133,12 @@ ImageAccessible::DoAction(uint8_t aIndex)
nsIDocument* document = mContent->OwnerDoc();
nsCOMPtr<nsPIDOMWindow> piWindow = document->GetWindow();
nsCOMPtr<nsIDOMWindow> win = do_QueryInterface(piWindow);
if (!win)
if (!piWindow)
return false;
nsCOMPtr<nsIDOMWindow> tmp;
return NS_SUCCEEDED(win->Open(spec, EmptyString(), EmptyString(),
getter_AddRefs(tmp)));
nsCOMPtr<nsPIDOMWindow> tmp;
return NS_SUCCEEDED(piWindow->Open(spec, EmptyString(), EmptyString(),
getter_AddRefs(tmp)));
}
////////////////////////////////////////////////////////////////////////////////

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

@ -486,11 +486,9 @@ RootAccessible::RelationByType(RelationType aType)
nsPIDOMWindow* rootWindow = mDocumentNode->GetWindow();
if (rootWindow) {
nsCOMPtr<nsIDOMWindow> contentWindow = nsGlobalWindow::Cast(rootWindow)->GetContent();
if (contentWindow) {
nsCOMPtr<nsIDOMDocument> contentDOMDocument;
contentWindow->GetDocument(getter_AddRefs(contentDOMDocument));
nsCOMPtr<nsIDocument> contentDocumentNode =
do_QueryInterface(contentDOMDocument);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(contentWindow);
if (piWindow) {
nsCOMPtr<nsIDocument> contentDocumentNode = piWindow->GetDoc();
if (contentDocumentNode) {
DocAccessible* contentDocument =
GetAccService()->GetDocAccessible(contentDocumentNode);

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

@ -56,6 +56,7 @@ LOCAL_INCLUDES += [
'/accessible/xpcom',
'/accessible/xul',
'/dom/base',
'/layout/style',
]
include('/ipc/chromium/chromium-config.mozbuild')

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

@ -15,13 +15,15 @@
#include "mozilla/Preferences.h"
#include "nsArrayUtils.h"
#include "nsIArray.h"
#include "nsICSSDeclaration.h"
#include "nsIDocument.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDOMElement.h"
#include "mozilla/dom/Element.h"
#include "nsXULAppAPI.h"
using namespace mozilla;
using namespace mozilla::a11y;
using mozilla::dom::Element;
// Window property used by ipc related code in identifying accessible
// tab windows.
@ -43,15 +45,18 @@ nsWinUtils::GetComputedStyleDeclaration(nsIContent* aContent)
return nullptr;
// Returns number of items in style declaration
nsCOMPtr<nsIDOMWindow> window =
nsCOMPtr<nsPIDOMWindow> window =
do_QueryInterface(elm->OwnerDoc()->GetWindow());
if (!window)
return nullptr;
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(elm));
window->GetComputedStyle(domElement, EmptyString(), getter_AddRefs(cssDecl));
return cssDecl.forget();
ErrorResult dummy;
nsCOMPtr<nsICSSDeclaration> cssDecl;
nsCOMPtr<Element> domElement(do_QueryInterface(elm));
cssDecl = window->GetComputedStyle(*domElement, EmptyString(), dummy);
nsCOMPtr<nsIDOMCSSStyleDeclaration> domDecl = do_QueryInterface(cssDecl);
dummy.SuppressException();
return domDecl.forget();
}
bool

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

@ -33,6 +33,7 @@ GENERATED_INCLUDES += [
]
LOCAL_INCLUDES += [
'/dom/base',
'/netwerk/base',
'/netwerk/protocol/res',
'/xpcom/components'

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

@ -313,15 +313,10 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURI, nsIURI* *aResult)
// theme stuff
static void FlushSkinBindingsForWindow(nsIDOMWindow* aWindow)
static void FlushSkinBindingsForWindow(nsPIDOMWindow* aWindow)
{
// Get the DOM document.
nsCOMPtr<nsIDOMDocument> domDocument;
aWindow->GetDocument(getter_AddRefs(domDocument));
if (!domDocument)
return;
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
// Get the document.
nsCOMPtr<nsIDocument> document = aWindow->GetDoc();
if (!document)
return;
@ -345,7 +340,7 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
nsCOMPtr<nsISupports> protoWindow;
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (protoWindow) {
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(protoWindow);
if (domWindow)
FlushSkinBindingsForWindow(domWindow);
}
@ -360,7 +355,7 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
nsCOMPtr<nsISupports> protoWindow;
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (protoWindow) {
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(protoWindow);
if (domWindow)
RefreshWindow(domWindow);
}
@ -382,28 +377,23 @@ nsChromeRegistry::FlushSkinCaches()
}
// XXXbsmedberg: move this to windowmediator
nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
{
// Deal with our subframes first.
nsCOMPtr<nsIDOMWindowCollection> frames;
aWindow->GetFrames(getter_AddRefs(frames));
nsCOMPtr<nsIDOMWindowCollection> frames = aWindow->GetFrames();
uint32_t length;
frames->GetLength(&length);
uint32_t j;
for (j = 0; j < length; j++) {
nsCOMPtr<nsIDOMWindow> childWin;
frames->Item(j, getter_AddRefs(childWin));
RefreshWindow(childWin);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(childWin);
RefreshWindow(piWindow);
}
nsresult rv;
// Get the DOM document.
nsCOMPtr<nsIDOMDocument> domDocument;
aWindow->GetDocument(getter_AddRefs(domDocument));
if (!domDocument)
return NS_OK;
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
// Get the document.
nsCOMPtr<nsIDocument> document = aWindow->GetDoc();
if (!document)
return NS_OK;
@ -521,10 +511,9 @@ nsChromeRegistry::ReloadChrome()
nsCOMPtr<nsISupports> protoWindow;
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(protoWindow);
if (domWindow) {
nsCOMPtr<nsIDOMLocation> location;
domWindow->GetLocation(getter_AddRefs(location));
nsIDOMLocation* location = domWindow->GetLocation();
if (location) {
rv = location->Reload(false);
if (NS_FAILED(rv)) return rv;

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

@ -22,7 +22,7 @@
#include "mozilla/FileLocation.h"
class nsIDOMWindow;
class nsPIDOMWindow;
class nsIPrefBranch;
class nsIURL;
@ -95,7 +95,7 @@ protected:
nsresult SelectLocaleFromPref(nsIPrefBranch* prefs);
static nsresult RefreshWindow(nsIDOMWindow* aWindow);
static nsresult RefreshWindow(nsPIDOMWindow* aWindow);
static nsresult GetProviderAndPath(nsIURL* aChromeURL,
nsACString& aProvider, nsACString& aPath);

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

@ -148,8 +148,8 @@ nsDSURIContentListener::DoContent(const nsACString& aContentType,
}
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
nsCOMPtr<nsIDOMWindow> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(
mDocShell ? mDocShell->GetWindow() : nullptr);
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
domWindow->Focus();
}
@ -294,7 +294,7 @@ nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
// window, if we're not the top. X-F-O: SAMEORIGIN requires that the
// document must be same-origin with top window. X-F-O: DENY requires that
// the document must never be framed.
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
nsCOMPtr<nsPIDOMWindow> thisWindow = mDocShell->GetWindow();
// If we don't have DOMWindow there is no risk of clickjacking
if (!thisWindow) {
return true;
@ -302,8 +302,7 @@ nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
// GetScriptableTop, not GetTop, because we want this to respect
// <iframe mozbrowser> boundaries.
nsCOMPtr<nsIDOMWindow> topWindow;
thisWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> topWindow = thisWindow->GetScriptableTop();
// if the document is in the top window, it's not in a frame.
if (thisWindow == topWindow) {

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

@ -3503,14 +3503,13 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
return false;
}
nsCOMPtr<nsIDOMWindow> targetWindow = aTargetItem->GetWindow();
nsCOMPtr<nsPIDOMWindow> targetWindow = aTargetItem->GetWindow();
if (!targetWindow) {
NS_ERROR("This should not happen, really");
return false;
}
nsCOMPtr<nsIDOMWindow> targetOpener;
targetWindow->GetOpener(getter_AddRefs(targetOpener));
nsCOMPtr<nsIDOMWindow> targetOpener = targetWindow->GetOpener();
nsCOMPtr<nsIWebNavigation> openerWebNav(do_GetInterface(targetOpener));
nsCOMPtr<nsIDocShellTreeItem> openerItem(do_QueryInterface(openerWebNav));
@ -7490,7 +7489,7 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
return NS_OK;
}
thisWindow->GetFrameElement(getter_AddRefs(frameElement));
frameElement = thisWindow->GetFrameElement();
if (!frameElement) {
return NS_OK;
}
@ -9739,8 +9738,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// So, the best we can do, is to tear down the new window
// that was just created!
//
nsCOMPtr<nsIDOMWindow> domWin = targetDocShell->GetWindow();
if (domWin) {
if (nsCOMPtr<nsPIDOMWindow> domWin = targetDocShell->GetWindow()) {
domWin->Close();
}
}
@ -13006,10 +13004,11 @@ nsDocShell::GetAssociatedWindow(nsIDOMWindow** aWindow)
NS_IMETHODIMP
nsDocShell::GetTopWindow(nsIDOMWindow** aWindow)
{
nsCOMPtr<nsIDOMWindow> win = GetWindow();
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
if (win) {
win->GetTop(aWindow);
win = win->GetTop();
}
win.forget(aWindow);
return NS_OK;
}
@ -13017,23 +13016,19 @@ NS_IMETHODIMP
nsDocShell::GetTopFrameElement(nsIDOMElement** aElement)
{
*aElement = nullptr;
nsCOMPtr<nsIDOMWindow> win = GetWindow();
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
if (!win) {
return NS_OK;
}
nsCOMPtr<nsIDOMWindow> top;
win->GetScriptableTop(getter_AddRefs(top));
nsCOMPtr<nsPIDOMWindow> top = win->GetScriptableTop();
NS_ENSURE_TRUE(top, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> piTop = do_QueryInterface(top);
NS_ENSURE_TRUE(piTop, NS_ERROR_FAILURE);
// GetFrameElementInternal, /not/ GetScriptableFrameElement -- if |top| is
// inside <iframe mozbrowser>, we want to return the iframe, not null.
// And we want to cross the content/chrome boundary.
nsCOMPtr<nsIDOMElement> elt =
do_QueryInterface(piTop->GetFrameElementInternal());
do_QueryInterface(top->GetFrameElementInternal());
elt.forget(aElement);
return NS_OK;
}

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

@ -158,9 +158,9 @@ nsDocShellEditorData::DetachFromWindow()
mDetachedMakeEditable = mMakeEditable;
mMakeEditable = false;
nsCOMPtr<nsIDOMDocument> domDoc;
domWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(domWindow);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
if (htmlDoc) {
mDetachedEditingState = htmlDoc->GetEditingState();
}
@ -183,9 +183,9 @@ nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell)
mIsDetached = false;
mMakeEditable = mDetachedMakeEditable;
nsCOMPtr<nsIDOMDocument> domDoc;
domWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(domWindow);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
if (htmlDoc) {
htmlDoc->SetEditingState(mDetachedEditingState);
}

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

@ -112,8 +112,7 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
MOZ_ASSERT(pInnerWindow->IsInnerWindow());
mInnerWindowID = pInnerWindow->WindowID();
nsCOMPtr<nsIDOMWindow> topWindow;
aWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> topWindow = pInnerWindow->GetScriptableTop();
if (NS_WARN_IF(!topWindow)) {
return NS_OK;
}

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

@ -97,18 +97,16 @@ NotifyChannelActive(uint64_t aWindowID, AudioChannel aAudioChannel,
}
already_AddRefed<nsPIDOMWindow>
GetTopWindow(nsIDOMWindow* aWindow)
GetTopWindow(nsPIDOMWindow* aWindow)
{
MOZ_ASSERT(aWindow);
nsCOMPtr<nsIDOMWindow> topWindow;
aWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> topWindow = aWindow->GetScriptableTop();
MOZ_ASSERT(topWindow);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(topWindow);
window = window->GetOuterWindow();
topWindow = topWindow->GetOuterWindow();
return window.forget();
return topWindow.forget();
}
bool
@ -347,8 +345,7 @@ AudioChannelService::GetState(nsPIDOMWindow* aWindow, uint32_t aAudioChannel,
*aVolume *= window->GetAudioVolume();
*aMuted = *aMuted || window->GetAudioMuted();
nsCOMPtr<nsIDOMWindow> win;
window->GetScriptableParent(getter_AddRefs(win));
nsCOMPtr<nsPIDOMWindow> win = window->GetScriptableParent();
if (window == win) {
break;
}
@ -540,14 +537,12 @@ AudioChannelService::RefreshAgentsVolume(nsPIDOMWindow* aWindow)
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
nsCOMPtr<nsIDOMWindow> topWindow;
aWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> pTopWindow = do_QueryInterface(topWindow);
if (!pTopWindow) {
nsCOMPtr<nsPIDOMWindow> topWindow = aWindow->GetScriptableTop();
if (!topWindow) {
return;
}
AudioChannelWindow* winData = GetWindowData(pTopWindow->WindowID());
AudioChannelWindow* winData = GetWindowData(topWindow->WindowID());
if (!winData) {
return;
}
@ -566,14 +561,12 @@ AudioChannelService::RefreshAgentsCapture(nsPIDOMWindow* aWindow,
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
nsCOMPtr<nsIDOMWindow> topWindow;
aWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> pTopWindow = do_QueryInterface(topWindow);
if (!pTopWindow) {
nsCOMPtr<nsPIDOMWindow> topWindow = aWindow->GetScriptableTop();
if (!topWindow) {
return;
}
AudioChannelWindow* winData = GetWindowData(pTopWindow->WindowID());
AudioChannelWindow* winData = GetWindowData(topWindow->WindowID());
// This can happen, but only during shutdown, because the the outer window
// changes ScriptableTop, so that its ID is different.
@ -707,7 +700,8 @@ AudioChannelService::GetAudioChannelVolume(nsIDOMWindow* aWindow,
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(aWindow);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(piWindow);
MOZ_ASSERT(window->IsOuterWindow());
*aVolume = GetAudioChannelVolume(window, (AudioChannel)aAudioChannel);
return NS_OK;
@ -734,7 +728,8 @@ AudioChannelService::SetAudioChannelVolume(nsIDOMWindow* aWindow,
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(aWindow);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(piWindow);
MOZ_ASSERT(window->IsOuterWindow());
SetAudioChannelVolume(window, (AudioChannel)aAudioChannel, aVolume);
return NS_OK;
@ -759,7 +754,8 @@ AudioChannelService::GetAudioChannelMuted(nsIDOMWindow* aWindow,
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(aWindow);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(piWindow);
MOZ_ASSERT(window->IsOuterWindow());
*aMuted = GetAudioChannelMuted(window, (AudioChannel)aAudioChannel);
return NS_OK;
@ -791,7 +787,8 @@ AudioChannelService::SetAudioChannelMuted(nsIDOMWindow* aWindow,
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(aWindow);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(piWindow);
MOZ_ASSERT(window->IsOuterWindow());
SetAudioChannelMuted(window, (AudioChannel)aAudioChannel, aMuted);
return NS_OK;
@ -816,7 +813,8 @@ AudioChannelService::IsAudioChannelActive(nsIDOMWindow* aWindow,
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(aWindow);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
nsCOMPtr<nsPIDOMWindow> window = GetTopWindow(piWindow);
MOZ_ASSERT(window->IsOuterWindow());
*aActive = IsAudioChannelActive(window, (AudioChannel)aAudioChannel);
return NS_OK;

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

@ -2645,12 +2645,8 @@ Navigator::HasPresentationSupport(JSContext* aCx, JSObject* aGlobal)
return false;
}
nsCOMPtr<nsIDOMWindow> top;
nsresult rv = win->GetTop(getter_AddRefs(top));
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
win = win->GetOuterWindow();
nsCOMPtr<nsPIDOMWindow> top = win->GetTop();
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(win);
nsCOMPtr<nsIScriptObjectPrincipal> topSop = do_QueryInterface(top);
if (!sop || !topSop) {
@ -2663,8 +2659,7 @@ Navigator::HasPresentationSupport(JSContext* aCx, JSObject* aGlobal)
return false;
}
nsCOMPtr<nsPIDOMWindow> piTop = do_QueryInterface(top);
if (!piTop || !(piTop = piTop->GetCurrentInnerWindow())) {
if (!(top = top->GetCurrentInnerWindow())) {
return false;
}
@ -2675,7 +2670,7 @@ Navigator::HasPresentationSupport(JSContext* aCx, JSObject* aGlobal)
}
nsAutoString sessionId;
presentationService->GetExistentSessionIdAtLaunch(piTop->WindowID(), sessionId);
presentationService->GetExistentSessionIdAtLaunch(top->WindowID(), sessionId);
return !sessionId.IsEmpty();
}

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

@ -141,14 +141,12 @@ ThirdPartyUtil::IsThirdPartyWindow(nsIDOMWindow* aWindow,
}
}
nsCOMPtr<nsIDOMWindow> current = aWindow, parent;
nsCOMPtr<nsPIDOMWindow> current = do_QueryInterface(aWindow), parent;
nsCOMPtr<nsIURI> parentURI;
do {
// We use GetScriptableParent rather than GetParent because we consider
// <iframe mozbrowser/mozapp> to be a top-level frame.
rv = current->GetScriptableParent(getter_AddRefs(parent));
NS_ENSURE_SUCCESS(rv, rv);
parent = current->GetScriptableParent();
if (SameCOMIdentity(parent, current)) {
// We're at the topmost content window. We already know the answer.
*aResult = false;
@ -275,9 +273,12 @@ ThirdPartyUtil::IsThirdPartyChannel(nsIChannel* aChannel,
ctx->GetAssociatedWindow(getter_AddRefs(ourWin));
if (!ourWin) return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsPIDOMWindow> piOurWin = do_QueryInterface(ourWin);
MOZ_ASSERT(piOurWin);
// We use GetScriptableParent rather than GetParent because we consider
// <iframe mozbrowser/mozapp> to be a top-level frame.
ourWin->GetScriptableParent(getter_AddRefs(parentWin));
parentWin = piOurWin->GetScriptableParent();
NS_ENSURE_TRUE(parentWin, NS_ERROR_INVALID_ARG);
// Check whether this is the document channel for this window (representing a
@ -315,7 +316,6 @@ ThirdPartyUtil::GetTopWindowForChannel(nsIChannel* aChannel, nsIDOMWindow** aWin
{
NS_ENSURE_ARG(aWin);
nsresult rv;
// Find the associated window and its parent window.
nsCOMPtr<nsILoadContext> ctx;
NS_QueryNotificationCallbacks(aChannel, ctx);
@ -324,13 +324,15 @@ ThirdPartyUtil::GetTopWindowForChannel(nsIChannel* aChannel, nsIDOMWindow** aWin
}
nsCOMPtr<nsIDOMWindow> window;
rv = ctx->GetAssociatedWindow(getter_AddRefs(window));
if (!window) {
ctx->GetAssociatedWindow(getter_AddRefs(window));
nsCOMPtr<nsPIDOMWindow> top = do_QueryInterface(window);
if (!top) {
return NS_ERROR_INVALID_ARG;
}
rv = window->GetTop(aWin);
return rv;
top = top->GetTop();
top.forget(aWin);
return NS_OK;
}
// Get the base domain for aHostURI; e.g. for "www.bbc.co.uk", this would be

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

@ -1139,16 +1139,20 @@ protected:
return true;
}
uint64_t windowID = 0;
nsCOMPtr<nsIDOMWindow> topWindow;
aWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> pTopWindow = do_QueryInterface(topWindow);
if (pTopWindow) {
pTopWindow = pTopWindow->GetCurrentInnerWindow();
if (aWindow->IsOuterWindow()) {
aWindow = aWindow->GetCurrentInnerWindow();
}
if (pTopWindow) {
windowID = pTopWindow->WindowID();
MOZ_ASSERT(aWindow);
uint64_t windowID = 0;
nsCOMPtr<nsPIDOMWindow> topWindow = aWindow->GetScriptableTop();
if (topWindow) {
topWindow = topWindow->GetCurrentInnerWindow();
}
if (topWindow) {
windowID = topWindow->WindowID();
}
mImpl->AsyncOpen(principal, windowID, mRv);
@ -1210,6 +1214,8 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
}
}
MOZ_ASSERT_IF(ownerWindow, ownerWindow->IsInnerWindow());
nsTArray<nsString> protocolArray;
for (uint32_t index = 0, len = aProtocols.Length(); index < len; ++index) {
@ -1323,16 +1329,16 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
if (NS_IsMainThread()) {
MOZ_ASSERT(principal);
nsPIDOMWindow* outerWindow = ownerWindow->GetOuterWindow();
uint64_t windowID = 0;
nsCOMPtr<nsIDOMWindow> topWindow;
ownerWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> pTopWindow = do_QueryInterface(topWindow);
if (pTopWindow) {
pTopWindow = pTopWindow->GetCurrentInnerWindow();
nsCOMPtr<nsPIDOMWindow> topWindow = outerWindow->GetScriptableTop();
if (topWindow) {
topWindow = topWindow->GetCurrentInnerWindow();
}
if (pTopWindow) {
windowID = pTopWindow->WindowID();
if (topWindow) {
windowID = topWindow->WindowID();
}
webSocket->mImpl->AsyncOpen(principal, windowID, aRv);

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

@ -393,7 +393,7 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer,
return NS_OK;
}
else {
mWindow->GetSelection(getter_AddRefs(selection));
selection = mWindow->GetSelection();
if (!selection)
return NS_OK;

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

@ -188,9 +188,8 @@ nsContentPolicy::CheckPolicy(CPMethod policyMethod,
MOZ_ASSERT(window->IsOuterWindow());
if (topFrameElement) {
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetScriptableTop(getter_AddRefs(topWindow));
isTopLevel = topWindow == static_cast<nsIDOMWindow*>(window);
nsCOMPtr<nsPIDOMWindow> topWindow = window->GetScriptableTop();
isTopLevel = topWindow == window;
} else {
// If we don't have a top frame element, then requestingContext is
// part of the top-level XUL document. Presumably it's the <browser>

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

@ -6913,7 +6913,7 @@ nsContentUtils::GetRootDocument(nsIDocument* aDoc)
/* static */
bool
nsContentUtils::IsInPointerLockContext(nsIDOMWindow* aWin)
nsContentUtils::IsInPointerLockContext(nsPIDOMWindow* aWin)
{
if (!aWin) {
return false;
@ -6925,11 +6925,8 @@ nsContentUtils::IsInPointerLockContext(nsIDOMWindow* aWin)
return false;
}
nsCOMPtr<nsIDOMWindow> lockTop;
pointerLockedDoc->GetWindow()->GetScriptableTop(getter_AddRefs(lockTop));
nsCOMPtr<nsIDOMWindow> top;
aWin->GetScriptableTop(getter_AddRefs(top));
nsCOMPtr<nsPIDOMWindow> lockTop = pointerLockedDoc->GetWindow()->GetScriptableTop();
nsCOMPtr<nsPIDOMWindow> top = aWin->GetScriptableTop();
return top == lockTop;
}

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

@ -2071,7 +2071,7 @@ public:
* Returns true if aWin and the current pointer lock document
* have common scriptable top window.
*/
static bool IsInPointerLockContext(nsIDOMWindow* aWin);
static bool IsInPointerLockContext(nsPIDOMWindow* aWin);
/**
* Returns the time limit on handling user input before

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

@ -1994,15 +1994,20 @@ nsDOMWindowUtils::GetVisitedDependentComputedStyle(
aResult.Truncate();
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
nsCOMPtr<Element> element = do_QueryInterface(aElement);
NS_ENSURE_STATE(window && element);
window = window->GetCurrentInnerWindow();
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDOMCSSStyleDeclaration> decl;
nsresult rv =
window->GetComputedStyle(aElement, aPseudoElement, getter_AddRefs(decl));
NS_ENSURE_SUCCESS(rv, rv);
{
ErrorResult rv;
decl = window->GetComputedStyle(*element, aPseudoElement, rv);
ENSURE_SUCCESS(rv, rv.StealNSResult());
}
static_cast<nsComputedDOMStyle*>(decl.get())->SetExposeVisitedStyle(true);
rv = decl->GetPropertyValue(aPropertyName, aResult);
nsresult rv = decl->GetPropertyValue(aPropertyName, aResult);
static_cast<nsComputedDOMStyle*>(decl.get())->SetExposeVisitedStyle(false);
return rv;

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

@ -3275,12 +3275,11 @@ nsIDocument::HasFocus(ErrorResult& rv) const
return false;
}
// Are we an ancestor of the focused DOMWindow?
nsCOMPtr<nsIDOMDocument> domDocument;
focusedWindow->GetDocument(getter_AddRefs(domDocument));
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(focusedWindow);
MOZ_ASSERT(piWindow);
for (nsIDocument* currentDoc = document; currentDoc;
// Are we an ancestor of the focused DOMWindow?
for (nsIDocument* currentDoc = piWindow->GetDoc(); currentDoc;
currentDoc = currentDoc->GetParentDocument()) {
if (currentDoc == this) {
// Yes, we are an ancestor
@ -7002,9 +7001,11 @@ nsIDocument::GetLocation() const
return nullptr;
}
nsCOMPtr<nsIDOMLocation> loc;
w->GetLocation(getter_AddRefs(loc));
return loc.forget().downcast<nsLocation>();
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(w.get());
ErrorResult dummy;
RefPtr<nsLocation> loc = window->GetLocation(dummy);
dummy.SuppressException();
return loc.forget();
}
Element*
@ -11789,9 +11790,7 @@ ShouldApplyFullscreenDirectly(nsIDocument* aDoc,
} else {
// If we are in the chrome process, and the window has not been in
// fullscreen, we certainly need to make that fullscreen first.
bool fullscreen;
NS_WARN_IF(NS_FAILED(aRootWin->GetFullScreen(&fullscreen)));
if (!fullscreen) {
if (!aRootWin->GetFullScreen()) {
return false;
}
// The iterator not being at end indicates there is still some
@ -12493,18 +12492,15 @@ nsDocument::ShouldLockPointer(Element* aElement, Element* aCurrentLock,
return false;
}
nsCOMPtr<nsIDOMWindow> top;
ownerWindow->GetScriptableTop(getter_AddRefs(top));
nsCOMPtr<nsPIDOMWindow> piTop = do_QueryInterface(top);
if (!piTop || !piTop->GetExtantDoc() ||
piTop->GetExtantDoc()->Hidden()) {
nsCOMPtr<nsPIDOMWindow> top = ownerWindow->GetScriptableTop();
if (!top || !top->GetExtantDoc() || top->GetExtantDoc()->Hidden()) {
NS_WARNING("ShouldLockPointer(): Top document isn't visible.");
return false;
}
if (!aNoFocusCheck) {
mozilla::ErrorResult rv;
if (!piTop->GetExtantDoc()->HasFocus(rv)) {
if (!top->GetExtantDoc()->HasFocus(rv)) {
NS_WARNING("ShouldLockPointer(): Top document isn't focused.");
return false;
}
@ -13286,10 +13282,7 @@ nsAutoSyncOperation::nsAutoSyncOperation(nsIDocument* aDoc)
if (aDoc) {
nsPIDOMWindow* win = aDoc->GetWindow();
if (win) {
nsCOMPtr<nsIDOMWindow> topWindow;
win->GetTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> top = do_QueryInterface(topWindow);
if (top) {
if (nsCOMPtr<nsPIDOMWindow> top = win->GetTop()) {
nsCOMPtr<nsIDocument> doc = top->GetExtantDoc();
MarkDocumentTreeToBeInSyncOperation(doc, &mDocuments);
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -526,31 +526,21 @@ public:
{
return FromSupports(wrapper->Native());
}
/**
* Wrap nsIDOMWindow::GetTop so we can overload the inline GetTop()
* implementation below. (nsIDOMWindow::GetTop simply calls
* nsIDOMWindow::GetRealTop().)
*/
nsresult GetTop(nsIDOMWindow **aWindow)
already_AddRefed<nsPIDOMWindow> GetTop() override;
nsPIDOMWindow* GetScriptableTop() override;
inline nsGlobalWindow *GetTopInternal()
{
return nsIDOMWindow::GetTop(aWindow);
}
inline nsGlobalWindow *GetTop()
{
nsCOMPtr<nsIDOMWindow> top;
GetTop(getter_AddRefs(top));
nsGlobalWindow* outer = IsOuterWindow() ? this : GetOuterWindowInternal();
nsCOMPtr<nsPIDOMWindow> top = outer ? outer->GetTop() : nullptr;
if (top)
return static_cast<nsGlobalWindow *>(top.get());
return nullptr;
}
inline nsGlobalWindow* GetScriptableTop()
inline nsGlobalWindow* GetScriptableTopInternal()
{
nsCOMPtr<nsIDOMWindow> top;
GetScriptableTop(getter_AddRefs(top));
return static_cast<nsGlobalWindow *>(top.get());
nsPIDOMWindow* top = GetScriptableTop();
return static_cast<nsGlobalWindow*>(top);
}
nsPIDOMWindow* GetChildWindow(const nsAString& aName);
@ -695,13 +685,8 @@ public:
IsTopLevelWindow()
{
MOZ_ASSERT(IsOuterWindow());
nsCOMPtr<nsIDOMWindow> parentWindow;
nsresult rv = GetScriptableTop(getter_AddRefs(parentWindow));
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
return parentWindow == static_cast<nsIDOMWindow*>(this);
nsPIDOMWindow* parentWindow = GetScriptableTop();
return parentWindow == static_cast<nsPIDOMWindow*>(this);
}
virtual void
@ -862,6 +847,7 @@ public:
void SetNameOuter(const nsAString& aName, mozilla::ErrorResult& aError);
void SetName(const nsAString& aName, mozilla::ErrorResult& aError);
nsLocation* GetLocation(mozilla::ErrorResult& aError);
nsIDOMLocation* GetLocation() override;
nsHistory* GetHistory(mozilla::ErrorResult& aError);
mozilla::dom::BarProp* GetLocationbar(mozilla::ErrorResult& aError);
mozilla::dom::BarProp* GetMenubar(mozilla::ErrorResult& aError);
@ -875,35 +861,44 @@ public:
void SetStatus(const nsAString& aStatus, mozilla::ErrorResult& aError);
void CloseOuter(bool aTrustedCaller);
void Close(mozilla::ErrorResult& aError);
nsresult Close() override;
bool GetClosedOuter();
bool GetClosed(mozilla::ErrorResult& aError);
bool Closed() override;
void StopOuter(mozilla::ErrorResult& aError);
void Stop(mozilla::ErrorResult& aError);
void FocusOuter(mozilla::ErrorResult& aError);
void Focus(mozilla::ErrorResult& aError);
nsresult Focus() override;
void BlurOuter();
void Blur(mozilla::ErrorResult& aError);
already_AddRefed<nsIDOMWindow> GetFramesOuter();
already_AddRefed<nsIDOMWindowCollection> GetFrames() override;
already_AddRefed<nsIDOMWindow> GetFrames(mozilla::ErrorResult& aError);
uint32_t Length();
already_AddRefed<nsIDOMWindow> GetTopOuter(mozilla::ErrorResult& aError);
already_AddRefed<nsIDOMWindow> GetTopOuter();
already_AddRefed<nsIDOMWindow> GetTop(mozilla::ErrorResult& aError);
nsresult GetPrompter(nsIPrompt** aPrompt) override;
protected:
explicit nsGlobalWindow(nsGlobalWindow *aOuterWindow);
nsIDOMWindow* GetOpenerWindowOuter();
nsIDOMWindow* GetOpenerWindow(mozilla::ErrorResult& aError);
nsPIDOMWindow* GetOpenerWindowOuter();
nsPIDOMWindow* GetOpenerWindow(mozilla::ErrorResult& aError);
// Initializes the mWasOffline member variable
void InitWasOffline();
public:
void GetOpener(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
already_AddRefed<nsPIDOMWindow> GetOpener() override;
void SetOpener(JSContext* aCx, JS::Handle<JS::Value> aOpener,
mozilla::ErrorResult& aError);
using nsIDOMWindow::GetParent;
already_AddRefed<nsIDOMWindow> GetParentOuter(mozilla::ErrorResult& aError);
already_AddRefed<nsIDOMWindow> GetParentOuter();
already_AddRefed<nsIDOMWindow> GetParent(mozilla::ErrorResult& aError);
already_AddRefed<nsPIDOMWindow> GetParent() override;
nsPIDOMWindow* GetScriptableParent() override;
mozilla::dom::Element* GetFrameElementOuter();
mozilla::dom::Element* GetFrameElement(mozilla::ErrorResult& aError);
already_AddRefed<nsIDOMElement> GetFrameElement() override;
already_AddRefed<nsIDOMWindow> OpenOuter(const nsAString& aUrl,
const nsAString& aName,
const nsAString& aOptions,
@ -912,8 +907,12 @@ public:
const nsAString& aName,
const nsAString& aOptions,
mozilla::ErrorResult& aError);
nsresult Open(const nsAString& aUrl, const nsAString& aName,
const nsAString& aOptions, nsPIDOMWindow **_retval) override;
mozilla::dom::Navigator* GetNavigator(mozilla::ErrorResult& aError);
nsIDOMNavigator* GetNavigator() override;
nsIDOMOfflineResourceList* GetApplicationCache(mozilla::ErrorResult& aError);
already_AddRefed<nsIDOMOfflineResourceList> GetApplicationCache() override;
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
int16_t Orientation() const;
@ -987,18 +986,21 @@ public:
mozilla::dom::DOMStorage* GetLocalStorage(mozilla::ErrorResult& aError);
mozilla::dom::Selection* GetSelectionOuter();
mozilla::dom::Selection* GetSelection(mozilla::ErrorResult& aError);
already_AddRefed<nsISelection> GetSelection() override;
mozilla::dom::indexedDB::IDBFactory* GetIndexedDB(mozilla::ErrorResult& aError);
already_AddRefed<nsICSSDeclaration>
GetComputedStyle(mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
mozilla::ErrorResult& aError);
mozilla::ErrorResult& aError) override;
already_AddRefed<mozilla::dom::MediaQueryList> MatchMediaOuter(const nsAString& aQuery);
already_AddRefed<mozilla::dom::MediaQueryList> MatchMedia(const nsAString& aQuery,
mozilla::ErrorResult& aError);
nsScreen* GetScreen(mozilla::ErrorResult& aError);
nsIDOMScreen* GetScreen() override;
void MoveToOuter(int32_t aXPos, int32_t aYPos, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void MoveTo(int32_t aXPos, int32_t aYPos, mozilla::ErrorResult& aError);
void MoveByOuter(int32_t aXDif, int32_t aYDif, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void MoveBy(int32_t aXDif, int32_t aYDif, mozilla::ErrorResult& aError);
nsresult MoveBy(int32_t aXDif, int32_t aYDif) override;
void ResizeToOuter(int32_t aWidth, int32_t aHeight, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void ResizeTo(int32_t aWidth, int32_t aHeight,
mozilla::ErrorResult& aError);
@ -1069,6 +1071,7 @@ public:
mozilla::dom::Crypto* GetCrypto(mozilla::ErrorResult& aError);
nsIControllers* GetControllersOuter(mozilla::ErrorResult& aError);
nsIControllers* GetControllers(mozilla::ErrorResult& aError);
nsresult GetControllers(nsIControllers** aControllers) override;
mozilla::dom::Element* GetRealFrameElementOuter();
mozilla::dom::Element* GetRealFrameElement(mozilla::ErrorResult& aError);
float GetMozInnerScreenXOuter();
@ -1077,12 +1080,15 @@ public:
float GetMozInnerScreenY(mozilla::ErrorResult& aError);
float GetDevicePixelRatioOuter();
float GetDevicePixelRatio(mozilla::ErrorResult& aError);
nsresult GetDevicePixelRatio(float* aRatio) override;
int32_t GetScrollMaxX(mozilla::ErrorResult& aError);
int32_t GetScrollMaxY(mozilla::ErrorResult& aError);
bool GetFullScreenOuter();
bool GetFullScreen(mozilla::ErrorResult& aError);
bool GetFullScreen() override;
void SetFullScreenOuter(bool aFullScreen, mozilla::ErrorResult& aError);
void SetFullScreen(bool aFullScreen, mozilla::ErrorResult& aError);
nsresult SetFullScreen(bool aFullScreen) override;
void BackOuter(mozilla::ErrorResult& aError);
void Back(mozilla::ErrorResult& aError);
void ForwardOuter(mozilla::ErrorResult& aError);
@ -1114,6 +1120,10 @@ public:
const nsAString& aOptions,
const mozilla::dom::Sequence<JS::Value>& aExtraArgument,
mozilla::ErrorResult& aError);
nsresult OpenDialog(const nsAString& aUrl, const nsAString& aName,
const nsAString& aOptions,
nsISupports* aExtraArgument, nsIDOMWindow** _retval) override;
nsresult UpdateCommands(const nsAString& anAction, nsISelection* aSel, int16_t aReason) override;
already_AddRefed<nsIDOMWindow>
GetContentInternal(mozilla::ErrorResult& aError, bool aUnprivilegedCaller);
@ -1217,12 +1227,18 @@ protected:
const char* aPropName,
mozilla::ErrorResult& aError);
// And the implementations of WindowCoordGetter/WindowCoordSetter.
public:
int32_t GetInnerWidthOuter(mozilla::ErrorResult& aError);
protected:
int32_t GetInnerWidth(mozilla::ErrorResult& aError);
nsresult GetInnerWidth(int32_t* aWidth) override;
void SetInnerWidthOuter(int32_t aInnerWidth, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void SetInnerWidth(int32_t aInnerWidth, mozilla::ErrorResult& aError);
public:
int32_t GetInnerHeightOuter(mozilla::ErrorResult& aError);
protected:
int32_t GetInnerHeight(mozilla::ErrorResult& aError);
nsresult GetInnerHeight(int32_t* aHeight) override;
void SetInnerHeightOuter(int32_t aInnerHeight, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void SetInnerHeight(int32_t aInnerHeight, mozilla::ErrorResult& aError);
int32_t GetScreenXOuter(mozilla::ErrorResult& aError);

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

@ -196,8 +196,7 @@ nsMimeTypeArray::EnsurePluginMimeTypes()
return;
}
nsCOMPtr<nsIDOMNavigator> navigator;
mWindow->GetNavigator(getter_AddRefs(navigator));
nsCOMPtr<nsIDOMNavigator> navigator = mWindow->GetNavigator();
if (!navigator) {
return;

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

@ -3300,17 +3300,14 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
MOZ_ASSERT(thisContent);
nsIDocument* ownerDoc = thisContent->OwnerDoc();
nsCOMPtr<nsIDOMWindow> window = ownerDoc->GetWindow();
nsCOMPtr<nsPIDOMWindow> window = ownerDoc->GetWindow();
if (!window) {
return false;
}
nsCOMPtr<nsIDOMWindow> topWindow;
rv = window->GetTop(getter_AddRefs(topWindow));
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIDOMDocument> topDocument;
rv = topWindow->GetDocument(getter_AddRefs(topDocument));
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIDocument> topDoc = do_QueryInterface(topDocument);
nsCOMPtr<nsPIDOMWindow> topWindow = window->GetTop();
NS_ENSURE_TRUE(topWindow, false);
nsCOMPtr<nsIDocument> topDoc = topWindow->GetDoc();
NS_ENSURE_TRUE(topDoc, false);
nsCOMPtr<nsIPermissionManager> permissionManager = services::GetPermissionManager();
NS_ENSURE_TRUE(permissionManager, false);

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

@ -22,6 +22,7 @@
class nsIArray;
class nsIContent;
class nsICSSDeclaration;
class nsIDocShell;
class nsIDocument;
class nsIIdleObserver;
@ -62,8 +63,8 @@ enum UIStateChangeType
};
#define NS_PIDOMWINDOW_IID \
{ 0x052e675a, 0xacd3, 0x48d1, \
{ 0x8a, 0xcd, 0xbf, 0xff, 0xbd, 0x24, 0x4c, 0xed } }
{ 0x775dabc9, 0x8f43, 0x4277, \
{ 0x9a, 0xdb, 0xf1, 0x99, 0x0d, 0x77, 0xcf, 0xfb } }
class nsPIDOMWindow : public nsIDOMWindowInternal
{
@ -76,6 +77,23 @@ public:
virtual void ActivateOrDeactivate(bool aActivate) = 0;
// this is called GetTopWindowRoot to avoid conflicts with nsIDOMWindow::GetWindowRoot
/**
* |top| gets the root of the window hierarchy.
*
* This function does not cross chrome-content boundaries, so if this
* window's parent is of a different type, |top| will return this window.
*
* When script reads the top property, we run GetScriptableTop, which
* will not cross an <iframe mozbrowser> boundary.
*
* In contrast, C++ calls to GetTop are forwarded to GetRealTop, which
* ignores <iframe mozbrowser> boundaries.
*/
virtual already_AddRefed<nsPIDOMWindow> GetTop() = 0; // Outer only
virtual already_AddRefed<nsPIDOMWindow> GetParent() = 0;
virtual nsPIDOMWindow* GetScriptableTop() = 0;
virtual nsPIDOMWindow* GetScriptableParent() = 0;
virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() = 0;
// Inner windows only.
@ -763,6 +781,38 @@ public:
return mMarkedCCGeneration;
}
virtual nsIDOMScreen* GetScreen() = 0;
virtual nsIDOMNavigator* GetNavigator() = 0;
virtual nsIDOMLocation* GetLocation() = 0;
virtual nsresult GetPrompter(nsIPrompt** aPrompt) = 0;
virtual nsresult GetControllers(nsIControllers** aControllers) = 0;
virtual already_AddRefed<nsISelection> GetSelection() = 0;
virtual already_AddRefed<nsPIDOMWindow> GetOpener() = 0;
virtual already_AddRefed<nsIDOMWindowCollection> GetFrames() = 0;
virtual nsresult Open(const nsAString& aUrl, const nsAString& aName,
const nsAString& aOptions, nsPIDOMWindow **_retval) = 0;
virtual nsresult OpenDialog(const nsAString& aUrl, const nsAString& aName,
const nsAString& aOptions,
nsISupports* aExtraArgument, nsIDOMWindow** _retval) = 0;
virtual nsresult GetDevicePixelRatio(float* aRatio) = 0;
virtual nsresult GetInnerWidth(int32_t* aWidth) = 0;
virtual nsresult GetInnerHeight(int32_t* aHeight) = 0;
virtual already_AddRefed<nsICSSDeclaration>
GetComputedStyle(mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
mozilla::ErrorResult& aError) = 0;
virtual already_AddRefed<nsIDOMElement> GetFrameElement() = 0;
virtual already_AddRefed<nsIDOMOfflineResourceList> GetApplicationCache() = 0;
virtual bool Closed() = 0;
virtual bool GetFullScreen() = 0;
virtual nsresult SetFullScreen(bool aFullScreen) = 0;
virtual nsresult Focus() = 0;
virtual nsresult Close() = 0;
virtual nsresult MoveBy(int32_t aXDif, int32_t aYDif) = 0;
virtual nsresult UpdateCommands(const nsAString& anAction, nsISelection* aSel, int16_t aReason) = 0;
protected:
// The nsPIDOMWindow constructor. The aOuterWindow argument should
// be null if and only if the created window itself is an outer

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

@ -147,8 +147,7 @@ nsPluginArray::Refresh(bool aReloadDocuments)
mPlugins.Clear();
nsCOMPtr<nsIDOMNavigator> navigator;
mWindow->GetNavigator(getter_AddRefs(navigator));
nsCOMPtr<nsIDOMNavigator> navigator = mWindow->GetNavigator();
if (!navigator) {
return;

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

@ -312,7 +312,7 @@ nsScreen::GetWindowInnerRect(nsRect& aRect)
{
aRect.x = 0;
aRect.y = 0;
nsCOMPtr<nsIDOMWindow> win = GetOwner();
nsCOMPtr<nsPIDOMWindow> win = GetOwner();
if (!win) {
return NS_ERROR_FAILURE;
}

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

@ -63,12 +63,10 @@ AddNonJSSizeOfWindowAndItsDescendents(nsGlobalWindow* aWindow,
innerWindowSizes.addToTabSizes(aSizes);
}
nsCOMPtr<nsIDOMWindowCollection> frames;
nsresult rv = aWindow->GetFrames(getter_AddRefs(frames));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMWindowCollection> frames = aWindow->GetFrames();
uint32_t length;
rv = frames->GetLength(&length);
nsresult rv = frames->GetLength(&length);
NS_ENSURE_SUCCESS(rv, rv);
// Measure this window's descendents.
@ -252,8 +250,8 @@ CollectWindowReports(nsGlobalWindow *aWindow,
nsCOMPtr<nsIURI> location;
if (aWindow->GetOuterWindow()) {
// Our window should have a null top iff it has a null docshell.
MOZ_ASSERT(!!aWindow->GetTop() == !!aWindow->GetDocShell());
top = aWindow->GetTop();
MOZ_ASSERT(!!aWindow->GetTopInternal() == !!aWindow->GetDocShell());
top = aWindow->GetTopInternal();
if (top) {
location = GetWindowURI(top);
}
@ -747,9 +745,9 @@ CheckForGhostWindowsEnumerator(nsISupports *aKey, TimeStamp& aTimeStamp,
// Avoid calling GetTop() if we have no outer window. Nothing will break if
// we do, but it will spew debug output, which can cause our test logs to
// overflow.
nsCOMPtr<nsIDOMWindow> top;
nsCOMPtr<nsPIDOMWindow> top;
if (window->GetOuterWindow()) {
window->GetTop(getter_AddRefs(top));
top = window->GetOuterWindow()->GetTop();
}
if (top) {
@ -806,7 +804,7 @@ GetNonDetachedWindowDomainsEnumerator(const uint64_t& aId, nsGlobalWindow* aWind
// Null outer window implies null top, but calling GetTop() when there's no
// outer window causes us to spew debug warnings.
if (!aWindow->GetOuterWindow() || !aWindow->GetTop()) {
if (!aWindow->GetOuterWindow() || !aWindow->GetTopInternal()) {
// This window is detached, so we don't care about its domain.
return PL_DHASH_NEXT;
}

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

@ -242,7 +242,7 @@ nsWindowRoot::GetControllers(nsIControllers** aResult)
return focusedWindow->GetControllers(aResult);
}
else {
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(focusedWindow);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(focusedWindow);
if (domWindow)
return domWindow->GetControllers(aResult);
}

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

@ -2941,17 +2941,15 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
nsCOMPtr<nsIDocument> suspendedDoc;
nsCOMPtr<nsIRunnable> resumeTimeoutRunnable;
if (GetOwner()) {
nsCOMPtr<nsIDOMWindow> topWindow;
if (NS_SUCCEEDED(GetOwner()->GetTop(getter_AddRefs(topWindow)))) {
nsCOMPtr<nsPIDOMWindow> suspendedWindow(do_QueryInterface(topWindow));
if (suspendedWindow &&
(suspendedWindow = suspendedWindow->GetCurrentInnerWindow())) {
suspendedDoc = suspendedWindow->GetExtantDoc();
if (nsCOMPtr<nsPIDOMWindow> topWindow = GetOwner()->GetOuterWindow()->GetTop()) {
if (topWindow &&
(topWindow = topWindow->GetCurrentInnerWindow())) {
suspendedDoc = topWindow->GetExtantDoc();
if (suspendedDoc) {
suspendedDoc->SuppressEventHandling(nsIDocument::eEvents);
}
suspendedWindow->SuspendTimeouts(1, false);
resumeTimeoutRunnable = new nsResumeTimeoutsEvent(suspendedWindow);
topWindow->SuspendTimeouts(1, false);
resumeTimeoutRunnable = new nsResumeTimeoutsEvent(topWindow);
}
}
}

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

@ -117,10 +117,7 @@ BrowserElementAudioChannel::Initialize()
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetScriptableTop(getter_AddRefs(topWindow));
mFrameWindow = do_QueryInterface(topWindow);
mFrameWindow = window->GetScriptableTop();
mFrameWindow = mFrameWindow->GetOuterWindow();
return NS_OK;
}
@ -137,10 +134,7 @@ BrowserElementAudioChannel::Initialize()
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetScriptableTop(getter_AddRefs(topWindow));
mFrameWindow = do_QueryInterface(topWindow);
mFrameWindow = window->GetScriptableTop();
mFrameWindow = mFrameWindow->GetOuterWindow();
return NS_OK;
}

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

@ -258,10 +258,8 @@ BrowserElementParent::OpenWindowInProcess(nsIDOMWindow* aOpenerWindow,
// GetScriptableTop gets us the <iframe mozbrowser>'s window; we'll use its
// frame element, rather than aOpenerWindow's frame element, as our "opener
// frame element" below.
nsCOMPtr<nsIDOMWindow> topWindow;
aOpenerWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(topWindow);
nsCOMPtr<nsPIDOMWindow> openerWindow = do_QueryInterface(aOpenerWindow);
nsCOMPtr<nsPIDOMWindow> win = openerWindow->GetScriptableTop();
nsCOMPtr<Element> openerFrameElement = win->GetFrameElementInternal();
NS_ENSURE_TRUE(openerFrameElement, BrowserElementParent::OPEN_WINDOW_IGNORED);

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

@ -3023,17 +3023,17 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
EnsureDocument(mPresContext);
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (mDocument && fm) {
nsCOMPtr<nsIDOMWindow> currentWindow;
fm->GetFocusedWindow(getter_AddRefs(currentWindow));
nsCOMPtr<nsIDOMWindow> window;
fm->GetFocusedWindow(getter_AddRefs(window));
nsCOMPtr<nsPIDOMWindow> currentWindow = do_QueryInterface(window);
if (currentWindow && mDocument->GetWindow() &&
currentWindow != mDocument->GetWindow() &&
!nsContentUtils::IsChromeDoc(mDocument)) {
nsCOMPtr<nsIDOMWindow> currentTop;
nsCOMPtr<nsIDOMWindow> newTop;
currentWindow->GetTop(getter_AddRefs(currentTop));
mDocument->GetWindow()->GetTop(getter_AddRefs(newTop));
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(currentWindow);
nsCOMPtr<nsIDocument> currentDoc = win->GetExtantDoc();
nsCOMPtr<nsPIDOMWindow> currentTop;
nsCOMPtr<nsPIDOMWindow> newTop;
currentTop = currentWindow->GetTop();
newTop = mDocument->GetWindow()->GetTop();
nsCOMPtr<nsIDocument> currentDoc = currentWindow->GetExtantDoc();
if (nsContentUtils::IsChromeDoc(currentDoc) ||
(currentTop && newTop && currentTop != newTop)) {
fm->SetFocusedWindow(mDocument->GetWindow());
@ -4112,19 +4112,20 @@ GetWindowInnerRectCenter(nsPIDOMWindow* aWindow,
{
NS_ENSURE_TRUE(aWindow && aWidget && aContext, LayoutDeviceIntPoint(0, 0));
float cssInnerX = 0.0;
aWindow->GetMozInnerScreenX(&cssInnerX);
nsGlobalWindow* window = nsGlobalWindow::Cast(aWindow);
float cssInnerX = window->GetMozInnerScreenXOuter();
int32_t innerX = int32_t(NS_round(cssInnerX));
float cssInnerY = 0.0;
aWindow->GetMozInnerScreenY(&cssInnerY);
float cssInnerY = window->GetMozInnerScreenYOuter();
int32_t innerY = int32_t(NS_round(cssInnerY));
int32_t innerWidth = 0;
aWindow->GetInnerWidth(&innerWidth);
int32_t innerHeight = 0;
aWindow->GetInnerHeight(&innerHeight);
ErrorResult dummy;
int32_t innerWidth = window->GetInnerWidthOuter(dummy);
dummy.SuppressException();
int32_t innerHeight = window->GetInnerHeightOuter(dummy);
dummy.SuppressException();
nsIntRect screen;
aWidget->GetScreenBounds(screen);

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

@ -1605,14 +1605,9 @@ Geolocation::WindowOwnerStillExists()
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mOwner);
if (window) {
bool closed = false;
window->GetClosed(&closed);
if (closed) {
return false;
}
nsPIDOMWindow* outer = window->GetOuterWindow();
if (!outer || outer->GetCurrentInnerWindow() != window) {
if (!outer || outer->GetCurrentInnerWindow() != window ||
outer->Closed()) {
return false;
}
}

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

@ -4953,12 +4953,11 @@ HTMLMediaElement::GetTopLevelPrincipal()
{
RefPtr<nsIPrincipal> principal;
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(OwnerDoc()->GetParentObject());
nsCOMPtr<nsIDOMWindow> topWindow;
if (!window) {
return nullptr;
}
window->GetTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> top = do_QueryInterface(topWindow);
window = window->GetOuterWindow();
nsCOMPtr<nsPIDOMWindow> top = window->GetTop();
if (!top) {
return nullptr;
}

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

@ -132,10 +132,8 @@ public:
}
// Trying to found the top window (equivalent to window.top).
nsCOMPtr<nsIDOMWindow> top;
window->GetTop(getter_AddRefs(top));
if (top) {
window = static_cast<nsPIDOMWindow*>(top.get());
if (nsCOMPtr<nsPIDOMWindow> top = window->GetTop()) {
window = top;
}
if (window->GetFocusedNode()) {

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

@ -14,463 +14,17 @@ interface nsISelection;
interface nsIVariant;
/**
* The nsIDOMWindow interface is the primary interface for a DOM
* window object. It represents a single window object that may
* contain child windows if the document in the window contains a
* HTML frameset document or if the document contains iframe elements.
*
* @see <http://www.whatwg.org/html/#window>
* Empty interface for compatibility with older versions.
* @deprecated Use WebIDL for script visible features,
* nsPIDOMWindow for C++ callers.
*/
[scriptable, uuid(ab30b7cc-f7f9-4b9b-befb-7dbf6cf86d46)]
interface nsIDOMWindow : nsISupports
{
// the current browsing context
readonly attribute nsIDOMWindow window;
/* [replaceable] self */
readonly attribute nsIDOMWindow self;
/**
* Accessor for the document in this window.
*/
readonly attribute nsIDOMDocument document;
/**
* Set/Get the name of this window.
*
* This attribute is "replaceable" in JavaScript
*/
attribute DOMString name;
/* The setter that takes a string argument needs to be special cased! */
readonly attribute nsIDOMLocation location;
readonly attribute nsISupports history;
/* [replaceable] locationbar */
/* BarProp */
readonly attribute nsISupports locationbar;
/* [replaceable] menubar */
/* BarProp */
readonly attribute nsISupports menubar;
/* [replaceable] personalbar */
/* BarProp */
readonly attribute nsISupports personalbar;
/**
* Accessor for the object that controls whether or not scrollbars
* are shown in this window.
*
* This attribute is "replaceable" in JavaScript
*/
/* BarProp */
readonly attribute nsISupports scrollbars;
/* [replaceable] statusbar */
/* BarProp */
readonly attribute nsISupports statusbar;
/* [replaceable] toolbar */
/* BarProp */
readonly attribute nsISupports toolbar;
/* [replaceable] */
attribute DOMString status;
void close();
void stop();
void focus();
void blur();
// other browsing contexts
/* [replaceable] length */
readonly attribute unsigned long length;
/**
* |top| gets the root of the window hierarchy.
*
* This function does not cross chrome-content boundaries, so if this
* window's parent is of a different type, |top| will return this window.
*
* When script reads the top property, we run GetScriptableTop, which
* will not cross an <iframe mozbrowser> boundary.
*
* In contrast, C++ calls to GetTop are forwarded to GetRealTop, which
* ignores <iframe mozbrowser> boundaries.
*
* This property is "replaceable" in JavaScript.
*/
[binaryname(ScriptableTop)]
readonly attribute nsIDOMWindow top;
/**
* You shouldn't need to call this function directly; call GetTop instead.
*/
[noscript]
readonly attribute nsIDOMWindow realTop;
%{C++
nsresult GetTop(nsIDOMWindow **aWindow)
{
return GetRealTop(aWindow);
}
%}
/**
* |parent| gets this window's parent window. If this window has no parent,
* we return the window itself.
*
* This property does not cross chrome-content boundaries, so if this
* window's parent is of a different type, we return the window itself as its
* parent.
*
* When script reads the property (or when C++ calls ScriptableTop), this
* property does not cross <iframe mozbrowser> boundaries. In contrast, when
* C++ calls GetParent, we ignore the mozbrowser attribute.
*/
[binaryname(ScriptableParent)]
readonly attribute nsIDOMWindow parent;
/**
* You shouldn't need to read this property directly; call GetParent instead.
*/
[noscript]
readonly attribute nsIDOMWindow realParent;
%{C++
inline nsresult GetParent(nsIDOMWindow **aWindow)
{
return GetRealParent(aWindow);
}
%}
[implicit_jscontext, binaryname(ScriptableOpener)]
attribute jsval opener;
[noscript, binaryname(Opener)]
attribute nsIDOMWindow openerWindow;
/**
* |frameElement| gets this window's <iframe> or <frame> element, if it has
* one.
*
* When script reads this property (or when C++ calls
* ScriptableFrameElement), we return |null| if the window is inside an
* <iframe mozbrowser>. In contrast, when C++ calls GetFrameElement, we
* ignore the mozbrowser attribute.
*/
[binaryname(ScriptableFrameElement)]
readonly attribute nsIDOMElement frameElement;
/**
* You shouldn't need to read this property directly; call GetFrameElement
* instead.
*/
[noscript]
readonly attribute nsIDOMElement realFrameElement;
%{C++
inline nsresult GetFrameElement(nsIDOMElement **aElement)
{
return GetRealFrameElement(aElement);
}
%}
// the user agent
readonly attribute nsIDOMNavigator navigator;
/**
* Get the application cache object for this window.
*/
readonly attribute nsIDOMOfflineResourceList applicationCache;
// user prompts
void alert([optional, Null(Stringify)] in DOMString text);
boolean confirm([optional] in DOMString text);
// prompt() should return a null string if cancel is pressed
DOMString prompt([optional] in DOMString aMessage,
[optional] in DOMString aInitial);
void print();
[optional_argc]
nsIVariant showModalDialog(in DOMString aURI,
[optional] in nsIVariant aArgs,
[optional] in DOMString aOptions);
// cross-document messaging
/**
* Implements a safe message-passing system which can cross same-origin
* boundaries.
*
* This method, when called, causes a MessageEvent to be asynchronously
* dispatched at the primary document for the window upon which this method is
* called. (Note that the postMessage property on windows is allAccess and
* thus is readable cross-origin.) The dispatched event will have message as
* its data, the calling context's window as its source, and an origin
* determined by the calling context's main document URI. The targetOrigin
* argument specifies a URI and is used to restrict the message to be sent
* only when the target window has the same origin as targetOrigin (since,
* when the sender and the target have different origins, neither can read the
* location of the other).
*
* @see <http://www.whatwg.org/html/#dom-window-postmessage>
*/
[implicit_jscontext, binaryname(PostMessageMoz)]
void postMessage(in jsval message, in DOMString targetOrigin,
[optional] in jsval transfer);
// WindowBase64
// Ascii base64 data to binary data and vice versa...
DOMString atob(in DOMString aAsciiString);
DOMString btoa(in DOMString aBase64Data);
// WindowSessionStorage
/**
* Session storage for the current browsing context.
* This attribute is a DOMStorage
*/
readonly attribute nsISupports sessionStorage;
// WindowLocalStorage
/**
* Local storage for the current browsing context.
* This attribute is a DOMStorage
*/
readonly attribute nsISupports localStorage;
// IndexedDB
// https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#requests
// IDBEnvironment
readonly attribute nsISupports indexedDB;
// DOM Range
/**
* Method for accessing this window's selection object.
*/
nsISelection getSelection();
// CSSOM-View
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-window-interface
nsISupports matchMedia(in DOMString media_query_list);
readonly attribute nsIDOMScreen screen;
// viewport
attribute long innerWidth;
attribute long innerHeight;
// viewport scrolling
/**
* Accessor for the current x scroll position in this window in
* pixels.
*
* This attribute is "replaceable" in JavaScript
*/
readonly attribute long scrollX;
/* The offset in pixels by which the window is scrolled */
readonly attribute long pageXOffset;
/**
* Accessor for the current y scroll position in this window in
* pixels.
*
* This attribute is "replaceable" in JavaScript
*/
readonly attribute long scrollY;
/* The offset in pixels by which the window is scrolled */
readonly attribute long pageYOffset;
void scroll(in long xScroll, in long yScroll);
/**
* Method for scrolling this window to an absolute pixel offset.
*/
void scrollTo(in long xScroll, in long yScroll);
/**
* Method for scrolling this window to a pixel offset relative to
* the current scroll position.
*/
void scrollBy(in long xScrollDif, in long yScrollDif);
// client
attribute long screenX;
attribute long screenY;
attribute long outerWidth;
attribute long outerHeight;
// CSSOM
/**
* @see <http://dev.w3.org/csswg/cssom/#dom-window-getcomputedstyle>
*/
nsIDOMCSSStyleDeclaration getComputedStyle(in nsIDOMElement elt,
[optional] in DOMString pseudoElt);
nsIDOMCSSStyleDeclaration getDefaultComputedStyle(in nsIDOMElement elt,
[optional] in DOMString pseudoElt);
// Mozilla extensions
/**
* Get the window root for this window. This is useful for hooking
* up event listeners to this window and every other window nested
* in the window root.
*/
[noscript] readonly attribute nsIDOMEventTarget windowRoot;
/**
* Accessor for the child windows in this window.
*/
[noscript] readonly attribute nsIDOMWindowCollection frames;
/**
* Set/Get the document scale factor as a multiplier on the default
* size. When setting this attribute, a NS_ERROR_NOT_IMPLEMENTED
* error may be returned by implementations not supporting
* zoom. Implementations not supporting zoom should return 1.0 all
* the time for the Get operation. 1.0 is equals normal size,
* i.e. no zoom.
*/
[noscript] attribute float textZoom;
/**
* Method for scrolling this window by a number of lines.
*/
void scrollByLines(in long numLines);
/**
* Method for scrolling this window by a number of pages.
*/
void scrollByPages(in long numPages);
/**
* Method for sizing this window to the content in the window.
*/
void sizeToContent();
/* [replaceable] prompter */
[noscript] readonly attribute nsIPrompt prompter;
readonly attribute boolean closed;
readonly attribute nsIDOMCrypto crypto;
// Note: this is [ChromeOnly] scriptable via WebIDL.
[noscript] readonly attribute nsIControllers controllers;
readonly attribute float mozInnerScreenX;
readonly attribute float mozInnerScreenY;
readonly attribute float devicePixelRatio;
/* The maximum offset that the window can be scrolled to
(i.e., the document width/height minus the scrollport width/height) */
readonly attribute long scrollMaxX;
readonly attribute long scrollMaxY;
attribute boolean fullScreen;
void back();
void forward();
void home();
void moveTo(in long xPos, in long yPos);
void moveBy(in long xDif, in long yDif);
void resizeTo(in long width, in long height);
void resizeBy(in long widthDif, in long heightDif);
/**
* Open a new window with this one as the parent. This method will
* NOT examine the JS stack for purposes of determining a caller.
* This window will be used for security checks during the search by
* name and the default character set on the newly opened window
* will just be the default character set of this window.
*/
[noscript] nsIDOMWindow open(in DOMString url, in DOMString name,
in DOMString options);
/**
* This method works like open except that aExtraArgument gets
* converted into the array window.arguments in JS, if
* aExtraArgument is a nsISupportsArray then the individual items in
* the array are inserted into window.arguments, and primitive
* nsISupports (nsISupportsPrimitives) types are converted to native
* JS types when possible.
*/
[noscript] nsIDOMWindow openDialog(in DOMString url, in DOMString name,
in DOMString options,
in nsISupports aExtraArgument);
// XXX Should this be in nsIDOMChromeWindow?
void updateCommands(in DOMString action,
[optional] in nsISelection sel,
[optional] in short reason);
/* Find in page.
* @param str: the search pattern
* @param caseSensitive: is the search caseSensitive
* @param backwards: should we search backwards
* @param wrapAround: should we wrap the search
* @param wholeWord: should we search only for whole words
* @param searchInFrames: should we search through all frames
* @param showDialog: should we show the Find dialog
*/
boolean find([optional] in DOMString str,
[optional] in boolean caseSensitive,
[optional] in boolean backwards,
[optional] in boolean wrapAround,
[optional] in boolean wholeWord,
[optional] in boolean searchInFrames,
[optional] in boolean showDialog);
/**
* Returns the number of times this document for this window has
* been painted to the screen.
*/
readonly attribute unsigned long long mozPaintCount;
/**
* Request a refresh of this browser window.
*
* @see <http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html>
*/
// jsval because we want a WebIDL callback here
[implicit_jscontext]
long requestAnimationFrame(in jsval aCallback);
/**
* Cancel a refresh callback.
*/
void cancelAnimationFrame(in long aHandle);
/**
* Console API
*/
[implicit_jscontext] attribute jsval console;
};
[scriptable, uuid(b8343993-0383-4add-9930-ad176b189240)]
interface nsIDOMWindow : nsISupports {};
/**
* Empty interface for compatibility with older versions.
* @deprecated Use nsIDOMWindow instead
*/
[scriptable, uuid(2ec49e81-b2ba-4633-991a-f48f1e1d8800)]
[scriptable, uuid(8c589e65-3237-4cd1-8bad-c5c47135e79b)]
interface nsIDOMWindowInternal : nsIDOMWindow {};

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

@ -1191,20 +1191,8 @@ TabChild::ProvideWindowCommon(nsIDOMWindow* aOpener,
NS_ConvertUTF8toUTF16(features),
aWindowIsNew);
} else {
nsCOMPtr<nsIDOMDocument> domDoc;
aOpener->GetDocument(getter_AddRefs(domDoc));
if (!domDoc) {
NS_ERROR("Could retrieve document from nsIBaseWindow");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc;
doc = do_QueryInterface(domDoc);
if (!doc) {
NS_ERROR("Document from nsIBaseWindow didn't QI to nsIDocument");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsPIDOMWindow> opener = do_QueryInterface(aOpener);
nsCOMPtr<nsIDocument> doc = opener->GetDoc();
nsCOMPtr<nsIURI> baseURI = doc->GetDocBaseURI();
if (!baseURI) {
NS_ERROR("nsIDocument didn't return a base URI");

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

@ -755,7 +755,7 @@ private:
nsCString* mURLToLoad;
};
static already_AddRefed<nsIDOMWindow>
static already_AddRefed<nsPIDOMWindow>
FindMostRecentOpenWindow()
{
nsCOMPtr<nsIWindowMediator> windowMediator =
@ -764,17 +764,16 @@ FindMostRecentOpenWindow()
windowMediator->GetEnumerator(MOZ_UTF16("navigator:browser"),
getter_AddRefs(windowEnumerator));
nsCOMPtr<nsIDOMWindow> latest;
nsCOMPtr<nsPIDOMWindow> latest;
bool hasMore = false;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(windowEnumerator->HasMoreElements(&hasMore)));
while (hasMore) {
nsCOMPtr<nsISupports> item;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(windowEnumerator->GetNext(getter_AddRefs(item))));
nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(item);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(item);
bool isClosed;
if (window && NS_SUCCEEDED(window->GetClosed(&isClosed)) && !isClosed) {
if (window && !window->Closed()) {
latest = window;
}
@ -827,17 +826,14 @@ TabParent::RecvCreateWindow(PBrowserParent* aNewTab,
nsCOMPtr<nsIContent> frame(do_QueryInterface(mFrameElement));
nsCOMPtr<nsIDOMWindow> parent;
nsCOMPtr<nsPIDOMWindow> parent;
if (frame) {
parent = do_QueryInterface(frame->OwnerDoc()->GetWindow());
parent = frame->OwnerDoc()->GetWindow();
// If our chrome window is in the process of closing, don't try to open a
// new tab in it.
if (parent) {
bool isClosed;
if (NS_SUCCEEDED(parent->GetClosed(&isClosed)) && isClosed) {
parent = nullptr;
}
if (parent && parent->Closed()) {
parent = nullptr;
}
}

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

@ -312,9 +312,8 @@ MediaKeys::Init(ErrorResult& aRv)
NS_LITERAL_CSTRING("Couldn't get top-level window in MediaKeys::Init"));
return promise.forget();
}
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> top = do_QueryInterface(topWindow);
window = window->GetOuterWindow();
nsCOMPtr<nsPIDOMWindow> top = window->GetTop();
if (!top || !top->GetExtantDoc()) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
NS_LITERAL_CSTRING("Couldn't get document in MediaKeys::Init"));

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

@ -3030,11 +3030,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
#ifndef XP_MACOSX
// If we're running in the content process, we need a remote widget created in chrome.
if (XRE_IsContentProcess()) {
nsCOMPtr<nsIDOMWindow> window = doc->GetWindow();
if (window) {
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetTop(getter_AddRefs(topWindow));
if (topWindow) {
if (nsCOMPtr<nsPIDOMWindow> window = doc->GetWindow()) {
if (nsCOMPtr<nsPIDOMWindow> topWindow = window->GetTop()) {
dom::TabChild* tc = dom::TabChild::GetFrom(topWindow);
if (tc) {
// This returns a PluginWidgetProxy which remotes a number of calls.

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

@ -217,15 +217,12 @@ nsDeviceSensors::Notify(const mozilla::hal::SensorData& aSensorData)
continue;
}
nsCOMPtr<nsIDOMDocument> domdoc;
windowListeners[i]->GetDocument(getter_AddRefs(domdoc));
if (domdoc) {
if (nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(pwindow->GetDoc())) {
nsCOMPtr<mozilla::dom::EventTarget> target = do_QueryInterface(windowListeners[i]);
if (type == nsIDeviceSensorData::TYPE_ACCELERATION ||
type == nsIDeviceSensorData::TYPE_LINEAR_ACCELERATION ||
type == nsIDeviceSensorData::TYPE_GYROSCOPE)
FireDOMMotionEvent(domdoc, target, type, x, y, z);
FireDOMMotionEvent(domDoc, target, type, x, y, z);
else if (type == nsIDeviceSensorData::TYPE_ORIENTATION)
FireDOMOrientationEvent(target, x, y, z);
else if (type == nsIDeviceSensorData::TYPE_PROXIMITY)

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

@ -572,9 +572,10 @@ nsXBLPrototypeHandler::GetController(EventTarget* aTarget)
}
if (!controllers) {
nsCOMPtr<nsIDOMWindow> domWindow(do_QueryInterface(aTarget));
if (domWindow)
nsCOMPtr<nsPIDOMWindow> domWindow(do_QueryInterface(aTarget));
if (domWindow) {
domWindow->GetControllers(getter_AddRefs(controllers));
}
}
// Return the first controller.

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

@ -5,14 +5,13 @@
#include "nsXMLPrettyPrinter.h"
#include "nsContentUtils.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsICSSDeclaration.h"
#include "nsIDOMDocumentXBL.h"
#include "nsIObserver.h"
#include "nsIXSLTProcessor.h"
#include "nsSyncLoadService.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIServiceManager.h"
#include "nsNetUtil.h"
#include "mozilla/dom/Element.h"
@ -55,22 +54,24 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument,
// check if we're in an invisible iframe
nsPIDOMWindow *internalWin = aDocument->GetWindow();
nsCOMPtr<nsIDOMElement> frameElem;
nsCOMPtr<Element> frameElem;
if (internalWin) {
internalWin->GetFrameElement(getter_AddRefs(frameElem));
frameElem = internalWin->GetFrameElementInternal();
}
if (frameElem) {
nsCOMPtr<nsIDOMCSSStyleDeclaration> computedStyle;
nsCOMPtr<nsIDOMDocument> frameOwnerDoc;
frameElem->GetOwnerDocument(getter_AddRefs(frameOwnerDoc));
if (frameOwnerDoc) {
nsCOMPtr<nsIDOMWindow> window;
frameOwnerDoc->GetDefaultView(getter_AddRefs(window));
if (window) {
window->GetComputedStyle(frameElem,
EmptyString(),
getter_AddRefs(computedStyle));
nsCOMPtr<nsICSSDeclaration> computedStyle;
if (nsIDocument* frameOwnerDoc = frameElem->OwnerDoc()) {
nsCOMPtr<nsIDOMWindow> window = frameOwnerDoc->GetDefaultView();
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(window);
if (piWindow) {
piWindow = piWindow->GetCurrentInnerWindow();
ErrorResult dummy;
computedStyle = piWindow->GetComputedStyle(*frameElem,
EmptyString(),
dummy);
dummy.SuppressException();
}
}

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

@ -160,13 +160,11 @@ nsXULCommandDispatcher::GetFocusedWindow(nsIDOMWindow** aWindow)
// Make sure the caller can access this window. The caller can access this
// window iff it can access the document.
nsCOMPtr<nsIDOMDocument> domdoc;
nsresult rv = window->GetDocument(getter_AddRefs(domdoc));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
// Note: If there is no document, then this window has been cleared and
// there's nothing left to protect, so let the window pass through.
if (domdoc && !nsContentUtils::CanCallerAccess(domdoc))
if (doc && !nsContentUtils::CanCallerAccess(doc))
return NS_ERROR_DOM_SECURITY_ERR;
window.forget(aWindow);

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

@ -120,15 +120,13 @@ nsXULPopupListener::HandleEvent(nsIDOMEvent* aEvent)
if (!targetNode && mIsContext) {
// Not a DOM node, see if it's the DOM window (bug 380818).
nsCOMPtr<nsIDOMWindow> domWin = do_QueryInterface(target);
nsCOMPtr<nsPIDOMWindow> domWin = do_QueryInterface(target);
if (!domWin) {
return NS_ERROR_DOM_WRONG_TYPE_ERR;
}
// Try to use the root node as target node.
nsCOMPtr<nsIDOMDocument> domDoc;
domWin->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc = domWin->GetDoc();
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
if (doc)
targetNode = do_QueryInterface(doc->GetRootElement());
if (!targetNode) {

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

@ -339,11 +339,13 @@ nsComposerCommandsUpdater::UpdateOneCommand(const char *aCommand)
bool
nsComposerCommandsUpdater::SelectionIsCollapsed()
{
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryReferent(mDOMWindow);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryReferent(mDOMWindow);
NS_ENSURE_TRUE(domWindow, true);
nsCOMPtr<nsISelection> domSelection;
if (NS_SUCCEEDED(domWindow->GetSelection(getter_AddRefs(domSelection))) && domSelection)
domWindow = domWindow->GetOuterWindow();
NS_ENSURE_TRUE(domWindow, true);
if (nsCOMPtr<nsISelection> domSelection = domWindow->GetSelection())
{
bool selectionCollapsed = false;
domSelection->GetIsCollapsed(&selectionCollapsed);

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

@ -302,11 +302,12 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
//must get the content type
// Note: the doc gets this from the network channel during StartPageLoad,
// so we don't have to get it from there ourselves
nsCOMPtr<nsIDOMDocument> doc;
nsAutoCString mimeCType;
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow);
MOZ_ASSERT(window);
//then lets check the mime type
if (NS_SUCCEEDED(aWindow->GetDocument(getter_AddRefs(doc))) && doc)
if (nsCOMPtr<nsIDocument> doc = window->GetDoc())
{
nsAutoString mimeType;
if (NS_SUCCEEDED(doc->GetContentType(mimeType)))
@ -534,9 +535,11 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow)
mDoneSetup = false;
// Check if we're turning off editing (from contentEditable or designMode).
nsCOMPtr<nsIDOMDocument> domDoc;
aWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow);
MOZ_ASSERT(window);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
bool stopEditing = htmlDoc && htmlDoc->IsEditingOn();
if (stopEditing)
RemoveWebProgressListener(aWindow);
@ -572,9 +575,6 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow)
if (mMakeWholeDocumentEditable)
{
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc, &rv);
NS_ENSURE_SUCCESS(rv, rv);
doc->SetEditableFlag(false);
nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(doc);
if (htmlDocument) {
@ -673,8 +673,8 @@ nsEditingSession::OnStateChange(nsIWebProgress *aWebProgress,
nsCOMPtr<nsIDOMWindow> window;
aWebProgress->GetDOMWindow(getter_AddRefs(window));
nsCOMPtr<nsIDOMDocument> doc;
window->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(window);
nsCOMPtr<nsIDocument> doc = piWindow->GetDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(doc));
@ -800,11 +800,10 @@ nsEditingSession::OnLocationChange(nsIWebProgress *aWebProgress,
nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMDocument> domDoc;
rv = domWindow->GetDocument(getter_AddRefs(domDoc));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(domWindow);
MOZ_ASSERT(piWindow);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
nsCOMPtr<nsIDocument> doc = piWindow->GetDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
doc->SetDocumentURI(aURI);
@ -1162,8 +1161,11 @@ nsEditingSession::SetupEditorCommandController(
NS_ENSURE_ARG_POINTER(aContext);
NS_ENSURE_ARG_POINTER(aControllerId);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
MOZ_ASSERT(piWindow);
nsCOMPtr<nsIControllers> controllers;
nsresult rv = aWindow->GetControllers(getter_AddRefs(controllers));
nsresult rv = piWindow->GetControllers(getter_AddRefs(controllers));
NS_ENSURE_SUCCESS(rv, rv);
// We only have to create each singleton controller once
@ -1201,8 +1203,11 @@ nsEditingSession::SetEditorOnControllers(nsIDOMWindow *aWindow,
{
NS_ENSURE_TRUE(aWindow, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
MOZ_ASSERT(piWindow);
nsCOMPtr<nsIControllers> controllers;
nsresult rv = aWindow->GetControllers(getter_AddRefs(controllers));
nsresult rv = piWindow->GetControllers(getter_AddRefs(controllers));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupports> editorAsISupports = do_QueryInterface(aEditor);
@ -1253,8 +1258,9 @@ nsEditingSession::RemoveEditorControllers(nsIDOMWindow *aWindow)
// tearing down/detaching editor.
nsCOMPtr<nsIControllers> controllers;
if (aWindow)
aWindow->GetControllers(getter_AddRefs(controllers));
if (nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow)) {
piWindow->GetControllers(getter_AddRefs(controllers));
}
if (controllers)
{

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

@ -50,4 +50,5 @@ FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/dom/base',
'/dom/svg',
'/layout/style',
]

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

@ -17,7 +17,7 @@
#include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLLinkElement.h"
#include "nsIDOMWindow.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsICSSDeclaration.h"
#include "nsIDOMCSSValue.h"
#include "nsIDOMCSSPrimitiveValue.h"
#include "nsNetUtil.h"
@ -29,6 +29,9 @@
#include "nsAutoPtr.h"
#include "imgRequestProxy.h"
using mozilla::dom::Element;
using mozilla::ErrorResult;
NS_IMPL_ISUPPORTS(nsContextMenuInfo, nsIContextMenuInfo)
nsContextMenuInfo::nsContextMenuInfo()
@ -260,6 +263,11 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode* aDOMNode,
document->GetDefaultView(getter_AddRefs(window));
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(window);
MOZ_ASSERT(piWindow);
piWindow = piWindow->GetCurrentInnerWindow();
MOZ_ASSERT(piWindow);
nsCOMPtr<nsIDOMCSSPrimitiveValue> primitiveValue;
nsAutoString bgStringValue;
@ -267,15 +275,16 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode* aDOMNode,
nsCOMPtr<nsIPrincipal> principal = doc ? doc->NodePrincipal() : nullptr;
while (true) {
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(domNode));
nsCOMPtr<Element> domElement(do_QueryInterface(domNode));
// bail for the parent node of the root element or null argument
if (!domElement) {
break;
}
nsCOMPtr<nsIDOMCSSStyleDeclaration> computedStyle;
window->GetComputedStyle(domElement, EmptyString(),
getter_AddRefs(computedStyle));
ErrorResult dummy;
nsCOMPtr<nsICSSDeclaration> computedStyle =
piWindow->GetComputedStyle(*domElement, EmptyString(), dummy);
dummy.SuppressException();
if (computedStyle) {
nsCOMPtr<nsIDOMCSSValue> cssValue;
computedStyle->GetPropertyCSSValue(NS_LITERAL_STRING("background-image"),

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

@ -248,10 +248,10 @@ nsCommandManager::GetControllerForCommand(const char* aCommand,
}
}
if (aTargetWindow) {
if (nsCOMPtr<nsPIDOMWindow> targetWindow = do_QueryInterface(aTargetWindow)) {
// get the controller for this particular window
nsCOMPtr<nsIControllers> controllers;
rv = aTargetWindow->GetControllers(getter_AddRefs(controllers));
rv = targetWindow->GetControllers(getter_AddRefs(controllers));
if (NS_FAILED(rv)) {
return rv;
}

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

@ -354,13 +354,12 @@ void
nsWebBrowserFind::SetSelectionAndScroll(nsIDOMWindow* aWindow,
nsIDOMRange* aRange)
{
nsCOMPtr<nsIDOMDocument> domDoc;
aWindow->GetDocument(getter_AddRefs(domDoc));
if (!domDoc) {
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
nsCOMPtr<nsIDocument> doc = piWindow->GetDoc();
if (!doc) {
return;
}
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
nsIPresShell* presShell = doc->GetShell();
if (!presShell) {
return;
@ -701,18 +700,13 @@ nsWebBrowserFind::SearchInFrame(nsIDOMWindow* aWindow, bool aWrapping,
*aDidFind = false;
nsCOMPtr<nsIDOMDocument> domDoc;
nsresult rv = aWindow->GetDocument(getter_AddRefs(domDoc));
NS_ENSURE_SUCCESS(rv, rv);
if (!domDoc) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
// Do security check, to ensure that the frame we're searching is
// acccessible from the frame where the Find is being run.
// get a uri for the window
nsCOMPtr<nsIDocument> theDoc = do_QueryInterface(domDoc);
nsCOMPtr<nsIDocument> theDoc = piWindow->GetDoc();
if (!theDoc) {
return NS_ERROR_FAILURE;
}
@ -721,6 +715,7 @@ nsWebBrowserFind::SearchInFrame(nsIDOMWindow* aWindow, bool aWrapping,
return NS_ERROR_DOM_PROP_ACCESS_DENIED;
}
nsresult rv;
nsCOMPtr<nsIFind> find = do_CreateInstance(NS_FIND_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -747,6 +742,9 @@ nsWebBrowserFind::SearchInFrame(nsIDOMWindow* aWindow, bool aWrapping,
nsCOMPtr<nsIDOMRange> foundRange;
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(theDoc);
MOZ_ASSERT(domDoc);
// If !aWrapping, search from selection to end
if (!aWrapping)
rv = GetSearchLimits(searchRange, startPt, endPt, domDoc, sel, false);
@ -794,13 +792,12 @@ nsWebBrowserFind::GetFrameSelection(nsIDOMWindow* aWindow, nsISelection** aSel)
{
*aSel = nullptr;
nsCOMPtr<nsIDOMDocument> domDoc;
aWindow->GetDocument(getter_AddRefs(domDoc));
if (!domDoc) {
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
nsCOMPtr<nsIDocument> doc = piWindow->GetDoc();
if (!doc) {
return;
}
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
nsIPresShell* presShell = doc->GetShell();
if (!presShell) {
return;

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

@ -10,6 +10,7 @@
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsPIDOMWindow.h"
NS_IMPL_ADDREF(nsPrintProgress)
NS_IMPL_RELEASE(nsPrintProgress)
@ -62,8 +63,11 @@ NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nullptr;
if (! m_closeProgress && m_dialog)
return m_dialog->GetPrompter(_retval);
if (! m_closeProgress && m_dialog) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(m_dialog);
MOZ_ASSERT(window);
return window->GetPrompter(_retval);
}
return NS_ERROR_FAILURE;
}

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

@ -92,13 +92,16 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
nsCOMPtr<nsIDOMWindow> ownerWindow = do_GetInterface(ownerXULWindow);
NS_ENSURE_STATE(ownerWindow);
nsCOMPtr<nsPIDOMWindow> piOwnerWindow = do_QueryInterface(ownerWindow);
MOZ_ASSERT(piOwnerWindow);
// Open the dialog.
nsCOMPtr<nsIDOMWindow> newWindow;
rv = ownerWindow->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL),
NS_LITERAL_STRING("_blank"),
NS_LITERAL_STRING("chrome,titlebar,dependent,centerscreen"),
array, getter_AddRefs(newWindow));
rv = piOwnerWindow->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL),
NS_LITERAL_STRING("_blank"),
NS_LITERAL_STRING("chrome,titlebar,dependent,centerscreen"),
array, getter_AddRefs(newWindow));
}
return rv;
@ -117,8 +120,11 @@ NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nullptr;
if (! m_closeProgress && m_dialog)
return m_dialog->GetPrompter(_retval);
if (! m_closeProgress && m_dialog) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(m_dialog);
MOZ_ASSERT(window);
return window->GetPrompter(_retval);
}
return NS_ERROR_FAILURE;
}

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

@ -120,12 +120,15 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
nsCOMPtr<nsIDOMWindow> ownerWindow = do_GetInterface(ownerXULWindow);
NS_ENSURE_STATE(ownerWindow);
nsCOMPtr<nsPIDOMWindow> piOwnerWindow = do_QueryInterface(ownerWindow);
MOZ_ASSERT(piOwnerWindow);
// Open the dialog.
nsCOMPtr<nsIDOMWindow> newWindow;
rv = ownerWindow->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL),
NS_LITERAL_STRING("_blank"),
NS_LITERAL_STRING("chrome,titlebar,dependent,centerscreen"),
array, getter_AddRefs(newWindow));
rv = piOwnerWindow->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL),
NS_LITERAL_STRING("_blank"),
NS_LITERAL_STRING("chrome,titlebar,dependent,centerscreen"),
array, getter_AddRefs(newWindow));
}
return rv;
@ -144,8 +147,11 @@ NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nullptr;
if (! m_closeProgress && m_dialog)
return m_dialog->GetPrompter(_retval);
if (! m_closeProgress && m_dialog) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(m_dialog);
MOZ_ASSERT(window);
return window->GetPrompter(_retval);
}
return NS_ERROR_FAILURE;
}

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

@ -549,9 +549,7 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow* aParent,
bool hasChromeParent = true;
if (aParent) {
// Check if the parent document has chrome privileges.
nsCOMPtr<nsIDOMDocument> domdoc;
aParent->GetDocument(getter_AddRefs(domdoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
nsIDocument* doc = parentWindow->GetDoc();
hasChromeParent =
doc && nsContentUtils::IsChromeDoc(doc) && !openedFromRemoteTab;
}
@ -630,11 +628,7 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow* aParent,
// If the parent trying to open a new window is sandboxed
// without 'allow-popups', this is not allowed and we fail here.
if (aParent) {
nsCOMPtr<nsIDOMDocument> domdoc;
aParent->GetDocument(getter_AddRefs(domdoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
if (doc) {
if (nsIDocument* doc = parentWindow->GetDoc()) {
// Save sandbox flags for copying to new browsing context (docShell).
activeDocsSandboxFlags = doc->GetSandboxFlags();
if (activeDocsSandboxFlags & SANDBOXED_AUXILIARY_NAVIGATION) {
@ -1437,11 +1431,11 @@ nsWindowWatcher::URIfromURL(const char* aURL,
nsIURI** aURI)
{
// Build the URI relative to the entry global.
nsCOMPtr<nsIDOMWindow> baseWindow = do_QueryInterface(GetEntryGlobal());
nsCOMPtr<nsPIDOMWindow> baseWindow = do_QueryInterface(GetEntryGlobal());
// failing that, build it relative to the parent window, if possible
if (!baseWindow) {
baseWindow = aParent;
baseWindow = do_QueryInterface(aParent);
}
// failing that, use the given URL unmodified. It had better not be relative.
@ -1450,14 +1444,8 @@ nsWindowWatcher::URIfromURL(const char* aURL,
// get baseWindow's document URI
if (baseWindow) {
nsCOMPtr<nsIDOMDocument> domDoc;
baseWindow->GetDocument(getter_AddRefs(domDoc));
if (domDoc) {
nsCOMPtr<nsIDocument> doc;
doc = do_QueryInterface(domDoc);
if (doc) {
baseURI = doc->GetDocBaseURI();
}
if (nsIDocument* doc = baseWindow->GetDoc()) {
baseURI = doc->GetDocBaseURI();
}
}
@ -1647,10 +1635,6 @@ nsWindowWatcher::CalculateChromeFlags(nsIDOMWindow* aParent,
branch->GetBoolPref("dom.disable_window_open_dialog_feature",
&disableDialogFeature);
bool isFullScreen = false;
if (aParent) {
aParent->GetFullScreen(&isFullScreen);
}
if (openedFromContentScript) {
// If the caller context is content, we do not support the
// dialog feature. See bug 1095236.
@ -2014,14 +1998,11 @@ nsWindowWatcher::SizeOpenedDocShellItem(nsIDocShellTreeItem* aDocShellItem,
double openerZoom = 1.0;
if (aParent) {
nsCOMPtr<nsIDOMDocument> openerDoc;
aParent->GetDocument(getter_AddRefs(openerDoc));
if (openerDoc) {
nsCOMPtr<nsIDocument> doc = do_QueryInterface(openerDoc);
nsIPresShell* shell = doc->GetShell();
if (shell) {
nsPresContext* presContext = shell->GetPresContext();
if (presContext) {
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aParent);
MOZ_ASSERT(piWindow);
if (nsIDocument* doc = piWindow->GetDoc()) {
if (nsIPresShell* shell = doc->GetShell()) {
if (nsPresContext* presContext = shell->GetPresContext()) {
openerZoom = presContext->GetFullZoom();
}
}
@ -2227,8 +2208,8 @@ nsWindowWatcher::GetWindowOpenLocation(nsIDOMWindow* aParent,
bool aSizeSpecified)
{
bool isFullScreen = false;
if (aParent) {
aParent->GetFullScreen(&isFullScreen);
if (nsCOMPtr<nsPIDOMWindow> piParent = do_QueryInterface(aParent)) {
isFullScreen = piParent->GetFullScreen();
}
// Where should we open this?

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

@ -120,8 +120,7 @@ IsFrameId(JSContext* cx, JSObject* obj, jsid idArg)
return false;
}
nsCOMPtr<nsIDOMWindowCollection> col;
win->GetFrames(getter_AddRefs(col));
nsCOMPtr<nsIDOMWindowCollection> col = win->GetFrames();
if (!col) {
return false;
}

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

@ -3777,9 +3777,9 @@ nsDocumentViewer::PrintPreview(nsIPrintSettings* aPrintSettings,
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMDocument> domDoc;
aChildDOMWin->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aChildDOMWin);
MOZ_ASSERT(window);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
NS_ENSURE_STATE(doc);
nsAutoPtr<nsPrintEventDispatcher> beforeAndAfterPrint(
@ -4349,9 +4349,9 @@ nsDocumentViewer::OnDonePrinting()
if (mDeferredWindowClose) {
mDeferredWindowClose = false;
if (mContainer) {
nsCOMPtr<nsIDOMWindow> win = mContainer->GetWindow();
if (win)
if (nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(mContainer->GetWindow())) {
win->Close();
}
}
} else if (mClosingWhilePrinting) {
if (mDocument) {

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

@ -788,10 +788,9 @@ nsPluginFrame::GetRemoteTabChromeOffset()
{
LayoutDeviceIntPoint offset;
if (XRE_IsContentProcess()) {
nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(GetContent()->OwnerDoc()->GetWindow());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(GetContent()->OwnerDoc()->GetWindow());
if (window) {
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> topWindow = window->GetTop();
if (topWindow) {
dom::TabChild* tc = dom::TabChild::GetFrom(topWindow);
if (tc) {

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

@ -790,13 +790,15 @@ nsPrintEngine::PrintPreview(nsIPrintSettings* aPrintSettings,
return NS_ERROR_FAILURE;
}
NS_ENSURE_STATE(aChildDOMWin);
nsCOMPtr<nsIDOMDocument> doc;
aChildDOMWin->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aChildDOMWin);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
NS_ENSURE_STATE(doc);
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(doc);
MOZ_ASSERT(domDoc);
// Document is not busy -- go ahead with the Print Preview
return CommonPrint(true, aPrintSettings, aWebProgressListener, doc);
return CommonPrint(true, aPrintSettings, aWebProgressListener, domDoc);
}
//----------------------------------------------------------------------------------
@ -3111,9 +3113,9 @@ nsPrintEngine::FindPrintObjectByDOMWin(nsPrintObject* aPO,
return nullptr;
}
nsCOMPtr<nsIDOMDocument> domDoc;
aDOMWin->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWin);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
if (aPO->mDocument && aPO->mDocument->GetOriginalDocument() == doc) {
return aPO;
}

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

@ -889,14 +889,13 @@ nsSVGOuterSVGFrame::IsRootOfReplacedElementSubDoc(nsIFrame **aEmbeddingFrame)
if (!mContent->GetParent()) {
// Our content is the document element
nsCOMPtr<nsIDocShell> docShell = PresContext()->GetDocShell();
nsCOMPtr<nsIDOMWindow> window;
nsCOMPtr<nsPIDOMWindow> window;
if (docShell) {
window = docShell->GetWindow();
}
if (window) {
nsCOMPtr<nsIDOMElement> frameElement;
window->GetFrameElement(getter_AddRefs(frameElement));
nsCOMPtr<nsIDOMElement> frameElement = window->GetFrameElement();
nsCOMPtr<nsIObjectLoadingContent> olc = do_QueryInterface(frameElement);
if (olc) {
// Our document is inside an HTML 'object', 'embed' or 'applet' element

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

@ -830,10 +830,10 @@ CheckCaretDrawingState()
if (!window)
return;
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDocument> focusedDoc;
window->GetDocument(getter_AddRefs(domDoc));
focusedDoc = do_QueryInterface(domDoc);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(window);
MOZ_ASSERT(piWindow);
nsCOMPtr<nsIDocument> focusedDoc = piWindow->GetDoc();
if (!focusedDoc)
return;

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

@ -569,10 +569,7 @@ nsXULTooltipListener::FindTooltip(nsIContent* aTarget, nsIContent** aTooltip)
return NS_OK;
}
bool closed;
window->GetClosed(&closed);
if (closed) {
if (window->Closed()) {
return NS_OK;
}

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

@ -686,13 +686,10 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
nsAutoCString locationCStr;
nsIDOMLocation* location;
res = mWindow->GetLocation(&location);
if (location && NS_SUCCEEDED(res)) {
if (nsCOMPtr<nsIDOMLocation> location = mWindow->GetLocation()) {
nsAutoString locationAStr;
location->ToString(locationAStr);
location->Release();
CopyUTF16toUTF8(locationAStr, locationCStr);
#define HELLO_CLICKER_URL_START "https://hello.firefox.com/"

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

@ -74,10 +74,8 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
mInnerWindowID = inner ? inner->WindowID() : 0;
mOuterWindowID = outerWindow->WindowID();
nsCOMPtr<nsIDOMWindow> parent;
outerWindow->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsPIDOMWindow> piParent = do_QueryInterface(parent);
mParentOuterWindowID = piParent->WindowID();
nsCOMPtr<nsPIDOMWindow> parent = outerWindow->GetParent();
mParentOuterWindowID = parent->WindowID();
}
mUpgradeInsecureRequests = aLoadingContext->OwnerDoc()->GetUpgradeInsecureRequests();

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

@ -2227,13 +2227,12 @@ nsHttpHandler::TickleWifi(nsIInterfaceRequestor *cb)
// If B2G requires a similar mechanism nsINetworkManager, currently only avail
// on B2G, contains the necessary information on wifi and gateway
nsCOMPtr<nsIDOMWindow> domWindow;
cb->GetInterface(NS_GET_IID(nsIDOMWindow), getter_AddRefs(domWindow));
if (!domWindow)
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(cb);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(domWindow);
if (!piWindow)
return;
nsCOMPtr<nsIDOMNavigator> domNavigator;
domWindow->GetNavigator(getter_AddRefs(domNavigator));
nsCOMPtr<nsIDOMNavigator> domNavigator = piWindow->GetNavigator();
nsCOMPtr<nsIMozNavigatorNetwork> networkNavigator =
do_QueryInterface(domNavigator);
if (!networkNavigator)

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

@ -68,17 +68,17 @@ GetPrivateWindow(JSContext* cx) {
return nullptr;
}
nsCOMPtr<nsIDOMWindow> top;
nsresult rv = win->GetTop(getter_AddRefs(top));
if (!top || NS_FAILED(rv)) {
win = win->GetOuterWindow();
if (!win) {
return nullptr;
}
nsCOMPtr<nsPIDOMWindow> ptop = do_QueryInterface(top);
if (!ptop) {
nsCOMPtr<nsPIDOMWindow> top = win->GetTop();
if (!top) {
return nullptr;
}
return ptop.forget();
return top.forget();
}
bool

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

@ -101,8 +101,8 @@ nsFormFillController::~nsFormFillController()
// Remove ourselves as a focus listener from all cached docShells
uint32_t count = mDocShells.Length();
for (uint32_t i = 0; i < count; ++i) {
nsCOMPtr<nsIDOMWindow> domWindow = GetWindowForDocShell(mDocShells[i]);
RemoveWindowListeners(domWindow);
nsCOMPtr<nsPIDOMWindow> window = GetWindowForDocShell(mDocShells[i]);
RemoveWindowListeners(window);
}
}
@ -241,8 +241,8 @@ nsFormFillController::AttachToBrowser(nsIDocShell *aDocShell, nsIAutoCompletePop
mPopups.AppendElement(aPopup);
// Listen for focus events on the domWindow of the docShell
nsCOMPtr<nsIDOMWindow> domWindow = GetWindowForDocShell(aDocShell);
AddWindowListeners(domWindow);
nsCOMPtr<nsPIDOMWindow> window = GetWindowForDocShell(aDocShell);
AddWindowListeners(window);
return NS_OK;
}
@ -254,9 +254,9 @@ nsFormFillController::DetachFromBrowser(nsIDocShell *aDocShell)
NS_ENSURE_TRUE(index >= 0, NS_ERROR_FAILURE);
// Stop listening for focus events on the domWindow of the docShell
nsCOMPtr<nsIDOMWindow> domWindow =
nsCOMPtr<nsPIDOMWindow> window =
GetWindowForDocShell(mDocShells.SafeElementAt(index));
RemoveWindowListeners(domWindow);
RemoveWindowListeners(window);
mDocShells.RemoveElementAt(index);
mPopups.RemoveElementAt(index);
@ -1080,15 +1080,12 @@ nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
//// nsFormFillController
void
nsFormFillController::AddWindowListeners(nsIDOMWindow *aWindow)
nsFormFillController::AddWindowListeners(nsPIDOMWindow *aWindow)
{
if (!aWindow)
return;
nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aWindow));
EventTarget* target = nullptr;
if (privateDOMWindow)
target = privateDOMWindow->GetChromeEventHandler();
EventTarget* target = aWindow->GetChromeEventHandler();
if (!target)
return;
@ -1116,23 +1113,18 @@ nsFormFillController::AddWindowListeners(nsIDOMWindow *aWindow)
}
void
nsFormFillController::RemoveWindowListeners(nsIDOMWindow *aWindow)
nsFormFillController::RemoveWindowListeners(nsPIDOMWindow *aWindow)
{
if (!aWindow)
return;
StopControllingInput();
nsCOMPtr<nsIDOMDocument> domDoc;
aWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
nsCOMPtr<nsIDocument> doc = aWindow->GetDoc();
PwmgrInputsEnumData ed(this, doc);
mPwmgrInputs.Enumerate(RemoveForDocumentEnumerator, &ed);
nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aWindow));
EventTarget* target = nullptr;
if (privateDOMWindow)
target = privateDOMWindow->GetChromeEventHandler();
EventTarget* target = aWindow->GetChromeEventHandler();
if (!target)
return;
@ -1227,7 +1219,7 @@ nsFormFillController::GetDocShellForInput(nsIDOMHTMLInputElement *aInput)
return win->GetDocShell();
}
nsIDOMWindow *
nsPIDOMWindow *
nsFormFillController::GetWindowForDocShell(nsIDocShell *aDocShell)
{
nsCOMPtr<nsIContentViewer> contentViewer;

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

@ -16,7 +16,6 @@
#include "nsCOMPtr.h"
#include "nsDataHashtable.h"
#include "nsIDocShell.h"
#include "nsIDOMWindow.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsILoginManager.h"
#include "nsIMutationObserver.h"
@ -30,6 +29,7 @@
class nsFormHistory;
class nsINode;
class nsPIDOMWindow;
class nsFormFillController final : public nsIFormFillController,
public nsIAutoCompleteInput,
@ -58,8 +58,8 @@ public:
protected:
virtual ~nsFormFillController();
void AddWindowListeners(nsIDOMWindow *aWindow);
void RemoveWindowListeners(nsIDOMWindow *aWindow);
void AddWindowListeners(nsPIDOMWindow *aWindow);
void RemoveWindowListeners(nsPIDOMWindow *aWindow);
void AddKeyListener(nsINode* aInput);
void RemoveKeyListener();
@ -79,7 +79,7 @@ protected:
bool RowMatch(nsFormHistory *aHistory, uint32_t aIndex, const nsAString &aInputName, const nsAString &aInputValue);
inline nsIDocShell *GetDocShellForInput(nsIDOMHTMLInputElement *aInput);
inline nsIDOMWindow *GetWindowForDocShell(nsIDocShell *aDocShell);
inline nsPIDOMWindow *GetWindowForDocShell(nsIDocShell *aDocShell);
inline int32_t GetIndexOfDocShell(nsIDocShell *aDocShell);
void MaybeRemoveMutationObserver(nsINode* aNode);

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

@ -433,11 +433,9 @@ nsAppStartup::Quit(uint32_t aMode)
ferocity = eAttemptQuit;
nsCOMPtr<nsISupports> window;
windowEnumerator->GetNext(getter_AddRefs(window));
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(window);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(window);
if (domWindow) {
bool closed = false;
domWindow->GetClosed(&closed);
if (!closed) {
if (!domWindow->Closed()) {
rv = NS_ERROR_FAILURE;
break;
}

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

@ -4,7 +4,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIAppStartup.h"
#include "nsIDOMWindow.h"
#include "nsIFile.h"
#include "nsIStringBundle.h"
#include "nsIToolkitProfile.h"
@ -14,6 +13,7 @@
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsPIDOMWindow.h"
#include "nsPrintfCString.h"
#include "nsToolkitCompsCID.h"
#include "nsXPCOMCIDInternal.h"
@ -164,7 +164,8 @@ ProfileResetCleanup(nsIToolkitProfile* aOldProfile)
return rv;
}
// Close the progress window now that the cleanup thread is done.
progressWindow->Close();
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(progressWindow);
piWindow->Close();
// Delete the old profile from profiles.ini. The folder was already deleted by the thread above.
rv = aOldProfile->Remove(false);

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

@ -82,14 +82,15 @@ UNIFIED_SOURCES += [
'nsNativeAppSupportBase.cpp',
'nsSigHandlers.cpp',
'nsXREDirProvider.cpp',
'ProfileReset.cpp',
]
# nsAppRunner.cpp cannot be built in unified mode because it pulls in OS X system headers.
# nsAppRunner.cpp and ProfileReset.cpp cannot be built in unified mode because
# they pull in OS X system headers.
# nsEmbedFunctions.cpp cannot be built in unified mode because it pulls in X11 headers.
SOURCES += [
'nsAppRunner.cpp',
'nsEmbedFunctions.cpp',
'ProfileReset.cpp',
]
if CONFIG['MOZ_GL_DEFAULT_PROVIDER'] == 'GLX':

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

@ -82,7 +82,8 @@ activateWindow( nsIDOMWindow *win ) {
::SetForegroundWindow( hwnd );
} else {
// Use internal method.
win->Focus();
nsCOMPtr<nsPIDOMWindow> piWin = do_QueryInterface(win);
piWin->Focus();
}
}
@ -1021,8 +1022,7 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
break;
}
// Get location.
nsCOMPtr<nsIDOMLocation> location;
internalContent->GetLocation( getter_AddRefs( location ) );
nsCOMPtr<nsIDOMLocation> location = internalContent->GetLocation();
if ( !location ) {
break;
}

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

@ -905,10 +905,7 @@ nsDocLoader::GetIsTopLevel(bool *aResult)
nsCOMPtr<nsPIDOMWindow> piwindow = do_QueryInterface(window);
NS_ENSURE_STATE(piwindow);
nsCOMPtr<nsIDOMWindow> topWindow;
nsresult rv = piwindow->GetTop(getter_AddRefs(topWindow));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsPIDOMWindow> topWindow = piwindow->GetTop();
*aResult = piwindow == topWindow;
}

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

@ -2552,17 +2552,15 @@ bool nsExternalAppHandler::GetNeverAskFlagFromPref(const char * prefName, const
nsresult nsExternalAppHandler::MaybeCloseWindow()
{
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mContentContext);
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mContentContext);
NS_ENSURE_STATE(window);
if (mShouldCloseWindow) {
// Reset the window context to the opener window so that the dependent
// dialogs have a parent
nsCOMPtr<nsIDOMWindow> opener;
window->GetOpener(getter_AddRefs(opener));
nsCOMPtr<nsPIDOMWindow> opener = window->GetOpener();
bool isClosed;
if (opener && NS_SUCCEEDED(opener->GetClosed(&isClosed)) && !isClosed) {
if (opener && !opener->Closed()) {
mContentContext = do_GetInterface(opener);
// Now close the old window. Do it on a timer so that we don't run
@ -2586,7 +2584,8 @@ nsExternalAppHandler::Notify(nsITimer* timer)
{
NS_ASSERTION(mWindowToClose, "No window to close after timer fired");
mWindowToClose->Close();
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mWindowToClose);
window->Close();
mWindowToClose = nullptr;
mTimer = nullptr;

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

@ -201,8 +201,10 @@ nsOfflineCachePendingUpdate::OnStateChange(nsIWebProgress* aWebProgress,
aWebProgress->GetDOMWindow(getter_AddRefs(window));
if (!window) return NS_OK;
nsCOMPtr<nsIDOMDocument> progressDoc;
window->GetDocument(getter_AddRefs(progressDoc));
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(window);
MOZ_ASSERT(piWindow);
nsCOMPtr<nsIDocument> progressDoc = piWindow->GetDoc();
if (!progressDoc) return NS_OK;
if (!SameCOMIdentity(progressDoc, updateDoc)) {
@ -541,12 +543,12 @@ nsOfflineCacheUpdateService::Schedule(nsIURI *aManifestURI,
nsresult rv;
if (aWindow) {
if (nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow)) {
// Ensure there is window.applicationCache object that is
// responsible for association of the new applicationCache
// with the corresponding document. Just ignore the result.
nsCOMPtr<nsIDOMOfflineResourceList> appCacheWindowObject;
aWindow->GetApplicationCache(getter_AddRefs(appCacheWindowObject));
nsCOMPtr<nsIDOMOfflineResourceList> appCacheWindowObject =
window->GetApplicationCache();
}
rv = update->Init(aManifestURI, aDocumentURI, aLoadingPrincipal, aDocument,

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

@ -87,6 +87,7 @@ FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/layout/forms',
'/layout/generic',
'/layout/style',
'/layout/xul',
'/widget',
]

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

@ -26,7 +26,7 @@
#include "nsNameSpaceManager.h"
#include "nsGkAtoms.h"
#include "nsIDOMElement.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsICSSDeclaration.h"
#include "nsIDOMCSSValue.h"
#include "nsIDOMCSSPrimitiveValue.h"
#include "nsIDOMRect.h"
@ -42,6 +42,7 @@
#include "nsContentUtils.h"
#include "nsIContentPolicy.h"
using mozilla::dom::Element;
using mozilla::gfx::SourceSurface;
static const uint32_t kIconWidth = 16;
@ -167,7 +168,7 @@ nsMenuItemIconX::GetIconURI(nsIURI** aIconURI)
nsresult rv;
nsCOMPtr<nsIDOMCSSValue> cssValue;
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssStyleDecl;
nsCOMPtr<nsICSSDeclaration> cssStyleDecl;
nsCOMPtr<nsIDOMCSSPrimitiveValue> primitiveValue;
uint16_t primitiveType;
if (!hasImageAttr) {
@ -181,14 +182,19 @@ nsMenuItemIconX::GetIconURI(nsIURI** aIconURI)
if (!window)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(mContent);
window = window->GetCurrentInnerWindow();
if (!window)
return NS_ERROR_FAILURE;
nsCOMPtr<Element> domElement = do_QueryInterface(mContent);
if (!domElement)
return NS_ERROR_FAILURE;
rv = window->GetComputedStyle(domElement, EmptyString(),
getter_AddRefs(cssStyleDecl));
if (NS_FAILED(rv))
return rv;
ErrorResult dummy;
cssStyleDecl = window->GetComputedStyle(*domElement, EmptyString(), dummy);
dummy.SuppressException();
if (!cssStyleDecl)
return NS_ERROR_FAILURE;
NS_NAMED_LITERAL_STRING(listStyleImage, "list-style-image");
rv = cssStyleDecl->GetPropertyCSSValue(listStyleImage,

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

@ -1136,7 +1136,7 @@ nsSiteWindow::Blur(void)
return NS_OK;
}
nsCOMPtr<nsIDOMWindow> domWindow(docshell->GetWindow());
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(docshell->GetWindow());
if (domWindow)
domWindow->Focus();
}

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

@ -1182,9 +1182,8 @@ bool nsXULWindow::LoadSizeFromXUL()
// constrain to screen size
nsCOMPtr<nsIDOMWindow> domWindow;
GetWindowDOMWindow(getter_AddRefs(domWindow));
if (domWindow) {
nsCOMPtr<nsIDOMScreen> screen;
domWindow->GetScreen(getter_AddRefs(screen));
if (nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(domWindow)) {
nsCOMPtr<nsIDOMScreen> screen = window->GetScreen();
if (screen) {
int32_t screenWidth;
int32_t screenHeight;
@ -1268,7 +1267,8 @@ bool nsXULWindow::LoadMiscPersistentAttributesFromXUL()
if (sizeMode == nsSizeMode_Fullscreen) {
nsCOMPtr<nsIDOMWindow> ourWindow;
GetWindowDOMWindow(getter_AddRefs(ourWindow));
ourWindow->SetFullScreen(true);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(ourWindow);
piWindow->SetFullScreen(true);
} else {
mWindow->SetSizeMode(sizeMode);
}
@ -1483,7 +1483,7 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
bool isFullscreen = false;
if (nsPIDOMWindow* domWindow = mDocShell->GetWindow()) {
domWindow->GetFullScreen(&isFullscreen);
isFullscreen = domWindow->GetFullScreen();
}
// get our size, position and mode to persist