|
|
|
Lines 166-174
static NS_DEFINE_CID(kDOMScriptObjectFac
|
Link Here
|
|---|
|
| 166 |
|
166 |
|
| 167 |
#if defined(DEBUG_bryner) |
167 |
#if defined(DEBUG_bryner) |
| 168 |
//#define DEBUG_DOCSHELL_FOCUS |
168 |
//#define DEBUG_DOCSHELL_FOCUS |
|
|
169 |
#define DEBUG_PAGE_CACHE |
| 169 |
#endif |
170 |
#endif |
| 170 |
|
171 |
|
| 171 |
#include "plevent.h" |
172 |
#include "plevent.h" |
|
|
173 |
#include "nsGUIEvent.h" |
| 174 |
#include "nsIPrivateDOMEvent.h" |
| 175 |
#include "nsIDOMEventReceiver.h" |
| 176 |
#include "nsIEventListenerManager.h" |
| 172 |
|
177 |
|
| 173 |
// Number of documents currently loading |
178 |
// Number of documents currently loading |
| 174 |
static PRInt32 gNumberOfDocumentsLoading = 0; |
179 |
static PRInt32 gNumberOfDocumentsLoading = 0; |
|
Lines 1355-1366
nsDocShell::SetCurrentURI(nsIURI *aURI,
|
Link Here
|
|---|
|
| 1355 |
isRoot = PR_TRUE; |
1360 |
isRoot = PR_TRUE; |
| 1356 |
} |
1361 |
} |
| 1357 |
if (mLSHE) { |
1362 |
if (mLSHE) { |
| 1358 |
nsCOMPtr<nsIHistoryEntry> historyEntry(do_QueryInterface(mLSHE)); |
1363 |
mLSHE->GetIsSubFrame(&isSubFrame); |
| 1359 |
|
|
|
| 1360 |
// Check if this is a subframe navigation |
| 1361 |
if (historyEntry) { |
| 1362 |
historyEntry->GetIsSubFrame(&isSubFrame); |
| 1363 |
} |
| 1364 |
} |
1364 |
} |
| 1365 |
|
1365 |
|
| 1366 |
if (!isSubFrame && !isRoot) { |
1366 |
if (!isSubFrame && !isRoot) { |
|
Lines 3261-3272
nsDocShell::LoadPage(nsISupports *aPageD
|
Link Here
|
|---|
|
| 3261 |
// load the page as view-source |
3261 |
// load the page as view-source |
| 3262 |
// |
3262 |
// |
| 3263 |
if (nsIWebPageDescriptor::DISPLAY_AS_SOURCE == aDisplayType) { |
3263 |
if (nsIWebPageDescriptor::DISPLAY_AS_SOURCE == aDisplayType) { |
| 3264 |
nsCOMPtr<nsIHistoryEntry> srcHE(do_QueryInterface(shEntry)); |
|
|
| 3265 |
nsCOMPtr<nsIURI> oldUri, newUri; |
3264 |
nsCOMPtr<nsIURI> oldUri, newUri; |
| 3266 |
nsCString spec, newSpec; |
3265 |
nsCString spec, newSpec; |
| 3267 |
|
3266 |
|
| 3268 |
// Create a new view-source URI and replace the original. |
3267 |
// Create a new view-source URI and replace the original. |
| 3269 |
rv = srcHE->GetURI(getter_AddRefs(oldUri)); |
3268 |
rv = shEntry->GetURI(getter_AddRefs(oldUri)); |
| 3270 |
if (NS_FAILED(rv)) |
3269 |
if (NS_FAILED(rv)) |
| 3271 |
return rv; |
3270 |
return rv; |
| 3272 |
|
3271 |
|
|
Lines 3720-3726
nsDocShell::SetTitle(const PRUnichar * a
|
Link Here
|
|---|
|
| 3720 |
// would suffice. |
3719 |
// would suffice. |
| 3721 |
if (mOSHE && (mLoadType != LOAD_BYPASS_HISTORY) && |
3720 |
if (mOSHE && (mLoadType != LOAD_BYPASS_HISTORY) && |
| 3722 |
(mLoadType != LOAD_HISTORY) && (mLoadType != LOAD_ERROR_PAGE)) { |
3721 |
(mLoadType != LOAD_HISTORY) && (mLoadType != LOAD_ERROR_PAGE)) { |
| 3723 |
mOSHE->SetTitle(mTitle.get()); |
3722 |
mOSHE->SetTitle(mTitle); |
| 3724 |
} |
3723 |
} |
| 3725 |
|
3724 |
|
| 3726 |
|
3725 |
|
|
Lines 4701-4706
nsDocShell::CreateAboutBlankContentViewe
|
Link Here
|
|---|
|
| 4701 |
return rv; |
4700 |
return rv; |
| 4702 |
} |
4701 |
} |
| 4703 |
|
4702 |
|
|
|
4703 |
PRBool |
| 4704 |
nsDocShell::CanSavePresentation() |
| 4705 |
{ |
| 4706 |
// If the document is not done loading, don't cache it. |
| 4707 |
nsCOMPtr<nsPIDOMWindow> pWin = do_QueryInterface(mScriptGlobal); |
| 4708 |
if (pWin && pWin->IsLoading()) |
| 4709 |
return PR_FALSE; |
| 4710 |
|
| 4711 |
// Only save presentation for "normal" loads and link loads. Anything else |
| 4712 |
// probably wants to refetch the page, so caching the old presentation |
| 4713 |
// would be incorrect. |
| 4714 |
if (mLoadType != LOAD_NORMAL && |
| 4715 |
mLoadType != LOAD_HISTORY && |
| 4716 |
mLoadType != LOAD_LINK) |
| 4717 |
return PR_FALSE; |
| 4718 |
|
| 4719 |
// If there is an unload or beforeunload listener on the window, then we do |
| 4720 |
// not save the presentation into the session history cache. |
| 4721 |
nsCOMPtr<nsIDOMEventReceiver> er = do_QueryInterface(mScriptGlobal); |
| 4722 |
if (er) { |
| 4723 |
nsCOMPtr<nsIEventListenerManager> eventManager; |
| 4724 |
er->GetListenerManager(getter_AddRefs(eventManager)); |
| 4725 |
|
| 4726 |
if (eventManager && eventManager->HasUnloadListeners()) |
| 4727 |
return PR_FALSE; |
| 4728 |
} |
| 4729 |
|
| 4730 |
// If the session history entry has the saveLayoutState flag set to false, |
| 4731 |
// then we should not cache the presentation. |
| 4732 |
|
| 4733 |
if (!mOSHE) |
| 4734 |
return PR_FALSE; // no entry to save into |
| 4735 |
|
| 4736 |
PRBool canSaveState; |
| 4737 |
mOSHE->GetSaveLayoutStateFlag(&canSaveState); |
| 4738 |
return canSaveState; |
| 4739 |
} |
| 4740 |
|
| 4741 |
// CaptureState() is called when saving presentation into session history, |
| 4742 |
// before any teardown of the document or content viewer. |
| 4743 |
|
| 4744 |
nsresult |
| 4745 |
nsDocShell::CaptureState() |
| 4746 |
{ |
| 4747 |
nsCOMPtr<nsPIDOMWindow> privWin = do_QueryInterface(mScriptGlobal); |
| 4748 |
if (!privWin || !mOSHE) |
| 4749 |
return NS_ERROR_FAILURE; |
| 4750 |
|
| 4751 |
nsCOMPtr<nsISupports> windowState; |
| 4752 |
nsresult rv = privWin->SaveWindowState(getter_AddRefs(windowState)); |
| 4753 |
NS_ENSURE_SUCCESS(rv, rv); |
| 4754 |
|
| 4755 |
#ifdef DEBUG_PAGE_CACHE |
| 4756 |
nsCOMPtr<nsIURI> uri; |
| 4757 |
mOSHE->GetURI(getter_AddRefs(uri)); |
| 4758 |
nsCAutoString spec; |
| 4759 |
if (uri) |
| 4760 |
uri->GetSpec(spec); |
| 4761 |
printf("Saving presentation into session history\n"); |
| 4762 |
printf(" SH URI: %s\n", spec.get()); |
| 4763 |
#endif |
| 4764 |
|
| 4765 |
rv = mOSHE->SetWindowState(windowState); |
| 4766 |
NS_ENSURE_SUCCESS(rv, rv); |
| 4767 |
|
| 4768 |
nsCOMPtr<nsIPresShell> shell; |
| 4769 |
nsDocShell::GetPresShell(getter_AddRefs(shell)); |
| 4770 |
if (shell) { |
| 4771 |
nsIViewManager *vm = shell->GetViewManager(); |
| 4772 |
if (vm) { |
| 4773 |
nsIView *rootView = nsnull; |
| 4774 |
vm->GetRootView(rootView); |
| 4775 |
if (rootView) { |
| 4776 |
nsIWidget *widget = rootView->GetWidget(); |
| 4777 |
if (widget) { |
| 4778 |
nsRect bounds(0, 0, 0, 0); |
| 4779 |
widget->GetBounds(bounds); |
| 4780 |
rv = mOSHE->SetViewerBounds(bounds); |
| 4781 |
} |
| 4782 |
} |
| 4783 |
} |
| 4784 |
} |
| 4785 |
|
| 4786 |
// Capture the docshell hierarchy |
| 4787 |
PRInt32 childCount = mChildList.Count(); |
| 4788 |
nsCOMPtr<nsIDocShellTreeItem> childShell; |
| 4789 |
mOSHE->ClearChildShells(); |
| 4790 |
|
| 4791 |
for (PRInt32 i = 0; i < childCount; ++i) { |
| 4792 |
childShell = do_QueryInterface(ChildAt(i)); |
| 4793 |
NS_ASSERTION(childShell, "null child shell"); |
| 4794 |
|
| 4795 |
mOSHE->AddChildShell(childShell); |
| 4796 |
} |
| 4797 |
|
| 4798 |
return rv; |
| 4799 |
} |
| 4800 |
|
| 4801 |
nsresult |
| 4802 |
nsDocShell::RestorePresentation(nsIURI *aURI, nsISHEntry *aSHEntry) |
| 4803 |
{ |
| 4804 |
nsCOMPtr<nsIContentViewer> viewer; |
| 4805 |
aSHEntry->GetContentViewer(getter_AddRefs(viewer)); |
| 4806 |
|
| 4807 |
#ifdef DEBUG_PAGE_CACHE |
| 4808 |
nsCAutoString spec; |
| 4809 |
if (aURI) |
| 4810 |
aURI->GetSpec(spec); |
| 4811 |
#endif |
| 4812 |
|
| 4813 |
if (!viewer) { |
| 4814 |
#ifdef DEBUG_PAGE_CACHE |
| 4815 |
printf("no saved presentation for uri: %s\n", spec.get()); |
| 4816 |
#endif |
| 4817 |
return NS_ERROR_FAILURE; |
| 4818 |
} |
| 4819 |
|
| 4820 |
NS_ASSERTION(mContentViewer != viewer, "Restoring existing presentation"); |
| 4821 |
|
| 4822 |
#ifdef DEBUG_PAGE_CACHE |
| 4823 |
printf("restoring presentation from session history: %s\n", spec.get()); |
| 4824 |
#endif |
| 4825 |
|
| 4826 |
// Save off the root view's parent and sibling so that we can insert the |
| 4827 |
// new content viewer's root view at the same position. Also save the |
| 4828 |
// bounds of the root view's widget. |
| 4829 |
|
| 4830 |
nsIView *rootViewSibling = nsnull, *rootViewParent = nsnull; |
| 4831 |
nsRect newBounds(0, 0, 0, 0); |
| 4832 |
|
| 4833 |
nsCOMPtr<nsIPresShell> oldPresShell; |
| 4834 |
nsDocShell::GetPresShell(getter_AddRefs(oldPresShell)); |
| 4835 |
if (oldPresShell) { |
| 4836 |
nsIViewManager *vm = oldPresShell->GetViewManager(); |
| 4837 |
if (vm) { |
| 4838 |
nsIView *oldRootView = nsnull; |
| 4839 |
vm->GetRootView(oldRootView); |
| 4840 |
|
| 4841 |
if (oldRootView) { |
| 4842 |
rootViewSibling = oldRootView->GetNextSibling(); |
| 4843 |
rootViewParent = oldRootView->GetParent(); |
| 4844 |
|
| 4845 |
nsIWidget *widget = oldRootView->GetWidget(); |
| 4846 |
if (widget) { |
| 4847 |
widget->GetBounds(newBounds); |
| 4848 |
} |
| 4849 |
} |
| 4850 |
} |
| 4851 |
} |
| 4852 |
|
| 4853 |
// Transfer ownership to mContentViewer. By ensuring that either the |
| 4854 |
// docshell or the session history, but not both, have references to the |
| 4855 |
// content viewer, we prevent the viewer from being torn down after |
| 4856 |
// Destroy() is called. |
| 4857 |
|
| 4858 |
PRBool savePresentation = CanSavePresentation(); |
| 4859 |
if (!savePresentation) |
| 4860 |
FireUnloadNotification(); |
| 4861 |
|
| 4862 |
mFiredUnloadEvent = PR_FALSE; |
| 4863 |
|
| 4864 |
if (mContentViewer) { |
| 4865 |
mContentViewer->Close(); |
| 4866 |
|
| 4867 |
if (savePresentation) |
| 4868 |
mContentViewer->SetHistoryEntry(mOSHE); |
| 4869 |
|
| 4870 |
mContentViewer->Destroy(); |
| 4871 |
} |
| 4872 |
|
| 4873 |
mContentViewer.swap(viewer); |
| 4874 |
viewer = nsnull; // force a release to complete ownership transfer |
| 4875 |
|
| 4876 |
// Pulling the viewer out of the CachedPresentation will thaw() it. |
| 4877 |
// We must first open it to prevent pending destruction. |
| 4878 |
nsresult rv = mContentViewer->Open(); |
| 4879 |
NS_ENSURE_SUCCESS(rv, rv); |
| 4880 |
|
| 4881 |
// Now remove it from the cached presentation. |
| 4882 |
aSHEntry->SetContentViewer(nsnull); |
| 4883 |
|
| 4884 |
// Restore our child docshell hierarchy. |
| 4885 |
PRInt32 i = 0; |
| 4886 |
nsCOMPtr<nsIDocShellTreeItem> childShell; |
| 4887 |
|
| 4888 |
DestroyChildren(); |
| 4889 |
while (NS_SUCCEEDED(aSHEntry->ChildShellAt(i++, |
| 4890 |
getter_AddRefs(childShell))) && |
| 4891 |
childShell) { |
| 4892 |
AddChild(childShell); |
| 4893 |
} |
| 4894 |
|
| 4895 |
// And release the references in the history entry. |
| 4896 |
aSHEntry->ClearChildShells(); |
| 4897 |
|
| 4898 |
// restore the sticky state of the viewer |
| 4899 |
PRBool sticky; |
| 4900 |
aSHEntry->GetSticky(&sticky); |
| 4901 |
mContentViewer->SetSticky(sticky); |
| 4902 |
|
| 4903 |
// save the previous content viewer size |
| 4904 |
nsRect oldBounds(0, 0, 0, 0); |
| 4905 |
aSHEntry->GetViewerBounds(oldBounds); |
| 4906 |
|
| 4907 |
// Insert the new root view at the correct location in the view tree. |
| 4908 |
if (rootViewParent) { |
| 4909 |
nsIViewManager *parentVM = rootViewParent->GetViewManager(); |
| 4910 |
|
| 4911 |
nsCOMPtr<nsIPresShell> shell; |
| 4912 |
nsDocShell::GetPresShell(getter_AddRefs(shell)); |
| 4913 |
|
| 4914 |
if (parentVM && shell) { |
| 4915 |
nsIViewManager *newVM = shell->GetViewManager(); |
| 4916 |
if (newVM) { |
| 4917 |
nsIView *newRootView = nsnull; |
| 4918 |
newVM->GetRootView(newRootView); |
| 4919 |
if (newRootView) { |
| 4920 |
parentVM->InsertChild(rootViewParent, newRootView, |
| 4921 |
rootViewSibling, PR_TRUE); |
| 4922 |
|
| 4923 |
NS_ASSERTION(newRootView->GetNextSibling() == |
| 4924 |
rootViewSibling, |
| 4925 |
"error in InsertChild"); |
| 4926 |
|
| 4927 |
if (oldPresShell) |
| 4928 |
oldPresShell->InvalidateViewManagers(); |
| 4929 |
} |
| 4930 |
} |
| 4931 |
} |
| 4932 |
} |
| 4933 |
|
| 4934 |
// restore the state of the window object |
| 4935 |
nsCOMPtr<nsPIDOMWindow> privWin = |
| 4936 |
do_GetInterface(NS_STATIC_CAST(nsIInterfaceRequestor*, this)); |
| 4937 |
NS_ASSERTION(privWin, "could not get nsPIDOMWindow interface"); |
| 4938 |
|
| 4939 |
nsCOMPtr<nsISupports> windowState; |
| 4940 |
aSHEntry->GetWindowState(getter_AddRefs(windowState)); |
| 4941 |
|
| 4942 |
rv = privWin->RestoreWindowState(windowState); |
| 4943 |
NS_ENSURE_SUCCESS(rv, rv); |
| 4944 |
|
| 4945 |
aSHEntry->SetWindowState(nsnull); |
| 4946 |
|
| 4947 |
mOSHE = aSHEntry; |
| 4948 |
EndPageLoad(nsnull, nsnull, NS_OK); |
| 4949 |
|
| 4950 |
nsCOMPtr<nsISHistory> rootSH; |
| 4951 |
GetRootSessionHistory(getter_AddRefs(rootSH)); |
| 4952 |
if (rootSH && (mLoadType & LOAD_CMD_HISTORY)) { |
| 4953 |
nsCOMPtr<nsISHistoryInternal> hist = do_QueryInterface(rootSH); |
| 4954 |
hist->UpdateIndex(); |
| 4955 |
} |
| 4956 |
|
| 4957 |
// Make sure this presentation is the same size as the previous |
| 4958 |
// presentation. If this is not the same size we showed it at last time, |
| 4959 |
// then we need to resize the widget. |
| 4960 |
|
| 4961 |
// XXXbryner This interacts poorly with Firefox's infobar. If the old |
| 4962 |
// presentation had the infobar visible, then we will resize the new |
| 4963 |
// presentation to that smaller size. However, firing the locationchanged |
| 4964 |
// event will hide the infobar, which will immediately resize the window |
| 4965 |
// back to the larger size. A future optimization might be to restore |
| 4966 |
// the presentation at the "wrong" size, then fire the locationchanged |
| 4967 |
// event and check whether the docshell's new size is the same as the |
| 4968 |
// cached viewer size (skipping the resize if they are equal). |
| 4969 |
|
| 4970 |
nsCOMPtr<nsIPresShell> shell; |
| 4971 |
nsDocShell::GetPresShell(getter_AddRefs(shell)); |
| 4972 |
|
| 4973 |
if (shell) { |
| 4974 |
nsIViewManager *vm = shell->GetViewManager(); |
| 4975 |
if (vm) { |
| 4976 |
nsIView *rootView = nsnull; |
| 4977 |
vm->GetRootView(rootView); |
| 4978 |
|
| 4979 |
if (rootView) { |
| 4980 |
nsIWidget *widget = rootView->GetWidget(); |
| 4981 |
if (widget && !newBounds.IsEmpty()) { |
| 4982 |
#ifdef DEBUG_PAGE_CACHE |
| 4983 |
printf("resize widget(%d, %d, %d, %d)\n", newBounds.x, |
| 4984 |
newBounds.y, newBounds.width, newBounds.height); |
| 4985 |
#endif |
| 4986 |
|
| 4987 |
widget->Resize(newBounds.x, newBounds.y, newBounds.width, |
| 4988 |
newBounds.height, PR_FALSE); |
| 4989 |
} |
| 4990 |
} |
| 4991 |
} |
| 4992 |
} |
| 4993 |
|
| 4994 |
SetCurrentURI(aURI); |
| 4995 |
|
| 4996 |
// Dispatch events. This is a little messy. We need to avoid firing |
| 4997 |
// onload so that it is visible from the content DOM window, but we _do_ |
| 4998 |
// want the chrome to see it for chrome/extensions that look for page load. |
| 4999 |
// In addition, we need to fire DOMPageRestore on the content window. |
| 5000 |
|
| 5001 |
nsEvent event(NS_PAGE_LOAD); |
| 5002 |
nsEventStatus status = nsEventStatus_eIgnore; |
| 5003 |
|
| 5004 |
nsCOMPtr<nsIChromeEventHandler> handler = privWin->GetChromeEventHandler(); |
| 5005 |
|
| 5006 |
nsCOMPtr<nsPresContext> presContext; |
| 5007 |
GetPresContext(getter_AddRefs(presContext)); |
| 5008 |
|
| 5009 |
PRUint32 flags = NS_EVENT_FLAG_INIT; |
| 5010 |
event.flags |= flags; |
| 5011 |
flags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL); |
| 5012 |
flags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE; |
| 5013 |
|
| 5014 |
nsIDOMEvent *domEvt = nsnull; |
| 5015 |
|
| 5016 |
rv = handler->HandleChromeEvent(presContext, &event, &domEvt, |
| 5017 |
flags & NS_EVENT_CAPTURE_MASK, &status); |
| 5018 |
NS_ENSURE_SUCCESS(rv, rv); |
| 5019 |
|
| 5020 |
if (domEvt) { |
| 5021 |
nsrefcnt rc; |
| 5022 |
NS_RELEASE2(domEvt, rc); |
| 5023 |
if (0 != rc) { |
| 5024 |
// Okay, so someone in the DOM loop (a listener, JS object) |
| 5025 |
// still has a ref to the DOM Event but the internal data |
| 5026 |
// hasn't been malloc'd. Force a copy of the data here so the |
| 5027 |
// DOM Event is still valid. |
| 5028 |
|
| 5029 |
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = |
| 5030 |
do_QueryInterface(domEvt); |
| 5031 |
|
| 5032 |
if (privateEvent) { |
| 5033 |
privateEvent->DuplicatePrivateData(); |
| 5034 |
} |
| 5035 |
} |
| 5036 |
} |
| 5037 |
|
| 5038 |
if (mScriptGlobal) { |
| 5039 |
nsEventStatus status = nsEventStatus_eIgnore; |
| 5040 |
nsEvent restoreEvent(NS_PAGE_RESTORE); |
| 5041 |
|
| 5042 |
nsCOMPtr<nsPresContext> presContext; |
| 5043 |
nsDocShell::GetPresContext(getter_AddRefs(presContext)); |
| 5044 |
|
| 5045 |
if (presContext) { |
| 5046 |
mScriptGlobal->HandleDOMEvent(presContext, &restoreEvent, nsnull, |
| 5047 |
NS_EVENT_FLAG_INIT, &status); |
| 5048 |
} |
| 5049 |
} |
| 5050 |
|
| 5051 |
rv = mContentViewer->Show(); |
| 5052 |
NS_ENSURE_SUCCESS(rv, rv); |
| 5053 |
|
| 5054 |
// Restart plugins |
| 5055 |
if (shell) |
| 5056 |
shell->StartPlugins(); |
| 5057 |
|
| 5058 |
// XXXbryner Making this invalidate synchronous causes unpainted areas |
| 5059 |
// (on Mac, at least) if the above locationchanged event hides Firefox's |
| 5060 |
// infobar. Doing it asynchronously seems to work around the problem, but |
| 5061 |
// shouldn't the style change that hides the infobar handle all necessary |
| 5062 |
// invalidation, including the newly-exposed area? |
| 5063 |
|
| 5064 |
return mParentWidget->Invalidate(PR_FALSE); |
| 5065 |
} |
| 5066 |
|
| 4704 |
NS_IMETHODIMP |
5067 |
NS_IMETHODIMP |
| 4705 |
nsDocShell::CreateContentViewer(const char *aContentType, |
5068 |
nsDocShell::CreateContentViewer(const char *aContentType, |
| 4706 |
nsIRequest * request, |
5069 |
nsIRequest * request, |
|
Lines 4727-4733
nsDocShell::CreateContentViewer(const ch
|
Link Here
|
|---|
|
| 4727 |
// is changed within the DocShell - otherwise, javascript will get the |
5090 |
// is changed within the DocShell - otherwise, javascript will get the |
| 4728 |
// wrong information :-( |
5091 |
// wrong information :-( |
| 4729 |
// |
5092 |
// |
| 4730 |
(void) FireUnloadNotification(); |
5093 |
|
|
|
5094 |
PRBool savePresentation = CanSavePresentation(); |
| 5095 |
if (!savePresentation) |
| 5096 |
FireUnloadNotification(); |
| 4731 |
|
5097 |
|
| 4732 |
// Set mFiredUnloadEvent = PR_FALSE so that the unload handler for the |
5098 |
// Set mFiredUnloadEvent = PR_FALSE so that the unload handler for the |
| 4733 |
// *new* document will fire. |
5099 |
// *new* document will fire. |
|
Lines 4742-4747
nsDocShell::CreateContentViewer(const ch
|
Link Here
|
|---|
|
| 4742 |
|
5108 |
|
| 4743 |
PRBool onLocationChangeNeeded = OnLoadingSite(aOpenedChannel, PR_FALSE); |
5109 |
PRBool onLocationChangeNeeded = OnLoadingSite(aOpenedChannel, PR_FALSE); |
| 4744 |
|
5110 |
|
|
|
5111 |
if (savePresentation) { |
| 5112 |
// The old content viewer will be saved during the call to Embed(). |
| 5113 |
rv = CaptureState(); |
| 5114 |
// XXX this isn't really fatal, necessarily... |
| 5115 |
// should we try to fire unload if NS_FAILED(rv) ? |
| 5116 |
} |
| 5117 |
|
| 4745 |
// let's try resetting the load group if we need to... |
5118 |
// let's try resetting the load group if we need to... |
| 4746 |
nsCOMPtr<nsILoadGroup> currentLoadGroup; |
5119 |
nsCOMPtr<nsILoadGroup> currentLoadGroup; |
| 4747 |
NS_ENSURE_SUCCESS(aOpenedChannel-> |
5120 |
NS_ENSURE_SUCCESS(aOpenedChannel-> |
|
Lines 5005-5010
nsDocShell::SetupNewViewer(nsIContentVie
|
Link Here
|
|---|
|
| 5005 |
|
5378 |
|
| 5006 |
// Ensure that the content viewer is destroyed *after* the GC - bug 71515 |
5379 |
// Ensure that the content viewer is destroyed *after* the GC - bug 71515 |
| 5007 |
nsCOMPtr<nsIContentViewer> kungfuDeathGrip = mContentViewer; |
5380 |
nsCOMPtr<nsIContentViewer> kungfuDeathGrip = mContentViewer; |
|
|
5381 |
nsCOMPtr<nsIDOMDocument> oldDocument; |
| 5008 |
if (mContentViewer) { |
5382 |
if (mContentViewer) { |
| 5009 |
// Stop any activity that may be happening in the old document before |
5383 |
// Stop any activity that may be happening in the old document before |
| 5010 |
// releasing it... |
5384 |
// releasing it... |
|
Lines 5030-5037
nsDocShell::SetupNewViewer(nsIContentVie
|
Link Here
|
|---|
|
| 5030 |
} |
5404 |
} |
| 5031 |
} |
5405 |
} |
| 5032 |
|
5406 |
|
|
|
5407 |
mContentViewer->GetDOMDocument(getter_AddRefs(oldDocument)); |
| 5408 |
|
| 5033 |
mContentViewer->Close(); |
5409 |
mContentViewer->Close(); |
| 5034 |
aNewViewer->SetPreviousViewer(mContentViewer); |
5410 |
aNewViewer->SetPreviousViewer(mContentViewer); |
|
|
5411 |
|
| 5412 |
if (CanSavePresentation()) { |
| 5413 |
// Tell the old content viewer to hibernate in session history when |
| 5414 |
// it is destroyed. |
| 5415 |
mContentViewer->SetHistoryEntry(mOSHE); |
| 5416 |
} |
| 5417 |
|
| 5035 |
mContentViewer = nsnull; |
5418 |
mContentViewer = nsnull; |
| 5036 |
} |
5419 |
} |
| 5037 |
|
5420 |
|
|
Lines 5572-5578
nsDocShell::InternalLoad(nsIURI * aURI,
|
Link Here
|
|---|
|
| 5572 |
NS_ENSURE_TRUE(hEntry, NS_ERROR_FAILURE); |
5955 |
NS_ENSURE_TRUE(hEntry, NS_ERROR_FAILURE); |
| 5573 |
nsCOMPtr<nsISHEntry> shEntry(do_QueryInterface(hEntry)); |
5956 |
nsCOMPtr<nsISHEntry> shEntry(do_QueryInterface(hEntry)); |
| 5574 |
if (shEntry) |
5957 |
if (shEntry) |
| 5575 |
shEntry->SetTitle(mTitle.get()); |
5958 |
shEntry->SetTitle(mTitle); |
| 5576 |
} |
5959 |
} |
| 5577 |
|
5960 |
|
| 5578 |
return NS_OK; |
5961 |
return NS_OK; |
|
Lines 5627-5632
nsDocShell::InternalLoad(nsIURI * aURI,
|
Link Here
|
|---|
|
| 5627 |
// been called. |
6010 |
// been called. |
| 5628 |
mLSHE = aSHEntry; |
6011 |
mLSHE = aSHEntry; |
| 5629 |
|
6012 |
|
|
|
6013 |
// If we have a saved content viewer in history, restore and show it now. |
| 6014 |
if (aSHEntry) { |
| 6015 |
if (!CanSavePresentation()) |
| 6016 |
FireUnloadNotification(); |
| 6017 |
|
| 6018 |
mFiredUnloadEvent = PR_FALSE; |
| 6019 |
|
| 6020 |
CaptureState(); |
| 6021 |
|
| 6022 |
rv = RestorePresentation(aURI, aSHEntry); |
| 6023 |
if (NS_SUCCEEDED(rv)) |
| 6024 |
return rv; |
| 6025 |
} |
| 6026 |
|
| 5630 |
nsCOMPtr<nsIRequest> req; |
6027 |
nsCOMPtr<nsIRequest> req; |
| 5631 |
rv = DoURILoad(aURI, aReferrer, |
6028 |
rv = DoURILoad(aURI, aReferrer, |
| 5632 |
!(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER), |
6029 |
!(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER), |
|
Lines 6524-6535
nsDocShell::AddToSessionHistory(nsIURI *
|
Link Here
|
|---|
|
| 6524 |
} |
6921 |
} |
| 6525 |
|
6922 |
|
| 6526 |
//Title is set in nsDocShell::SetTitle() |
6923 |
//Title is set in nsDocShell::SetTitle() |
| 6527 |
entry->Create(aURI, // uri |
6924 |
entry->Create(aURI, // uri |
| 6528 |
nsnull, // Title |
6925 |
EmptyString(), // Title |
| 6529 |
nsnull, // DOMDocument |
6926 |
inputStream, // Post data stream |
| 6530 |
inputStream, // Post data stream |
6927 |
nsnull, // LayoutHistory state |
| 6531 |
nsnull, // LayoutHistory state |
6928 |
cacheKey, // CacheKey |
| 6532 |
cacheKey, // CacheKey |
|
|
| 6533 |
mContentTypeHint); // Content-type |
6929 |
mContentTypeHint); // Content-type |
| 6534 |
entry->SetReferrerURI(referrerURI); |
6930 |
entry->SetReferrerURI(referrerURI); |
| 6535 |
/* If cache got a 'no-store', ask SH not to store |
6931 |
/* If cache got a 'no-store', ask SH not to store |
|
Lines 6560-6566
nsDocShell::AddToSessionHistory(nsIURI *
|
Link Here
|
|---|
|
| 6560 |
if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY)) { |
6956 |
if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY)) { |
| 6561 |
// Replace current entry in session history. |
6957 |
// Replace current entry in session history. |
| 6562 |
PRInt32 index = 0; |
6958 |
PRInt32 index = 0; |
| 6563 |
nsCOMPtr<nsIHistoryEntry> hEntry; |
|
|
| 6564 |
mSessionHistory->GetIndex(&index); |
6959 |
mSessionHistory->GetIndex(&index); |
| 6565 |
nsCOMPtr<nsISHistoryInternal> shPrivate(do_QueryInterface(mSessionHistory)); |
6960 |
nsCOMPtr<nsISHistoryInternal> shPrivate(do_QueryInterface(mSessionHistory)); |
| 6566 |
// Replace the current entry with the new entry |
6961 |
// Replace the current entry with the new entry |
|
Lines 6605-6614
nsDocShell::LoadHistoryEntry(nsISHEntry
|
Link Here
|
|---|
|
| 6605 |
nsCAutoString contentType; |
7000 |
nsCAutoString contentType; |
| 6606 |
|
7001 |
|
| 6607 |
NS_ENSURE_TRUE(aEntry, NS_ERROR_FAILURE); |
7002 |
NS_ENSURE_TRUE(aEntry, NS_ERROR_FAILURE); |
| 6608 |
nsCOMPtr<nsIHistoryEntry> hEntry(do_QueryInterface(aEntry)); |
|
|
| 6609 |
NS_ENSURE_TRUE(hEntry, NS_ERROR_FAILURE); |
| 6610 |
|
7003 |
|
| 6611 |
NS_ENSURE_SUCCESS(hEntry->GetURI(getter_AddRefs(uri)), NS_ERROR_FAILURE); |
7004 |
NS_ENSURE_SUCCESS(aEntry->GetURI(getter_AddRefs(uri)), NS_ERROR_FAILURE); |
| 6612 |
NS_ENSURE_SUCCESS(aEntry->GetReferrerURI(getter_AddRefs(referrerURI)), |
7005 |
NS_ENSURE_SUCCESS(aEntry->GetReferrerURI(getter_AddRefs(referrerURI)), |
| 6613 |
NS_ERROR_FAILURE); |
7006 |
NS_ERROR_FAILURE); |
| 6614 |
NS_ENSURE_SUCCESS(aEntry->GetPostData(getter_AddRefs(postData)), |
7007 |
NS_ENSURE_SUCCESS(aEntry->GetPostData(getter_AddRefs(postData)), |
|
Lines 6703-6711
nsDocShell::CloneAndReplace(nsISHEntry *
|
Link Here
|
|---|
|
| 6703 |
nsISHEntry *dest = (nsISHEntry *) nsnull; |
7096 |
nsISHEntry *dest = (nsISHEntry *) nsnull; |
| 6704 |
PRUint32 srcID; |
7097 |
PRUint32 srcID; |
| 6705 |
src->GetID(&srcID); |
7098 |
src->GetID(&srcID); |
| 6706 |
nsCOMPtr<nsIHistoryEntry> srcHE(do_QueryInterface(src)); |
|
|
| 6707 |
|
7099 |
|
| 6708 |
if (!src || !replaceEntry || !srcHE) |
7100 |
if (!src || !replaceEntry) |
| 6709 |
return NS_ERROR_FAILURE; |
7101 |
return NS_ERROR_FAILURE; |
| 6710 |
|
7102 |
|
| 6711 |
if (srcID == aCloneID) { |
7103 |
if (srcID == aCloneID) { |