mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 549452: Clean up nsGlobalWindow::SetNewDocument. r=mrbkap sr=jst
--HG-- extra : rebase_source : 1e13da2a339089ccf17b8cf9f41d59e188aa8165
This commit is contained in:
parent
8ce014db8d
commit
986107fb30
@ -1961,7 +1961,7 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
mWillReparent = PR_TRUE;
|
||||
#endif
|
||||
|
||||
rv = window->SetNewDocument(this, nsnull, PR_FALSE);
|
||||
rv = window->SetNewDocument(this, nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -1568,39 +1568,18 @@ NS_IMPL_ISUPPORTS1(WindowStateHolder, WindowStateHolder)
|
||||
|
||||
nsresult
|
||||
nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
nsISupports* aState,
|
||||
PRBool aClearScopeHint)
|
||||
nsISupports* aState)
|
||||
{
|
||||
return SetNewDocument(aDocument, aState, aClearScopeHint, PR_FALSE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
nsISupports* aState,
|
||||
PRBool aClearScopeHint,
|
||||
PRBool aIsInternalCall)
|
||||
{
|
||||
NS_ASSERTION(mDocumentPrincipal == nsnull,
|
||||
NS_PRECONDITION(mDocumentPrincipal == nsnull,
|
||||
"mDocumentPrincipal prematurely set!");
|
||||
#ifdef PR_LOGGING
|
||||
if (IsInnerWindow() && aDocument && gDOMLeakPRLog &&
|
||||
PR_LOG_TEST(gDOMLeakPRLog, PR_LOG_DEBUG)) {
|
||||
nsIURI *uri = aDocument->GetDocumentURI();
|
||||
nsCAutoString spec;
|
||||
if (uri)
|
||||
uri->GetSpec(spec);
|
||||
PR_LogPrint("DOMWINDOW %p SetNewDocument %s", this, spec.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (IsOuterWindow() && IsFrozen()) {
|
||||
// This outer is now getting its first inner, thaw the outer now
|
||||
// that it's ready and is getting an inner window.
|
||||
if (!aDocument) {
|
||||
NS_ERROR("SetNewDocument(null) called!");
|
||||
|
||||
Thaw();
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!aIsInternalCall && IsInnerWindow()) {
|
||||
if (IsInnerWindow()) {
|
||||
if (!mOuterWindow) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
@ -1611,15 +1590,15 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return GetOuterWindowInternal()->SetNewDocument(aDocument,
|
||||
aState,
|
||||
aClearScopeHint, PR_TRUE);
|
||||
return GetOuterWindowInternal()->SetNewDocument(aDocument, aState);
|
||||
}
|
||||
|
||||
if (!aDocument) {
|
||||
NS_ERROR("SetNewDocument(null) called!");
|
||||
NS_PRECONDITION(IsOuterWindow(), "Must only be called on outer windows");
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (IsFrozen()) {
|
||||
// This outer is now getting its first inner, thaw the outer now
|
||||
// that it's ready and is getting an inner window.
|
||||
Thaw();
|
||||
}
|
||||
|
||||
NS_ASSERTION(!GetCurrentInnerWindow() ||
|
||||
@ -1667,16 +1646,10 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
SetStatus(EmptyString());
|
||||
SetDefaultStatus(EmptyString());
|
||||
|
||||
// This code should not be called during shutdown any more (now that
|
||||
// we don't ever call SetNewDocument(nsnull), so no need to null
|
||||
// check xpc here.
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
|
||||
PRBool reUseInnerWindow = WouldReuseInnerWindow(aDocument);
|
||||
|
||||
// Remember the old document's principal.
|
||||
nsIPrincipal *oldPrincipal = nsnull;
|
||||
|
||||
if (oldDoc) {
|
||||
oldPrincipal = oldDoc->NodePrincipal();
|
||||
}
|
||||
@ -1707,22 +1680,17 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
mNavigator->LoadingNewDocument();
|
||||
}
|
||||
|
||||
PRUint32 st_id, st_ndx; // we loop over all our context/globs lots!
|
||||
|
||||
// Set mDocument even if this is an outer window to avoid
|
||||
// having to *always* reach into the inner window to find the
|
||||
// document.
|
||||
|
||||
mDocument = do_QueryInterface(aDocument);
|
||||
mDoc = aDocument;
|
||||
mLocalStorage = nsnull;
|
||||
mSessionStorage = nsnull;
|
||||
|
||||
#ifdef DEBUG
|
||||
mLastOpenedURI = aDocument->GetDocumentURI();
|
||||
#endif
|
||||
|
||||
if (IsOuterWindow()) {
|
||||
PRUint32 st_id; // we loop over all our context/globs lots!
|
||||
NS_STID_FOR_ID(st_id) {
|
||||
nsIScriptContext *langContext = GetScriptContextInternal(st_id);
|
||||
if (langContext)
|
||||
@ -1844,7 +1812,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
// new global.
|
||||
rv = NS_OK;
|
||||
NS_STID_FOR_ID(st_id) {
|
||||
st_ndx = NS_STID_INDEX(st_id);
|
||||
PRUint32 st_ndx = NS_STID_INDEX(st_id);
|
||||
nsIScriptContext *this_ctx = GetScriptContextInternal(st_id);
|
||||
if (this_ctx) {
|
||||
void *&newGlobal = newInnerWindow->mScriptGlobals[st_ndx];
|
||||
@ -1976,6 +1944,11 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
html_doc);
|
||||
}
|
||||
|
||||
// This code should not be called during shutdown any more (now that
|
||||
// we don't ever call SetNewDocument(nsnull), so no need to null
|
||||
// check xpc here.
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
|
||||
if (aState) {
|
||||
// Restoring from session history.
|
||||
|
||||
@ -2026,8 +1999,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
::JS_DeleteProperty(cx, currentInner->mJSObject, "document");
|
||||
}
|
||||
} else {
|
||||
rv = newInnerWindow->SetNewDocument(aDocument, nsnull,
|
||||
aClearScopeHint, PR_TRUE);
|
||||
rv = newInnerWindow->InnerWindowSetNewDocument(aDocument);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_STID_FOR_ID(st_id) {
|
||||
@ -2088,8 +2060,35 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
this_ctx->DidInitializeContext();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGlobalWindow::InnerWindowSetNewDocument(nsIDocument* aDocument)
|
||||
{
|
||||
NS_PRECONDITION(IsInnerWindow(), "Must only be called on inner windows");
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (aDocument && gDOMLeakPRLog &&
|
||||
PR_LOG_TEST(gDOMLeakPRLog, PR_LOG_DEBUG)) {
|
||||
nsIURI *uri = aDocument->GetDocumentURI();
|
||||
nsCAutoString spec;
|
||||
if (uri)
|
||||
uri->GetSpec(spec);
|
||||
PR_LogPrint("DOMWINDOW %p SetNewDocument %s", this, spec.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
mDocument = do_QueryInterface(aDocument);
|
||||
mDoc = aDocument;
|
||||
mLocalStorage = nsnull;
|
||||
mSessionStorage = nsnull;
|
||||
|
||||
#ifdef DEBUG
|
||||
mLastOpenedURI = aDocument->GetDocumentURI();
|
||||
#endif
|
||||
|
||||
// Clear our mutation bitfield.
|
||||
mMutationBits = 0;
|
||||
|
||||
@ -9445,8 +9444,7 @@ nsGlobalModalWindow::SetReturnValue(nsIVariant *aRetVal)
|
||||
|
||||
nsresult
|
||||
nsGlobalModalWindow::SetNewDocument(nsIDocument *aDocument,
|
||||
nsISupports *aState,
|
||||
PRBool aClearScopeHint)
|
||||
nsISupports *aState)
|
||||
{
|
||||
// If we're loading a new document into a modal dialog, clear the
|
||||
// return value that was set, if any, by the current document.
|
||||
@ -9454,7 +9452,7 @@ nsGlobalModalWindow::SetNewDocument(nsIDocument *aDocument,
|
||||
mReturnValue = nsnull;
|
||||
}
|
||||
|
||||
return nsGlobalWindow::SetNewDocument(aDocument, aState, aClearScopeHint);
|
||||
return nsGlobalWindow::SetNewDocument(aDocument, aState);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -335,8 +335,7 @@ public:
|
||||
|
||||
virtual NS_HIDDEN_(void) SetDocShell(nsIDocShell* aDocShell);
|
||||
virtual NS_HIDDEN_(nsresult) SetNewDocument(nsIDocument *aDocument,
|
||||
nsISupports *aState,
|
||||
PRBool aClearScopeHint);
|
||||
nsISupports *aState);
|
||||
virtual NS_HIDDEN_(void) SetOpenerWindow(nsIDOMWindowInternal *aOpener,
|
||||
PRBool aOriginalOpener);
|
||||
virtual NS_HIDDEN_(void) EnsureSizeUpToDate();
|
||||
@ -463,10 +462,8 @@ protected:
|
||||
void FreeInnerObjects(PRBool aClearScope);
|
||||
nsGlobalWindow *CallerInnerWindow();
|
||||
|
||||
nsresult SetNewDocument(nsIDocument *aDocument,
|
||||
nsISupports *aState,
|
||||
PRBool aClearScopeHint,
|
||||
PRBool aIsInternalCall);
|
||||
nsresult InnerWindowSetNewDocument(nsIDocument* aDocument);
|
||||
|
||||
nsresult DefineArgumentsProperty(nsIArray *aArguments);
|
||||
|
||||
// Get the parent, returns null if this is a toplevel window
|
||||
@ -848,8 +845,7 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsGlobalModalWindow, nsGlobalWindow)
|
||||
|
||||
virtual NS_HIDDEN_(nsresult) SetNewDocument(nsIDocument *aDocument,
|
||||
nsISupports *aState,
|
||||
PRBool aClearScopeHint);
|
||||
nsISupports *aState);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIVariant> mReturnValue;
|
||||
|
@ -78,8 +78,8 @@ class nsIArray;
|
||||
class nsPIWindowRoot;
|
||||
|
||||
#define NS_PIDOMWINDOW_IID \
|
||||
{ 0x2962cfa4, 0x13f9, 0x4606, \
|
||||
{ 0x84, 0x64, 0xef, 0x4c, 0xfa, 0x33, 0xcc, 0xce } }
|
||||
{ 0x81cdf500, 0x2183, 0x4af6, \
|
||||
{ 0xa4, 0x56, 0x35, 0x1f, 0x4a, 0x0d, 0x1a, 0x0b } }
|
||||
|
||||
class nsPIDOMWindow : public nsIDOMWindowInternal
|
||||
{
|
||||
@ -353,8 +353,7 @@ public:
|
||||
* created.
|
||||
*/
|
||||
virtual nsresult SetNewDocument(nsIDocument *aDocument,
|
||||
nsISupports *aState,
|
||||
PRBool aClearScope) = 0;
|
||||
nsISupports *aState) = 0;
|
||||
|
||||
/**
|
||||
* Set the opener window. aOriginalOpener is true if and only if this is the
|
||||
|
@ -946,7 +946,7 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
|
||||
getter_AddRefs(window));
|
||||
|
||||
if (window) {
|
||||
window->SetNewDocument(mDocument, aState, PR_TRUE);
|
||||
window->SetNewDocument(mDocument, aState);
|
||||
|
||||
nsJSContext::LoadStart();
|
||||
}
|
||||
@ -1695,7 +1695,7 @@ DocumentViewerImpl::SetDOMDocument(nsIDOMDocument *aDocument)
|
||||
// Set the script global object on the new document
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(container);
|
||||
if (window) {
|
||||
window->SetNewDocument(newDoc, nsnull, PR_TRUE);
|
||||
window->SetNewDocument(newDoc, nsnull);
|
||||
}
|
||||
|
||||
// Clear the list of old child docshells. CChild docshells for the new
|
||||
|
Loading…
Reference in New Issue
Block a user