mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
first part of fix for bug 112209, making nsStr private by switching nsStaticNameTable over to nsAFlatString. r=dbaron, sr=blake
This commit is contained in:
parent
2997b1ffa6
commit
8e1f300899
@ -4244,7 +4244,7 @@ PRBool CSSDeclarationImpl::AppendValueToString(nsCSSProperty aProperty, const ns
|
||||
}
|
||||
}
|
||||
else {
|
||||
const nsCString& name = nsCSSProps::LookupPropertyValue(aProperty, aValue.GetIntValue());
|
||||
const nsAFlatCString& name = nsCSSProps::LookupPropertyValue(aProperty, aValue.GetIntValue());
|
||||
aResult.Append(NS_ConvertASCIItoUCS2(name));
|
||||
}
|
||||
}
|
||||
|
@ -4244,7 +4244,7 @@ PRBool CSSDeclarationImpl::AppendValueToString(nsCSSProperty aProperty, const ns
|
||||
}
|
||||
}
|
||||
else {
|
||||
const nsCString& name = nsCSSProps::LookupPropertyValue(aProperty, aValue.GetIntValue());
|
||||
const nsAFlatCString& name = nsCSSProps::LookupPropertyValue(aProperty, aValue.GetIntValue());
|
||||
aResult.Append(NS_ConvertASCIItoUCS2(name));
|
||||
}
|
||||
}
|
||||
|
@ -691,7 +691,7 @@ nsComputedDOMStyle::GetCssFloat(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Display,(const nsStyleStruct*&)display,aFrame);
|
||||
|
||||
if(display) {
|
||||
const nsCString& cssFloat =
|
||||
const nsAFlatCString& cssFloat =
|
||||
nsCSSProps::SearchKeywordTable(display->mFloats,
|
||||
nsCSSProps::kFloatKTable);
|
||||
val->SetString(cssFloat.get());
|
||||
@ -951,7 +951,7 @@ nsComputedDOMStyle::GetFontStyle(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
||||
|
||||
if(font) {
|
||||
const nsCString& style=
|
||||
const nsAFlatCString& style=
|
||||
nsCSSProps::SearchKeywordTable(font->mFont.style,
|
||||
nsCSSProps::kFontStyleKTable);
|
||||
val->SetString(style.get());
|
||||
@ -975,7 +975,7 @@ nsComputedDOMStyle::GetFontWeight(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
||||
|
||||
if(font) {
|
||||
const nsCString& str_weight=
|
||||
const nsAFlatCString& str_weight=
|
||||
nsCSSProps::SearchKeywordTable(font->mFont.weight,
|
||||
nsCSSProps::kFontWeightKTable);
|
||||
if(str_weight.Length()>0) {
|
||||
@ -1006,7 +1006,7 @@ nsComputedDOMStyle::GetFontVariant(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
||||
|
||||
if(font) {
|
||||
const nsCString& variant=
|
||||
const nsAFlatCString& variant=
|
||||
nsCSSProps::SearchKeywordTable(font->mFont.variant,
|
||||
nsCSSProps::kFontVariantKTable);
|
||||
val->SetString(variant.get());
|
||||
@ -1032,7 +1032,7 @@ nsComputedDOMStyle::GetBackgroundColor(nsIFrame *aFrame,
|
||||
if(color) {
|
||||
if ((color->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) &&
|
||||
!(color->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT)) {
|
||||
const nsCString& backgroundColor =
|
||||
const nsAFlatCString& backgroundColor =
|
||||
nsCSSProps::SearchKeywordTable(NS_STYLE_BG_COLOR_TRANSPARENT,
|
||||
nsCSSProps::kBackgroundColorKTable);
|
||||
val->SetString(backgroundColor.get());
|
||||
@ -1119,7 +1119,7 @@ nsComputedDOMStyle::GetBorderCollapse(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_TableBorder, (const nsStyleStruct*&)table, aFrame);
|
||||
|
||||
if(table) {
|
||||
const nsCString& ident=
|
||||
const nsAFlatCString& ident=
|
||||
nsCSSProps::SearchKeywordTable(table->mBorderCollapse,
|
||||
nsCSSProps::kBorderCollapseKTable);
|
||||
val->SetString(ident.get());
|
||||
@ -1325,7 +1325,7 @@ nsComputedDOMStyle::GetOutlineStyle(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Outline, (const nsStyleStruct*&)outline, aFrame);
|
||||
|
||||
if(outline) {
|
||||
const nsCString& style=
|
||||
const nsAFlatCString& style=
|
||||
nsCSSProps::SearchKeywordTable(outline->GetOutlineStyle(),
|
||||
nsCSSProps::kBorderStyleKTable);
|
||||
val->SetString(style.get());
|
||||
@ -1429,7 +1429,7 @@ nsComputedDOMStyle::GetTextAlign(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Text, (const nsStyleStruct*&)text, aFrame);
|
||||
|
||||
if(text) {
|
||||
const nsCString& align=
|
||||
const nsAFlatCString& align=
|
||||
nsCSSProps::SearchKeywordTable(text->mTextAlign,
|
||||
nsCSSProps::kTextAlignKTable);
|
||||
val->SetString(align.get());
|
||||
@ -1453,7 +1453,7 @@ nsComputedDOMStyle::GetTextDecoration(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_TextReset,(const nsStyleStruct*&)text,aFrame);
|
||||
|
||||
if(text) {
|
||||
const nsCString& decoration=
|
||||
const nsAFlatCString& decoration=
|
||||
nsCSSProps::SearchKeywordTable(text->mTextDecoration,
|
||||
nsCSSProps::kTextDecorationKTable);
|
||||
val->SetString(decoration.get());
|
||||
@ -1477,7 +1477,7 @@ nsComputedDOMStyle::GetVisibility(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Visibility,(const nsStyleStruct*&)visibility,aFrame);
|
||||
|
||||
if(visibility) {
|
||||
const nsCString& value=
|
||||
const nsAFlatCString& value=
|
||||
nsCSSProps::SearchKeywordTable(visibility->mVisible,
|
||||
nsCSSProps::kVisibilityKTable);
|
||||
val->SetString(value.get());
|
||||
@ -2610,7 +2610,7 @@ nsComputedDOMStyle::GetBorderWidthFor(PRUint8 aSide,
|
||||
case eStyleUnit_Enumerated:
|
||||
case eStyleUnit_Chars:
|
||||
{
|
||||
const nsCString& width=
|
||||
const nsAFlatCString& width=
|
||||
nsCSSProps::SearchKeywordTable(coord.GetIntValue(),
|
||||
nsCSSProps::kBorderWidthKTable);
|
||||
val->SetString(width.get()); break;
|
||||
@ -2718,7 +2718,7 @@ nsComputedDOMStyle::GetBorderStyleFor(PRUint8 aSide,
|
||||
GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border, aFrame);
|
||||
|
||||
if(border) {
|
||||
const nsCString& style=
|
||||
const nsAFlatCString& style=
|
||||
nsCSSProps::SearchKeywordTable(border->GetBorderStyle(aSide),
|
||||
nsCSSProps::kBorderStyleKTable);
|
||||
val->SetString(style.get());
|
||||
|
@ -38,8 +38,9 @@
|
||||
#ifndef nsCSSKeywords_h___
|
||||
#define nsCSSKeywords_h___
|
||||
|
||||
class nsString;
|
||||
class nsCString;
|
||||
class nsAString;
|
||||
class nsACString;
|
||||
class nsAFlatCString;
|
||||
|
||||
/*
|
||||
Declare the enum list using the magic of preprocessing
|
||||
@ -63,11 +64,11 @@ public:
|
||||
static void ReleaseTable(void);
|
||||
|
||||
// Given a keyword string, return the enum value
|
||||
static nsCSSKeyword LookupKeyword(const nsCString& aKeyword);
|
||||
static nsCSSKeyword LookupKeyword(const nsString& aKeyword);
|
||||
static nsCSSKeyword LookupKeyword(const nsACString& aKeyword);
|
||||
static nsCSSKeyword LookupKeyword(const nsAString& aKeyword);
|
||||
|
||||
// Given a keyword enum, get the string value
|
||||
static const nsCString& GetStringValue(nsCSSKeyword aKeyword);
|
||||
static const nsAFlatCString& GetStringValue(nsCSSKeyword aKeyword);
|
||||
};
|
||||
|
||||
#endif /* nsCSSKeywords_h___ */
|
||||
|
@ -63,22 +63,22 @@ public:
|
||||
|
||||
// Given a property string, return the enum value
|
||||
static nsCSSProperty LookupProperty(const nsAReadableString& aProperty);
|
||||
static nsCSSProperty LookupProperty(const nsCString& aProperty);
|
||||
static nsCSSProperty LookupProperty(const nsACString& aProperty);
|
||||
|
||||
// Given a property enum, get the string value
|
||||
static const nsCString& GetStringValue(nsCSSProperty aProperty);
|
||||
static const nsAFlatCString& GetStringValue(nsCSSProperty aProperty);
|
||||
|
||||
// Given a CSS Property and a Property Enum Value
|
||||
// Return back a const nsString& representation of the
|
||||
// value. Return back nullstr if no value is found
|
||||
static const nsCString& LookupPropertyValue(nsCSSProperty aProperty, PRInt32 aValue);
|
||||
static const nsAFlatCString& LookupPropertyValue(nsCSSProperty aProperty, PRInt32 aValue);
|
||||
|
||||
// Get a color name for a predefined color value like buttonhighlight or activeborder
|
||||
// Sets the aStr param to the name of the propertyID
|
||||
static PRBool GetColorName(PRInt32 aPropID, nsCString &aStr);
|
||||
|
||||
static PRInt32 SearchKeywordTableInt(PRInt32 aValue, const PRInt32 aTable[]);
|
||||
static const nsCString& SearchKeywordTable(PRInt32 aValue, const PRInt32 aTable[]);
|
||||
static const nsAFlatCString& SearchKeywordTable(PRInt32 aValue, const PRInt32 aTable[]);
|
||||
|
||||
static const PRInt32 kHintTable[];
|
||||
|
||||
|
@ -86,7 +86,7 @@ nsCSSKeywords::ReleaseTable(void)
|
||||
}
|
||||
|
||||
nsCSSKeyword
|
||||
nsCSSKeywords::LookupKeyword(const nsCString& aKeyword)
|
||||
nsCSSKeywords::LookupKeyword(const nsACString& aKeyword)
|
||||
{
|
||||
NS_ASSERTION(gKeywordTable, "no lookup table, needs addref");
|
||||
if (gKeywordTable) {
|
||||
@ -96,7 +96,7 @@ nsCSSKeywords::LookupKeyword(const nsCString& aKeyword)
|
||||
}
|
||||
|
||||
nsCSSKeyword
|
||||
nsCSSKeywords::LookupKeyword(const nsString& aKeyword)
|
||||
nsCSSKeywords::LookupKeyword(const nsAString& aKeyword)
|
||||
{
|
||||
NS_ASSERTION(gKeywordTable, "no lookup table, needs addref");
|
||||
if (gKeywordTable) {
|
||||
@ -105,14 +105,14 @@ nsCSSKeywords::LookupKeyword(const nsString& aKeyword)
|
||||
return eCSSKeyword_UNKNOWN;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsCSSKeywords::GetStringValue(nsCSSKeyword aKeyword)
|
||||
{
|
||||
NS_ASSERTION(gKeywordTable, "no lookup table, needs addref");
|
||||
if (gKeywordTable) {
|
||||
return gKeywordTable->GetStringValue(PRInt32(aKeyword));
|
||||
} else {
|
||||
static nsCString kNullStr;
|
||||
static nsDependentCString kNullStr("");
|
||||
return kNullStr;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ nsCSSProps::ReleaseTable(void)
|
||||
}
|
||||
|
||||
nsCSSProperty
|
||||
nsCSSProps::LookupProperty(const nsCString& aProperty)
|
||||
nsCSSProps::LookupProperty(const nsACString& aProperty)
|
||||
{
|
||||
NS_ASSERTION(gPropertyTable, "no lookup table, needs addref");
|
||||
if (gPropertyTable) {
|
||||
@ -107,14 +107,14 @@ nsCSSProps::LookupProperty(const nsAReadableString& aProperty) {
|
||||
return LookupProperty(theProp);
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsCSSProps::GetStringValue(nsCSSProperty aProperty)
|
||||
{
|
||||
NS_ASSERTION(gPropertyTable, "no lookup table, needs addref");
|
||||
if (gPropertyTable) {
|
||||
return gPropertyTable->GetStringValue(PRInt32(aProperty));
|
||||
} else {
|
||||
static nsCString sNullStr;
|
||||
static nsDependentCString sNullStr("");
|
||||
return sNullStr;
|
||||
}
|
||||
}
|
||||
@ -754,19 +754,19 @@ nsCSSProps::SearchKeywordTableInt(PRInt32 aValue, const PRInt32 aTable[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsCSSProps::SearchKeywordTable(PRInt32 aValue, const PRInt32 aTable[])
|
||||
{
|
||||
PRInt32 i = SearchKeywordTableInt(aValue, aTable);
|
||||
if (i < 0) {
|
||||
static nsCString sNullStr;
|
||||
static nsDependentCString sNullStr("");
|
||||
return sNullStr;
|
||||
} else {
|
||||
return nsCSSKeywords::GetStringValue(nsCSSKeyword(i));
|
||||
}
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsCSSProps::LookupPropertyValue(nsCSSProperty aProp, PRInt32 aValue)
|
||||
{
|
||||
static const PRInt32 kBackgroundXPositionKTable[] = {
|
||||
@ -1128,7 +1128,7 @@ static const PRInt32 kBackgroundYPositionKTable[] = {
|
||||
NS_ERROR("invalid property");
|
||||
break;
|
||||
}
|
||||
static nsCString sNullStr;
|
||||
static nsDependentCString sNullStr("");
|
||||
return sNullStr;
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,9 @@
|
||||
#include "nsColor.h"
|
||||
|
||||
struct nsStr;
|
||||
class nsCString;
|
||||
class nsACString;
|
||||
class nsAFlatCString;
|
||||
class nsAString;
|
||||
class nsACString;
|
||||
|
||||
/*
|
||||
Declare the enum list using the magic of preprocessing
|
||||
@ -71,7 +71,7 @@ public:
|
||||
static nsColorName LookupName(const nsAString& aName);
|
||||
static nsColorName LookupName(const nsACString& aName);
|
||||
|
||||
static const nsCString& GetStringValue(nsColorName aColorName);
|
||||
static const nsAFlatCString& GetStringValue(nsColorName aColorName);
|
||||
|
||||
// Color id to rgb value table
|
||||
static const nscolor kColors[];
|
||||
|
@ -112,14 +112,14 @@ nsColorNames::LookupName(const nsAString& aColor)
|
||||
return eColorName_UNKNOWN;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsColorNames::GetStringValue(nsColorName aColor)
|
||||
{
|
||||
NS_ASSERTION(gColorTable, "no lookup table, needs addref");
|
||||
if (gColorTable) {
|
||||
return gColorTable->GetStringValue(PRInt32(aColor));
|
||||
} else {
|
||||
static nsCString kNullStr;
|
||||
static nsDependentCString kNullStr("");
|
||||
return kNullStr;
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,9 @@
|
||||
#ifndef nsHTMLTags_h___
|
||||
#define nsHTMLTags_h___
|
||||
|
||||
class nsString;
|
||||
class nsCString;
|
||||
class nsAString;
|
||||
class nsACString;
|
||||
class nsAFlatCString;
|
||||
|
||||
/*
|
||||
Declare the enum list using the magic of preprocessing
|
||||
@ -71,9 +72,9 @@ public:
|
||||
static void AddRefTable(void);
|
||||
static void ReleaseTable(void);
|
||||
|
||||
static nsHTMLTag LookupTag(const nsString& aTag);
|
||||
static nsHTMLTag LookupTag(const nsCString& aTag);
|
||||
static const nsCString& GetStringValue(nsHTMLTag aEnum);
|
||||
static nsHTMLTag LookupTag(const nsAString& aTag);
|
||||
static nsHTMLTag LookupTag(const nsACString& aTag);
|
||||
static const nsAFlatCString& GetStringValue(nsHTMLTag aEnum);
|
||||
static const char* GetCStringValue(nsHTMLTag aEnum);
|
||||
};
|
||||
|
||||
|
@ -86,7 +86,7 @@ nsHTMLTags::ReleaseTable(void)
|
||||
}
|
||||
|
||||
nsHTMLTag
|
||||
nsHTMLTags::LookupTag(const nsCString& aTag)
|
||||
nsHTMLTags::LookupTag(const nsACString& aTag)
|
||||
{
|
||||
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
|
||||
if (gTagTable) {
|
||||
@ -111,7 +111,7 @@ nsHTMLTags::LookupTag(const nsCString& aTag)
|
||||
}
|
||||
|
||||
nsHTMLTag
|
||||
nsHTMLTags::LookupTag(const nsString& aTag)
|
||||
nsHTMLTags::LookupTag(const nsAString& aTag)
|
||||
{
|
||||
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
|
||||
if (gTagTable) {
|
||||
@ -140,7 +140,7 @@ nsHTMLTags::LookupTag(const nsString& aTag)
|
||||
return eHTMLTag_userdefined;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsHTMLTags::GetStringValue(nsHTMLTag aTag)
|
||||
{
|
||||
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
|
||||
@ -148,7 +148,7 @@ nsHTMLTags::GetStringValue(nsHTMLTag aTag)
|
||||
// table is zero based, but tags are one based
|
||||
return gTagTable->GetStringValue(PRInt32(aTag)-1);
|
||||
} else {
|
||||
static nsCString kNullStr;
|
||||
static nsDependentCString kNullStr("");
|
||||
return kNullStr;
|
||||
}
|
||||
}
|
||||
|
@ -2267,7 +2267,8 @@ const nsAReadableString& CStyleToken::GetStringValue(void)
|
||||
* @return
|
||||
*/
|
||||
const char* GetTagName(PRInt32 aTag) {
|
||||
const nsCString& result = nsHTMLTags::GetStringValue((nsHTMLTag) aTag);
|
||||
const nsAFlatCString& result =
|
||||
nsHTMLTags::GetStringValue((nsHTMLTag) aTag);
|
||||
if (0 == result.Length()) {
|
||||
if(aTag>=eHTMLTag_userdefined)
|
||||
return gUserdefined;
|
||||
|
@ -4244,7 +4244,7 @@ PRBool CSSDeclarationImpl::AppendValueToString(nsCSSProperty aProperty, const ns
|
||||
}
|
||||
}
|
||||
else {
|
||||
const nsCString& name = nsCSSProps::LookupPropertyValue(aProperty, aValue.GetIntValue());
|
||||
const nsAFlatCString& name = nsCSSProps::LookupPropertyValue(aProperty, aValue.GetIntValue());
|
||||
aResult.Append(NS_ConvertASCIItoUCS2(name));
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ nsCSSKeywords::ReleaseTable(void)
|
||||
}
|
||||
|
||||
nsCSSKeyword
|
||||
nsCSSKeywords::LookupKeyword(const nsCString& aKeyword)
|
||||
nsCSSKeywords::LookupKeyword(const nsACString& aKeyword)
|
||||
{
|
||||
NS_ASSERTION(gKeywordTable, "no lookup table, needs addref");
|
||||
if (gKeywordTable) {
|
||||
@ -96,7 +96,7 @@ nsCSSKeywords::LookupKeyword(const nsCString& aKeyword)
|
||||
}
|
||||
|
||||
nsCSSKeyword
|
||||
nsCSSKeywords::LookupKeyword(const nsString& aKeyword)
|
||||
nsCSSKeywords::LookupKeyword(const nsAString& aKeyword)
|
||||
{
|
||||
NS_ASSERTION(gKeywordTable, "no lookup table, needs addref");
|
||||
if (gKeywordTable) {
|
||||
@ -105,14 +105,14 @@ nsCSSKeywords::LookupKeyword(const nsString& aKeyword)
|
||||
return eCSSKeyword_UNKNOWN;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsCSSKeywords::GetStringValue(nsCSSKeyword aKeyword)
|
||||
{
|
||||
NS_ASSERTION(gKeywordTable, "no lookup table, needs addref");
|
||||
if (gKeywordTable) {
|
||||
return gKeywordTable->GetStringValue(PRInt32(aKeyword));
|
||||
} else {
|
||||
static nsCString kNullStr;
|
||||
static nsDependentCString kNullStr("");
|
||||
return kNullStr;
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +38,9 @@
|
||||
#ifndef nsCSSKeywords_h___
|
||||
#define nsCSSKeywords_h___
|
||||
|
||||
class nsString;
|
||||
class nsCString;
|
||||
class nsAString;
|
||||
class nsACString;
|
||||
class nsAFlatCString;
|
||||
|
||||
/*
|
||||
Declare the enum list using the magic of preprocessing
|
||||
@ -63,11 +64,11 @@ public:
|
||||
static void ReleaseTable(void);
|
||||
|
||||
// Given a keyword string, return the enum value
|
||||
static nsCSSKeyword LookupKeyword(const nsCString& aKeyword);
|
||||
static nsCSSKeyword LookupKeyword(const nsString& aKeyword);
|
||||
static nsCSSKeyword LookupKeyword(const nsACString& aKeyword);
|
||||
static nsCSSKeyword LookupKeyword(const nsAString& aKeyword);
|
||||
|
||||
// Given a keyword enum, get the string value
|
||||
static const nsCString& GetStringValue(nsCSSKeyword aKeyword);
|
||||
static const nsAFlatCString& GetStringValue(nsCSSKeyword aKeyword);
|
||||
};
|
||||
|
||||
#endif /* nsCSSKeywords_h___ */
|
||||
|
@ -92,7 +92,7 @@ nsCSSProps::ReleaseTable(void)
|
||||
}
|
||||
|
||||
nsCSSProperty
|
||||
nsCSSProps::LookupProperty(const nsCString& aProperty)
|
||||
nsCSSProps::LookupProperty(const nsACString& aProperty)
|
||||
{
|
||||
NS_ASSERTION(gPropertyTable, "no lookup table, needs addref");
|
||||
if (gPropertyTable) {
|
||||
@ -107,14 +107,14 @@ nsCSSProps::LookupProperty(const nsAReadableString& aProperty) {
|
||||
return LookupProperty(theProp);
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsCSSProps::GetStringValue(nsCSSProperty aProperty)
|
||||
{
|
||||
NS_ASSERTION(gPropertyTable, "no lookup table, needs addref");
|
||||
if (gPropertyTable) {
|
||||
return gPropertyTable->GetStringValue(PRInt32(aProperty));
|
||||
} else {
|
||||
static nsCString sNullStr;
|
||||
static nsDependentCString sNullStr("");
|
||||
return sNullStr;
|
||||
}
|
||||
}
|
||||
@ -754,19 +754,19 @@ nsCSSProps::SearchKeywordTableInt(PRInt32 aValue, const PRInt32 aTable[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsCSSProps::SearchKeywordTable(PRInt32 aValue, const PRInt32 aTable[])
|
||||
{
|
||||
PRInt32 i = SearchKeywordTableInt(aValue, aTable);
|
||||
if (i < 0) {
|
||||
static nsCString sNullStr;
|
||||
static nsDependentCString sNullStr("");
|
||||
return sNullStr;
|
||||
} else {
|
||||
return nsCSSKeywords::GetStringValue(nsCSSKeyword(i));
|
||||
}
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsCSSProps::LookupPropertyValue(nsCSSProperty aProp, PRInt32 aValue)
|
||||
{
|
||||
static const PRInt32 kBackgroundXPositionKTable[] = {
|
||||
@ -1128,7 +1128,7 @@ static const PRInt32 kBackgroundYPositionKTable[] = {
|
||||
NS_ERROR("invalid property");
|
||||
break;
|
||||
}
|
||||
static nsCString sNullStr;
|
||||
static nsDependentCString sNullStr("");
|
||||
return sNullStr;
|
||||
}
|
||||
|
||||
|
@ -63,22 +63,22 @@ public:
|
||||
|
||||
// Given a property string, return the enum value
|
||||
static nsCSSProperty LookupProperty(const nsAReadableString& aProperty);
|
||||
static nsCSSProperty LookupProperty(const nsCString& aProperty);
|
||||
static nsCSSProperty LookupProperty(const nsACString& aProperty);
|
||||
|
||||
// Given a property enum, get the string value
|
||||
static const nsCString& GetStringValue(nsCSSProperty aProperty);
|
||||
static const nsAFlatCString& GetStringValue(nsCSSProperty aProperty);
|
||||
|
||||
// Given a CSS Property and a Property Enum Value
|
||||
// Return back a const nsString& representation of the
|
||||
// value. Return back nullstr if no value is found
|
||||
static const nsCString& LookupPropertyValue(nsCSSProperty aProperty, PRInt32 aValue);
|
||||
static const nsAFlatCString& LookupPropertyValue(nsCSSProperty aProperty, PRInt32 aValue);
|
||||
|
||||
// Get a color name for a predefined color value like buttonhighlight or activeborder
|
||||
// Sets the aStr param to the name of the propertyID
|
||||
static PRBool GetColorName(PRInt32 aPropID, nsCString &aStr);
|
||||
|
||||
static PRInt32 SearchKeywordTableInt(PRInt32 aValue, const PRInt32 aTable[]);
|
||||
static const nsCString& SearchKeywordTable(PRInt32 aValue, const PRInt32 aTable[]);
|
||||
static const nsAFlatCString& SearchKeywordTable(PRInt32 aValue, const PRInt32 aTable[]);
|
||||
|
||||
static const PRInt32 kHintTable[];
|
||||
|
||||
|
@ -4244,7 +4244,7 @@ PRBool CSSDeclarationImpl::AppendValueToString(nsCSSProperty aProperty, const ns
|
||||
}
|
||||
}
|
||||
else {
|
||||
const nsCString& name = nsCSSProps::LookupPropertyValue(aProperty, aValue.GetIntValue());
|
||||
const nsAFlatCString& name = nsCSSProps::LookupPropertyValue(aProperty, aValue.GetIntValue());
|
||||
aResult.Append(NS_ConvertASCIItoUCS2(name));
|
||||
}
|
||||
}
|
||||
|
@ -691,7 +691,7 @@ nsComputedDOMStyle::GetCssFloat(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Display,(const nsStyleStruct*&)display,aFrame);
|
||||
|
||||
if(display) {
|
||||
const nsCString& cssFloat =
|
||||
const nsAFlatCString& cssFloat =
|
||||
nsCSSProps::SearchKeywordTable(display->mFloats,
|
||||
nsCSSProps::kFloatKTable);
|
||||
val->SetString(cssFloat.get());
|
||||
@ -951,7 +951,7 @@ nsComputedDOMStyle::GetFontStyle(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
||||
|
||||
if(font) {
|
||||
const nsCString& style=
|
||||
const nsAFlatCString& style=
|
||||
nsCSSProps::SearchKeywordTable(font->mFont.style,
|
||||
nsCSSProps::kFontStyleKTable);
|
||||
val->SetString(style.get());
|
||||
@ -975,7 +975,7 @@ nsComputedDOMStyle::GetFontWeight(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
||||
|
||||
if(font) {
|
||||
const nsCString& str_weight=
|
||||
const nsAFlatCString& str_weight=
|
||||
nsCSSProps::SearchKeywordTable(font->mFont.weight,
|
||||
nsCSSProps::kFontWeightKTable);
|
||||
if(str_weight.Length()>0) {
|
||||
@ -1006,7 +1006,7 @@ nsComputedDOMStyle::GetFontVariant(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font, aFrame);
|
||||
|
||||
if(font) {
|
||||
const nsCString& variant=
|
||||
const nsAFlatCString& variant=
|
||||
nsCSSProps::SearchKeywordTable(font->mFont.variant,
|
||||
nsCSSProps::kFontVariantKTable);
|
||||
val->SetString(variant.get());
|
||||
@ -1032,7 +1032,7 @@ nsComputedDOMStyle::GetBackgroundColor(nsIFrame *aFrame,
|
||||
if(color) {
|
||||
if ((color->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) &&
|
||||
!(color->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT)) {
|
||||
const nsCString& backgroundColor =
|
||||
const nsAFlatCString& backgroundColor =
|
||||
nsCSSProps::SearchKeywordTable(NS_STYLE_BG_COLOR_TRANSPARENT,
|
||||
nsCSSProps::kBackgroundColorKTable);
|
||||
val->SetString(backgroundColor.get());
|
||||
@ -1119,7 +1119,7 @@ nsComputedDOMStyle::GetBorderCollapse(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_TableBorder, (const nsStyleStruct*&)table, aFrame);
|
||||
|
||||
if(table) {
|
||||
const nsCString& ident=
|
||||
const nsAFlatCString& ident=
|
||||
nsCSSProps::SearchKeywordTable(table->mBorderCollapse,
|
||||
nsCSSProps::kBorderCollapseKTable);
|
||||
val->SetString(ident.get());
|
||||
@ -1325,7 +1325,7 @@ nsComputedDOMStyle::GetOutlineStyle(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Outline, (const nsStyleStruct*&)outline, aFrame);
|
||||
|
||||
if(outline) {
|
||||
const nsCString& style=
|
||||
const nsAFlatCString& style=
|
||||
nsCSSProps::SearchKeywordTable(outline->GetOutlineStyle(),
|
||||
nsCSSProps::kBorderStyleKTable);
|
||||
val->SetString(style.get());
|
||||
@ -1429,7 +1429,7 @@ nsComputedDOMStyle::GetTextAlign(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Text, (const nsStyleStruct*&)text, aFrame);
|
||||
|
||||
if(text) {
|
||||
const nsCString& align=
|
||||
const nsAFlatCString& align=
|
||||
nsCSSProps::SearchKeywordTable(text->mTextAlign,
|
||||
nsCSSProps::kTextAlignKTable);
|
||||
val->SetString(align.get());
|
||||
@ -1453,7 +1453,7 @@ nsComputedDOMStyle::GetTextDecoration(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_TextReset,(const nsStyleStruct*&)text,aFrame);
|
||||
|
||||
if(text) {
|
||||
const nsCString& decoration=
|
||||
const nsAFlatCString& decoration=
|
||||
nsCSSProps::SearchKeywordTable(text->mTextDecoration,
|
||||
nsCSSProps::kTextDecorationKTable);
|
||||
val->SetString(decoration.get());
|
||||
@ -1477,7 +1477,7 @@ nsComputedDOMStyle::GetVisibility(nsIFrame *aFrame,
|
||||
GetStyleData(eStyleStruct_Visibility,(const nsStyleStruct*&)visibility,aFrame);
|
||||
|
||||
if(visibility) {
|
||||
const nsCString& value=
|
||||
const nsAFlatCString& value=
|
||||
nsCSSProps::SearchKeywordTable(visibility->mVisible,
|
||||
nsCSSProps::kVisibilityKTable);
|
||||
val->SetString(value.get());
|
||||
@ -2610,7 +2610,7 @@ nsComputedDOMStyle::GetBorderWidthFor(PRUint8 aSide,
|
||||
case eStyleUnit_Enumerated:
|
||||
case eStyleUnit_Chars:
|
||||
{
|
||||
const nsCString& width=
|
||||
const nsAFlatCString& width=
|
||||
nsCSSProps::SearchKeywordTable(coord.GetIntValue(),
|
||||
nsCSSProps::kBorderWidthKTable);
|
||||
val->SetString(width.get()); break;
|
||||
@ -2718,7 +2718,7 @@ nsComputedDOMStyle::GetBorderStyleFor(PRUint8 aSide,
|
||||
GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border, aFrame);
|
||||
|
||||
if(border) {
|
||||
const nsCString& style=
|
||||
const nsAFlatCString& style=
|
||||
nsCSSProps::SearchKeywordTable(border->GetBorderStyle(aSide),
|
||||
nsCSSProps::kBorderStyleKTable);
|
||||
val->SetString(style.get());
|
||||
|
@ -39,8 +39,9 @@
|
||||
#ifndef nsHTMLTags_h___
|
||||
#define nsHTMLTags_h___
|
||||
|
||||
class nsString;
|
||||
class nsCString;
|
||||
class nsAString;
|
||||
class nsACString;
|
||||
class nsAFlatCString;
|
||||
|
||||
/*
|
||||
Declare the enum list using the magic of preprocessing
|
||||
@ -71,9 +72,9 @@ public:
|
||||
static void AddRefTable(void);
|
||||
static void ReleaseTable(void);
|
||||
|
||||
static nsHTMLTag LookupTag(const nsString& aTag);
|
||||
static nsHTMLTag LookupTag(const nsCString& aTag);
|
||||
static const nsCString& GetStringValue(nsHTMLTag aEnum);
|
||||
static nsHTMLTag LookupTag(const nsAString& aTag);
|
||||
static nsHTMLTag LookupTag(const nsACString& aTag);
|
||||
static const nsAFlatCString& GetStringValue(nsHTMLTag aEnum);
|
||||
static const char* GetCStringValue(nsHTMLTag aEnum);
|
||||
};
|
||||
|
||||
|
@ -86,7 +86,7 @@ nsHTMLTags::ReleaseTable(void)
|
||||
}
|
||||
|
||||
nsHTMLTag
|
||||
nsHTMLTags::LookupTag(const nsCString& aTag)
|
||||
nsHTMLTags::LookupTag(const nsACString& aTag)
|
||||
{
|
||||
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
|
||||
if (gTagTable) {
|
||||
@ -111,7 +111,7 @@ nsHTMLTags::LookupTag(const nsCString& aTag)
|
||||
}
|
||||
|
||||
nsHTMLTag
|
||||
nsHTMLTags::LookupTag(const nsString& aTag)
|
||||
nsHTMLTags::LookupTag(const nsAString& aTag)
|
||||
{
|
||||
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
|
||||
if (gTagTable) {
|
||||
@ -140,7 +140,7 @@ nsHTMLTags::LookupTag(const nsString& aTag)
|
||||
return eHTMLTag_userdefined;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsHTMLTags::GetStringValue(nsHTMLTag aTag)
|
||||
{
|
||||
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
|
||||
@ -148,7 +148,7 @@ nsHTMLTags::GetStringValue(nsHTMLTag aTag)
|
||||
// table is zero based, but tags are one based
|
||||
return gTagTable->GetStringValue(PRInt32(aTag)-1);
|
||||
} else {
|
||||
static nsCString kNullStr;
|
||||
static nsDependentCString kNullStr("");
|
||||
return kNullStr;
|
||||
}
|
||||
}
|
||||
|
@ -2267,7 +2267,8 @@ const nsAReadableString& CStyleToken::GetStringValue(void)
|
||||
* @return
|
||||
*/
|
||||
const char* GetTagName(PRInt32 aTag) {
|
||||
const nsCString& result = nsHTMLTags::GetStringValue((nsHTMLTag) aTag);
|
||||
const nsAFlatCString& result =
|
||||
nsHTMLTags::GetStringValue((nsHTMLTag) aTag);
|
||||
if (0 == result.Length()) {
|
||||
if(aTag>=eHTMLTag_userdefined)
|
||||
return gUserdefined;
|
||||
|
@ -37,16 +37,21 @@
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStaticNameTable.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
nsStaticCaseInsensitiveNameTable::nsStaticCaseInsensitiveNameTable()
|
||||
: mNameArray(nsnull), mNameTable(nsnull), mCount(0)
|
||||
: mNameArray(nsnull), mNameTable(nsnull), mCount(0), mNullStr("")
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsStaticCaseInsensitiveNameTable);
|
||||
}
|
||||
|
||||
nsStaticCaseInsensitiveNameTable::~nsStaticCaseInsensitiveNameTable()
|
||||
{
|
||||
delete [] mNameArray;
|
||||
// manually call the destructor on placement-new'ed objects
|
||||
for (PRInt32 index = 0; index < mCount; index++) {
|
||||
mNameArray[index].~nsDependentCString();
|
||||
}
|
||||
nsMemory::Free((void*)mNameArray);
|
||||
delete mNameTable;
|
||||
MOZ_COUNT_DTOR(nsStaticCaseInsensitiveNameTable);
|
||||
}
|
||||
@ -60,7 +65,7 @@ nsStaticCaseInsensitiveNameTable::Init(const char* Names[], PRInt32 Count)
|
||||
NS_ASSERTION(Count, "0 count");
|
||||
|
||||
mCount = Count;
|
||||
mNameArray = new nsCString[Count];
|
||||
mNameArray = (nsDependentCString*)nsMemory::Alloc(Count * sizeof(nsDependentCString));
|
||||
// XXX best bucket count heuristic?
|
||||
mNameTable = new nsHashtable(Count<16 ? Count : Count<128 ? Count/4 : 128);
|
||||
if (!mNameArray || !mNameTable) {
|
||||
@ -70,17 +75,18 @@ nsStaticCaseInsensitiveNameTable::Init(const char* Names[], PRInt32 Count)
|
||||
for (PRInt32 index = 0; index < Count; ++index) {
|
||||
char* raw = (char*) Names[index];
|
||||
PRUint32 len = nsCRT::strlen(raw);
|
||||
nsStr* str = NS_STATIC_CAST(nsStr*, &mNameArray[index]);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
// verify invarients of contents
|
||||
nsCAutoString temp1(raw);
|
||||
nsCAutoString temp2(raw);
|
||||
nsDependentCString temp2(raw);
|
||||
temp1.ToLowerCase();
|
||||
NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
|
||||
}
|
||||
#endif
|
||||
nsStr::Initialize(*str, raw, len, len, eOneByte, PR_FALSE);
|
||||
#endif
|
||||
// use placement-new to initialize the string object
|
||||
nsDependentCString *str =
|
||||
new (&mNameArray[index]) nsDependentCString(raw);
|
||||
nsCStringKey key(raw, len, nsCStringKey::NEVER_OWN);
|
||||
mNameTable->Put(&key, (void*)(index+1)); // to make 0 != nsnull
|
||||
}
|
||||
@ -88,7 +94,7 @@ nsStaticCaseInsensitiveNameTable::Init(const char* Names[], PRInt32 Count)
|
||||
}
|
||||
|
||||
inline PRInt32
|
||||
LookupLowercasedKeyword(const nsCString& aLowercasedKeyword,
|
||||
LookupLowercasedKeyword(const nsACString& aLowercasedKeyword,
|
||||
nsHashtable* aTable)
|
||||
{
|
||||
nsCStringKey key(aLowercasedKeyword);
|
||||
@ -105,7 +111,7 @@ nsStaticCaseInsensitiveNameTable::Lookup(const nsACString& aName)
|
||||
NS_ASSERTION(mCount, "not inited");
|
||||
|
||||
nsCAutoString strLower(aName);
|
||||
strLower.ToLowerCase();
|
||||
ToLowerCase(strLower);
|
||||
return LookupLowercasedKeyword(strLower, mNameTable);
|
||||
}
|
||||
|
||||
@ -118,11 +124,11 @@ nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName)
|
||||
|
||||
nsCAutoString strLower;
|
||||
strLower.AssignWithConversion(aName);
|
||||
strLower.ToLowerCase();
|
||||
ToLowerCase(strLower);
|
||||
return LookupLowercasedKeyword(strLower, mNameTable);
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
const nsAFlatCString&
|
||||
nsStaticCaseInsensitiveNameTable::GetStringValue(PRInt32 index)
|
||||
{
|
||||
NS_ASSERTION(mNameArray, "not inited");
|
||||
|
@ -63,17 +63,16 @@ public:
|
||||
PRBool Init(const char* Names[], PRInt32 Count);
|
||||
PRInt32 Lookup(const nsACString& aName);
|
||||
PRInt32 Lookup(const nsAString& aName);
|
||||
const nsCString& GetStringValue(PRInt32 index);
|
||||
PRBool IsNullString(const nsCString& s) {return s == mNullStr;}
|
||||
const nsAFlatCString& GetStringValue(PRInt32 index);
|
||||
|
||||
nsStaticCaseInsensitiveNameTable();
|
||||
~nsStaticCaseInsensitiveNameTable();
|
||||
|
||||
private:
|
||||
nsCString* mNameArray;
|
||||
nsDependentCString* mNameArray;
|
||||
nsHashtable* mNameTable;
|
||||
PRInt32 mCount;
|
||||
nsCString mNullStr;
|
||||
nsDependentCString mNullStr;
|
||||
};
|
||||
|
||||
#endif /* nsStaticNameTable_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user