From 4c052abfbd8e075ae7a150b34c96787518043604 Mon Sep 17 00:00:00 2001 From: "nisheeth%netscape.com" Date: Mon, 30 Aug 1999 22:45:46 +0000 Subject: [PATCH] Added a GetHistoryState method to be use by session history to ask layout for the current document's state. git-svn-id: svn://10.0.0.236/trunk@45215 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 28 ++++++++++++++++++++++++++- mozilla/webshell/public/nsIWebShell.h | 5 +++++ mozilla/webshell/src/nsWebShell.cpp | 28 ++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 6c1ed1c6b69..a1bfbeed9ac 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -232,7 +232,7 @@ public: // Document load api's NS_IMETHOD GetDocumentLoader(nsIDocumentLoader*& aResult); NS_IMETHOD LoadURL(const PRUnichar *aURLSpec, - nsIInputStream* aPostDataStream=nsnull, + nsIInputStream* aPostDataStream=nsnull, PRBool aModifyHistory=PR_TRUE, #ifdef NECKO nsLoadFlags aType = nsIChannel::LOAD_NORMAL, @@ -289,6 +289,7 @@ public: nsIDOMWindow* aWindow, nsIDOMWindow** outPopup); NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult); NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken); + NS_IMETHOD GetHistoryState(nsISupports** aLayoutHistoryState); // nsIWebShellServices NS_IMETHOD LoadDocument(const char* aURL, @@ -2818,6 +2819,31 @@ nsWebShell::FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken) return NS_OK; } +NS_IMETHODIMP +nsWebShell::GetHistoryState(nsISupports** aLayoutHistoryState) +{ + nsresult rv = NS_OK; + // XXX Need to think about what to do for framesets. + // For now, return an error if this webshell + // contains a frame or a frameset document. + if (mParent || mChildren.Count() > 0) { + return NS_ERROR_NOT_IMPLEMENTED; + } + + // Ask the pres shell for the history state + if (mContentViewer) { + nsCOMPtr docv = do_QueryInterface(mContentViewer); + if (nsnull != docv) { + nsCOMPtr shell; + rv = docv->GetPresShell(*getter_AddRefs(shell)); + if (NS_SUCCEEDED(rv)) { + rv = shell->GetHistoryState((nsILayoutHistoryState**) aLayoutHistoryState); + } + } + } + + return rv; +} //---------------------------------------------------------------------- // Web Shell Services API diff --git a/mozilla/webshell/public/nsIWebShell.h b/mozilla/webshell/public/nsIWebShell.h index aba7e83ea72..ea53d973c16 100644 --- a/mozilla/webshell/public/nsIWebShell.h +++ b/mozilla/webshell/public/nsIWebShell.h @@ -461,6 +461,11 @@ public: NS_IMETHOD SetUrlDispatcher(nsIUrlDispatcher * anObserver) = 0; NS_IMETHOD GetUrlDispatcher(nsIUrlDispatcher *& aResult)=0; + /** + * Get the history state for the document. + */ + NS_IMETHOD GetHistoryState(nsISupports** aLayoutHistoryState) = 0; + }; extern "C" NS_WEB nsresult diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 6c1ed1c6b69..a1bfbeed9ac 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -232,7 +232,7 @@ public: // Document load api's NS_IMETHOD GetDocumentLoader(nsIDocumentLoader*& aResult); NS_IMETHOD LoadURL(const PRUnichar *aURLSpec, - nsIInputStream* aPostDataStream=nsnull, + nsIInputStream* aPostDataStream=nsnull, PRBool aModifyHistory=PR_TRUE, #ifdef NECKO nsLoadFlags aType = nsIChannel::LOAD_NORMAL, @@ -289,6 +289,7 @@ public: nsIDOMWindow* aWindow, nsIDOMWindow** outPopup); NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult); NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken); + NS_IMETHOD GetHistoryState(nsISupports** aLayoutHistoryState); // nsIWebShellServices NS_IMETHOD LoadDocument(const char* aURL, @@ -2818,6 +2819,31 @@ nsWebShell::FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken) return NS_OK; } +NS_IMETHODIMP +nsWebShell::GetHistoryState(nsISupports** aLayoutHistoryState) +{ + nsresult rv = NS_OK; + // XXX Need to think about what to do for framesets. + // For now, return an error if this webshell + // contains a frame or a frameset document. + if (mParent || mChildren.Count() > 0) { + return NS_ERROR_NOT_IMPLEMENTED; + } + + // Ask the pres shell for the history state + if (mContentViewer) { + nsCOMPtr docv = do_QueryInterface(mContentViewer); + if (nsnull != docv) { + nsCOMPtr shell; + rv = docv->GetPresShell(*getter_AddRefs(shell)); + if (NS_SUCCEEDED(rv)) { + rv = shell->GetHistoryState((nsILayoutHistoryState**) aLayoutHistoryState); + } + } + } + + return rv; +} //---------------------------------------------------------------------- // Web Shell Services API