Bug 1018486 - Part 5: Changes in docshell/ and uriloader/, r=bz

MozReview-Commit-ID: GiyHWL3aaOv
This commit is contained in:
Michael Layzell
2016-07-18 12:38:32 -04:00
parent c987b38274
commit 829f88a6df
8 changed files with 21 additions and 27 deletions

View File

@@ -1654,14 +1654,14 @@ nsDocShell::FirePageHideNotification(bool aIsUnload)
if (mContentViewer && !mFiredUnloadEvent) {
// Keep an explicit reference since calling PageHide could release
// mContentViewer
nsCOMPtr<nsIContentViewer> kungFuDeathGrip(mContentViewer);
nsCOMPtr<nsIContentViewer> contentViewer(mContentViewer);
mFiredUnloadEvent = true;
if (mTiming) {
mTiming->NotifyUnloadEventStart();
}
mContentViewer->PageHide(aIsUnload);
contentViewer->PageHide(aIsUnload);
if (mTiming) {
mTiming->NotifyUnloadEventEnd();
@@ -7590,6 +7590,7 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
// nsDocShell::EndPageLoad will clear mLSHE, but we may need this history
// entry further down in this method.
nsCOMPtr<nsISHEntry> loadingSHE = mLSHE;
mozilla::Unused << loadingSHE; // XXX: Not sure if we need this anymore
//
// one of many safeguards that prevent death and destruction if
@@ -9324,23 +9325,23 @@ nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
nscolor bgcolor = NS_RGBA(0, 0, 0, 0);
// Ensure that the content viewer is destroyed *after* the GC - bug 71515
nsCOMPtr<nsIContentViewer> kungfuDeathGrip = mContentViewer;
if (mContentViewer) {
nsCOMPtr<nsIContentViewer> contentViewer = mContentViewer;
if (contentViewer) {
// Stop any activity that may be happening in the old document before
// releasing it...
mContentViewer->Stop();
contentViewer->Stop();
// Try to extract the canvas background color from the old
// presentation shell, so we can use it for the next document.
nsCOMPtr<nsIPresShell> shell;
mContentViewer->GetPresShell(getter_AddRefs(shell));
contentViewer->GetPresShell(getter_AddRefs(shell));
if (shell) {
bgcolor = shell->GetCanvasBackground();
}
mContentViewer->Close(mSavingOldViewer ? mOSHE.get() : nullptr);
aNewViewer->SetPreviousViewer(mContentViewer);
contentViewer->Close(mSavingOldViewer ? mOSHE.get() : nullptr);
aNewViewer->SetPreviousViewer(contentViewer);
}
if (mOSHE && (!mContentViewer || !mSavingOldViewer)) {
// We don't plan to save a viewer in mOSHE; tell it to drop
@@ -9759,13 +9760,14 @@ nsDocShell::InternalLoad(nsIURI* aURI,
isJavaScript = false;
}
RefPtr<nsGlobalWindow> scriptGlobal = mScriptGlobal;
// First, notify any nsIContentPolicy listeners about the document load.
// Only abort the load if a content policy listener explicitly vetos it!
// Use nsPIDOMWindow since we _want_ to cross the chrome boundary if needed
nsCOMPtr<Element> requestingElement =
mScriptGlobal->AsOuter()->GetFrameElementInternal();
scriptGlobal->AsOuter()->GetFrameElementInternal();
RefPtr<nsGlobalWindow> MMADeathGrip = mScriptGlobal;
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
uint32_t contentType;
@@ -9811,7 +9813,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
nsISupports* context = requestingElement;
if (!context) {
context = ToSupports(mScriptGlobal);
context = ToSupports(scriptGlobal);
}
// XXXbz would be nice to know the loading principal here... but we don't
@@ -10317,8 +10319,8 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// applies to aURI.
CopyFavicon(currentURI, aURI, doc->NodePrincipal(), UsePrivateBrowsing());
RefPtr<nsGlobalWindow> win = mScriptGlobal ?
mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
RefPtr<nsGlobalWindow> win = scriptGlobal ?
scriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
// ScrollToAnchor doesn't necessarily cause us to scroll the window;
// the function decides whether a scroll is appropriate based on the