Skip to content

Commit

Permalink
Bug 725770. r=bz
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Pearce committed Aug 15, 2012
1 parent 73f095d commit addad8e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docshell/base/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,7 @@ LOCAL_INCLUDES += \
-I$(topsrcdir)/dom/base \
-I$(topsrcdir)/layout/base \
-I$(topsrcdir)/xpcom/ds \
-I$(topsrcdir)/layout/generic \
-I$(topsrcdir)/layout/xul/base/src \
-I$(topsrcdir)/content/base/src \
$(NULL)
32 changes: 27 additions & 5 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
#include "nsEventStateManager.h"

#include "nsIFrame.h"
#include "nsSubDocumentFrame.h"

// for embedding
#include "nsIWebBrowserChromeFocus.h"
Expand Down Expand Up @@ -7162,7 +7163,7 @@ nsDocShell::RestoreFromHistory()
// Make sure to blow away our mLoadingURI just in case. No loads
// from inside this pagehide.
mLoadingURI = nullptr;

// Notify the old content viewer that it's being hidden.
FirePageHideNotification(!mSavingOldViewer);

Expand Down Expand Up @@ -7243,6 +7244,17 @@ nsDocShell::RestoreFromHistory()
}
}

nsCOMPtr<nsIContent> container;
nsCOMPtr<nsIDocument> sibling;
if (rootViewParent && rootViewParent->GetParent()) {
nsIFrame* frame = rootViewParent->GetParent()->GetFrame();
container = frame ? frame->GetContent() : nullptr;
}
if (rootViewSibling) {
nsIFrame *frame = rootViewSibling->GetFrame();
sibling = frame ? frame->PresContext()->PresShell()->GetDocument() : nullptr;
}

// Transfer ownership to mContentViewer. 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
Expand Down Expand Up @@ -7331,7 +7343,7 @@ nsDocShell::RestoreFromHistory()

// mLSHE is now our currently-loaded document.
SetHistoryEntry(&mOSHE, mLSHE);

// XXX special wyciwyg handling in Embed()?

// We aren't going to restore any items from the LayoutHistoryState,
Expand Down Expand Up @@ -7445,10 +7457,20 @@ nsDocShell::RestoreFromHistory()
nsIView *newRootView = newVM ? newVM->GetRootView() : nullptr;

// Insert the new root view at the correct location in the view tree.
if (rootViewParent) {
if (container) {
nsSubDocumentFrame* subDocFrame = do_QueryFrame(container->GetPrimaryFrame());
rootViewParent = subDocFrame ? subDocFrame->EnsureInnerView() : nullptr;
}
if (sibling &&
sibling->GetShell() &&
sibling->GetShell()->GetViewManager()) {
rootViewSibling = sibling->GetShell()->GetViewManager()->GetRootView();
} else {
rootViewSibling = nullptr;
}
if (rootViewParent && newRootView && newRootView->GetParent() != rootViewParent) {
nsIViewManager *parentVM = rootViewParent->GetViewManager();

if (parentVM && newRootView) {
if (parentVM) {
// InsertChild(parent, child, sib, true) inserts the child after
// sib in content order, which is before sib in view order. BUT
// when sib is null it inserts at the end of the the document
Expand Down

0 comments on commit addad8e

Please sign in to comment.