Get rid of nsILanguageAtom and deCOMtaminate nsILanguageAtomService (bug 230603). Also, fix a bunch of atom double-addref leaks in nsFontMetricsXlib. r+sr=dbaron.
This commit is contained in:
@@ -668,12 +668,8 @@ NS_IMETHODIMP nsAccessibleText::GetCharacterExtents(PRInt32 aOffset,
|
||||
const nsStyleFont *font = frame->GetStyleFont();
|
||||
|
||||
const nsStyleVisibility *visibility = frame->GetStyleVisibility();
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
if (visibility->mLanguage) {
|
||||
visibility->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
||||
}
|
||||
|
||||
if (NS_FAILED(rc->SetFont(font->mFont, langGroup))) {
|
||||
if (NS_FAILED(rc->SetFont(font->mFont, visibility->mLangGroup))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -2805,8 +2805,7 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct,
|
||||
if (gLangService) {
|
||||
nsAutoString lang;
|
||||
displayData.mLang.GetStringValue(lang);
|
||||
gLangService->LookupLanguage(lang.get(),
|
||||
getter_AddRefs(visibility->mLanguage));
|
||||
visibility->mLangGroup = gLangService->LookupLanguage(lang);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
#define _nsStyleContext_h_
|
||||
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
class nsIPresContext;
|
||||
class nsIAtom;
|
||||
|
||||
class nsStyleContext
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsILanguageAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
class nsIFrame;
|
||||
@@ -684,7 +684,7 @@ struct nsStyleVisibility : public nsStyleStruct {
|
||||
|
||||
PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
|
||||
PRUint8 mVisible; // [inherited]
|
||||
nsCOMPtr<nsILanguageAtom> mLanguage; // [inherited]
|
||||
nsCOMPtr<nsIAtom> mLangGroup; // [inherited]
|
||||
|
||||
PRBool IsVisible() const {
|
||||
return (mVisible == NS_STYLE_VISIBILITY_VISIBLE);
|
||||
|
||||
@@ -1129,7 +1129,7 @@ nsStyleVisibility::nsStyleVisibility(nsIPresContext* aPresContext)
|
||||
else
|
||||
mDirection = NS_STYLE_DIRECTION_LTR;
|
||||
|
||||
mLanguage = aPresContext->GetLanguage();
|
||||
mLangGroup = aPresContext->GetLangGroup();
|
||||
mVisible = NS_STYLE_VISIBILITY_VISIBLE;
|
||||
}
|
||||
|
||||
@@ -1137,13 +1137,13 @@ nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
||||
{
|
||||
mDirection = aSource.mDirection;
|
||||
mVisible = aSource.mVisible;
|
||||
mLanguage = aSource.mLanguage;
|
||||
mLangGroup = aSource.mLangGroup;
|
||||
}
|
||||
|
||||
nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther) const
|
||||
{
|
||||
if ((mDirection == aOther.mDirection) &&
|
||||
(mLanguage == aOther.mLanguage)) {
|
||||
(mLangGroup == aOther.mLangGroup)) {
|
||||
if ((mVisible == aOther.mVisible)) {
|
||||
return NS_STYLE_HINT_NONE;
|
||||
}
|
||||
|
||||
@@ -1155,7 +1155,7 @@ InitGlobals(nsIDeviceContext *aDevice)
|
||||
nsCOMPtr<nsILanguageAtomService> langService;
|
||||
langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
if (langService) {
|
||||
langService->GetLocaleLanguageGroup(&gUsersLocale);
|
||||
NS_IF_ADDREF(gUsersLocale = langService->GetLocaleLanguageGroup());
|
||||
}
|
||||
if (!gUsersLocale) {
|
||||
gUsersLocale = NS_NewAtom("x-western");
|
||||
|
||||
@@ -285,7 +285,7 @@ DeviceContextImpl::GetLocaleLangGroup(void)
|
||||
nsCOMPtr<nsILanguageAtomService> langService;
|
||||
langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
if (langService) {
|
||||
langService->GetLocaleLanguageGroup(getter_AddRefs(mLocaleLangGroup));
|
||||
mLocaleLangGroup = langService->GetLocaleLanguageGroup();
|
||||
}
|
||||
if (!mLocaleLangGroup) {
|
||||
mLocaleLangGroup = do_GetAtom("x-western");
|
||||
|
||||
@@ -224,7 +224,7 @@ InitGlobals(void)
|
||||
nsCOMPtr<nsILanguageAtomService> langService;
|
||||
langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
if (langService) {
|
||||
langService->GetLocaleLanguageGroup(&gUsersLocale);
|
||||
NS_IF_ADDREF(gUsersLocale = langService->GetLocaleLanguageGroup());
|
||||
}
|
||||
if (!gUsersLocale) {
|
||||
gUsersLocale = NS_NewAtom("x-western");
|
||||
|
||||
@@ -229,7 +229,7 @@ nsDeviceContextPS::InitDeviceContextPS(nsIDeviceContext *aCreatingDeviceContext,
|
||||
nsCOMPtr<nsILanguageAtomService> langService;
|
||||
langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
if (langService) {
|
||||
langService->GetLocaleLanguageGroup(&gUsersLocale);
|
||||
NS_IF_ADDREF(gUsersLocale = langService->GetLocaleLanguageGroup());
|
||||
}
|
||||
if (!gUsersLocale) {
|
||||
gUsersLocale = NS_NewAtom("x-western");
|
||||
|
||||
@@ -304,7 +304,7 @@ InitGlobals(void)
|
||||
nsCOMPtr<nsILanguageAtomService> langService;
|
||||
langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
if (langService) {
|
||||
langService->GetLocaleLanguageGroup(&gUsersLocale);
|
||||
NS_IF_ADDREF(gUsersLocale = langService->GetLocaleLanguageGroup());
|
||||
}
|
||||
if (!gUsersLocale) {
|
||||
gUsersLocale = NS_NewAtom("x-western");
|
||||
|
||||
@@ -1477,23 +1477,23 @@ nsFontMetricsXlibContext::Init(nsIDeviceContext *aDevice, PRBool aPrintermode)
|
||||
specialCharSetMap++;
|
||||
}
|
||||
|
||||
mUnicode = NS_NewAtom("x-unicode");
|
||||
mUnicode = do_GetAtom("x-unicode");
|
||||
if (!mUnicode) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mUserDefined = NS_NewAtom(USER_DEFINED);
|
||||
mUserDefined = do_GetAtom(USER_DEFINED);
|
||||
if (!mUserDefined) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mZHTW = NS_NewAtom("zh-TW");
|
||||
mZHTW = do_GetAtom("zh-TW");
|
||||
if (!mZHTW) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mZHHK = NS_NewAtom("zh-HK");
|
||||
mZHHK = do_GetAtom("zh-HK");
|
||||
if (!mZHHK) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mZHTWHK = NS_NewAtom("x-zh-TWHK");
|
||||
mZHTWHK = do_GetAtom("x-zh-TWHK");
|
||||
if (!mZHTWHK) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@@ -1502,14 +1502,12 @@ nsFontMetricsXlibContext::Init(nsIDeviceContext *aDevice, PRBool aPrintermode)
|
||||
nsCOMPtr<nsILanguageAtomService> langService;
|
||||
langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
if (langService) {
|
||||
nsIAtom *atom;
|
||||
langService->GetLocaleLanguageGroup(&atom);
|
||||
mUsersLocale = atom;
|
||||
mUsersLocale = langService->GetLocaleLanguageGroup();
|
||||
}
|
||||
if (!mUsersLocale) {
|
||||
mUsersLocale = NS_NewAtom("x-western");
|
||||
mUsersLocale = do_GetAtom("x-western");
|
||||
}
|
||||
mWesternLocale = NS_NewAtom("x-western");
|
||||
mWesternLocale = do_GetAtom("x-western");
|
||||
if (!mUsersLocale) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,6 @@ MODULE = locale
|
||||
GRE_MODULE = 1
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsILanguageAtom.idl \
|
||||
nsILanguageAtomService.idl \
|
||||
nsIFontPackageService.idl \
|
||||
nsIFontPackageProxy.idl \
|
||||
nsIFontPackageHandler.idl \
|
||||
|
||||
@@ -49,6 +49,7 @@ EXPORTS = \
|
||||
nsDateTimeFormatCID.h \
|
||||
nsICollation.h \
|
||||
nsIDateTimeFormat.h \
|
||||
nsILanguageAtomService.h \
|
||||
nsIMacLocale.h \
|
||||
nsIPosixLocale.h \
|
||||
nsIOS2Locale.h \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
@@ -22,6 +22,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Erik van der Poel
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@@ -37,28 +38,36 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAtom.idl"
|
||||
#ifndef nsILanguageAtomService_h_
|
||||
#define nsILanguageAtomService_h_
|
||||
|
||||
/*
|
||||
* The nsILanguageAtom interface encapsulates a language code (as used in
|
||||
* HTML LANG attributes, for example). This interface also provides access
|
||||
* to the corresponding "language group" atom, to be used in the font
|
||||
* engine with preferences, for example.
|
||||
*
|
||||
* The nsILanguageAtom interface is similar to nsIAtom, in the sense that
|
||||
* one can compare 2 pointers for equality. The nsILanguageAtomService
|
||||
* creates nsILanguageAtoms by first lower-casing the language (since it's
|
||||
* case-insensitive according to RFC 1766), and then looking up that
|
||||
* language in a set of existing nsILanguageAtom objects. If it already
|
||||
* exists, that object is returned. If not, a new one is created and added
|
||||
* to the set for future retrieval.
|
||||
* The nsILanguageAtomService provides a mapping from languages or
|
||||
* character sets to language groups.
|
||||
*/
|
||||
[scriptable, uuid(a6cf911e-15b3-11d2-932e-00805f8add32)]
|
||||
interface nsILanguageAtom : nsISupports
|
||||
{
|
||||
readonly attribute wstring language;
|
||||
readonly attribute nsIAtom languageGroup;
|
||||
|
||||
boolean LanguageIs(in wstring aLanguage);
|
||||
#include "nsISupports.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
#define NS_ILANGUAGEATOMSERVICE_IID \
|
||||
{0x24b45737, 0x9e94, 0x4e40, \
|
||||
{ 0x9d, 0x59, 0x29, 0xcd, 0x62, 0x96, 0x3a, 0xdd }}
|
||||
|
||||
#define NS_LANGUAGEATOMSERVICE_CONTRACTID \
|
||||
"@mozilla.org/intl/nslanguageatomservice;1"
|
||||
|
||||
class nsILanguageAtomService : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILANGUAGEATOMSERVICE_IID)
|
||||
|
||||
virtual nsIAtom* LookupLanguage(const nsAString &aLanguage,
|
||||
nsresult *aError = nsnull) = 0;
|
||||
virtual already_AddRefed<nsIAtom>
|
||||
LookupCharSet(const char *aCharSet, nsresult *aError = nsnull) = 0;
|
||||
|
||||
virtual nsIAtom* GetLocaleLanguageGroup(nsresult *aError = nsnull) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -43,94 +43,14 @@
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
class nsLanguageAtom : public nsILanguageAtom
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSILANGUAGEATOM
|
||||
|
||||
nsLanguageAtom();
|
||||
virtual ~nsLanguageAtom();
|
||||
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
virtual void Init(const nsString& aLanguage, nsIAtom* aLangGroup);
|
||||
|
||||
protected:
|
||||
nsAutoString mLang;
|
||||
nsCOMPtr<nsIAtom> mLangGroup;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsLanguageAtom, nsILanguageAtom)
|
||||
|
||||
nsLanguageAtom::nsLanguageAtom()
|
||||
{
|
||||
}
|
||||
|
||||
nsLanguageAtom::~nsLanguageAtom()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsLanguageAtom::Init(const nsString& aLanguage, nsIAtom* aLangGroup)
|
||||
{
|
||||
mLang = aLanguage;
|
||||
mLangGroup = aLangGroup;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLanguageAtom::GetLanguage(PRUnichar** aLanguage)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLanguage);
|
||||
*aLanguage = nsnull;
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLanguageAtom::GetLanguageGroup(nsIAtom** aLanguageGroup)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLanguageGroup);
|
||||
|
||||
*aLanguageGroup = mLangGroup;
|
||||
NS_IF_ADDREF(*aLanguageGroup);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLanguageAtom::LanguageIs(const PRUnichar* aLanguage, PRBool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLanguage);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = mLang.Equals(nsDependentString(aLanguage));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsLanguageAtomService, nsILanguageAtomService)
|
||||
|
||||
nsLanguageAtomService::nsLanguageAtomService()
|
||||
{
|
||||
mLangs.Init();
|
||||
}
|
||||
|
||||
nsLanguageAtomService::~nsLanguageAtomService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLanguageAtomService::InitLangTable()
|
||||
{
|
||||
if (!mLangs) {
|
||||
NS_ENSURE_SUCCESS(NS_NewISupportsArray(getter_AddRefs(mLangs)),
|
||||
NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsLanguageAtomService::InitLangGroupTable()
|
||||
{
|
||||
if (mLangGroups) return NS_OK;
|
||||
@@ -146,41 +66,18 @@ nsLanguageAtomService::InitLangGroupTable()
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLanguageAtomService::LookupLanguage(const PRUnichar* aLanguage,
|
||||
nsILanguageAtom** aResult)
|
||||
nsIAtom*
|
||||
nsLanguageAtomService::LookupLanguage(const nsAString &aLanguage,
|
||||
nsresult *aError)
|
||||
{
|
||||
nsresult res;
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nsnull;
|
||||
NS_ENSURE_ARG_POINTER(aLanguage);
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (!mLangs) {
|
||||
NS_ENSURE_SUCCESS(InitLangTable(), NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
nsAutoString lowered(aLanguage);
|
||||
ToLowerCase(lowered);
|
||||
nsCOMPtr<nsILanguageAtom> lang;
|
||||
PRUint32 n;
|
||||
NS_ENSURE_SUCCESS(mLangs->Count(&n), NS_ERROR_FAILURE);
|
||||
for (PRUint32 i = 0; i < n; i++) {
|
||||
res = mLangs->QueryElementAt(i, NS_GET_IID(nsILanguageAtom),
|
||||
getter_AddRefs(lang));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
PRBool same = PR_FALSE;
|
||||
NS_ENSURE_SUCCESS(lang->LanguageIs(lowered.get(), &same),
|
||||
NS_ERROR_FAILURE);
|
||||
if (same) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
lang = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom *lang = mLangs.GetWeak(lowered);
|
||||
|
||||
if (!lang) {
|
||||
nsLanguageAtom* language = new nsLanguageAtom();
|
||||
NS_ENSURE_TRUE(language, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsXPIDLString langGroupStr;
|
||||
|
||||
if (lowered.EqualsLiteral("en-us")) {
|
||||
@@ -191,7 +88,12 @@ nsLanguageAtomService::LookupLanguage(const PRUnichar* aLanguage,
|
||||
langGroupStr.Assign(NS_LITERAL_STRING("ja"));
|
||||
} else {
|
||||
if (!mLangGroups) {
|
||||
NS_ENSURE_SUCCESS(InitLangGroupTable(), NS_ERROR_FAILURE);
|
||||
if (NS_FAILED(InitLangGroupTable())) {
|
||||
if (aError)
|
||||
*aError = NS_ERROR_FAILURE;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
res = mLangGroups->GetStringFromName(lowered.get(), getter_Copies(langGroupStr));
|
||||
if (NS_FAILED(res)) {
|
||||
@@ -208,109 +110,98 @@ nsLanguageAtomService::LookupLanguage(const PRUnichar* aLanguage,
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIAtom> langGroup = do_GetAtom(langGroupStr);
|
||||
language->Init(lowered, langGroup);
|
||||
lang = language;
|
||||
mLangs->AppendElement(lang);
|
||||
}
|
||||
*aResult = lang;
|
||||
NS_ADDREF(*aResult);
|
||||
lang = do_GetAtom(langGroupStr);
|
||||
|
||||
return NS_OK;
|
||||
// The hashtable will keep an owning reference to the atom
|
||||
mLangs.Put(lowered, lang);
|
||||
}
|
||||
|
||||
if (aError)
|
||||
*aError = res;
|
||||
|
||||
return lang;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLanguageAtomService::LookupCharSet(const char* aCharSet,
|
||||
nsILanguageAtom** aResult)
|
||||
already_AddRefed<nsIAtom>
|
||||
nsLanguageAtomService::LookupCharSet(const char *aCharSet, nsresult *aError)
|
||||
{
|
||||
nsresult res;
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nsnull;
|
||||
NS_ENSURE_ARG_POINTER(aCharSet);
|
||||
|
||||
if (!mLangs) {
|
||||
NS_ENSURE_SUCCESS(InitLangTable(), NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
if (!mCharSets) {
|
||||
mCharSets = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mCharSets, NS_ERROR_FAILURE);
|
||||
if (!mCharSets) {
|
||||
if (aError)
|
||||
*aError = NS_ERROR_FAILURE;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
if (!mUnicode) {
|
||||
mUnicode = do_GetAtom("x-unicode");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
mCharSets->GetCharsetLangGroup(aCharSet,
|
||||
getter_AddRefs(langGroup));
|
||||
mCharSets->GetCharsetLangGroup(aCharSet, getter_AddRefs(langGroup));
|
||||
if (!langGroup) {
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aError)
|
||||
*aError = NS_ERROR_FAILURE;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
#if !defined(XP_BEOS)
|
||||
if (langGroup.get() == mUnicode.get()) {
|
||||
res = GetLocaleLanguageGroup(getter_AddRefs(langGroup));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
#endif
|
||||
nsCOMPtr<nsILanguageAtom> lang;
|
||||
PRUint32 n;
|
||||
NS_ENSURE_SUCCESS(mLangs->Count(&n), NS_ERROR_FAILURE);
|
||||
for (PRUint32 i = 0; i < n; i++) {
|
||||
res = mLangs->QueryElementAt(i, NS_GET_IID(nsILanguageAtom),
|
||||
getter_AddRefs(lang));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsIAtom> group;
|
||||
NS_ENSURE_SUCCESS(lang->GetLanguageGroup(getter_AddRefs(group)),
|
||||
NS_ERROR_FAILURE);
|
||||
if (langGroup.get() == group.get()) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
lang = nsnull;
|
||||
}
|
||||
if (langGroup == mUnicode) {
|
||||
langGroup = GetLocaleLanguageGroup(&res);
|
||||
if (NS_FAILED(res)) {
|
||||
if (aError)
|
||||
*aError = res;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
if (!lang) {
|
||||
nsLanguageAtom* language = new nsLanguageAtom();
|
||||
NS_ENSURE_TRUE(language, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsAutoString empty;
|
||||
language->Init(empty, langGroup);
|
||||
lang = language;
|
||||
mLangs->AppendElement(lang);
|
||||
}
|
||||
*aResult = lang;
|
||||
NS_ADDREF(*aResult);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
// transfer reference to raw pointer
|
||||
nsIAtom *raw = nsnull;
|
||||
langGroup.swap(raw);
|
||||
|
||||
if (aError)
|
||||
*aError = NS_OK;
|
||||
|
||||
return raw;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLanguageAtomService::GetLocaleLanguageGroup(nsIAtom** aResult)
|
||||
nsIAtom*
|
||||
nsLanguageAtomService::GetLocaleLanguageGroup(nsresult *aError)
|
||||
{
|
||||
nsresult res;
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nsnull;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (!mLocaleLangGroup) {
|
||||
nsCOMPtr<nsILocaleService> localeService;
|
||||
localeService = do_GetService(NS_LOCALESERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(localeService, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsILocale> locale;
|
||||
res = localeService->GetApplicationLocale(getter_AddRefs(locale));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsAutoString category;
|
||||
category.AssignWithConversion(NSILOCALE_MESSAGE);
|
||||
nsAutoString loc;
|
||||
res = locale->GetCategory(category, loc);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsCOMPtr<nsILanguageAtom> langAtom;
|
||||
res = LookupLanguage(loc.get(), getter_AddRefs(langAtom));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = langAtom->GetLanguageGroup(getter_AddRefs(mLocaleLangGroup));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
do {
|
||||
if (!mLocaleLangGroup) {
|
||||
nsCOMPtr<nsILocaleService> localeService;
|
||||
localeService = do_GetService(NS_LOCALESERVICE_CONTRACTID);
|
||||
if (!localeService) {
|
||||
res = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
*aResult = mLocaleLangGroup;
|
||||
NS_ADDREF(*aResult);
|
||||
nsCOMPtr<nsILocale> locale;
|
||||
res = localeService->GetApplicationLocale(getter_AddRefs(locale));
|
||||
if (NS_FAILED(res))
|
||||
break;
|
||||
|
||||
return NS_OK;
|
||||
nsAutoString category;
|
||||
category.AssignWithConversion(NSILOCALE_MESSAGE);
|
||||
nsAutoString loc;
|
||||
res = locale->GetCategory(category, loc);
|
||||
if (NS_FAILED(res))
|
||||
break;
|
||||
|
||||
mLocaleLangGroup = LookupLanguage(loc, &res);
|
||||
}
|
||||
} while (0);
|
||||
|
||||
if (aError)
|
||||
*aError = res;
|
||||
|
||||
return mLocaleLangGroup;
|
||||
}
|
||||
|
||||
@@ -41,24 +41,36 @@
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
#define NS_LANGUAGEATOMSERVICE_CID \
|
||||
{0xa6cf9120, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsLanguageAtomService : public nsILanguageAtomService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSILANGUAGEATOMSERVICE
|
||||
|
||||
nsLanguageAtomService();
|
||||
virtual ~nsLanguageAtomService();
|
||||
// nsILanguageAtomService
|
||||
virtual NS_HIDDEN_(nsIAtom*)
|
||||
LookupLanguage(const nsAString &aLanguage, nsresult *aError);
|
||||
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
virtual NS_HIDDEN_(already_AddRefed<nsIAtom>)
|
||||
LookupCharSet(const char *aCharSet, nsresult *aError);
|
||||
|
||||
NS_IMETHOD InitLangTable();
|
||||
NS_IMETHOD InitLangGroupTable();
|
||||
virtual NS_HIDDEN_(nsIAtom*) GetLocaleLanguageGroup(nsresult *aError);
|
||||
|
||||
nsLanguageAtomService() NS_HIDDEN;
|
||||
|
||||
private:
|
||||
NS_HIDDEN ~nsLanguageAtomService() { }
|
||||
|
||||
protected:
|
||||
NS_HIDDEN_(nsresult) InitLangGroupTable();
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> mCharSets;
|
||||
nsCOMPtr<nsISupportsArray> mLangs;
|
||||
nsInterfaceHashtable<nsStringHashKey, nsIAtom> mLangs;
|
||||
nsCOMPtr<nsIStringBundle> mLangGroups;
|
||||
nsCOMPtr<nsIAtom> mLocaleLangGroup;
|
||||
nsCOMPtr<nsIAtom> mUnicode;
|
||||
|
||||
@@ -984,10 +984,7 @@ void nsCaret::GetCaretRectAndInvert()
|
||||
{
|
||||
const nsStyleFont* fontStyle = mLastCaretFrame->GetStyleFont();
|
||||
const nsStyleVisibility* vis = mLastCaretFrame->GetStyleVisibility();
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
if (vis->mLanguage)
|
||||
vis->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
||||
mRendContext->SetFont(fontStyle->mFont, langGroup);
|
||||
mRendContext->SetFont(fontStyle->mFont, vis->mLangGroup);
|
||||
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
mRendContext->GetFontMetrics(*getter_AddRefs(fm));
|
||||
|
||||
@@ -231,7 +231,7 @@ nsPresContext::~nsPresContext()
|
||||
|
||||
NS_IF_RELEASE(mDeviceContext);
|
||||
NS_IF_RELEASE(mLookAndFeel);
|
||||
NS_IF_RELEASE(mLanguage);
|
||||
NS_IF_RELEASE(mLangGroup);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
|
||||
@@ -253,7 +253,7 @@ static const char* const kGenericFont[] = {
|
||||
void
|
||||
nsPresContext::GetFontPreferences()
|
||||
{
|
||||
if (!mLanguage)
|
||||
if (!mLangGroup)
|
||||
return;
|
||||
|
||||
/* Fetch the font prefs to be used -- see bug 61883 for details.
|
||||
@@ -277,10 +277,8 @@ nsPresContext::GetFontPreferences()
|
||||
mDefaultVariableFont.size = NSFloatPixelsToTwips((float)16, p2t);
|
||||
mDefaultFixedFont.size = NSFloatPixelsToTwips((float)13, p2t);
|
||||
|
||||
nsAutoString langGroup;
|
||||
nsCOMPtr<nsIAtom> langGroupAtom;
|
||||
mLanguage->GetLanguageGroup(getter_AddRefs(langGroupAtom));
|
||||
langGroupAtom->ToString(langGroup);
|
||||
const char *langGroup;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
|
||||
nsCAutoString pref;
|
||||
|
||||
@@ -307,7 +305,7 @@ nsPresContext::GetFontPreferences()
|
||||
// get font.minimum-size.[langGroup]
|
||||
|
||||
pref.Assign("font.minimum-size.");
|
||||
AppendUTF16toUTF8(langGroup, pref);
|
||||
pref.Append(langGroup);
|
||||
|
||||
PRInt32 size = nsContentUtils::GetIntPref(pref.get());
|
||||
if (size > 0) {
|
||||
@@ -323,7 +321,7 @@ nsPresContext::GetFontPreferences()
|
||||
nsCAutoString generic_dot_langGroup;
|
||||
for (PRInt32 eType = eDefaultFont_Variable; eType < eDefaultFont_COUNT; ++eType) {
|
||||
generic_dot_langGroup.Assign(kGenericFont[eType]);
|
||||
AppendUTF16toUTF8(langGroup, generic_dot_langGroup);
|
||||
generic_dot_langGroup.Append(langGroup);
|
||||
|
||||
nsFont* font;
|
||||
switch (eType) {
|
||||
@@ -726,25 +724,20 @@ void
|
||||
nsPresContext::UpdateCharSet(const char* aCharSet)
|
||||
{
|
||||
if (mLangService) {
|
||||
NS_IF_RELEASE(mLanguage);
|
||||
mLangService->LookupCharSet(aCharSet, &mLanguage); // addrefs
|
||||
NS_IF_RELEASE(mLangGroup);
|
||||
mLangGroup = mLangService->LookupCharSet(aCharSet).get(); // addrefs
|
||||
GetFontPreferences();
|
||||
if (mLanguage) {
|
||||
nsCOMPtr<nsIAtom> langGroupAtom;
|
||||
mLanguage->GetLanguageGroup(getter_AddRefs(langGroupAtom));
|
||||
NS_ASSERTION(langGroupAtom, "non-NULL language group atom expected");
|
||||
if (langGroupAtom.get() == nsLayoutAtoms::Japanese) {
|
||||
mLanguageSpecificTransformType =
|
||||
if (mLangGroup == nsLayoutAtoms::Japanese) {
|
||||
mLanguageSpecificTransformType =
|
||||
eLanguageSpecificTransformType_Japanese;
|
||||
}
|
||||
else if (langGroupAtom.get() == nsLayoutAtoms::Korean) {
|
||||
mLanguageSpecificTransformType =
|
||||
}
|
||||
else if (mLangGroup == nsLayoutAtoms::Korean) {
|
||||
mLanguageSpecificTransformType =
|
||||
eLanguageSpecificTransformType_Korean;
|
||||
}
|
||||
else {
|
||||
mLanguageSpecificTransformType =
|
||||
}
|
||||
else {
|
||||
mLanguageSpecificTransformType =
|
||||
eLanguageSpecificTransformType_None;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef IBMBIDI
|
||||
@@ -873,11 +866,7 @@ nsPresContext::GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult)
|
||||
NS_PRECONDITION(aResult, "null out param");
|
||||
|
||||
nsIFontMetrics* metrics = nsnull;
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
if (mLanguage) {
|
||||
mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
||||
}
|
||||
mDeviceContext->GetMetricsFor(aFont, langGroup, metrics);
|
||||
mDeviceContext->GetMetricsFor(aFont, mLangGroup, metrics);
|
||||
*aResult = metrics;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class nsIEventStateManager;
|
||||
class nsIURI;
|
||||
class nsILookAndFeel;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsILanguageAtom;
|
||||
class nsIAtom;
|
||||
class nsITheme;
|
||||
struct nsStyleStruct;
|
||||
struct nsStyleBackground;
|
||||
@@ -80,8 +80,8 @@ class nsIRenderingContext;
|
||||
#endif
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0xfaf7c34a, 0x347c, 0x48f6, \
|
||||
{0x81, 0x76, 0xc0, 0xf6, 0xd4, 0xe5, 0x74, 0x2e} }
|
||||
{ 0x2820eeff, 0x7e66, 0x43df, \
|
||||
{0xae, 0x19, 0xee, 0xf6, 0x09, 0xc1, 0xcf, 0xfe} }
|
||||
|
||||
enum nsWidgetType {
|
||||
eWidgetType_Button = 1,
|
||||
@@ -358,7 +358,7 @@ public:
|
||||
|
||||
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
|
||||
nsIEventStateManager* EventStateManager() { return mEventManager; }
|
||||
nsILanguageAtom* GetLanguage() { return mLanguage; }
|
||||
nsIAtom* GetLangGroup() { return mLangGroup; }
|
||||
|
||||
/**
|
||||
* Get the language-specific transform type for the current document.
|
||||
@@ -525,7 +525,7 @@ protected:
|
||||
// weak pointer to static atom
|
||||
|
||||
nsILinkHandler* mLinkHandler; // [WEAK]
|
||||
nsILanguageAtom* mLanguage; // [STRONG]
|
||||
nsIAtom* mLangGroup; // [STRONG]
|
||||
|
||||
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
|
||||
PRInt32 mFontScaler;
|
||||
|
||||
@@ -70,7 +70,7 @@ class nsIEventStateManager;
|
||||
class nsIURI;
|
||||
class nsILookAndFeel;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsILanguageAtom;
|
||||
class nsIAtom;
|
||||
class nsITheme;
|
||||
struct nsStyleStruct;
|
||||
struct nsStyleBackground;
|
||||
@@ -80,8 +80,8 @@ class nsIRenderingContext;
|
||||
#endif
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0xfaf7c34a, 0x347c, 0x48f6, \
|
||||
{0x81, 0x76, 0xc0, 0xf6, 0xd4, 0xe5, 0x74, 0x2e} }
|
||||
{ 0x2820eeff, 0x7e66, 0x43df, \
|
||||
{0xae, 0x19, 0xee, 0xf6, 0x09, 0xc1, 0xcf, 0xfe} }
|
||||
|
||||
enum nsWidgetType {
|
||||
eWidgetType_Button = 1,
|
||||
@@ -358,7 +358,7 @@ public:
|
||||
|
||||
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
|
||||
nsIEventStateManager* EventStateManager() { return mEventManager; }
|
||||
nsILanguageAtom* GetLanguage() { return mLanguage; }
|
||||
nsIAtom* GetLangGroup() { return mLangGroup; }
|
||||
|
||||
/**
|
||||
* Get the language-specific transform type for the current document.
|
||||
@@ -525,7 +525,7 @@ protected:
|
||||
// weak pointer to static atom
|
||||
|
||||
nsILinkHandler* mLinkHandler; // [WEAK]
|
||||
nsILanguageAtom* mLanguage; // [STRONG]
|
||||
nsIAtom* mLangGroup; // [STRONG]
|
||||
|
||||
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
|
||||
PRInt32 mFontScaler;
|
||||
|
||||
@@ -70,7 +70,7 @@ class nsIEventStateManager;
|
||||
class nsIURI;
|
||||
class nsILookAndFeel;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsILanguageAtom;
|
||||
class nsIAtom;
|
||||
class nsITheme;
|
||||
struct nsStyleStruct;
|
||||
struct nsStyleBackground;
|
||||
@@ -80,8 +80,8 @@ class nsIRenderingContext;
|
||||
#endif
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0xfaf7c34a, 0x347c, 0x48f6, \
|
||||
{0x81, 0x76, 0xc0, 0xf6, 0xd4, 0xe5, 0x74, 0x2e} }
|
||||
{ 0x2820eeff, 0x7e66, 0x43df, \
|
||||
{0xae, 0x19, 0xee, 0xf6, 0x09, 0xc1, 0xcf, 0xfe} }
|
||||
|
||||
enum nsWidgetType {
|
||||
eWidgetType_Button = 1,
|
||||
@@ -358,7 +358,7 @@ public:
|
||||
|
||||
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
|
||||
nsIEventStateManager* EventStateManager() { return mEventManager; }
|
||||
nsILanguageAtom* GetLanguage() { return mLanguage; }
|
||||
nsIAtom* GetLangGroup() { return mLangGroup; }
|
||||
|
||||
/**
|
||||
* Get the language-specific transform type for the current document.
|
||||
@@ -525,7 +525,7 @@ protected:
|
||||
// weak pointer to static atom
|
||||
|
||||
nsILinkHandler* mLinkHandler; // [WEAK]
|
||||
nsILanguageAtom* mLanguage; // [STRONG]
|
||||
nsIAtom* mLangGroup; // [STRONG]
|
||||
|
||||
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
|
||||
PRInt32 mFontScaler;
|
||||
|
||||
@@ -984,10 +984,7 @@ void nsCaret::GetCaretRectAndInvert()
|
||||
{
|
||||
const nsStyleFont* fontStyle = mLastCaretFrame->GetStyleFont();
|
||||
const nsStyleVisibility* vis = mLastCaretFrame->GetStyleVisibility();
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
if (vis->mLanguage)
|
||||
vis->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
||||
mRendContext->SetFont(fontStyle->mFont, langGroup);
|
||||
mRendContext->SetFont(fontStyle->mFont, vis->mLangGroup);
|
||||
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
mRendContext->GetFontMetrics(*getter_AddRefs(fm));
|
||||
|
||||
@@ -231,7 +231,7 @@ nsPresContext::~nsPresContext()
|
||||
|
||||
NS_IF_RELEASE(mDeviceContext);
|
||||
NS_IF_RELEASE(mLookAndFeel);
|
||||
NS_IF_RELEASE(mLanguage);
|
||||
NS_IF_RELEASE(mLangGroup);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
|
||||
@@ -253,7 +253,7 @@ static const char* const kGenericFont[] = {
|
||||
void
|
||||
nsPresContext::GetFontPreferences()
|
||||
{
|
||||
if (!mLanguage)
|
||||
if (!mLangGroup)
|
||||
return;
|
||||
|
||||
/* Fetch the font prefs to be used -- see bug 61883 for details.
|
||||
@@ -277,10 +277,8 @@ nsPresContext::GetFontPreferences()
|
||||
mDefaultVariableFont.size = NSFloatPixelsToTwips((float)16, p2t);
|
||||
mDefaultFixedFont.size = NSFloatPixelsToTwips((float)13, p2t);
|
||||
|
||||
nsAutoString langGroup;
|
||||
nsCOMPtr<nsIAtom> langGroupAtom;
|
||||
mLanguage->GetLanguageGroup(getter_AddRefs(langGroupAtom));
|
||||
langGroupAtom->ToString(langGroup);
|
||||
const char *langGroup;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
|
||||
nsCAutoString pref;
|
||||
|
||||
@@ -307,7 +305,7 @@ nsPresContext::GetFontPreferences()
|
||||
// get font.minimum-size.[langGroup]
|
||||
|
||||
pref.Assign("font.minimum-size.");
|
||||
AppendUTF16toUTF8(langGroup, pref);
|
||||
pref.Append(langGroup);
|
||||
|
||||
PRInt32 size = nsContentUtils::GetIntPref(pref.get());
|
||||
if (size > 0) {
|
||||
@@ -323,7 +321,7 @@ nsPresContext::GetFontPreferences()
|
||||
nsCAutoString generic_dot_langGroup;
|
||||
for (PRInt32 eType = eDefaultFont_Variable; eType < eDefaultFont_COUNT; ++eType) {
|
||||
generic_dot_langGroup.Assign(kGenericFont[eType]);
|
||||
AppendUTF16toUTF8(langGroup, generic_dot_langGroup);
|
||||
generic_dot_langGroup.Append(langGroup);
|
||||
|
||||
nsFont* font;
|
||||
switch (eType) {
|
||||
@@ -726,25 +724,20 @@ void
|
||||
nsPresContext::UpdateCharSet(const char* aCharSet)
|
||||
{
|
||||
if (mLangService) {
|
||||
NS_IF_RELEASE(mLanguage);
|
||||
mLangService->LookupCharSet(aCharSet, &mLanguage); // addrefs
|
||||
NS_IF_RELEASE(mLangGroup);
|
||||
mLangGroup = mLangService->LookupCharSet(aCharSet).get(); // addrefs
|
||||
GetFontPreferences();
|
||||
if (mLanguage) {
|
||||
nsCOMPtr<nsIAtom> langGroupAtom;
|
||||
mLanguage->GetLanguageGroup(getter_AddRefs(langGroupAtom));
|
||||
NS_ASSERTION(langGroupAtom, "non-NULL language group atom expected");
|
||||
if (langGroupAtom.get() == nsLayoutAtoms::Japanese) {
|
||||
mLanguageSpecificTransformType =
|
||||
if (mLangGroup == nsLayoutAtoms::Japanese) {
|
||||
mLanguageSpecificTransformType =
|
||||
eLanguageSpecificTransformType_Japanese;
|
||||
}
|
||||
else if (langGroupAtom.get() == nsLayoutAtoms::Korean) {
|
||||
mLanguageSpecificTransformType =
|
||||
}
|
||||
else if (mLangGroup == nsLayoutAtoms::Korean) {
|
||||
mLanguageSpecificTransformType =
|
||||
eLanguageSpecificTransformType_Korean;
|
||||
}
|
||||
else {
|
||||
mLanguageSpecificTransformType =
|
||||
}
|
||||
else {
|
||||
mLanguageSpecificTransformType =
|
||||
eLanguageSpecificTransformType_None;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef IBMBIDI
|
||||
@@ -873,11 +866,7 @@ nsPresContext::GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult)
|
||||
NS_PRECONDITION(aResult, "null out param");
|
||||
|
||||
nsIFontMetrics* metrics = nsnull;
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
if (mLanguage) {
|
||||
mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
||||
}
|
||||
mDeviceContext->GetMetricsFor(aFont, langGroup, metrics);
|
||||
mDeviceContext->GetMetricsFor(aFont, mLangGroup, metrics);
|
||||
*aResult = metrics;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -402,12 +402,7 @@ void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC)
|
||||
const nsStyleFont* font = aSC->GetStyleFont();
|
||||
const nsStyleVisibility* visibility = aSC->GetStyleVisibility();
|
||||
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
if (visibility->mLanguage) {
|
||||
visibility->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
||||
}
|
||||
|
||||
aRC->SetFont(font->mFont, langGroup);
|
||||
aRC->SetFont(font->mFont, visibility->mLangGroup);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
||||
@@ -2143,12 +2143,9 @@ ComputeLineHeight(nsIPresContext* aPresContext,
|
||||
} else {
|
||||
nsCOMPtr<nsIDeviceContext> deviceContext;
|
||||
aRenderingContext->GetDeviceContext(*getter_AddRefs(deviceContext));
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
if (vis->mLanguage) {
|
||||
vis->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
||||
}
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
deviceContext->GetMetricsFor(font->mFont, langGroup, *getter_AddRefs(fm));
|
||||
deviceContext->GetMetricsFor(font->mFont, vis->mLangGroup,
|
||||
*getter_AddRefs(fm));
|
||||
if (unit == eStyleUnit_Factor) {
|
||||
// For factor units the computed value of the line-height property
|
||||
// is found by multiplying the factor by the font's <b>actual</b>
|
||||
|
||||
@@ -402,12 +402,7 @@ void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC)
|
||||
const nsStyleFont* font = aSC->GetStyleFont();
|
||||
const nsStyleVisibility* visibility = aSC->GetStyleVisibility();
|
||||
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
if (visibility->mLanguage) {
|
||||
visibility->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
||||
}
|
||||
|
||||
aRC->SetFont(font->mFont, langGroup);
|
||||
aRC->SetFont(font->mFont, visibility->mLangGroup);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
||||
@@ -2143,12 +2143,9 @@ ComputeLineHeight(nsIPresContext* aPresContext,
|
||||
} else {
|
||||
nsCOMPtr<nsIDeviceContext> deviceContext;
|
||||
aRenderingContext->GetDeviceContext(*getter_AddRefs(deviceContext));
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
if (vis->mLanguage) {
|
||||
vis->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
|
||||
}
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
deviceContext->GetMetricsFor(font->mFont, langGroup, *getter_AddRefs(fm));
|
||||
deviceContext->GetMetricsFor(font->mFont, vis->mLangGroup,
|
||||
*getter_AddRefs(fm));
|
||||
if (unit == eStyleUnit_Factor) {
|
||||
// For factor units the computed value of the line-height property
|
||||
// is found by multiplying the factor by the font's <b>actual</b>
|
||||
|
||||
@@ -2805,8 +2805,7 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct,
|
||||
if (gLangService) {
|
||||
nsAutoString lang;
|
||||
displayData.mLang.GetStringValue(lang);
|
||||
gLangService->LookupLanguage(lang.get(),
|
||||
getter_AddRefs(visibility->mLanguage));
|
||||
visibility->mLangGroup = gLangService->LookupLanguage(lang);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
#define _nsStyleContext_h_
|
||||
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
class nsIPresContext;
|
||||
class nsIAtom;
|
||||
|
||||
class nsStyleContext
|
||||
{
|
||||
|
||||
@@ -1129,7 +1129,7 @@ nsStyleVisibility::nsStyleVisibility(nsIPresContext* aPresContext)
|
||||
else
|
||||
mDirection = NS_STYLE_DIRECTION_LTR;
|
||||
|
||||
mLanguage = aPresContext->GetLanguage();
|
||||
mLangGroup = aPresContext->GetLangGroup();
|
||||
mVisible = NS_STYLE_VISIBILITY_VISIBLE;
|
||||
}
|
||||
|
||||
@@ -1137,13 +1137,13 @@ nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
||||
{
|
||||
mDirection = aSource.mDirection;
|
||||
mVisible = aSource.mVisible;
|
||||
mLanguage = aSource.mLanguage;
|
||||
mLangGroup = aSource.mLangGroup;
|
||||
}
|
||||
|
||||
nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther) const
|
||||
{
|
||||
if ((mDirection == aOther.mDirection) &&
|
||||
(mLanguage == aOther.mLanguage)) {
|
||||
(mLangGroup == aOther.mLangGroup)) {
|
||||
if ((mVisible == aOther.mVisible)) {
|
||||
return NS_STYLE_HINT_NONE;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsILanguageAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
class nsIFrame;
|
||||
@@ -684,7 +684,7 @@ struct nsStyleVisibility : public nsStyleStruct {
|
||||
|
||||
PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
|
||||
PRUint8 mVisible; // [inherited]
|
||||
nsCOMPtr<nsILanguageAtom> mLanguage; // [inherited]
|
||||
nsCOMPtr<nsIAtom> mLangGroup; // [inherited]
|
||||
|
||||
PRBool IsVisible() const {
|
||||
return (mVisible == NS_STYLE_VISIBILITY_VISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user