Fixing bug 68215. Adding support for the onbeforeunload event. r=peterv@propagandism.org, sr=brendan@mozilla.org
git-svn-id: svn://10.0.0.236/trunk@152654 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -2020,15 +2020,28 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURI)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docshell = do_QueryReferent(mDocumentContainer);
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Stop current loads targeted at the window this document is in.
|
||||
if (mScriptGlobalObject && docshell) {
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
docshell->GetContentViewer(getter_AddRefs(cv));
|
||||
|
||||
if (cv) {
|
||||
PRBool okToUnload;
|
||||
rv = cv->PermitUnload(&okToUnload);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !okToUnload) {
|
||||
// We don't want to unload, so stop here, but don't throw an
|
||||
// exception.
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(docshell));
|
||||
webnav->Stop(nsIWebNavigation::STOP_NETWORK);
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// The open occurred after the document finished loading.
|
||||
// So we reset the document and create a new one.
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
@@ -2242,7 +2255,11 @@ nsHTMLDocument::WriteCommon(const nsAString& aText,
|
||||
|
||||
if (!mParser) {
|
||||
rv = Open();
|
||||
if (NS_FAILED(rv)) {
|
||||
|
||||
// If Open() fails, or if it didn't create a parser (as it won't
|
||||
// if the user chose to not discard the current document through
|
||||
// onbeforeunload), don't write anything.
|
||||
if (NS_FAILED(rv) || !mParser) {
|
||||
return rv;
|
||||
}
|
||||
} else if (IsXHTML()) {
|
||||
|
||||
Reference in New Issue
Block a user