From f55cd93707eb8e877771800958bbe9acf0eb6e1b Mon Sep 17 00:00:00 2001 From: "ftang%netscape.com" Date: Wed, 19 May 1999 00:23:03 +0000 Subject: [PATCH] add method to push necessary informaiton to implement Meta charset observeration git-svn-id: svn://10.0.0.236/trunk@32186 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 43 ++++++++++++++++++- mozilla/webshell/public/nsIWebShell.h | 6 +++ mozilla/webshell/public/nsIWebShellServices.h | 6 ++- mozilla/webshell/src/nsWebShell.cpp | 43 ++++++++++++++++++- 4 files changed, 92 insertions(+), 6 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 9966aa260d0..113d4d47e72 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -251,8 +251,10 @@ public: // nsIWebShellServices NS_IMETHOD LoadDocument(const char* aURL, - const char* aCharset, - nsCharsetSource aSource); + const char* aCharset= nsnull , + nsCharsetSource aSource = kCharsetUninitialized); + NS_IMETHOD ReloadDocument(const char* aCharset= nsnull , + nsCharsetSource aSource = kCharsetUninitialized); NS_IMETHOD StopDocumentLoad(void); NS_IMETHOD SetRendering(PRBool aRender); @@ -358,6 +360,8 @@ public: NS_IMETHOD GetDefaultCharacterSet (const PRUnichar** aDefaultCharacterSet); NS_IMETHOD SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet); + NS_IMETHOD GetCharacterSetHint (const PRUnichar** oHintCharset, nsCharsetSource* oSource); + protected: void InitFrameData(PRBool aCompleteInitScrolling); nsresult CheckForTrailingSlash(nsIURL* aURL); @@ -413,6 +417,10 @@ protected: static nsIPluginManager *mPluginManager; static PRUint32 mPluginInitCnt; PRBool mProcessedEndDocumentLoad; + + // XXX store mHintCharset and mHintCharsetSource here untill we find out a good cood path + nsString mHintCharset; + nsCharsetSource mHintCharsetSource; }; //---------------------------------------------------------------------- @@ -527,6 +535,8 @@ nsWebShell::nsWebShell() // XXX we should get such mDefaultCharacterSet from pref laster... mDefaultCharacterSet = "ISO-8859-1"; mProcessedEndDocumentLoad = PR_FALSE; + mHintCharset = ""; + mHintCharsetSource = kCharsetUninitialized; } nsWebShell::~nsWebShell() @@ -1981,11 +1991,26 @@ nsWebShell::LoadDocument(const char* aURL, const char* aCharset, nsCharsetSource aSource) { + // XXX hack. kee the aCharset and aSource wait to pick it up + mHintCharset = aCharset; + mHintCharsetSource = aSource; + nsAutoString url(aURL); LoadURL(url.GetUnicode()); return NS_OK; } +NS_IMETHODIMP +nsWebShell::ReloadDocument(const char* aCharset, + nsCharsetSource aSource) +{ + // XXX hack. kee the aCharset and aSource wait to pick it up + mHintCharset = aCharset; + mHintCharsetSource= aSource; + + return this->Reload(nsURLReload); +} + NS_IMETHODIMP nsWebShell::StopDocumentLoad(void) { @@ -2908,6 +2933,20 @@ nsWebShell::SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet) return NS_OK; } +NS_IMETHODIMP nsWebShell::GetCharacterSetHint (const PRUnichar** oHintCharset, nsCharsetSource* oSource) +{ + *oSource = mHintCharsetSource; + if(kCharsetUninitialized == mHintCharsetSource) { + *oHintCharset = nsnull; + } else { + *oHintCharset = mHintCharset.GetUnicode(); + // clean up after we access it. + mHintCharsetSource = kCharsetUninitialized; + } + return NS_OK; +} + + //---------------------------------------------------- NS_IMETHODIMP nsWebShell::FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound) diff --git a/mozilla/webshell/public/nsIWebShell.h b/mozilla/webshell/public/nsIWebShell.h index cb51f1c70d1..aa39bc72707 100644 --- a/mozilla/webshell/public/nsIWebShell.h +++ b/mozilla/webshell/public/nsIWebShell.h @@ -25,6 +25,8 @@ #include "nsIContentViewerContainer.h" #include "nsILoadAttribs.h" #include "nsIScrollableView.h" +#include "nsIParser.h" // for nsCharsetSource only + class nsIDOMElement; class nsIDOMWindow; @@ -379,6 +381,10 @@ public: NS_IMETHOD GetDefaultCharacterSet (const PRUnichar** aDefaultCharacterSet) = 0; NS_IMETHOD SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet) = 0; + + /* the following is the hacky access method */ + NS_IMETHOD GetCharacterSetHint (const PRUnichar** oHintCharset, nsCharsetSource* oSource) = 0; + /** * Set/Get the document scale factor */ diff --git a/mozilla/webshell/public/nsIWebShellServices.h b/mozilla/webshell/public/nsIWebShellServices.h index 925ccdbad66..13068ef17ce 100644 --- a/mozilla/webshell/public/nsIWebShellServices.h +++ b/mozilla/webshell/public/nsIWebShellServices.h @@ -36,8 +36,10 @@ public: static const nsIID& GetIID() { static nsIID iid = NS_IWEB_SHELL_SERVICES_IID; return iid; } NS_IMETHOD LoadDocument(const char* aURL, - const char* aCharset, - nsCharsetSource aSource) = 0; + const char* aCharset= nsnull , + nsCharsetSource aSource = kCharsetUninitialized) = 0; + NS_IMETHOD ReloadDocument(const char* aCharset = nsnull , + nsCharsetSource aSource = kCharsetUninitialized) = 0; NS_IMETHOD StopDocumentLoad(void) = 0; NS_IMETHOD SetRendering(PRBool aRender) = 0; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 9966aa260d0..113d4d47e72 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -251,8 +251,10 @@ public: // nsIWebShellServices NS_IMETHOD LoadDocument(const char* aURL, - const char* aCharset, - nsCharsetSource aSource); + const char* aCharset= nsnull , + nsCharsetSource aSource = kCharsetUninitialized); + NS_IMETHOD ReloadDocument(const char* aCharset= nsnull , + nsCharsetSource aSource = kCharsetUninitialized); NS_IMETHOD StopDocumentLoad(void); NS_IMETHOD SetRendering(PRBool aRender); @@ -358,6 +360,8 @@ public: NS_IMETHOD GetDefaultCharacterSet (const PRUnichar** aDefaultCharacterSet); NS_IMETHOD SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet); + NS_IMETHOD GetCharacterSetHint (const PRUnichar** oHintCharset, nsCharsetSource* oSource); + protected: void InitFrameData(PRBool aCompleteInitScrolling); nsresult CheckForTrailingSlash(nsIURL* aURL); @@ -413,6 +417,10 @@ protected: static nsIPluginManager *mPluginManager; static PRUint32 mPluginInitCnt; PRBool mProcessedEndDocumentLoad; + + // XXX store mHintCharset and mHintCharsetSource here untill we find out a good cood path + nsString mHintCharset; + nsCharsetSource mHintCharsetSource; }; //---------------------------------------------------------------------- @@ -527,6 +535,8 @@ nsWebShell::nsWebShell() // XXX we should get such mDefaultCharacterSet from pref laster... mDefaultCharacterSet = "ISO-8859-1"; mProcessedEndDocumentLoad = PR_FALSE; + mHintCharset = ""; + mHintCharsetSource = kCharsetUninitialized; } nsWebShell::~nsWebShell() @@ -1981,11 +1991,26 @@ nsWebShell::LoadDocument(const char* aURL, const char* aCharset, nsCharsetSource aSource) { + // XXX hack. kee the aCharset and aSource wait to pick it up + mHintCharset = aCharset; + mHintCharsetSource = aSource; + nsAutoString url(aURL); LoadURL(url.GetUnicode()); return NS_OK; } +NS_IMETHODIMP +nsWebShell::ReloadDocument(const char* aCharset, + nsCharsetSource aSource) +{ + // XXX hack. kee the aCharset and aSource wait to pick it up + mHintCharset = aCharset; + mHintCharsetSource= aSource; + + return this->Reload(nsURLReload); +} + NS_IMETHODIMP nsWebShell::StopDocumentLoad(void) { @@ -2908,6 +2933,20 @@ nsWebShell::SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet) return NS_OK; } +NS_IMETHODIMP nsWebShell::GetCharacterSetHint (const PRUnichar** oHintCharset, nsCharsetSource* oSource) +{ + *oSource = mHintCharsetSource; + if(kCharsetUninitialized == mHintCharsetSource) { + *oHintCharset = nsnull; + } else { + *oHintCharset = mHintCharset.GetUnicode(); + // clean up after we access it. + mHintCharsetSource = kCharsetUninitialized; + } + return NS_OK; +} + + //---------------------------------------------------- NS_IMETHODIMP nsWebShell::FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound)