зеркало из https://github.com/mozilla/pjs.git
change S/GetDocumentCharacterSet method for nsIDocument interface.
This commit is contained in:
Родитель
bd6abbf35b
Коммит
1301749405
|
@ -114,8 +114,8 @@ public:
|
|||
* Return a standard name for the document's character set. This will
|
||||
* trigger a startDocumentLoad if necessary to answer the question.
|
||||
*/
|
||||
virtual nsString* GetDocumentCharacterSet() const = 0;
|
||||
virtual void SetDocumentCharacterSet(nsString* aCharSetID) = 0;
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharSetID) = 0;
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID) = 0;
|
||||
|
||||
/**
|
||||
* Return the Line Breaker for the document
|
||||
|
|
|
@ -615,7 +615,7 @@ nsDocument::nsDocument()
|
|||
mDocumentTitle = nsnull;
|
||||
mDocumentURL = nsnull;
|
||||
mDocumentURLGroup = nsnull;
|
||||
mCharacterSet = nsnull;
|
||||
mCharacterSet = "ISO-8859-1";
|
||||
mParentDocument = nsnull;
|
||||
mRootContent = nsnull;
|
||||
mScriptObject = nsnull;
|
||||
|
@ -902,14 +902,16 @@ nsDocument::GetBaseURL(nsIURL*& aURL) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString* nsDocument::GetDocumentCharacterSet() const
|
||||
NS_IMETHODIMP nsDocument::GetDocumentCharacterSet(nsString& oCharSetID)
|
||||
{
|
||||
return mCharacterSet;
|
||||
oCharSetID = mCharacterSet;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDocument::SetDocumentCharacterSet(nsString* aCharSetID)
|
||||
NS_IMETHODIMP nsDocument::SetDocumentCharacterSet(const nsString& aCharSetID)
|
||||
{
|
||||
mCharacterSet = aCharSetID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocument::GetLineBreaker(nsILineBreaker** aResult)
|
||||
|
@ -2621,9 +2623,7 @@ void nsDocument::CreateXIF(nsString & aBuffer, nsIDOMSelection* aSelection)
|
|||
converter.AddStartTag("section");
|
||||
converter.AddStartTag("section_head");
|
||||
|
||||
nsString charset = "ISO-8859-1";
|
||||
if (mCharacterSet != nsnull)
|
||||
charset = *mCharacterSet;
|
||||
nsString charset = mCharacterSet;
|
||||
|
||||
converter.BeginStartTag("document_info");
|
||||
converter.AddAttribute(nsString("charset"),charset);
|
||||
|
|
|
@ -137,8 +137,8 @@ public:
|
|||
* Return a standard name for the document's character set. This will
|
||||
* trigger a startDocumentLoad if necessary to answer the question.
|
||||
*/
|
||||
virtual nsString* GetDocumentCharacterSet() const;
|
||||
virtual void SetDocumentCharacterSet(nsString* aCharSetID);
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharsetID);
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID);
|
||||
|
||||
/**
|
||||
* Return the Line Breaker for the document
|
||||
|
@ -401,7 +401,7 @@ protected:
|
|||
nsString* mDocumentTitle;
|
||||
nsIURL* mDocumentURL;
|
||||
nsIURLGroup* mDocumentURLGroup;
|
||||
nsString* mCharacterSet;
|
||||
nsString mCharacterSet;
|
||||
nsIDocument* mParentDocument;
|
||||
nsVoidArray mSubDocuments;
|
||||
nsVoidArray mPresShells;
|
||||
|
|
|
@ -289,7 +289,7 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
|||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink;
|
||||
|
||||
nsAutoString defaultHTMLCharset = "ISO-8859-1"; // fallback value in case webShell return error
|
||||
nsAutoString charset = "ISO-8859-1"; // fallback value in case webShell return error
|
||||
nsCharsetSource charsetSource = kCharsetFromDocTypeDefault;
|
||||
|
||||
|
||||
|
@ -299,15 +299,28 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
|||
NS_PRECONDITION(nsnull != aContainer, "No content viewer container");
|
||||
aContainer->QueryInterface(kIWebShellIID, (void**)&webShell);
|
||||
rv = NS_NewHTMLContentSink(&sink, this, aURL, webShell);
|
||||
if (NS_OK == rv) {
|
||||
const PRUnichar* defaultFromWebShell = NULL;
|
||||
rv = webShell->GetDefaultCharacterSet(&defaultFromWebShell);
|
||||
defaultHTMLCharset = defaultFromWebShell;
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
const PRUnichar* defaultCharsetFromWebShell = NULL;
|
||||
rv = webShell->GetDefaultCharacterSet(&defaultCharsetFromWebShell);
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
charset = defaultCharsetFromWebShell;
|
||||
charsetSource = kCharsetFromUserDefault;
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(webShell);
|
||||
#endif
|
||||
|
||||
// XXXX
|
||||
// We should take care two more cases here
|
||||
// 1. The charset attribute from HTTP header
|
||||
// 2. The charset parameter from the META Tag -
|
||||
// which explicit pass to nsWebShell from nsCharsetObserver
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = this->SetDocumentCharacterSet(charset);
|
||||
}
|
||||
|
||||
if (NS_OK == rv) {
|
||||
// Set the parser as the stream listener for the document loader...
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
|
@ -323,7 +336,7 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
|||
// nsIDTD* theDTD=0;
|
||||
// NS_NewNavHTMLDTD(&theDTD);
|
||||
// mParser->RegisterDTD(theDTD);
|
||||
mParser->SetDocumentCharset( defaultHTMLCharset, charsetSource);
|
||||
mParser->SetDocumentCharset( charset, charsetSource);
|
||||
mParser->SetCommand(aCommand);
|
||||
mParser->SetContentSink(sink);
|
||||
mParser->Parse(aURL);
|
||||
|
|
|
@ -399,9 +399,9 @@ public:
|
|||
|
||||
NS_IMETHOD GetBaseURL(nsIURL*& aURL) const;
|
||||
|
||||
virtual nsString* GetDocumentCharacterSet() const;
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharSetID);
|
||||
|
||||
virtual void SetDocumentCharacterSet(nsString* aCharSetID);
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID);
|
||||
|
||||
NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) ;
|
||||
NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) ;
|
||||
|
@ -687,7 +687,7 @@ protected:
|
|||
nsIDocument* mParentDocument;
|
||||
nsIScriptContextOwner* mScriptContextOwner;
|
||||
void* mScriptObject;
|
||||
nsString* mCharSetID;
|
||||
nsString mCharSetID;
|
||||
nsVoidArray mStyleSheets;
|
||||
nsIDOMSelection* mSelection;
|
||||
PRBool mDisplaySelection;
|
||||
|
@ -736,6 +736,7 @@ XULDocumentImpl::XULDocumentImpl(void)
|
|||
mXULBuilder(nsnull),
|
||||
mLocalDataSource(nsnull),
|
||||
mDocumentDataSource(nsnull),
|
||||
mCharSetID("UTF-8"),
|
||||
mLineBreaker(nsnull),
|
||||
mWordBreaker(nsnull),
|
||||
mContentViewerContainer(nsnull),
|
||||
|
@ -1190,6 +1191,8 @@ XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
|||
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->SetCommand(aCommand);
|
||||
nsAutoString utf8("UTF-8");
|
||||
parser->SetDocumentCharset(utf8, kCharsetFromDocTypeDefault);
|
||||
parser->SetContentSink(sink); // grabs a reference to the parser
|
||||
|
||||
*created_parser = parser;
|
||||
|
@ -1271,16 +1274,18 @@ XULDocumentImpl::GetBaseURL(nsIURL*& aURL) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString*
|
||||
XULDocumentImpl::GetDocumentCharacterSet() const
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetDocumentCharacterSet(nsString& oCharSetID)
|
||||
{
|
||||
return mCharSetID;
|
||||
oCharSetID = mCharSetID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
XULDocumentImpl::SetDocumentCharacterSet(nsString* aCharSetID)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::SetDocumentCharacterSet(const nsString& aCharSetID)
|
||||
{
|
||||
mCharSetID = aCharSetID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -114,8 +114,8 @@ public:
|
|||
* Return a standard name for the document's character set. This will
|
||||
* trigger a startDocumentLoad if necessary to answer the question.
|
||||
*/
|
||||
virtual nsString* GetDocumentCharacterSet() const = 0;
|
||||
virtual void SetDocumentCharacterSet(nsString* aCharSetID) = 0;
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharSetID) = 0;
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID) = 0;
|
||||
|
||||
/**
|
||||
* Return the Line Breaker for the document
|
||||
|
|
|
@ -615,7 +615,7 @@ nsDocument::nsDocument()
|
|||
mDocumentTitle = nsnull;
|
||||
mDocumentURL = nsnull;
|
||||
mDocumentURLGroup = nsnull;
|
||||
mCharacterSet = nsnull;
|
||||
mCharacterSet = "ISO-8859-1";
|
||||
mParentDocument = nsnull;
|
||||
mRootContent = nsnull;
|
||||
mScriptObject = nsnull;
|
||||
|
@ -902,14 +902,16 @@ nsDocument::GetBaseURL(nsIURL*& aURL) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString* nsDocument::GetDocumentCharacterSet() const
|
||||
NS_IMETHODIMP nsDocument::GetDocumentCharacterSet(nsString& oCharSetID)
|
||||
{
|
||||
return mCharacterSet;
|
||||
oCharSetID = mCharacterSet;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDocument::SetDocumentCharacterSet(nsString* aCharSetID)
|
||||
NS_IMETHODIMP nsDocument::SetDocumentCharacterSet(const nsString& aCharSetID)
|
||||
{
|
||||
mCharacterSet = aCharSetID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocument::GetLineBreaker(nsILineBreaker** aResult)
|
||||
|
@ -2621,9 +2623,7 @@ void nsDocument::CreateXIF(nsString & aBuffer, nsIDOMSelection* aSelection)
|
|||
converter.AddStartTag("section");
|
||||
converter.AddStartTag("section_head");
|
||||
|
||||
nsString charset = "ISO-8859-1";
|
||||
if (mCharacterSet != nsnull)
|
||||
charset = *mCharacterSet;
|
||||
nsString charset = mCharacterSet;
|
||||
|
||||
converter.BeginStartTag("document_info");
|
||||
converter.AddAttribute(nsString("charset"),charset);
|
||||
|
|
|
@ -137,8 +137,8 @@ public:
|
|||
* Return a standard name for the document's character set. This will
|
||||
* trigger a startDocumentLoad if necessary to answer the question.
|
||||
*/
|
||||
virtual nsString* GetDocumentCharacterSet() const;
|
||||
virtual void SetDocumentCharacterSet(nsString* aCharSetID);
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharsetID);
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID);
|
||||
|
||||
/**
|
||||
* Return the Line Breaker for the document
|
||||
|
@ -401,7 +401,7 @@ protected:
|
|||
nsString* mDocumentTitle;
|
||||
nsIURL* mDocumentURL;
|
||||
nsIURLGroup* mDocumentURLGroup;
|
||||
nsString* mCharacterSet;
|
||||
nsString mCharacterSet;
|
||||
nsIDocument* mParentDocument;
|
||||
nsVoidArray mSubDocuments;
|
||||
nsVoidArray mPresShells;
|
||||
|
|
|
@ -289,7 +289,7 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
|||
if (NS_OK == rv) {
|
||||
nsIHTMLContentSink* sink;
|
||||
|
||||
nsAutoString defaultHTMLCharset = "ISO-8859-1"; // fallback value in case webShell return error
|
||||
nsAutoString charset = "ISO-8859-1"; // fallback value in case webShell return error
|
||||
nsCharsetSource charsetSource = kCharsetFromDocTypeDefault;
|
||||
|
||||
|
||||
|
@ -299,15 +299,28 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
|||
NS_PRECONDITION(nsnull != aContainer, "No content viewer container");
|
||||
aContainer->QueryInterface(kIWebShellIID, (void**)&webShell);
|
||||
rv = NS_NewHTMLContentSink(&sink, this, aURL, webShell);
|
||||
if (NS_OK == rv) {
|
||||
const PRUnichar* defaultFromWebShell = NULL;
|
||||
rv = webShell->GetDefaultCharacterSet(&defaultFromWebShell);
|
||||
defaultHTMLCharset = defaultFromWebShell;
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
const PRUnichar* defaultCharsetFromWebShell = NULL;
|
||||
rv = webShell->GetDefaultCharacterSet(&defaultCharsetFromWebShell);
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
charset = defaultCharsetFromWebShell;
|
||||
charsetSource = kCharsetFromUserDefault;
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(webShell);
|
||||
#endif
|
||||
|
||||
// XXXX
|
||||
// We should take care two more cases here
|
||||
// 1. The charset attribute from HTTP header
|
||||
// 2. The charset parameter from the META Tag -
|
||||
// which explicit pass to nsWebShell from nsCharsetObserver
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = this->SetDocumentCharacterSet(charset);
|
||||
}
|
||||
|
||||
if (NS_OK == rv) {
|
||||
// Set the parser as the stream listener for the document loader...
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
|
@ -323,7 +336,7 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
|
|||
// nsIDTD* theDTD=0;
|
||||
// NS_NewNavHTMLDTD(&theDTD);
|
||||
// mParser->RegisterDTD(theDTD);
|
||||
mParser->SetDocumentCharset( defaultHTMLCharset, charsetSource);
|
||||
mParser->SetDocumentCharset( charset, charsetSource);
|
||||
mParser->SetCommand(aCommand);
|
||||
mParser->SetContentSink(sink);
|
||||
mParser->Parse(aURL);
|
||||
|
|
|
@ -231,11 +231,7 @@ nsresult nsMsgAppCore::SetDocumentCharset(class nsString const & aCharset)
|
|||
res = domDoc->QueryInterface(nsIDocument::GetIID(), (void**)&doc);
|
||||
if (NS_SUCCEEDED(res) && nsnull != doc)
|
||||
{
|
||||
nsString *aNewCharset = new nsString(aCharset);
|
||||
if (nsnull != aNewCharset)
|
||||
{
|
||||
doc->SetDocumentCharacterSet(aNewCharset);
|
||||
}
|
||||
doc->SetDocumentCharacterSet(aCharset);
|
||||
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
|
@ -252,11 +248,7 @@ nsresult nsMsgAppCore::SetDocumentCharset(class nsString const & aCharset)
|
|||
// Get the document object
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (NS_SUCCEEDED(res = docViewer->GetDocument(*getter_AddRefs(doc)))) {
|
||||
nsString *aNewCharset = new nsString(aCharset);
|
||||
if (nsnull != aNewCharset)
|
||||
{
|
||||
doc->SetDocumentCharacterSet(aNewCharset);
|
||||
}
|
||||
doc->SetDocumentCharacterSet(aCharset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -355,11 +355,7 @@ nsresult nsComposeAppCore::SetDocumentCharset(class nsString const & aCharset)
|
|||
res = domDoc->QueryInterface(kIDocumentIID,(void**)&doc);
|
||||
if (NS_SUCCEEDED(res) && nsnull != doc)
|
||||
{
|
||||
nsString *aNewCharset = new nsString(aCharset);
|
||||
if (nsnull != aNewCharset)
|
||||
{
|
||||
doc->SetDocumentCharacterSet(aNewCharset);
|
||||
}
|
||||
doc->SetDocumentCharacterSet(aCharset);
|
||||
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
|
|
|
@ -399,9 +399,9 @@ public:
|
|||
|
||||
NS_IMETHOD GetBaseURL(nsIURL*& aURL) const;
|
||||
|
||||
virtual nsString* GetDocumentCharacterSet() const;
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsString& oCharSetID);
|
||||
|
||||
virtual void SetDocumentCharacterSet(nsString* aCharSetID);
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsString& aCharSetID);
|
||||
|
||||
NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) ;
|
||||
NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) ;
|
||||
|
@ -687,7 +687,7 @@ protected:
|
|||
nsIDocument* mParentDocument;
|
||||
nsIScriptContextOwner* mScriptContextOwner;
|
||||
void* mScriptObject;
|
||||
nsString* mCharSetID;
|
||||
nsString mCharSetID;
|
||||
nsVoidArray mStyleSheets;
|
||||
nsIDOMSelection* mSelection;
|
||||
PRBool mDisplaySelection;
|
||||
|
@ -736,6 +736,7 @@ XULDocumentImpl::XULDocumentImpl(void)
|
|||
mXULBuilder(nsnull),
|
||||
mLocalDataSource(nsnull),
|
||||
mDocumentDataSource(nsnull),
|
||||
mCharSetID("UTF-8"),
|
||||
mLineBreaker(nsnull),
|
||||
mWordBreaker(nsnull),
|
||||
mContentViewerContainer(nsnull),
|
||||
|
@ -1190,6 +1191,8 @@ XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
|||
|
||||
parser->RegisterDTD(dtd);
|
||||
parser->SetCommand(aCommand);
|
||||
nsAutoString utf8("UTF-8");
|
||||
parser->SetDocumentCharset(utf8, kCharsetFromDocTypeDefault);
|
||||
parser->SetContentSink(sink); // grabs a reference to the parser
|
||||
|
||||
*created_parser = parser;
|
||||
|
@ -1271,16 +1274,18 @@ XULDocumentImpl::GetBaseURL(nsIURL*& aURL) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString*
|
||||
XULDocumentImpl::GetDocumentCharacterSet() const
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetDocumentCharacterSet(nsString& oCharSetID)
|
||||
{
|
||||
return mCharSetID;
|
||||
oCharSetID = mCharSetID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
XULDocumentImpl::SetDocumentCharacterSet(nsString* aCharSetID)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::SetDocumentCharacterSet(const nsString& aCharSetID)
|
||||
{
|
||||
mCharSetID = aCharSetID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче