Bugzilla Bug 98929 Implementation of Content-Language in HTTP

patch by drepper@cygnus.com r=peterv sr=jst
This commit is contained in:
timeless%mac.com 2001-09-11 21:12:23 +00:00
Родитель a2b2565a87
Коммит 4d364f1035
5 изменённых файлов: 53 добавлений и 1 удалений

Просмотреть файл

@ -159,6 +159,11 @@ public:
*/
NS_IMETHOD RemoveCharSetObserver(nsIObserver* aObserver) = 0;
/**
* Return the language of this document.
*/
NS_IMETHOD GetContentLanguage(nsAWritableString& aContentLanguage) const = 0;
#ifdef IBMBIDI
// The state BidiEnabled should persist across multiple views (screen, print)
// of the same document.

Просмотреть файл

@ -122,6 +122,8 @@ static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
#include "nsIHTMLDocument.h"
#include "nsHTMLAtoms.h"
#include "nsIHttpChannel.h"
#include "nsIPref.h"
nsDOMStyleSheetList::nsDOMStyleSheetList(nsIDocument *aDocument)
{
@ -705,6 +707,29 @@ nsDocument::StartDocumentLoad(const char* aCommand,
nsresult rv = NS_OK;
if (aReset)
rv = Reset(aChannel, aLoadGroup);
PRBool have_contentLanguage = PR_FALSE;
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
if (httpChannel) {
nsXPIDLCString contentLanguage;
if (NS_SUCCEEDED(httpChannel->GetResponseHeader("Content-Language",
getter_Copies(contentLanguage)))) {
mContentLanguage.AssignWithConversion(contentLanguage);
have_contentLanguage = PR_TRUE;
}
}
if (!have_contentLanguage) {
nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID));
if(pref) {
nsXPIDLCString prefLanguage;
if (NS_SUCCEEDED(pref->GetCharPref("intl.accept_languages",
getter_Copies(prefLanguage)))) {
mContentLanguage.AssignWithConversion(prefLanguage);
have_contentLanguage = PR_TRUE;
}
}
}
return rv;
}
@ -772,6 +797,13 @@ nsDocument::GetContentType(nsAWritableString& aContentType) const
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDocument::GetContentLanguage(nsAWritableString& aContentLanguage) const
{
aContentLanguage = mContentLanguage;
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetDocumentLoadGroup(nsILoadGroup **aGroup) const
{

Просмотреть файл

@ -254,6 +254,11 @@ public:
*/
NS_IMETHOD GetContentType(nsAWritableString& aContentType) const;
/**
* Return the content language of this document.
*/
NS_IMETHOD GetContentLanguage(nsAWritableString& aContentLanguage) const;
/**
* Return the LoadGroup for the document. May return null.
*/
@ -590,6 +595,8 @@ protected:
nsCOMPtr<nsICSSLoader> mCSSLoader;
nsWeakPtr mFocusController;
nsString mContentLanguage;
private:
// These are not implemented and not supported.
nsDocument(const nsDocument& aOther);

Просмотреть файл

@ -619,6 +619,13 @@ nsXULDocument::GetContentType(nsAWritableString& aContentType) const
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::GetContentLanguage(nsAWritableString& aContentLanguage) const
{
aContentLanguage.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::PrepareStyleSheets(nsIURI* anURL)
{
@ -6974,4 +6981,3 @@ XULElementFactoryImpl::CreateInstanceByTag(nsINodeInfo *aNodeInfo,
{
return nsXULElement::Create(aNodeInfo, aResult);
}

Просмотреть файл

@ -164,6 +164,8 @@ public:
NS_IMETHOD SetDocumentCharacterSet(const nsAReadableString& aCharSetID);
NS_IMETHOD GetContentLanguage(nsAWritableString& aContentLanguage) const;
#ifdef IBMBIDI
/**
* Retrieve and get bidi state of the document