зеркало из https://github.com/mozilla/gecko-dev.git
#105199 glyph search order is NOT lang dependent
lang is mapped to CSS Display structure and apply to document using CSS rule tree. r=dbaron sr=attinasi
This commit is contained in:
Родитель
54b2401ae4
Коммит
fdf39e6da8
|
@ -395,6 +395,8 @@ void nsRuleNode::CreateRootNode(nsIPresContext* aPresContext, nsRuleNode** aResu
|
|||
*aResult = new (aPresContext) nsRuleNode(aPresContext);
|
||||
}
|
||||
|
||||
nsILanguageAtomService* nsRuleNode::gLangService = nsnull;
|
||||
|
||||
nsRuleNode::nsRuleNode(nsIPresContext* aContext, nsIStyleRule* aRule, nsRuleNode* aParent)
|
||||
:mPresContext(aContext), mParent(aParent), mInheritBits(0), mNoneBits(0)
|
||||
{
|
||||
|
@ -784,6 +786,7 @@ static const PropertyCheckData DisplayCheckProperties[] = {
|
|||
static const PropertyCheckData VisibilityCheckProperties[] = {
|
||||
CHECKDATA_PROP(nsCSSDisplay, mVisibility, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSDisplay, mDirection, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSDisplay, mLang, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSDisplay, mOpacity, CHECKDATA_VALUE, PR_FALSE)
|
||||
};
|
||||
|
||||
|
@ -2910,6 +2913,21 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsCSSStruct
|
|||
visibility->mVisible = parentVisibility->mVisible;
|
||||
}
|
||||
|
||||
// lang: string, inherit
|
||||
// this is not a real CSS property, it is a html attribute mapped to CSS struture
|
||||
if (eCSSUnit_String == displayData.mLang.GetUnit()) {
|
||||
if (!gLangService) {
|
||||
CallGetService(NS_LANGUAGEATOMSERVICE_CONTRACTID, &gLangService);
|
||||
}
|
||||
|
||||
if (gLangService) {
|
||||
nsAutoString lang;
|
||||
displayData.mLang.GetStringValue(lang);
|
||||
gLangService->LookupLanguage(lang.get(),
|
||||
getter_AddRefs(visibility->mLanguage));
|
||||
}
|
||||
}
|
||||
|
||||
if (inherited)
|
||||
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
|
||||
// style context.
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
#include "nsPlainTextSerializer.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsXMLContentSerializer.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
class nsIDocumentLoaderFactory;
|
||||
|
||||
|
@ -226,10 +227,9 @@ Shutdown(nsIModule* aSelf)
|
|||
#endif
|
||||
|
||||
NS_IF_RELEASE(nsContentDLF::gUAStyleSheet);
|
||||
|
||||
NS_IF_RELEASE(nsRuleNode::gLangService);
|
||||
nsContentUtils::Shutdown();
|
||||
nsGenericHTMLElement::Shutdown();
|
||||
|
||||
NS_NameSpaceManagerShutdown();
|
||||
}
|
||||
|
||||
|
|
|
@ -207,10 +207,6 @@ static void ReleaseAttributes(nsIHTMLAttributes*& aAttributes)
|
|||
NS_RELEASE(aAttributes);
|
||||
}
|
||||
|
||||
static int gGenericHTMLElementCount = 0;
|
||||
static nsILanguageAtomService* gLangService = nsnull;
|
||||
|
||||
|
||||
class nsGenericHTMLElementTearoff : public nsIDOMNSHTMLElement,
|
||||
public nsIDOMElementCSSInlineStyle
|
||||
{
|
||||
|
@ -267,7 +263,6 @@ static NS_DEFINE_CID(kCSSOMFactoryCID, NS_CSSOMFACTORY_CID);
|
|||
nsGenericHTMLElement::nsGenericHTMLElement()
|
||||
{
|
||||
mAttributes = nsnull;
|
||||
gGenericHTMLElementCount++;
|
||||
}
|
||||
|
||||
nsGenericHTMLElement::~nsGenericHTMLElement()
|
||||
|
@ -275,9 +270,6 @@ nsGenericHTMLElement::~nsGenericHTMLElement()
|
|||
if (nsnull != mAttributes) {
|
||||
ReleaseAttributes(mAttributes);
|
||||
}
|
||||
if (!--gGenericHTMLElementCount) {
|
||||
NS_IF_RELEASE(gLangService);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3229,30 +3221,6 @@ nsGenericHTMLElement::ParseStyleAttribute(const nsAReadableString& aValue, nsHTM
|
|||
return result;
|
||||
}
|
||||
|
||||
static void PostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleData)
|
||||
{
|
||||
if (!aRuleData->mAttributes)
|
||||
return;
|
||||
|
||||
nsHTMLValue value;
|
||||
aRuleData->mAttributes->GetAttribute(nsHTMLAtoms::lang, value);
|
||||
if (value.GetUnit() == eHTMLUnit_String) {
|
||||
if (!gLangService) {
|
||||
nsServiceManager::GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID,
|
||||
NS_GET_IID(nsILanguageAtomService), (nsISupports**) &gLangService);
|
||||
if (!gLangService) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
nsStyleVisibility* vis = (nsStyleVisibility*)aStyleStruct;
|
||||
|
||||
nsAutoString lang;
|
||||
value.GetStringValue(lang);
|
||||
gLangService->LookupLanguage(lang.get(),
|
||||
getter_AddRefs(vis->mLanguage));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle attributes common to all html elements
|
||||
*/
|
||||
|
@ -3279,10 +3247,10 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsIHTMLMappedAttributes* aAt
|
|||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::lang, value);
|
||||
if (value.GetUnit() == eHTMLUnit_String) {
|
||||
// Register a post-resolve callback for filling in the language atom
|
||||
// over in the computed style data.
|
||||
aData->mAttributes = (nsIHTMLMappedAttributes*)aAttributes;
|
||||
aData->mPostResolveCallback = &PostResolveCallback;
|
||||
nsAutoString lang;
|
||||
value.GetStringValue(lang);
|
||||
aData->mDisplayData->mLang.SetStringValue(lang,
|
||||
eCSSUnit_String);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,7 +374,8 @@ nsCSSDisplay::nsCSSDisplay(const nsCSSDisplay& aCopy)
|
|||
mClip(nsnull),
|
||||
mOverflow(aCopy.mOverflow),
|
||||
mVisibility(aCopy.mVisibility),
|
||||
mOpacity(aCopy.mOpacity)
|
||||
mOpacity(aCopy.mOpacity),
|
||||
mLang(aCopy.mLang)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSDisplay);
|
||||
CSS_IF_COPY(mClip, nsCSSRect);
|
||||
|
|
|
@ -374,7 +374,8 @@ nsCSSDisplay::nsCSSDisplay(const nsCSSDisplay& aCopy)
|
|||
mClip(nsnull),
|
||||
mOverflow(aCopy.mOverflow),
|
||||
mVisibility(aCopy.mVisibility),
|
||||
mOpacity(aCopy.mOpacity)
|
||||
mOpacity(aCopy.mOpacity),
|
||||
mLang(aCopy.mLang)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSDisplay);
|
||||
CSS_IF_COPY(mClip, nsCSSRect);
|
||||
|
|
|
@ -223,6 +223,10 @@ struct nsCSSDisplay : public nsCSSStruct {
|
|||
nsCSSValue mOverflow;
|
||||
nsCSSValue mVisibility;
|
||||
nsCSSValue mOpacity;
|
||||
// mLang member variable is here not because in needs to be stored
|
||||
// in nsCSSDeclaration objects but because it's needed on the
|
||||
// stack when the struct is used in WalkRuleTree.
|
||||
nsCSSValue mLang;
|
||||
};
|
||||
|
||||
struct nsCSSMargin : public nsCSSStruct {
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
#include "nsFixedSizeAllocator.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
|
||||
class nsIHTMLMappedAttributes;
|
||||
class nsIStyleContext;
|
||||
struct nsRuleList;
|
||||
|
||||
|
@ -269,9 +269,6 @@ struct nsRuleData
|
|||
nsIStyleContext* mStyleContext;
|
||||
nsPostResolveFunc mPostResolveCallback;
|
||||
PRBool mCanStoreInRuleTree;
|
||||
|
||||
nsIHTMLMappedAttributes* mAttributes; // Can be cached in the rule data by a content node for a post-resolve callback.
|
||||
|
||||
nsCSSFont* mFontData; // Should always be stack-allocated! We don't own these structures!
|
||||
nsCSSDisplay* mDisplayData;
|
||||
nsCSSMargin* mMarginData;
|
||||
|
@ -289,7 +286,7 @@ struct nsRuleData
|
|||
|
||||
nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext)
|
||||
:mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
|
||||
mAttributes(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
|
||||
mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
|
||||
mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
|
||||
mUIData(nsnull)
|
||||
{
|
||||
|
@ -361,19 +358,18 @@ private:
|
|||
// rule node on that branch, so that you can break out of the rule tree
|
||||
// early.
|
||||
|
||||
static PRUint32 gRefCnt;
|
||||
|
||||
friend struct nsRuleList;
|
||||
|
||||
protected:
|
||||
// The callback function for deleting rule nodes from our rule tree.
|
||||
static PRBool PR_CALLBACK DeleteChildren(nsHashKey *aKey, void *aData, void *closure);
|
||||
|
||||
|
||||
public:
|
||||
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
|
||||
// (which comes from the presShell) to perform the allocation.
|
||||
void* operator new(size_t sz, nsIPresContext* aContext);
|
||||
void Destroy();
|
||||
static nsILanguageAtomService *gLangService;
|
||||
|
||||
protected:
|
||||
void PropagateInheritBit(PRUint32 aBit, nsRuleNode* aHighestNode);
|
||||
|
|
|
@ -374,7 +374,8 @@ nsCSSDisplay::nsCSSDisplay(const nsCSSDisplay& aCopy)
|
|||
mClip(nsnull),
|
||||
mOverflow(aCopy.mOverflow),
|
||||
mVisibility(aCopy.mVisibility),
|
||||
mOpacity(aCopy.mOpacity)
|
||||
mOpacity(aCopy.mOpacity),
|
||||
mLang(aCopy.mLang)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSDisplay);
|
||||
CSS_IF_COPY(mClip, nsCSSRect);
|
||||
|
|
|
@ -374,7 +374,8 @@ nsCSSDisplay::nsCSSDisplay(const nsCSSDisplay& aCopy)
|
|||
mClip(nsnull),
|
||||
mOverflow(aCopy.mOverflow),
|
||||
mVisibility(aCopy.mVisibility),
|
||||
mOpacity(aCopy.mOpacity)
|
||||
mOpacity(aCopy.mOpacity),
|
||||
mLang(aCopy.mLang)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSDisplay);
|
||||
CSS_IF_COPY(mClip, nsCSSRect);
|
||||
|
|
|
@ -395,6 +395,8 @@ void nsRuleNode::CreateRootNode(nsIPresContext* aPresContext, nsRuleNode** aResu
|
|||
*aResult = new (aPresContext) nsRuleNode(aPresContext);
|
||||
}
|
||||
|
||||
nsILanguageAtomService* nsRuleNode::gLangService = nsnull;
|
||||
|
||||
nsRuleNode::nsRuleNode(nsIPresContext* aContext, nsIStyleRule* aRule, nsRuleNode* aParent)
|
||||
:mPresContext(aContext), mParent(aParent), mInheritBits(0), mNoneBits(0)
|
||||
{
|
||||
|
@ -784,6 +786,7 @@ static const PropertyCheckData DisplayCheckProperties[] = {
|
|||
static const PropertyCheckData VisibilityCheckProperties[] = {
|
||||
CHECKDATA_PROP(nsCSSDisplay, mVisibility, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSDisplay, mDirection, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSDisplay, mLang, CHECKDATA_VALUE, PR_FALSE),
|
||||
CHECKDATA_PROP(nsCSSDisplay, mOpacity, CHECKDATA_VALUE, PR_FALSE)
|
||||
};
|
||||
|
||||
|
@ -2910,6 +2913,21 @@ nsRuleNode::ComputeVisibilityData(nsStyleStruct* aStartStruct, const nsCSSStruct
|
|||
visibility->mVisible = parentVisibility->mVisible;
|
||||
}
|
||||
|
||||
// lang: string, inherit
|
||||
// this is not a real CSS property, it is a html attribute mapped to CSS struture
|
||||
if (eCSSUnit_String == displayData.mLang.GetUnit()) {
|
||||
if (!gLangService) {
|
||||
CallGetService(NS_LANGUAGEATOMSERVICE_CONTRACTID, &gLangService);
|
||||
}
|
||||
|
||||
if (gLangService) {
|
||||
nsAutoString lang;
|
||||
displayData.mLang.GetStringValue(lang);
|
||||
gLangService->LookupLanguage(lang.get(),
|
||||
getter_AddRefs(visibility->mLanguage));
|
||||
}
|
||||
}
|
||||
|
||||
if (inherited)
|
||||
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
|
||||
// style context.
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
#include "nsFixedSizeAllocator.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
|
||||
class nsIHTMLMappedAttributes;
|
||||
class nsIStyleContext;
|
||||
struct nsRuleList;
|
||||
|
||||
|
@ -269,9 +269,6 @@ struct nsRuleData
|
|||
nsIStyleContext* mStyleContext;
|
||||
nsPostResolveFunc mPostResolveCallback;
|
||||
PRBool mCanStoreInRuleTree;
|
||||
|
||||
nsIHTMLMappedAttributes* mAttributes; // Can be cached in the rule data by a content node for a post-resolve callback.
|
||||
|
||||
nsCSSFont* mFontData; // Should always be stack-allocated! We don't own these structures!
|
||||
nsCSSDisplay* mDisplayData;
|
||||
nsCSSMargin* mMarginData;
|
||||
|
@ -289,7 +286,7 @@ struct nsRuleData
|
|||
|
||||
nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext)
|
||||
:mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
|
||||
mAttributes(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
|
||||
mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
|
||||
mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
|
||||
mUIData(nsnull)
|
||||
{
|
||||
|
@ -361,19 +358,18 @@ private:
|
|||
// rule node on that branch, so that you can break out of the rule tree
|
||||
// early.
|
||||
|
||||
static PRUint32 gRefCnt;
|
||||
|
||||
friend struct nsRuleList;
|
||||
|
||||
protected:
|
||||
// The callback function for deleting rule nodes from our rule tree.
|
||||
static PRBool PR_CALLBACK DeleteChildren(nsHashKey *aKey, void *aData, void *closure);
|
||||
|
||||
|
||||
public:
|
||||
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
|
||||
// (which comes from the presShell) to perform the allocation.
|
||||
void* operator new(size_t sz, nsIPresContext* aContext);
|
||||
void Destroy();
|
||||
static nsILanguageAtomService *gLangService;
|
||||
|
||||
protected:
|
||||
void PropagateInheritBit(PRUint32 aBit, nsRuleNode* aHighestNode);
|
||||
|
|
Загрузка…
Ссылка в новой задаче