Bug 1865918 p6. Update nsDocShell::mContentViewer and local variables to reflect nsIDocumentViewer's new name. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D194294
This commit is contained in:
Jonathan Watt 2023-11-22 13:50:58 +00:00
Родитель 63ce29be2b
Коммит 8bfef8f8d3
2 изменённых файлов: 128 добавлений и 128 удалений

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

@ -389,10 +389,10 @@ nsDocShell::~nsDocShell() {
Destroy();
if (mContentViewer) {
mContentViewer->Close(nullptr);
mContentViewer->Destroy();
mContentViewer = nullptr;
if (mDocumentViewer) {
mDocumentViewer->Close(nullptr);
mDocumentViewer->Destroy();
mDocumentViewer = nullptr;
}
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p destroyed\n", this));
@ -590,7 +590,7 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink) {
return mScriptGlobal->QueryInterface(aIID, aSink);
} else if (aIID.Equals(NS_GET_IID(Document)) &&
NS_SUCCEEDED(EnsureDocumentViewer())) {
RefPtr<Document> doc = mContentViewer->GetDocument();
RefPtr<Document> doc = mDocumentViewer->GetDocument();
doc.forget(aSink);
return *aSink ? NS_OK : NS_NOINTERFACE;
} else if (aIID.Equals(NS_GET_IID(nsIPrompt)) &&
@ -1209,17 +1209,17 @@ nsDocShell::FirePageHideNotification(bool aIsUnload) {
void nsDocShell::FirePageHideNotificationInternal(
bool aIsUnload, bool aSkipCheckingDynEntries) {
if (mContentViewer && !mFiredUnloadEvent) {
if (mDocumentViewer && !mFiredUnloadEvent) {
// Keep an explicit reference since calling PageHide could release
// mContentViewer
nsCOMPtr<nsIDocumentViewer> contentViewer(mContentViewer);
// mDocumentViewer
nsCOMPtr<nsIDocumentViewer> viewer(mDocumentViewer);
mFiredUnloadEvent = true;
if (mTiming) {
mTiming->NotifyUnloadEventStart();
}
contentViewer->PageHide(aIsUnload);
viewer->PageHide(aIsUnload);
if (mTiming) {
mTiming->NotifyUnloadEventEnd();
@ -1287,7 +1287,7 @@ void nsDocShell::ThawFreezeNonRecursive(bool aThaw) {
void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
MOZ_ASSERT(mozilla::BFCacheInParent());
if (!mContentViewer) {
if (!mDocumentViewer) {
return;
}
@ -1295,13 +1295,13 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
// add and remove a request and before that call SetCurrentURI to get
// the location change notification.
// For pagehide, set mFiredUnloadEvent to true, so that unload doesn't fire.
nsCOMPtr<nsIDocumentViewer> contentViewer(mContentViewer);
nsCOMPtr<nsIDocumentViewer> viewer(mDocumentViewer);
if (aShow) {
contentViewer->SetIsHidden(false);
viewer->SetIsHidden(false);
mRefreshURIList = std::move(mBFCachedRefreshURIList);
RefreshURIFromQueue();
mFiredUnloadEvent = false;
RefPtr<Document> doc = contentViewer->GetDocument();
RefPtr<Document> doc = viewer->GetDocument();
if (doc) {
doc->NotifyActivityChanged();
nsCOMPtr<nsPIDOMWindowInner> inner =
@ -1358,7 +1358,7 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
}
mFiredUnloadEvent = true;
contentViewer->PageHide(false);
viewer->PageHide(false);
RefPtr<PresShell> presShell = GetPresShell();
if (presShell) {
@ -1432,7 +1432,7 @@ nsDOMNavigationTiming* nsDocShell::GetNavigationTiming() const {
}
nsPresContext* nsDocShell::GetEldestPresContext() {
nsIDocumentViewer* viewer = mContentViewer;
nsIDocumentViewer* viewer = mDocumentViewer;
while (viewer) {
nsIDocumentViewer* prevViewer = viewer->GetPreviousViewer();
if (!prevViewer) {
@ -1445,11 +1445,11 @@ nsPresContext* nsDocShell::GetEldestPresContext() {
}
nsPresContext* nsDocShell::GetPresContext() {
if (!mContentViewer) {
if (!mDocumentViewer) {
return nullptr;
}
return mContentViewer->GetPresContext();
return mDocumentViewer->GetPresContext();
}
PresShell* nsDocShell::GetPresShell() {
@ -1471,7 +1471,7 @@ NS_IMETHODIMP
nsDocShell::GetContentViewer(nsIDocumentViewer** aContentViewer) {
NS_ENSURE_ARG_POINTER(aContentViewer);
*aContentViewer = mContentViewer;
*aContentViewer = mDocumentViewer;
NS_IF_ADDREF(*aContentViewer);
return NS_OK;
}
@ -2035,10 +2035,10 @@ NS_IMETHODIMP
nsDocShell::GetMayEnableCharacterEncodingMenu(
bool* aMayEnableCharacterEncodingMenu) {
*aMayEnableCharacterEncodingMenu = false;
if (!mContentViewer) {
if (!mDocumentViewer) {
return NS_OK;
}
Document* doc = mContentViewer->GetDocument();
Document* doc = mDocumentViewer->GetDocument();
if (!doc) {
return NS_OK;
}
@ -2271,8 +2271,8 @@ nsDocShell::GetCurrentDocumentChannel(nsIChannel** aResult) {
}
nsIChannel* nsDocShell::GetCurrentDocChannel() {
if (mContentViewer) {
Document* doc = mContentViewer->GetDocument();
if (mDocumentViewer) {
Document* doc = mDocumentViewer->GetDocument();
if (doc) {
return doc->GetChannel();
}
@ -2918,10 +2918,10 @@ nsDocShell::AddChild(nsIDocShellTreeItem* aChild) {
}
// get the parent's current charset
if (!mContentViewer) {
if (!mDocumentViewer) {
return NS_OK;
}
Document* doc = mContentViewer->GetDocument();
Document* doc = mDocumentViewer->GetDocument();
if (!doc) {
return NS_OK;
}
@ -3109,11 +3109,11 @@ nsIScriptGlobalObject* nsDocShell::GetScriptGlobalObject() {
Document* nsDocShell::GetDocument() {
NS_ENSURE_SUCCESS(EnsureDocumentViewer(), nullptr);
return mContentViewer->GetDocument();
return mDocumentViewer->GetDocument();
}
Document* nsDocShell::GetExtantDocument() {
return mContentViewer ? mContentViewer->GetDocument() : nullptr;
return mDocumentViewer ? mDocumentViewer->GetDocument() : nullptr;
}
nsPIDOMWindowOuter* nsDocShell::GetWindow() {
@ -3183,11 +3183,11 @@ bool nsDocShell::IsNavigationAllowed(bool aDisplayPrintErrorDialog,
if (!isAllowed) {
return false;
}
if (!mContentViewer) {
if (!mDocumentViewer) {
return true;
}
bool firingBeforeUnload;
mContentViewer->GetBeforeUnloadFiring(&firingBeforeUnload);
mDocumentViewer->GetBeforeUnloadFiring(&firingBeforeUnload);
return !firingBeforeUnload;
}
@ -4000,7 +4000,7 @@ nsDocShell::Reload(uint32_t aReloadFlags) {
if (!XRE_IsParentProcess()) {
++mPendingReloadCount;
RefPtr<nsDocShell> docShell(this);
nsCOMPtr<nsIDocumentViewer> viewer(mContentViewer);
nsCOMPtr<nsIDocumentViewer> viewer(mDocumentViewer);
NS_ENSURE_STATE(viewer);
bool okToUnload = true;
@ -4233,14 +4233,14 @@ nsDocShell::Stop(uint32_t aStopFlags) {
if (nsIWebNavigation::STOP_CONTENT & aStopFlags) {
// Stop the document loading and animations
if (mContentViewer) {
nsCOMPtr<nsIDocumentViewer> viewer = mContentViewer;
if (mDocumentViewer) {
nsCOMPtr<nsIDocumentViewer> viewer = mDocumentViewer;
viewer->Stop();
}
} else if (nsIWebNavigation::STOP_NETWORK & aStopFlags) {
// Stop the document loading only
if (mContentViewer) {
RefPtr<Document> doc = mContentViewer->GetDocument();
if (mDocumentViewer) {
RefPtr<Document> doc = mDocumentViewer->GetDocument();
if (doc) {
doc->StopDocumentLoad();
}
@ -4282,7 +4282,7 @@ nsDocShell::GetDocument(Document** aDocument) {
NS_ENSURE_ARG_POINTER(aDocument);
NS_ENSURE_SUCCESS(EnsureDocumentViewer(), NS_ERROR_FAILURE);
RefPtr<Document> doc = mContentViewer->GetDocument();
RefPtr<Document> doc = mDocumentViewer->GetDocument();
if (!doc) {
return NS_ERROR_NOT_AVAILABLE;
}
@ -4523,10 +4523,10 @@ nsDocShell::Destroy() {
docShellParentAsItem->RemoveChild(this);
}
if (mContentViewer) {
mContentViewer->Close(nullptr);
mContentViewer->Destroy();
mContentViewer = nullptr;
if (mDocumentViewer) {
mDocumentViewer->Close(nullptr);
mDocumentViewer->Destroy();
mDocumentViewer = nullptr;
}
nsDocLoader::Destroy();
@ -4593,8 +4593,8 @@ NS_IMETHODIMP
nsDocShell::SetPosition(int32_t aX, int32_t aY) {
mBounds.MoveTo(aX, aY);
if (mContentViewer) {
NS_ENSURE_SUCCESS(mContentViewer->Move(aX, aY), NS_ERROR_FAILURE);
if (mDocumentViewer) {
NS_ENSURE_SUCCESS(mDocumentViewer->Move(aX, aY), NS_ERROR_FAILURE);
}
return NS_OK;
@ -4635,8 +4635,8 @@ nsDocShell::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aWidth,
int32_t aHeight, uint32_t aFlags) {
mBounds.SetRect(aX, aY, aWidth, aHeight);
// Hold strong ref, since SetBounds can make us null out mContentViewer
nsCOMPtr<nsIDocumentViewer> viewer = mContentViewer;
// Hold strong ref, since SetBounds can make us null out mDocumentViewer
nsCOMPtr<nsIDocumentViewer> viewer = mDocumentViewer;
if (viewer) {
uint32_t cvflags = (aFlags & nsIBaseWindow::eDelayResize)
? nsIDocumentViewer::eDelayResize
@ -4760,7 +4760,7 @@ nsDocShell::GetVisibility(bool* aVisibility) {
*aVisibility = false;
if (!mContentViewer) {
if (!mDocumentViewer) {
return NS_OK;
}
@ -4857,8 +4857,8 @@ void nsDocShell::ActivenessMaybeChanged() {
// Tell the nsDOMNavigationTiming about it
RefPtr<nsDOMNavigationTiming> timing = mTiming;
if (!timing && mContentViewer) {
if (Document* doc = mContentViewer->GetDocument()) {
if (!timing && mDocumentViewer) {
if (Document* doc = mDocumentViewer->GetDocument()) {
timing = doc->GetNavigationTiming();
}
}
@ -4915,8 +4915,8 @@ nsDocShell::GetFailedChannel(nsIChannel** aFailedChannel) {
NS_IMETHODIMP
nsDocShell::SetVisibility(bool aVisibility) {
// Show()/Hide() may change mContentViewer.
nsCOMPtr<nsIDocumentViewer> viewer = mContentViewer;
// Show()/Hide() may change mDocumentViewer.
nsCOMPtr<nsIDocumentViewer> viewer = mDocumentViewer;
if (!viewer) {
return NS_OK;
}
@ -6340,12 +6340,12 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
//
nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
// Notify the ContentViewer that the Document has finished loading. This
// Notify the DocumentViewer that the Document has finished loading. This
// will cause any OnLoad(...) and PopState(...) handlers to fire.
if (!mEODForCurrentDocument && mContentViewer) {
if (!mEODForCurrentDocument && mDocumentViewer) {
mIsExecutingOnLoadHandler = true;
nsCOMPtr<nsIDocumentViewer> contentViewer = mContentViewer;
contentViewer->LoadComplete(aStatus);
nsCOMPtr<nsIDocumentViewer> viewer = mDocumentViewer;
viewer->LoadComplete(aStatus);
mIsExecutingOnLoadHandler = false;
mEODForCurrentDocument = true;
@ -6461,7 +6461,7 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
//*****************************************************************************
nsresult nsDocShell::EnsureDocumentViewer() {
if (mContentViewer) {
if (mDocumentViewer) {
return NS_OK;
}
if (mIsBeingDestroyed) {
@ -6489,7 +6489,7 @@ nsresult nsDocShell::EnsureDocumentViewer() {
principal, partitionedPrincipal, cspToInheritForAboutBlank, baseURI,
/* aIsInitialDocument */ true);
NS_ENSURE_STATE(mContentViewer);
NS_ENSURE_STATE(mDocumentViewer);
if (NS_SUCCEEDED(rv)) {
RefPtr<Document> doc(GetDocument());
@ -6538,7 +6538,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
return NS_ERROR_NOT_AVAILABLE;
}
// mContentViewer->PermitUnload may release |this| docshell.
// mDocumentViewer->PermitUnload may release |this| docshell.
nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
AutoRestore<bool> creatingDocument(mCreatingDocument);
@ -6554,7 +6554,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
// already, so we don't clobber the timing for an in-progress load.
bool hadTiming = mTiming;
bool toBeReset = MaybeInitTiming();
if (mContentViewer) {
if (mDocumentViewer) {
if (aCheckPermitUnload) {
// We've got a content viewer already. Make sure the user
// permits us to discard the current document and replace it
@ -6566,7 +6566,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
mTiming->NotifyBeforeUnload();
bool okToUnload;
rv = mContentViewer->PermitUnload(&okToUnload);
rv = mDocumentViewer->PermitUnload(&okToUnload);
if (NS_SUCCEEDED(rv) && !okToUnload) {
// The user chose not to unload the page, interrupt the load.
@ -7014,9 +7014,9 @@ nsresult nsDocShell::CaptureState() {
mOSHE->SetRefreshURIList(mSavedRefreshURIList);
// Capture the current content viewer bounds.
if (mContentViewer) {
if (mDocumentViewer) {
nsIntRect bounds;
mContentViewer->GetBounds(bounds);
mDocumentViewer->GetBounds(bounds);
mOSHE->SetViewerBounds(bounds);
}
@ -7053,7 +7053,7 @@ nsDocShell::BeginRestore(nsIDocumentViewer* aContentViewer, bool aTop) {
rv = EnsureDocumentViewer();
NS_ENSURE_SUCCESS(rv, rv);
aContentViewer = mContentViewer;
aContentViewer = mDocumentViewer;
}
// Dispatch events for restoring the presentation. We try to simulate
@ -7185,7 +7185,7 @@ nsresult nsDocShell::RestorePresentation(nsISHEntry* aSHEntry,
return NS_ERROR_FAILURE;
}
NS_ASSERTION(mContentViewer != viewer, "Restoring existing presentation");
NS_ASSERTION(mDocumentViewer != viewer, "Restoring existing presentation");
MOZ_LOG(gPageCacheLog, LogLevel::Debug,
("restoring presentation from session history: %s", spec.get()));
@ -7331,7 +7331,7 @@ nsresult nsDocShell::RestoreFromHistory() {
// XXX can we refactor this so that we can just call Embed()?
PersistLayoutHistoryState();
nsresult rv;
if (mContentViewer) {
if (mDocumentViewer) {
if (mSavingOldViewer && NS_FAILED(CaptureState())) {
if (mOSHE) {
mOSHE->SyncPresentationState();
@ -7348,13 +7348,13 @@ nsresult nsDocShell::RestoreFromHistory() {
// before we grab the root view sibling, so that we don't grab a view
// that's about to go away.
if (mContentViewer) {
if (mDocumentViewer) {
// Make sure to hold a strong ref to previousViewer here while we
// drop the reference to it from mContentViewer.
// drop the reference to it from mDocumentViewer.
nsCOMPtr<nsIDocumentViewer> previousViewer =
mContentViewer->GetPreviousViewer();
mDocumentViewer->GetPreviousViewer();
if (previousViewer) {
mContentViewer->SetPreviousViewer(nullptr);
mDocumentViewer->SetPreviousViewer(nullptr);
previousViewer->Destroy();
}
}
@ -7377,7 +7377,7 @@ nsresult nsDocShell::RestoreFromHistory() {
rootViewSibling = oldRootView->GetNextSibling();
rootViewParent = oldRootView->GetParent();
mContentViewer->GetBounds(newBounds);
mDocumentViewer->GetBounds(newBounds);
}
}
}
@ -7393,29 +7393,29 @@ nsresult nsDocShell::RestoreFromHistory() {
sibling = frame ? frame->PresShell()->GetDocument() : nullptr;
}
// Transfer ownership to mContentViewer. By ensuring that either the
// Transfer ownership to mDocumentViewer. By ensuring that either the
// docshell or the session history, but not both, have references to the
// content viewer, we prevent the viewer from being torn down after
// Destroy() is called.
if (mContentViewer) {
mContentViewer->Close(mSavingOldViewer ? mOSHE.get() : nullptr);
viewer->SetPreviousViewer(mContentViewer);
if (mDocumentViewer) {
mDocumentViewer->Close(mSavingOldViewer ? mOSHE.get() : nullptr);
viewer->SetPreviousViewer(mDocumentViewer);
}
if (mOSHE && (!mContentViewer || !mSavingOldViewer)) {
if (mOSHE && (!mDocumentViewer || !mSavingOldViewer)) {
// We don't plan to save a viewer in mOSHE; tell it to drop
// any other state it's holding.
mOSHE->SyncPresentationState();
}
// Order the mContentViewer setup just like Embed does.
mContentViewer = nullptr;
// Order the mDocumentViewer setup just like Embed does.
mDocumentViewer = nullptr;
// Now that we're about to switch documents, forget all of our children.
// Note that we cached them as needed up in CaptureState above.
DestroyChildren();
mContentViewer.swap(viewer);
mDocumentViewer.swap(viewer);
// Grab all of the related presentation from the SHEntry now.
// Clearing the viewer from the SHEntry will clear all of this state.
@ -7424,7 +7424,7 @@ nsresult nsDocShell::RestoreFromHistory() {
bool sticky = mLSHE->GetSticky();
RefPtr<Document> document = mContentViewer->GetDocument();
RefPtr<Document> document = mDocumentViewer->GetDocument();
nsCOMArray<nsIDocShellTreeItem> childShells;
int32_t i = 0;
@ -7444,7 +7444,7 @@ nsresult nsDocShell::RestoreFromHistory() {
// Reattach to the window object.
mIsRestoringDocument = true; // for MediaDocument::BecomeInteractive
rv = mContentViewer->Open(windowState, mLSHE);
rv = mDocumentViewer->Open(windowState, mLSHE);
mIsRestoringDocument = false;
// Hack to keep nsDocShellEditorData alive across the
@ -7470,7 +7470,7 @@ nsresult nsDocShell::RestoreFromHistory() {
// Restore the sticky state of the viewer. The viewer has set this state
// on the history entry in Destroy() just before marking itself non-sticky,
// to avoid teardown of the presentation.
mContentViewer->SetSticky(sticky);
mDocumentViewer->SetSticky(sticky);
NS_ENSURE_SUCCESS(rv, rv);
@ -7579,7 +7579,7 @@ nsresult nsDocShell::RestoreFromHistory() {
// presShell->BackingScaleFactorChanged().
// But we depend on that device context when adjusting the view size
// via mContentViewer->SetBounds(newBounds) below. So we need to
// via mDocumentViewer->SetBounds(newBounds) below. So we need to
// explicitly tell it to check for changed resolution here.
if (presShell) {
RefPtr<nsPresContext> pc = presShell->GetPresContext();
@ -7676,7 +7676,7 @@ nsresult nsDocShell::RestoreFromHistory() {
MOZ_LOG(gPageCacheLog, LogLevel::Debug,
("resize widget(%d, %d, %d, %d)", newBounds.x, newBounds.y,
newBounds.width, newBounds.height));
mContentViewer->SetBounds(newBounds);
mDocumentViewer->SetBounds(newBounds);
} else {
nsIScrollableFrame* rootScrollFrame =
presShell->GetRootScrollFrameAsScrollable();
@ -7911,7 +7911,7 @@ nsresult nsDocShell::CreateDocumentViewer(const nsACString& aContentType,
}
if (DocGroup::TryToLoadIframesInBackground()) {
if ((!mContentViewer || GetDocument()->IsInitialDocument()) &&
if ((!mDocumentViewer || GetDocument()->IsInitialDocument()) &&
IsSubframe()) {
// At this point, we know we just created a new iframe document based on
// the response from the server, and we check if it's a cross-domain
@ -8055,13 +8055,13 @@ nsresult nsDocShell::SetupNewViewer(nsIDocumentViewer* aNewViewer,
// |newMUDV| also serves as a flag to set the data from the above vars
nsCOMPtr<nsIDocumentViewer> newViewer;
if (mContentViewer || parent) {
if (mDocumentViewer || parent) {
nsCOMPtr<nsIDocumentViewer> oldViewer;
if (mContentViewer) {
if (mDocumentViewer) {
// Get any interesting state from old content viewer
// XXX: it would be far better to just reuse the document viewer ,
// since we know we're just displaying the same document as before
oldViewer = mContentViewer;
oldViewer = mDocumentViewer;
// Tell the old content viewer to hibernate in session history when
// it is destroyed.
@ -8089,48 +8089,48 @@ nsresult nsDocShell::SetupNewViewer(nsIDocumentViewer* aNewViewer,
nscolor bgcolor = NS_RGBA(0, 0, 0, 0);
bool isUnderHiddenEmbedderElement = false;
// Ensure that the content viewer is destroyed *after* the GC - bug 71515
nsCOMPtr<nsIDocumentViewer> contentViewer = mContentViewer;
if (contentViewer) {
nsCOMPtr<nsIDocumentViewer> viewer = mDocumentViewer;
if (viewer) {
// Stop any activity that may be happening in the old document before
// releasing it...
contentViewer->Stop();
viewer->Stop();
// Try to extract the canvas background color from the old
// presentation shell, so we can use it for the next document.
if (PresShell* presShell = contentViewer->GetPresShell()) {
if (PresShell* presShell = viewer->GetPresShell()) {
bgcolor = presShell->GetCanvasBackground();
isUnderHiddenEmbedderElement = presShell->IsUnderHiddenEmbedderElement();
}
contentViewer->Close(mSavingOldViewer ? mOSHE.get() : nullptr);
aNewViewer->SetPreviousViewer(contentViewer);
viewer->Close(mSavingOldViewer ? mOSHE.get() : nullptr);
aNewViewer->SetPreviousViewer(viewer);
}
if (mOSHE && (!mContentViewer || !mSavingOldViewer)) {
if (mOSHE && (!mDocumentViewer || !mSavingOldViewer)) {
// We don't plan to save a viewer in mOSHE; tell it to drop
// any other state it's holding.
mOSHE->SyncPresentationState();
}
mContentViewer = nullptr;
mDocumentViewer = nullptr;
// Now that we're about to switch documents, forget all of our children.
// Note that we cached them as needed up in CaptureState above.
DestroyChildren();
mContentViewer = aNewViewer;
mDocumentViewer = aNewViewer;
nsCOMPtr<nsIWidget> widget;
NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE);
nsIntRect bounds(x, y, cx, cy);
mContentViewer->SetNavigationTiming(mTiming);
mDocumentViewer->SetNavigationTiming(mTiming);
if (NS_FAILED(mContentViewer->Init(widget, bounds, aWindowActor))) {
nsCOMPtr<nsIDocumentViewer> viewer = mContentViewer;
if (NS_FAILED(mDocumentViewer->Init(widget, bounds, aWindowActor))) {
nsCOMPtr<nsIDocumentViewer> viewer = mDocumentViewer;
viewer->Close(nullptr);
viewer->Destroy();
mContentViewer = nullptr;
mDocumentViewer = nullptr;
SetCurrentURIInternal(nullptr);
NS_WARNING("ContentViewer Initialization failed");
return NS_ERROR_FAILURE;
@ -8142,11 +8142,11 @@ nsresult nsDocShell::SetupNewViewer(nsIDocumentViewer* aNewViewer,
newViewer->SetReloadEncodingAndSource(reloadEncoding, reloadEncodingSource);
}
NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(mDocumentViewer, NS_ERROR_FAILURE);
// Stuff the bgcolor from the old pres shell into the new
// pres shell. This improves page load continuity.
if (RefPtr<PresShell> presShell = mContentViewer->GetPresShell()) {
if (RefPtr<PresShell> presShell = mDocumentViewer->GetPresShell()) {
presShell->SetCanvasBackground(bgcolor);
presShell->ActivenessMaybeChanged();
if (isUnderHiddenEmbedderElement) {
@ -8157,7 +8157,7 @@ nsresult nsDocShell::SetupNewViewer(nsIDocumentViewer* aNewViewer,
// XXX: It looks like the LayoutState gets restored again in Embed()
// right after the call to SetupNewViewer(...)
// We don't show the mContentViewer yet, since we want to draw the old page
// We don't show the mDocumentViewer yet, since we want to draw the old page
// until we have enough of the new page to show. Just return with the new
// viewer still set to hidden.
@ -8166,7 +8166,7 @@ nsresult nsDocShell::SetupNewViewer(nsIDocumentViewer* aNewViewer,
void nsDocShell::SetDocCurrentStateObj(nsISHEntry* aShEntry,
SessionHistoryInfo* aInfo) {
NS_ENSURE_TRUE_VOID(mContentViewer);
NS_ENSURE_TRUE_VOID(mDocumentViewer);
RefPtr<Document> document = GetDocument();
NS_ENSURE_TRUE_VOID(document);
@ -8448,8 +8448,8 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
// If the docshell's document is sandboxed, only open a new window
// if the document's SANDBOXED_AUXILLARY_NAVIGATION flag is not set.
// (i.e. if allow-popups is specified)
NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);
Document* doc = mContentViewer->GetDocument();
NS_ENSURE_TRUE(mDocumentViewer, NS_ERROR_FAILURE);
Document* doc = mDocumentViewer->GetDocument();
const bool isDocumentAuxSandboxed =
doc && (doc->GetSandboxFlags() & SANDBOXED_AUXILIARY_NAVIGATION);
@ -9408,7 +9408,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
}
}
// mContentViewer->PermitUnload can destroy |this| docShell, which
// mDocumentViewer->PermitUnload can destroy |this| docShell, which
// causes the next call of CanSavePresentation to crash.
// Hold onto |this| until we return, to prevent a crash from happening.
// (bug#331040)
@ -9433,7 +9433,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
// Check if the page doesn't want to be unloaded. The javascript:
// protocol handler deals with this for javascript: URLs.
if (!isJavaScript && isNotDownload &&
!aLoadState->NotifiedBeforeUnloadListeners() && mContentViewer) {
!aLoadState->NotifiedBeforeUnloadListeners() && mDocumentViewer) {
bool okToUnload;
// Check if request is exempted from HTTPSOnlyMode and if https-first is
@ -9459,11 +9459,11 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
// unload and just unload.
if (!isHistoryOrReload && aLoadState->IsExemptFromHTTPSFirstMode() &&
nsHTTPSOnlyUtils::IsHttpsFirstModeEnabled(isPrivateWin)) {
rv = mContentViewer->PermitUnload(
rv = mDocumentViewer->PermitUnload(
nsIDocumentViewer::PermitUnloadAction::eDontPromptAndUnload,
&okToUnload);
} else {
rv = mContentViewer->PermitUnload(&okToUnload);
rv = mDocumentViewer->PermitUnload(&okToUnload);
}
if (NS_SUCCEEDED(rv) && !okToUnload) {
@ -9543,7 +9543,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
// If not a zombie, don't stop content until data
// starts arriving from the new URI...
if ((mContentViewer && mContentViewer->GetPreviousViewer()) ||
if ((mDocumentViewer && mDocumentViewer->GetPreviousViewer()) ||
LOAD_TYPE_HAS_FLAGS(aLoadState->LoadType(), LOAD_FLAGS_STOP_CONTENT)) {
rv = Stop(nsIWebNavigation::STOP_ALL);
} else {
@ -9591,13 +9591,13 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
shistory->RemovePendingHistoryNavigations();
}
if (!mozilla::SessionHistoryInParent()) {
// It's possible that the previous viewer of mContentViewer is the
// It's possible that the previous viewer of mDocumentViewer is the
// viewer that will end up in aLoadState->SHEntry() when it gets closed.
// If that's the case, we need to go ahead and force it into its shentry
// so we can restore it.
if (mContentViewer) {
if (mDocumentViewer) {
nsCOMPtr<nsIDocumentViewer> prevViewer =
mContentViewer->GetPreviousViewer();
mDocumentViewer->GetPreviousViewer();
if (prevViewer) {
#ifdef DEBUG
nsCOMPtr<nsIDocumentViewer> prevPrevViewer =
@ -9608,7 +9608,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
prevViewer->GetHistoryEntry(getter_AddRefs(viewerEntry));
if (viewerEntry == aLoadState->SHEntry()) {
// Make sure this viewer ends up in the right place
mContentViewer->SetPreviousViewer(nullptr);
mDocumentViewer->SetPreviousViewer(nullptr);
prevViewer->Destroy();
}
}
@ -9733,8 +9733,8 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
RefPtr<Document> document;
bool inheritedFromCurrent = false;
if (aConsiderCurrentDocument && mContentViewer) {
document = mContentViewer->GetDocument();
if (aConsiderCurrentDocument && mDocumentViewer) {
document = mDocumentViewer->GetDocument();
inheritedFromCurrent = true;
}
@ -9754,10 +9754,10 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
// Make sure we end up with _something_ as the principal no matter
// what.If this fails, we'll just get a null docViewer and bail.
EnsureDocumentViewer();
if (!mContentViewer) {
if (!mDocumentViewer) {
return nullptr;
}
document = mContentViewer->GetDocument();
document = mDocumentViewer->GetDocument();
}
//-- Get the document's principal
@ -10165,8 +10165,8 @@ bool nsDocShell::IsAboutBlankLoadOntoInitialAboutBlank(
nsIURI* aURI, bool aInheritPrincipal, nsIPrincipal* aPrincipalToInherit) {
return NS_IsAboutBlank(aURI) && aInheritPrincipal &&
(aPrincipalToInherit == GetInheritedPrincipal(false)) &&
(!mContentViewer || !mContentViewer->GetDocument() ||
mContentViewer->GetDocument()->IsInitialDocument());
(!mDocumentViewer || !mDocumentViewer->GetDocument() ||
mDocumentViewer->GetDocument()->IsInitialDocument());
}
nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
@ -11165,7 +11165,7 @@ Maybe<Wireframe> nsDocShell::GetWireframe() {
return Nothing();
}
RefPtr<Document> doc = mContentViewer->GetDocument();
RefPtr<Document> doc = mDocumentViewer->GetDocument();
Nullable<Wireframe> wireframe;
doc->GetWireframeWithoutFlushing(false, wireframe);
if (wireframe.IsNull()) {
@ -13198,11 +13198,11 @@ bool nsDocShell::ShouldBlockLoadingForBackButton() {
}
bool nsDocShell::PluginsAllowedInCurrentDoc() {
if (!mContentViewer) {
if (!mDocumentViewer) {
return false;
}
Document* doc = mContentViewer->GetDocument();
Document* doc = mDocumentViewer->GetDocument();
if (!doc) {
return false;
}
@ -13254,7 +13254,7 @@ nsresult nsDocShell::CharsetChangeStopDocumentLoad() {
NS_IMETHODIMP nsDocShell::ExitPrintPreview() {
#if NS_PRINT_PREVIEW
nsCOMPtr<nsIWebBrowserPrint> viewer = do_QueryInterface(mContentViewer);
nsCOMPtr<nsIWebBrowserPrint> viewer = do_QueryInterface(mDocumentViewer);
return viewer->ExitPrintPreview();
#else
return NS_OK;

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

@ -493,7 +493,7 @@ class nsDocShell final : public nsDocLoader,
static void ExtractLastVisit(nsIChannel* aChannel, nsIURI** aURI,
uint32_t* aChannelRedirectFlags);
bool HasDocumentViewer() const { return !!mContentViewer; }
bool HasDocumentViewer() const { return !!mDocumentViewer; }
static uint32_t ComputeURILoaderFlags(
mozilla::dom::BrowsingContext* aBrowsingContext, uint32_t aLoadType);
@ -841,13 +841,13 @@ class nsDocShell final : public nsDocLoader,
// The following methods deal with saving and restoring content viewers
// in session history.
// mContentViewer points to the current content viewer associated with
// mDocumentViewer points to the current content viewer associated with
// this docshell. When loading a new document, the content viewer is
// either destroyed or stored into a session history entry. To make sure
// that destruction happens in a controlled fashion, a given content viewer
// is always owned in exactly one of these ways:
// 1) The content viewer is active and owned by a docshell's
// mContentViewer.
// mDocumentViewer.
// 2) The content viewer is still being displayed while we begin loading
// a new document. The content viewer is owned by the _new_
// content viewer's mPreviousViewer, and has a pointer to the
@ -860,11 +860,11 @@ class nsDocShell final : public nsDocLoader,
//
// When restoring a content viewer from session history, open() is called
// to reattach the document to the window object. The content viewer is
// then placed into mContentViewer and removed from the history entry.
// (mContentViewer is put into session history as described above, if
// then placed into mDocumentViewer and removed from the history entry.
// (mDocumentViewer is put into session history as described above, if
// applicable).
// Determines whether we can safely cache the current mContentViewer in
// Determines whether we can safely cache the current mDocumentViewer in
// session history. This checks a number of factors such as cache policy,
// pending requests, and unload handlers.
// |aLoadType| should be the load type that will replace the current
@ -1166,7 +1166,7 @@ class nsDocShell final : public nsDocLoader,
// mBFCachedRefreshURIList.
nsCOMPtr<nsIMutableArray> mBFCachedRefreshURIList;
uint64_t mContentWindowID;
nsCOMPtr<nsIDocumentViewer> mContentViewer;
nsCOMPtr<nsIDocumentViewer> mDocumentViewer;
nsCOMPtr<nsIWidget> mParentWidget;
RefPtr<mozilla::dom::ChildSHistory> mSessionHistory;
nsCOMPtr<nsIWebBrowserFind> mFind;