Bug 861729 - Remove nsPIDOMWindow::GetExtantDocument r=Ms2ger

This commit is contained in:
David Zbarsky 2013-04-24 00:22:37 -04:00
parent cddd249036
commit 82391d9a22
42 changed files with 135 additions and 174 deletions

View File

@ -425,7 +425,7 @@ public:
*
* @return The document or null if no JS Context.
*/
static nsIDOMDocument *GetDocumentFromCaller();
static nsIDocument* GetDocumentFromCaller();
/**
* Get the document through the JS context that's currently on the stack.
@ -434,7 +434,7 @@ public:
*
* @return The document or null if no JS context
*/
static nsIDOMDocument *GetDocumentFromContext();
static nsIDocument* GetDocumentFromContext();
// Check if a node is in the document prolog, i.e. before the document
// element.

View File

@ -1709,7 +1709,7 @@ nsContentUtils::GetWindowFromCaller()
return nullptr;
}
nsIDOMDocument *
nsIDocument*
nsContentUtils::GetDocumentFromCaller()
{
JSContext *cx = nullptr;
@ -1725,10 +1725,10 @@ nsContentUtils::GetDocumentFromCaller()
return nullptr;
}
return win->GetExtantDocument();
return win->GetExtantDoc();
}
nsIDOMDocument *
nsIDocument*
nsContentUtils::GetDocumentFromContext()
{
JSContext *cx = nullptr;
@ -1740,7 +1740,7 @@ nsContentUtils::GetDocumentFromContext()
if (sgo) {
nsCOMPtr<nsPIDOMWindow> pwin = do_QueryInterface(sgo);
if (pwin) {
return pwin->GetExtantDocument();
return pwin->GetExtantDoc();
}
}
}

View File

@ -260,8 +260,7 @@ nsDOMFileBase::MozSlice(int64_t aStart, int64_t aEnd,
if (sgo) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(sgo);
if (window) {
nsCOMPtr<nsIDocument> document =
do_QueryInterface(window->GetExtantDocument());
nsCOMPtr<nsIDocument> document = window->GetExtantDoc();
if (document) {
document->WarnOnceAbout(nsIDocument::eMozSlice);
}
@ -276,7 +275,7 @@ nsDOMFileBase::GetInternalStream(nsIInputStream **aStream)
{
// Must be overridden
NS_NOTREACHED("Must override GetInternalStream");
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -408,7 +408,7 @@ protected:
bool Suppressed()
{
if (mOwner) {
nsCOMPtr<nsIDocument> d = do_QueryInterface(mOwner->GetExtantDocument());
nsCOMPtr<nsIDocument> d = mOwner->GetExtantDoc();
return d && d->IsInSyncOperation();
}
return false;

View File

@ -11236,7 +11236,7 @@ nsAutoSyncOperation::nsAutoSyncOperation(nsIDocument* aDoc)
win->GetTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> top = do_QueryInterface(topWindow);
if (top) {
nsCOMPtr<nsIDocument> doc = do_QueryInterface(top->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = top->GetExtantDoc();
MarkDocumentTreeToBeInSyncOperation(doc, &mDocuments);
}
}

View File

@ -1095,10 +1095,8 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
SameCOMIdentity(otherChromeEventHandler, otherContent),
"How did that happen, exactly?");
nsCOMPtr<nsIDocument> ourChildDocument =
do_QueryInterface(ourWindow->GetExtantDocument());
nsCOMPtr<nsIDocument> otherChildDocument =
do_QueryInterface(otherWindow->GetExtantDocument());
nsCOMPtr<nsIDocument> ourChildDocument = ourWindow->GetExtantDoc();
nsCOMPtr<nsIDocument> otherChildDocument = otherWindow ->GetExtantDoc();
if (!ourChildDocument || !otherChildDocument) {
// This shouldn't be happening
return NS_ERROR_NOT_IMPLEMENTED;

View File

@ -390,7 +390,7 @@ nsXMLHttpRequest::InitParameters(bool aAnon, bool aSystem)
// Chrome is always allowed access, so do the permission check only
// for non-chrome pages.
if (!nsContentUtils::IsCallerChrome()) {
nsCOMPtr<nsIDocument> doc = do_QueryInterface(window->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
if (!doc) {
return;
}
@ -560,7 +560,7 @@ static void LogMessage(const char* aWarning, nsPIDOMWindow* aWindow)
{
nsCOMPtr<nsIDocument> doc;
if (aWindow) {
doc = do_QueryInterface(aWindow->GetExtantDocument());
doc = aWindow->GetExtantDoc();
}
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"DOM", doc,
@ -2861,7 +2861,7 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
nsCOMPtr<nsPIDOMWindow> suspendedWindow(do_QueryInterface(topWindow));
if (suspendedWindow &&
(suspendedWindow = suspendedWindow->GetCurrentInnerWindow())) {
suspendedDoc = do_QueryInterface(suspendedWindow->GetExtantDocument());
suspendedDoc = suspendedWindow->GetExtantDoc();
if (suspendedDoc) {
suspendedDoc->SuppressEventHandling();
}

View File

@ -321,7 +321,7 @@ nsDOMEvent::Initialize(nsISupports* aOwner, JSContext* aCx, JSObject* aObj,
bool trusted = false;
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aOwner);
if (w) {
nsCOMPtr<nsIDocument> d = do_QueryInterface(w->GetExtantDocument());
nsCOMPtr<nsIDocument> d = w->GetExtantDoc();
if (d) {
trusted = nsContentUtils::IsChromeDoc(d);
nsIPresShell* s = d->GetShell();
@ -369,7 +369,7 @@ nsDOMEvent::Init(mozilla::dom::EventTarget* aGlobal)
bool trusted = false;
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aGlobal);
if (w) {
nsCOMPtr<nsIDocument> d = do_QueryInterface(w->GetExtantDocument());
nsCOMPtr<nsIDocument> d = w->GetExtantDoc();
if (d) {
trusted = nsContentUtils::IsChromeDoc(d);
nsIPresShell* s = d->GetShell();
@ -521,7 +521,7 @@ nsDOMEvent::PreventDefault()
if (!node) {
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(mEvent->currentTarget);
if (win) {
node = do_QueryInterface(win->GetExtantDocument());
node = win->GetExtantDoc();
}
}
if (node && !nsContentUtils::IsChromeDoc(node->OwnerDoc())) {

View File

@ -26,8 +26,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDOMEventTargetHelper)
if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
char name[512];
nsAutoString uri;
if (tmp->mOwnerWindow && tmp->mOwnerWindow->GetExtantDocument()) {
tmp->mOwnerWindow->GetExtantDocument()->GetDocumentURI(uri);
if (tmp->mOwnerWindow && tmp->mOwnerWindow->GetExtantDoc()) {
tmp->mOwnerWindow->GetExtantDoc()->GetDocumentURI(uri);
}
PR_snprintf(name, sizeof(name), "nsDOMEventTargetHelper %s",
NS_ConvertUTF16toUTF8(uri).get());

View File

@ -463,7 +463,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
if (!node) {
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aTarget);
if (win) {
node = do_QueryInterface(win->GetExtantDocument());
node = win->GetExtantDoc();
}
}

View File

@ -282,7 +282,7 @@ nsEventListenerManager::AddEventListenerInternal(
// Go from our target to the nearest enclosing DOM window.
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (window) {
nsCOMPtr<nsIDocument> doc = do_QueryInterface(window->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
if (doc) {
doc->WarnOnceAbout(nsIDocument::eMutationEvent);
}
@ -336,7 +336,7 @@ nsEventListenerManager::AddEventListenerInternal(
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (window) {
#ifdef DEBUG
nsCOMPtr<nsIDocument> d = do_QueryInterface(window->GetExtantDocument());
nsCOMPtr<nsIDocument> d = window->GetExtantDoc();
NS_WARN_IF_FALSE(!nsContentUtils::IsChromeDoc(d),
"Please do not use mouseenter/leave events in chrome. "
"They are slower than mouseover/out!");
@ -828,7 +828,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
} else {
win = do_QueryInterface(mTarget);
if (win) {
doc = do_QueryInterface(win->GetExtantDocument());
doc = win->GetExtantDoc();
}
}

View File

@ -264,13 +264,7 @@ static nsIDocument *
GetDocumentFromWindow(nsIDOMWindow *aWindow)
{
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aWindow);
nsCOMPtr<nsIDocument> doc;
if (win) {
doc = do_QueryInterface(win->GetExtantDocument());
}
return doc;
return win ? win->GetExtantDoc() : nullptr;
}
static int32_t
@ -3256,7 +3250,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
currentWindow->GetTop(getter_AddRefs(currentTop));
mDocument->GetWindow()->GetTop(getter_AddRefs(newTop));
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(currentWindow);
nsCOMPtr<nsIDocument> currentDoc = do_QueryInterface(win->GetExtantDocument());
nsCOMPtr<nsIDocument> currentDoc = win->GetExtantDoc();
if (nsContentUtils::IsChromeDoc(currentDoc) ||
(currentTop && newTop && currentTop != newTop)) {
fm->SetFocusedWindow(mDocument->GetWindow());

View File

@ -52,8 +52,7 @@ NS_NewHTMLImageElement(already_AddRefed<nsINodeInfo> aNodeInfo,
*/
nsCOMPtr<nsINodeInfo> nodeInfo(aNodeInfo);
if (!nodeInfo) {
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(nsContentUtils::GetDocumentFromCaller());
nsCOMPtr<nsIDocument> doc = nsContentUtils::GetDocumentFromCaller();
NS_ENSURE_TRUE(doc, nullptr);
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::img, nullptr,

View File

@ -396,8 +396,7 @@ HTMLInputElement::AsyncClickHandler::Run()
uint32_t permission;
pm->TestPermission(doc->NodePrincipal(), &permission);
if (permission == nsIPopupWindowManager::DENY_POPUP) {
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(doc);
nsGlobalWindow::FirePopupBlockedEvent(domDoc, win, nullptr, EmptyString(), EmptyString());
nsGlobalWindow::FirePopupBlockedEvent(doc, win, nullptr, EmptyString(), EmptyString());
return NS_OK;
}
}

View File

@ -43,8 +43,7 @@ NS_NewHTMLOptionElement(already_AddRefed<nsINodeInfo> aNodeInfo,
*/
nsCOMPtr<nsINodeInfo> nodeInfo(aNodeInfo);
if (!nodeInfo) {
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(nsContentUtils::GetDocumentFromCaller());
nsCOMPtr<nsIDocument> doc = nsContentUtils::GetDocumentFromCaller();
NS_ENSURE_TRUE(doc, nullptr);
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::option, nullptr,

View File

@ -1504,8 +1504,7 @@ nsHTMLDocument::Open(JSContext* cx,
// Note: We want to use GetDocumentFromContext here because this document
// should inherit the security information of the document that's opening us,
// (since if it's secure, then it's presumably trusted).
nsCOMPtr<nsIDocument> callerDoc =
do_QueryInterface(nsContentUtils::GetDocumentFromContext());
nsCOMPtr<nsIDocument> callerDoc = nsContentUtils::GetDocumentFromContext();
if (!callerDoc) {
// If we're called from C++ or in some other way without an originating
// document we can't do a document.open w/o changing the principal of the

View File

@ -320,8 +320,7 @@ XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv)
ReportUseOfDeprecatedMethod(this, "UseOfDOM3LoadMethodWarning");
nsCOMPtr<nsIDocument> callingDoc =
do_QueryInterface(nsContentUtils::GetDocumentFromContext());
nsCOMPtr<nsIDocument> callingDoc = nsContentUtils::GetDocumentFromContext();
nsIURI *baseURI = mDocumentURI;
nsAutoCString charset;

View File

@ -1074,8 +1074,7 @@ nsXULTemplateBuilder::Observe(nsISupports* aSubject,
if (!strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC)) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aSubject);
if (window) {
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(window->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
if (doc && doc == mObservedDocument)
NodeWillBeDestroyed(doc);
}

View File

@ -7048,10 +7048,7 @@ nsDocShell::CanSavePresentation(uint32_t aLoadType,
// If the document does not want its presentation cached, then don't.
nsCOMPtr<nsIDocument> doc = mScriptGlobal->GetExtantDoc();
if (!doc || !doc->CanSavePresentation(aNewRequest))
return false;
return true;
return doc && doc->CanSavePresentation(aNewRequest);
}
void
@ -8677,8 +8674,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
// document in |newWin|, if any.
nsCOMPtr<nsPIDOMWindow> piNewWin = do_QueryInterface(newWin);
if (piNewWin) {
nsCOMPtr<nsIDocument> newDoc =
do_QueryInterface(piNewWin->GetExtantDocument());
nsCOMPtr<nsIDocument> newDoc = piNewWin->GetExtantDoc();
if (!newDoc || newDoc->IsInitialDocument()) {
isNewWindow = true;
aFlags |= INTERNAL_LOAD_FLAGS_FIRST_LOAD;

View File

@ -481,7 +481,7 @@ Navigator::GetCookieEnabled(bool* aCookieEnabled)
return NS_OK;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(win->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = win->GetExtantDoc();
if (!doc) {
return NS_OK;
}
@ -626,17 +626,16 @@ namespace {
class VibrateWindowListener : public nsIDOMEventListener
{
public:
VibrateWindowListener(nsIDOMWindow *aWindow, nsIDOMDocument *aDocument)
VibrateWindowListener(nsIDOMWindow* aWindow, nsIDocument* aDocument)
{
mWindow = do_GetWeakReference(aWindow);
mDocument = do_GetWeakReference(aDocument);
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(aDocument);
NS_NAMED_LITERAL_STRING(visibilitychange, "visibilitychange");
target->AddSystemEventListener(visibilitychange,
this, /* listener */
true, /* use capture */
false /* wants untrusted */);
aDocument->AddSystemEventListener(visibilitychange,
this, /* listener */
true, /* use capture */
false /* wants untrusted */);
}
virtual ~VibrateWindowListener()
@ -754,12 +753,9 @@ Navigator::Vibrate(const JS::Value& aPattern, JSContext* cx)
nsCOMPtr<nsPIDOMWindow> win = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(win, NS_OK);
nsCOMPtr<nsIDOMDocument> domDoc = win->GetExtantDocument();
NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
bool hidden = true;
domDoc->GetHidden(&hidden);
if (hidden) {
nsCOMPtr<nsIDocument> doc = win->GetExtantDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
if (doc->Hidden()) {
// Hidden documents cannot start or stop a vibration.
return NS_OK;
}
@ -819,7 +815,7 @@ Navigator::Vibrate(const JS::Value& aPattern, JSContext* cx)
else {
gVibrateWindowListener->RemoveListener();
}
gVibrateWindowListener = new VibrateWindowListener(win, domDoc);
gVibrateWindowListener = new VibrateWindowListener(win, doc);
nsCOMPtr<nsIDOMWindow> domWindow =
do_QueryInterface(static_cast<nsIDOMWindow*>(win));

View File

@ -3268,7 +3268,7 @@ nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSHandleObject obj,
// The rest of this function is for HTML documents only.
//
nsCOMPtr<nsIHTMLDocument> htmlDoc =
do_QueryInterface(win->GetExtantDocument());
do_QueryInterface(win->GetExtantDoc());
if (!htmlDoc)
return true;
nsHTMLDocument *document = static_cast<nsHTMLDocument*>(htmlDoc.get());
@ -6200,7 +6200,7 @@ nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
nsIDOMDocument* currentDoc = win->GetExtantDocument();
nsIDocument* currentDoc = win->GetExtantDoc();
if (SameCOMIdentity(doc, currentDoc)) {
jsval winVal;

View File

@ -183,8 +183,7 @@ nsDOMException::GetCode(uint16_t* aCode)
// Warn only when the code was changed (other than DOM Core)
// or the code is useless (zero)
if (NS_ERROR_GET_MODULE(mResult) != NS_ERROR_MODULE_DOM || !mCode) {
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(nsContentUtils::GetDocumentFromCaller());
nsCOMPtr<nsIDocument> doc = nsContentUtils::GetDocumentFromCaller();
if (doc) {
doc->WarnOnceAbout(nsIDocument::eDOMExceptionCode);
}

View File

@ -188,14 +188,14 @@ nsDOMWindowUtils::GetDocumentMetadata(const nsAString& aName,
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
if (window) {
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
if (doc) {
nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
doc->GetHeaderData(name, aValue);
return NS_OK;
}
}
aValue.Truncate();
return NS_OK;
}
@ -266,7 +266,7 @@ nsDOMWindowUtils::GetViewportInfo(uint32_t aDisplayWidth,
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
nsViewportInfo info = nsContentUtils::GetViewportInfo(doc, aDisplayWidth, aDisplayHeight);
@ -1247,7 +1247,7 @@ nsDOMWindowUtils::ElementFromPoint(float aX, float aY,
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
Element* el =
@ -1272,7 +1272,7 @@ nsDOMWindowUtils::NodesFromRect(float aX, float aY,
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
return doc->NodesFromRectHelper(aX, aY, aTopSize, aRightSize, aBottomSize, aLeftSize,
@ -1424,7 +1424,7 @@ nsDOMWindowUtils::SuppressEventHandling(bool aSuppress)
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
if (aSuppress) {
@ -1446,7 +1446,7 @@ nsDOMWindowUtils::GetScrollXY(bool aFlushLayout, int32_t* aScrollX, int32_t* aSc
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
if (aFlushLayout) {
@ -2460,15 +2460,15 @@ nsDOMWindowUtils::GetCursorType(int16_t *aCursor)
NS_ENSURE_ARG_POINTER(aCursor);
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
bool isSameDoc = false;
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
do {
if (nsEventStateManager::sMouseOverDocument == doc.get()) {
if (nsEventStateManager::sMouseOverDocument == doc) {
isSameDoc = true;
break;
}
@ -2937,17 +2937,13 @@ nsDOMWindowUtils::GetPlugins(JSContext* cx, JS::Value* aPlugins)
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsIDOMDocument* ddoc = window->GetExtantDocument();
nsresult rv;
nsCOMPtr<nsIDocument> doc = do_QueryInterface(ddoc, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
nsTArray<nsIObjectLoadingContent*> plugins;
doc->GetPlugins(plugins);
JSObject* jsPlugins = nullptr;
rv = nsTArrayToJSArray(cx, plugins, &jsPlugins);
nsresult rv = nsTArrayToJSArray(cx, plugins, &jsPlugins);
NS_ENSURE_SUCCESS(rv, rv);
*aPlugins = OBJECT_TO_JSVAL(jsPlugins);
@ -3014,7 +3010,7 @@ nsDOMWindowUtils::RemoteFrameFullscreenChanged(nsIDOMElement* aFrameElement,
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
doc->RemoteFrameFullscreenChanged(aFrameElement, aNewOrigin);
@ -3031,7 +3027,7 @@ nsDOMWindowUtils::RemoteFrameFullscreenReverted()
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
doc->RemoteFrameFullscreenReverted();

View File

@ -168,6 +168,7 @@
#endif
#include "xpcprivate.h"
#include "nsDOMEvent.h"
#ifdef NS_PRINTING
#include "nsIPrintSettings.h"
@ -2143,7 +2144,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
}
NS_ASSERTION(!GetCurrentInnerWindow() ||
GetCurrentInnerWindow()->GetExtantDocument() == mDocument,
GetCurrentInnerWindow()->GetExtantDoc() == mDoc,
"Uh, mDocument doesn't match the current inner window "
"document!");
@ -6099,7 +6100,7 @@ nsGlobalWindow::SetResizable(bool aResizable)
static void
ReportUseOfDeprecatedMethod(nsGlobalWindow* aWindow, const char* aWarning)
{
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aWindow->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"DOM Events", doc,
nsContentUtils::eDOM_PROPERTIES,
@ -6161,8 +6162,8 @@ bool IsPopupBlocked(nsIDOMDocument* aDoc)
}
/* static */
void
nsGlobalWindow::FirePopupBlockedEvent(nsIDOMDocument* aDoc,
void
nsGlobalWindow::FirePopupBlockedEvent(nsIDocument* aDoc,
nsIDOMWindow *aRequestingWindow, nsIURI *aPopupURI,
const nsAString &aPopupWindowName,
const nsAString &aPopupWindowFeatures)
@ -6170,20 +6171,19 @@ nsGlobalWindow::FirePopupBlockedEvent(nsIDOMDocument* aDoc,
if (aDoc) {
// Fire a "DOMPopupBlocked" event so that the UI can hear about
// blocked popups.
nsCOMPtr<nsIDOMEvent> event;
aDoc->CreateEvent(NS_LITERAL_STRING("PopupBlockedEvents"),
getter_AddRefs(event));
ErrorResult rv;
nsRefPtr<nsDOMEvent> event =
aDoc->CreateEvent(NS_LITERAL_STRING("PopupBlockedEvents"), rv);
if (event) {
nsCOMPtr<nsIDOMPopupBlockedEvent> pbev(do_QueryInterface(event));
nsCOMPtr<nsIDOMPopupBlockedEvent> pbev(do_QueryObject(event));
pbev->InitPopupBlockedEvent(NS_LITERAL_STRING("DOMPopupBlocked"),
true, true, aRequestingWindow,
aPopupURI, aPopupWindowName,
aPopupWindowFeatures);
event->SetTrusted(true);
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(aDoc));
bool defaultActionEnabled;
targ->DispatchEvent(event, &defaultActionEnabled);
aDoc->DispatchEvent(event, &defaultActionEnabled);
}
}
}
@ -6324,9 +6324,11 @@ nsGlobalWindow::FireAbuseEvents(bool aBlocked, bool aWindow,
getter_AddRefs(popupURI));
// fire an event chock full of informative URIs
if (aBlocked)
FirePopupBlockedEvent(topDoc, this, popupURI, aPopupWindowName,
if (aBlocked) {
nsCOMPtr<nsIDocument> topDocument = do_QueryInterface(topDoc);
FirePopupBlockedEvent(topDocument, this, popupURI, aPopupWindowName,
aPopupWindowFeatures);
}
if (aWindow)
FirePopupWindowEvent(topDoc);
}
@ -6853,7 +6855,7 @@ nsGlobalWindow::PostMessageMoz(const JS::Value& aMessage,
}
else if (callerInnerWin) {
// otherwise use the URI of the document to generate origin
nsCOMPtr<nsIDocument> doc = do_QueryInterface(callerInnerWin->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = callerInnerWin->GetExtantDoc();
if (!doc)
return NS_OK;
callerOuterURI = doc->GetDocumentURI();
@ -7173,7 +7175,7 @@ nsGlobalWindow::EnterModalState()
if (topWin->mModalStateDepth == 0) {
NS_ASSERTION(!mSuspendedDoc, "Shouldn't have mSuspendedDoc here!");
mSuspendedDoc = do_QueryInterface(topWin->GetExtantDocument());
mSuspendedDoc = topWin->GetExtantDoc();
if (mSuspendedDoc && mSuspendedDoc->EventHandlingSuppressed()) {
mSuspendedDoc->SuppressEventHandling();
} else {
@ -7286,8 +7288,7 @@ nsGlobalWindow::LeaveModalState(nsIDOMWindow *aCallerWin)
NS_WARNING("failed to dispatch pending timeout runnable");
if (mSuspendedDoc) {
nsCOMPtr<nsIDocument> currentDoc =
do_QueryInterface(topWin->GetExtantDocument());
nsCOMPtr<nsIDocument> currentDoc = topWin->GetExtantDoc();
mSuspendedDoc->UnsuppressEventHandlingAndFireEvents(currentDoc == mSuspendedDoc);
mSuspendedDoc = nullptr;
}
@ -7777,7 +7778,7 @@ nsGlobalWindow::UpdateCommands(const nsAString& anAction)
return NS_OK;
nsCOMPtr<nsIDOMXULDocument> xulDoc =
do_QueryInterface(rootWindow->GetExtantDocument());
do_QueryInterface(rootWindow->GetExtantDoc());
// See if we contain a XUL document.
if (xulDoc) {
// Retrieve the command dispatcher and call updateCommands on it.
@ -9939,10 +9940,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
#ifdef DEBUG_jst
{
nsCOMPtr<nsPIDOMWindow> pidomwin(do_QueryInterface(*aReturn));
nsIDOMDocument *temp = pidomwin->GetExtantDocument();
NS_ASSERTION(temp, "No document in new window!!!");
NS_ASSERTION(pidomwin->GetExtantDoc(), "No document in new window!!!");
}
#endif
@ -9950,7 +9948,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
(*aReturn)->GetDocument(getter_AddRefs(doc));
}
}
if (checkForPopup) {
if (abuseLevel >= openControlled) {
nsGlobalWindow *opened = static_cast<nsGlobalWindow *>(*aReturn);

View File

@ -584,7 +584,7 @@ public:
mCleanedUp);
}
static void FirePopupBlockedEvent(nsIDOMDocument* aDoc,
static void FirePopupBlockedEvent(nsIDocument* aDoc,
nsIDOMWindow *aRequestingWindow, nsIURI *aPopupURI,
const nsAString &aPopupWindowName,
const nsAString &aPopupWindowFeatures);

View File

@ -345,7 +345,7 @@ nsClipboardCommand::IsCommandEnabled(const char* aCommandName, nsISupports *aCon
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aContext);
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(window->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
*outCmdEnabled = nsCopySupport::CanCopy(doc);
return NS_OK;
}

View File

@ -231,8 +231,7 @@ nsHistory::Go(int32_t aDelta)
// trick to work around gecko reflow bugs, and this should have
// the same effect.
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(window->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
nsIPresShell *shell;
nsPresContext *pcx;
@ -338,8 +337,7 @@ nsHistory::GetState(nsIVariant **aState)
if (!nsContentUtils::CanCallerAccess(win->GetOuterWindow()))
return NS_ERROR_DOM_SECURITY_ERR;
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(win->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = win->GetExtantDoc();
if (!doc)
return NS_ERROR_NOT_AVAILABLE;

View File

@ -620,7 +620,7 @@ PrintWinURI(nsGlobalWindow *win)
return;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(win->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = win->GetExtantDoc();
if (!doc) {
printf("No document in the window.\n");
return;

View File

@ -241,7 +241,7 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
if (expr) {
// if CSP is enabled, and setTimeout/setInterval was called with a string
// or object, disable the registration and log an error
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aWindow->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
if (doc) {
nsCOMPtr<nsIContentSecurityPolicy> csp;

View File

@ -787,7 +787,7 @@ nsLocation::Reload(bool aForceget)
// page since some sites may use this trick to work around gecko
// reflow bugs, and this should have the same effect.
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
nsIPresShell *shell;
nsPresContext *pcx;

View File

@ -172,11 +172,6 @@ public:
virtual void MaybeUpdateTouchState() {}
virtual void UpdateTouchState() {}
// GetExtantDocument provides a backdoor to the DOM GetDocument accessor
nsIDOMDocument* GetExtantDocument() const
{
return mDocument;
}
nsIDocument* GetExtantDoc() const
{
return mDoc;

View File

@ -58,7 +58,7 @@ GetWindowURI(nsIDOMWindow *aWindow)
nsCOMPtr<nsPIDOMWindow> pWindow = do_QueryInterface(aWindow);
NS_ENSURE_TRUE(pWindow, NULL);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(pWindow->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = pWindow->GetExtantDoc();
nsCOMPtr<nsIURI> uri;
if (doc) {

View File

@ -102,8 +102,7 @@ public:
return nullptr;
}
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(GetOwner()->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = GetOwner()->GetExtantDoc();
return doc.forget();
}

View File

@ -975,9 +975,8 @@ MediaManager::GetUserMedia(bool aPrivileged, nsPIDOMWindow* aWindow,
nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
pm->TestPermission(doc->NodePrincipal(), &permission);
if (permission == nsIPopupWindowManager::DENY_POPUP) {
nsCOMPtr<nsIDOMDocument> domDoc = aWindow->GetExtantDocument();
nsGlobalWindow::FirePopupBlockedEvent(
domDoc, aWindow, nullptr, EmptyString(), EmptyString()
doc, aWindow, nullptr, EmptyString(), EmptyString()
);
return NS_OK;
}

View File

@ -11,7 +11,6 @@
#include "nsError.h"
#include "nsIDOMWindow.h"
#include "nsIDOMEvent.h"
#include "nsIDOMDocument.h"
#include "nsPIDOMWindow.h"
#include "PowerManager.h"
@ -68,9 +67,9 @@ WakeLock::Init(const nsAString &aTopic, nsIDOMWindow *aWindow)
* is always considered invisible.
*/
if (window) {
nsCOMPtr<nsIDOMDocument> domDoc = window->GetExtantDocument();
NS_ENSURE_STATE(domDoc);
domDoc->GetHidden(&mHidden);
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
mHidden = doc->Hidden();
}
AttachEventListener();
@ -167,17 +166,16 @@ void
WakeLock::AttachEventListener()
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
if (window) {
nsCOMPtr<nsIDOMDocument> domDoc = window->GetExtantDocument();
if (domDoc) {
nsCOMPtr<EventTarget> target = do_QueryInterface(domDoc);
target->AddSystemEventListener(NS_LITERAL_STRING("visibilitychange"),
this,
/* useCapture = */ true,
/* wantsUntrusted = */ false);
target = do_QueryInterface(window);
if (window) {
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
if (doc) {
doc->AddSystemEventListener(NS_LITERAL_STRING("visibilitychange"),
this,
/* useCapture = */ true,
/* wantsUntrusted = */ false);
nsCOMPtr<EventTarget> target = do_QueryInterface(window);
target->AddSystemEventListener(NS_LITERAL_STRING("pagehide"),
this,
/* useCapture = */ true,
@ -196,13 +194,12 @@ WakeLock::DetachEventListener()
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
if (window) {
nsCOMPtr<nsIDOMDocument> domDoc = window->GetExtantDocument();
if (domDoc) {
nsCOMPtr<EventTarget> target = do_QueryInterface(domDoc);
target->RemoveSystemEventListener(NS_LITERAL_STRING("visibilitychange"),
this,
/* useCapture = */ true);
target = do_QueryInterface(window);
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
if (doc) {
doc->RemoveSystemEventListener(NS_LITERAL_STRING("visibilitychange"),
this,
/* useCapture = */ true);
nsCOMPtr<EventTarget> target = do_QueryInterface(window);
target->RemoveSystemEventListener(NS_LITERAL_STRING("pagehide"),
this,
/* useCapture = */ true);

View File

@ -641,8 +641,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
}
}
mDocumentOnloadBlockedOn =
do_QueryInterface(mOriginalInnerWindow->GetExtantDocument());
mDocumentOnloadBlockedOn = mOriginalInnerWindow->GetExtantDoc();
if (mDocumentOnloadBlockedOn) {
// If we're a document channel, we need to actually block onload on our
// _parent_ document. This is because we don't actually set our
@ -667,7 +666,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
if (mIsAsync) {
// post an event to do the rest
method = &nsJSChannel::EvaluateScript;
} else {
} else {
EvaluateScript();
if (mOpenedStreamChannel) {
// That will handle notifying things

View File

@ -2505,7 +2505,7 @@ WorkerPrivate::Create(JSContext* aCx, JSObject* aObj, WorkerPrivate* aParent,
// If we're called from a window then we can dig out the principal and URI
// from the document.
document = do_QueryInterface(window->GetExtantDocument());
document = window->GetExtantDoc();
if (!document) {
JS_ReportError(aCx, "No document in this window!");
return nullptr;
@ -3114,7 +3114,7 @@ WorkerPrivate::CheckXHRParamsAllowed(nsPIDOMWindow* aWindow)
return false;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aWindow->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
if (!doc) {
return false;
}

View File

@ -5,13 +5,18 @@
#include "nsAutoWindowStateHelper.h"
#include "nsDOMEvent.h"
#include "nsGUIEvent.h"
#include "nsIDocument.h"
#include "nsIDOMEvent.h"
#include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMEvent.h"
#include "nsString.h"
#include "nsGUIEvent.h"
using namespace mozilla;
using namespace mozilla::dom;
/****************************************************************
****************** nsAutoWindowStateHelper *********************
****************************************************************/
@ -50,18 +55,21 @@ nsAutoWindowStateHelper::DispatchEventToChrome(const char *aEventName)
// The functions of nsContentUtils do not provide the required behavior,
// so the following is inlined.
nsIDOMDocument* doc = window->GetExtantDocument();
nsIDocument* doc = window->GetExtantDoc();
if (!doc) {
return true;
}
nsCOMPtr<nsIDOMEvent> event;
doc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
ErrorResult rv;
nsRefPtr<nsDOMEvent> event = doc->CreateEvent(NS_LITERAL_STRING("Events"), rv);
if (rv.Failed()) {
return false;
}
NS_ENSURE_TRUE(NS_SUCCEEDED(event->InitEvent(NS_ConvertASCIItoUTF16(aEventName), true, true)), false);
event->SetTrusted(true);
event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(window));
nsCOMPtr<EventTarget> target = do_QueryInterface(window);
bool defaultActionEnabled;
target->DispatchEvent(event, &defaultActionEnabled);
return defaultActionEnabled;

View File

@ -772,8 +772,7 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
nsCOMPtr<nsIDocShellTreeItem> callerItem = GetCallerTreeItem(parentItem);
nsCOMPtr<nsPIDOMWindow> callerWin = do_GetInterface(callerItem);
if (callerWin) {
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(callerWin->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = callerWin->GetExtantDoc();
if (doc) {
newMuCV->SetDefaultCharacterSet(doc->GetDocumentCharacterSet());
}
@ -911,8 +910,8 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
Also using GetDocument to force document creation seems to
screw up focus in the hidden window; see bug 36016.
*/
nsCOMPtr<nsIDocument> doc(do_QueryInterface(w->GetExtantDocument()));
if (doc) {
nsCOMPtr<nsIDocument> doc = w->GetExtantDoc();
if (doc) {
// Set the referrer
loadInfo->SetReferrer(doc->GetDocumentURI());
}
@ -1799,8 +1798,7 @@ nsWindowWatcher::ReadyOpenedDocShellItem(nsIDocShellTreeItem *aOpenedItem,
NS_ASSERTION(!chan, "Why is there a document channel?");
#endif
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(piOpenedWindow->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = piOpenedWindow->GetExtantDoc();
if (doc) {
doc->SetIsInitialDocument(true);
}

View File

@ -4950,8 +4950,7 @@ ContentComponentsGetterOp(JSContext *cx, JSHandleObject obj, JSHandleId id,
nsCOMPtr<nsPIDOMWindow> win =
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(obj));
if (win) {
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(win->GetExtantDocument());
nsCOMPtr<nsIDocument> doc = win->GetExtantDoc();
if (doc)
doc->WarnOnceAbout(nsIDocument::eComponents, /* asError = */ true);
}

View File

@ -933,8 +933,7 @@ nsDocumentViewer::InitInternal(nsIWidget* aParentWidget,
getter_AddRefs(window));
if (window) {
nsCOMPtr<nsIDocument> curDoc =
do_QueryInterface(window->GetExtantDocument());
nsCOMPtr<nsIDocument> curDoc = window->GetExtantDoc();
if (aForceSetNewDocument || curDoc != mDocument) {
window->SetNewDocument(mDocument, aState, false);
nsJSContext::LoadStart();
@ -3343,7 +3342,7 @@ nsDocumentViewer::GetPopupNode(nsIDOMNode** aNode)
if (!node) {
nsPIDOMWindow* rootWindow = root->GetWindow();
if (rootWindow) {
nsCOMPtr<nsIDocument> rootDoc = do_QueryInterface(rootWindow->GetExtantDocument());
nsCOMPtr<nsIDocument> rootDoc = rootWindow->GetExtantDoc();
if (rootDoc) {
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {

View File

@ -5980,7 +5980,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,
return NS_OK;
}
retargetEventDoc = do_QueryInterface(window->GetExtantDocument());
retargetEventDoc = window->GetExtantDoc();
if (!retargetEventDoc)
return NS_OK;
} else if (capturingContent) {