Bug 1803968 - [refactor] Migrate NS_STYLE_LIST_STYLE_* defines r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D163792
This commit is contained in:
Ben Freist 2022-12-07 09:58:22 +00:00
Родитель dda315bf6a
Коммит 13d8696801
9 изменённых файлов: 230 добавлений и 233 удалений

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

@ -23,20 +23,17 @@ NS_IMPL_ELEMENT_CLONE(HTMLLIElement)
// values that are handled case-insensitively
static const nsAttrValue::EnumTable kUnorderedListItemTypeTable[] = {
{"disc", NS_STYLE_LIST_STYLE_DISC},
{"circle", NS_STYLE_LIST_STYLE_CIRCLE},
{"round", NS_STYLE_LIST_STYLE_CIRCLE},
{"square", NS_STYLE_LIST_STYLE_SQUARE},
{"disc", ListStyle::Disc},
{"circle", ListStyle::Circle},
{"round", ListStyle::Circle},
{"square", ListStyle::Square},
{nullptr, 0}};
// values that are handled case-sensitively
static const nsAttrValue::EnumTable kOrderedListItemTypeTable[] = {
{"A", NS_STYLE_LIST_STYLE_UPPER_ALPHA},
{"a", NS_STYLE_LIST_STYLE_LOWER_ALPHA},
{"I", NS_STYLE_LIST_STYLE_UPPER_ROMAN},
{"i", NS_STYLE_LIST_STYLE_LOWER_ROMAN},
{"1", NS_STYLE_LIST_STYLE_DECIMAL},
{nullptr, 0}};
{"A", ListStyle::UpperAlpha}, {"a", ListStyle::LowerAlpha},
{"I", ListStyle::UpperRoman}, {"i", ListStyle::LowerRoman},
{"1", ListStyle::Decimal}, {nullptr, 0}};
bool HTMLLIElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,

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

@ -97,8 +97,7 @@ static void DirectoryMapAttributesIntoRule(
aDecls.SetKeywordValue(eCSSProperty_list_style_type,
value->GetEnumValue());
} else {
aDecls.SetKeywordValue(eCSSProperty_list_style_type,
NS_STYLE_LIST_STYLE_DISC);
aDecls.SetKeywordValue(eCSSProperty_list_style_type, ListStyle::Disc);
}
}
}

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

@ -29,25 +29,22 @@ NS_IMPL_ELEMENT_CLONE(HTMLSharedListElement)
// Shared with nsHTMLSharedElement.cpp
nsAttrValue::EnumTable kListTypeTable[] = {
{"none", NS_STYLE_LIST_STYLE_NONE},
{"disc", NS_STYLE_LIST_STYLE_DISC},
{"circle", NS_STYLE_LIST_STYLE_CIRCLE},
{"round", NS_STYLE_LIST_STYLE_CIRCLE},
{"square", NS_STYLE_LIST_STYLE_SQUARE},
{"decimal", NS_STYLE_LIST_STYLE_DECIMAL},
{"lower-roman", NS_STYLE_LIST_STYLE_LOWER_ROMAN},
{"upper-roman", NS_STYLE_LIST_STYLE_UPPER_ROMAN},
{"lower-alpha", NS_STYLE_LIST_STYLE_LOWER_ALPHA},
{"upper-alpha", NS_STYLE_LIST_STYLE_UPPER_ALPHA},
{"none", ListStyle::None},
{"disc", ListStyle::Disc},
{"circle", ListStyle::Circle},
{"round", ListStyle::Circle},
{"square", ListStyle::Square},
{"decimal", ListStyle::Decimal},
{"lower-roman", ListStyle::LowerRoman},
{"upper-roman", ListStyle::UpperRoman},
{"lower-alpha", ListStyle::LowerAlpha},
{"upper-alpha", ListStyle::UpperAlpha},
{nullptr, 0}};
static const nsAttrValue::EnumTable kOldListTypeTable[] = {
{"1", NS_STYLE_LIST_STYLE_DECIMAL},
{"A", NS_STYLE_LIST_STYLE_UPPER_ALPHA},
{"a", NS_STYLE_LIST_STYLE_LOWER_ALPHA},
{"I", NS_STYLE_LIST_STYLE_UPPER_ROMAN},
{"i", NS_STYLE_LIST_STYLE_LOWER_ROMAN},
{nullptr, 0}};
{"1", ListStyle::Decimal}, {"A", ListStyle::UpperAlpha},
{"a", ListStyle::LowerAlpha}, {"I", ListStyle::UpperRoman},
{"i", ListStyle::LowerRoman}, {nullptr, 0}};
bool HTMLSharedListElement::ParseAttribute(
int32_t aNamespaceID, nsAtom* aAttribute, const nsAString& aValue,

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

@ -1758,13 +1758,13 @@ void nsCSSFrameConstructor::CreateGeneratedContentFromListStyleType(
styleList->mCounterStyle);
bool needUseNode = false;
switch (counterStyle->GetStyle()) {
case NS_STYLE_LIST_STYLE_NONE:
case ListStyle::None:
return;
case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_SQUARE:
case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
case ListStyle::Disc:
case ListStyle::Circle:
case ListStyle::Square:
case ListStyle::DisclosureClosed:
case ListStyle::DisclosureOpen:
break;
default:
const auto* anonStyle = counterStyle->AsAnonymous();

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

@ -16,23 +16,23 @@
*/
// none and decimal are not redefinable, so they have to be builtin.
BUILTIN_COUNTER_STYLE(NONE, none)
BUILTIN_COUNTER_STYLE(DECIMAL, decimal)
BUILTIN_COUNTER_STYLE(None, none)
BUILTIN_COUNTER_STYLE(Decimal, decimal)
// the following graphic styles are processed in a different way.
BUILTIN_COUNTER_STYLE(DISC, disc)
BUILTIN_COUNTER_STYLE(CIRCLE, circle)
BUILTIN_COUNTER_STYLE(SQUARE, square)
BUILTIN_COUNTER_STYLE(DISCLOSURE_CLOSED, disclosure_closed)
BUILTIN_COUNTER_STYLE(DISCLOSURE_OPEN, disclosure_open)
BUILTIN_COUNTER_STYLE(Disc, disc)
BUILTIN_COUNTER_STYLE(Circle, circle)
BUILTIN_COUNTER_STYLE(Square, square)
BUILTIN_COUNTER_STYLE(DisclosureClosed, disclosure_closed)
BUILTIN_COUNTER_STYLE(DisclosureOpen, disclosure_open)
// the following counter styles require specific algorithms to generate.
BUILTIN_COUNTER_STYLE(HEBREW, hebrew)
BUILTIN_COUNTER_STYLE(JAPANESE_INFORMAL, japanese_informal)
BUILTIN_COUNTER_STYLE(JAPANESE_FORMAL, japanese_formal)
BUILTIN_COUNTER_STYLE(KOREAN_HANGUL_FORMAL, korean_hangul_formal)
BUILTIN_COUNTER_STYLE(KOREAN_HANJA_INFORMAL, korean_hanja_informal)
BUILTIN_COUNTER_STYLE(KOREAN_HANJA_FORMAL, korean_hanja_formal)
BUILTIN_COUNTER_STYLE(SIMP_CHINESE_INFORMAL, simp_chinese_informal)
BUILTIN_COUNTER_STYLE(SIMP_CHINESE_FORMAL, simp_chinese_formal)
BUILTIN_COUNTER_STYLE(TRAD_CHINESE_INFORMAL, trad_chinese_informal)
BUILTIN_COUNTER_STYLE(TRAD_CHINESE_FORMAL, trad_chinese_formal)
BUILTIN_COUNTER_STYLE(ETHIOPIC_NUMERIC, ethiopic_numeric)
BUILTIN_COUNTER_STYLE(Hebrew, hebrew)
BUILTIN_COUNTER_STYLE(JapaneseInformal, japanese_informal)
BUILTIN_COUNTER_STYLE(JapaneseFormal, japanese_formal)
BUILTIN_COUNTER_STYLE(KoreanHangulFormal, korean_hangul_formal)
BUILTIN_COUNTER_STYLE(KoreanHanjaInformal, korean_hanja_informal)
BUILTIN_COUNTER_STYLE(KoreanHanjaFormal, korean_hanja_formal)
BUILTIN_COUNTER_STYLE(SimpChineseInformal, simp_chinese_informal)
BUILTIN_COUNTER_STYLE(SimpChineseFormal, simp_chinese_formal)
BUILTIN_COUNTER_STYLE(TradChineseInformal, trad_chinese_informal)
BUILTIN_COUNTER_STYLE(TradChineseFormal, trad_chinese_formal)
BUILTIN_COUNTER_STYLE(EthiopicNumeric, ethiopic_numeric)

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

@ -510,7 +510,7 @@ static bool SystemUsesNegativeSign(StyleCounterSystem aSystem) {
class BuiltinCounterStyle : public CounterStyle {
public:
constexpr BuiltinCounterStyle(int32_t aStyle, nsStaticAtom* aName)
constexpr BuiltinCounterStyle(ListStyle aStyle, nsStaticAtom* aName)
: CounterStyle(aStyle), mName(aName) {}
nsStaticAtom* GetStyleName() const { return mName; }
@ -549,31 +549,31 @@ void BuiltinCounterStyle::GetPrefix(nsAString& aResult) { aResult.Truncate(); }
/* virtual */
void BuiltinCounterStyle::GetSuffix(nsAString& aResult) {
switch (mStyle) {
case NS_STYLE_LIST_STYLE_NONE:
case ListStyle::None:
aResult.Truncate();
break;
case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_SQUARE:
case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
case NS_STYLE_LIST_STYLE_ETHIOPIC_NUMERIC:
case ListStyle::Disc:
case ListStyle::Circle:
case ListStyle::Square:
case ListStyle::DisclosureClosed:
case ListStyle::DisclosureOpen:
case ListStyle::EthiopicNumeric:
aResult = ' ';
break;
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
case ListStyle::TradChineseInformal:
case ListStyle::TradChineseFormal:
case ListStyle::SimpChineseInformal:
case ListStyle::SimpChineseFormal:
case ListStyle::JapaneseInformal:
case ListStyle::JapaneseFormal:
aResult = 0x3001;
break;
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
case ListStyle::KoreanHangulFormal:
case ListStyle::KoreanHanjaInformal:
case ListStyle::KoreanHanjaFormal:
aResult.AssignLiteral(u", ");
break;
@ -596,12 +596,12 @@ void BuiltinCounterStyle::GetSpokenCounterText(CounterValue aOrdinal,
nsAString& aResult,
bool& aIsBullet) {
switch (mStyle) {
case NS_STYLE_LIST_STYLE_NONE:
case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_SQUARE:
case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN: {
case ListStyle::None:
case ListStyle::Disc:
case ListStyle::Circle:
case ListStyle::Square:
case ListStyle::DisclosureClosed:
case ListStyle::DisclosureOpen: {
// Same as the initial representation
bool isRTL;
GetInitialCounterText(aOrdinal, aWritingMode, aResult, isRTL);
@ -618,11 +618,11 @@ void BuiltinCounterStyle::GetSpokenCounterText(CounterValue aOrdinal,
/* virtual */
bool BuiltinCounterStyle::IsBullet() {
switch (mStyle) {
case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_SQUARE:
case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
case ListStyle::Disc:
case ListStyle::Circle:
case ListStyle::Square:
case ListStyle::DisclosureClosed:
case ListStyle::DisclosureOpen:
return true;
default:
return false;
@ -639,24 +639,24 @@ static const char16_t gTradChineseNegative[] = {0x8ca0, 0x0000};
/* virtual */
void BuiltinCounterStyle::GetNegative(NegativeType& aResult) {
switch (mStyle) {
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
case ListStyle::JapaneseFormal:
case ListStyle::JapaneseInformal:
aResult.before = gJapaneseNegative;
break;
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
case ListStyle::KoreanHangulFormal:
case ListStyle::KoreanHanjaInformal:
case ListStyle::KoreanHanjaFormal:
aResult.before = gKoreanNegative;
break;
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
case ListStyle::SimpChineseFormal:
case ListStyle::SimpChineseInformal:
aResult.before = gSimpChineseNegative;
break;
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
case ListStyle::TradChineseFormal:
case ListStyle::TradChineseInformal:
aResult.before = gTradChineseNegative;
break;
@ -671,32 +671,32 @@ bool BuiltinCounterStyle::IsOrdinalInRange(CounterValue aOrdinal) {
switch (mStyle) {
default:
// cyclic
case NS_STYLE_LIST_STYLE_NONE:
case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_SQUARE:
case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
case ListStyle::None:
case ListStyle::Disc:
case ListStyle::Circle:
case ListStyle::Square:
case ListStyle::DisclosureClosed:
case ListStyle::DisclosureOpen:
// use DecimalToText
case NS_STYLE_LIST_STYLE_DECIMAL:
case ListStyle::Decimal:
// use CJKIdeographicToText
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
case ListStyle::JapaneseFormal:
case ListStyle::JapaneseInformal:
case ListStyle::KoreanHanjaFormal:
case ListStyle::KoreanHanjaInformal:
case ListStyle::KoreanHangulFormal:
case ListStyle::TradChineseFormal:
case ListStyle::TradChineseInformal:
case ListStyle::SimpChineseFormal:
case ListStyle::SimpChineseInformal:
return true;
// use EthiopicToText
case NS_STYLE_LIST_STYLE_ETHIOPIC_NUMERIC:
case ListStyle::EthiopicNumeric:
return aOrdinal >= 1;
// use HebrewToText
case NS_STYLE_LIST_STYLE_HEBREW:
case ListStyle::Hebrew:
return aOrdinal >= 1 && aOrdinal <= 999999;
}
}
@ -705,31 +705,31 @@ bool BuiltinCounterStyle::IsOrdinalInRange(CounterValue aOrdinal) {
bool BuiltinCounterStyle::IsOrdinalInAutoRange(CounterValue aOrdinal) {
switch (mStyle) {
// cyclic:
case NS_STYLE_LIST_STYLE_NONE:
case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_SQUARE:
case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
case ListStyle::None:
case ListStyle::Disc:
case ListStyle::Circle:
case ListStyle::Square:
case ListStyle::DisclosureClosed:
case ListStyle::DisclosureOpen:
// numeric:
case NS_STYLE_LIST_STYLE_DECIMAL:
case ListStyle::Decimal:
return true;
// additive:
case NS_STYLE_LIST_STYLE_HEBREW:
case ListStyle::Hebrew:
return aOrdinal >= 0;
// complex predefined:
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_ETHIOPIC_NUMERIC:
case ListStyle::JapaneseFormal:
case ListStyle::JapaneseInformal:
case ListStyle::KoreanHanjaFormal:
case ListStyle::KoreanHanjaInformal:
case ListStyle::KoreanHangulFormal:
case ListStyle::TradChineseFormal:
case ListStyle::TradChineseInformal:
case ListStyle::SimpChineseFormal:
case ListStyle::SimpChineseInformal:
case ListStyle::EthiopicNumeric:
return IsOrdinalInRange(aOrdinal);
default:
@ -754,12 +754,12 @@ CounterStyle* BuiltinCounterStyle::GetFallback() {
/* virtual */
SpeakAs BuiltinCounterStyle::GetSpeakAs() {
switch (mStyle) {
case NS_STYLE_LIST_STYLE_NONE:
case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_SQUARE:
case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
case ListStyle::None:
case ListStyle::Disc:
case ListStyle::Circle:
case ListStyle::Square:
case ListStyle::DisclosureClosed:
case ListStyle::DisclosureOpen:
return SpeakAs::Bullets;
default:
return SpeakAs::Numbers;
@ -769,12 +769,12 @@ SpeakAs BuiltinCounterStyle::GetSpeakAs() {
/* virtual */
bool BuiltinCounterStyle::UseNegativeSign() {
switch (mStyle) {
case NS_STYLE_LIST_STYLE_NONE:
case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_SQUARE:
case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
case ListStyle::None:
case ListStyle::Disc:
case ListStyle::Circle:
case ListStyle::Square:
case ListStyle::DisclosureClosed:
case ListStyle::DisclosureOpen:
return false;
default:
return true;
@ -790,19 +790,19 @@ bool BuiltinCounterStyle::GetInitialCounterText(CounterValue aOrdinal,
switch (mStyle) {
// used by counters & extends counter-style code only
// XXX We really need to do this the same way we do list bullets.
case NS_STYLE_LIST_STYLE_NONE:
case ListStyle::None:
aResult.Truncate();
return true;
case NS_STYLE_LIST_STYLE_DISC:
case ListStyle::Disc:
aResult.Assign(kDiscCharacter);
return true;
case NS_STYLE_LIST_STYLE_CIRCLE:
case ListStyle::Circle:
aResult.Assign(kCircleCharacter);
return true;
case NS_STYLE_LIST_STYLE_SQUARE:
case ListStyle::Square:
aResult.Assign(kSquareCharacter);
return true;
case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
case ListStyle::DisclosureClosed:
if (aWritingMode.IsVertical()) {
aResult.Assign(kDownPointingCharacter);
} else if (aWritingMode.IsBidiLTR()) {
@ -811,7 +811,7 @@ bool BuiltinCounterStyle::GetInitialCounterText(CounterValue aOrdinal,
aResult.Assign(kLeftPointingCharacter);
}
return true;
case NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN:
case ListStyle::DisclosureOpen:
if (!aWritingMode.IsVertical()) {
aResult.Assign(kDownPointingCharacter);
} else if (aWritingMode.IsVerticalLR()) {
@ -821,33 +821,33 @@ bool BuiltinCounterStyle::GetInitialCounterText(CounterValue aOrdinal,
}
return true;
case NS_STYLE_LIST_STYLE_DECIMAL:
case ListStyle::Decimal:
return DecimalToText(aOrdinal, aResult);
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
case ListStyle::TradChineseInformal:
return CJKIdeographicToText(aOrdinal, aResult, gDataTradChineseInformal);
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
case ListStyle::TradChineseFormal:
return CJKIdeographicToText(aOrdinal, aResult, gDataTradChineseFormal);
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
case ListStyle::SimpChineseInformal:
return CJKIdeographicToText(aOrdinal, aResult, gDataSimpChineseInformal);
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
case ListStyle::SimpChineseFormal:
return CJKIdeographicToText(aOrdinal, aResult, gDataSimpChineseFormal);
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
case ListStyle::JapaneseInformal:
return CJKIdeographicToText(aOrdinal, aResult, gDataJapaneseInformal);
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
case ListStyle::JapaneseFormal:
return CJKIdeographicToText(aOrdinal, aResult, gDataJapaneseFormal);
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
case ListStyle::KoreanHangulFormal:
return CJKIdeographicToText(aOrdinal, aResult, gDataKoreanHangulFormal);
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
case ListStyle::KoreanHanjaInformal:
return CJKIdeographicToText(aOrdinal, aResult, gDataKoreanHanjaInformal);
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
case ListStyle::KoreanHanjaFormal:
return CJKIdeographicToText(aOrdinal, aResult, gDataKoreanHanjaFormal);
case NS_STYLE_LIST_STYLE_HEBREW:
case ListStyle::Hebrew:
aIsRTL = true;
return HebrewToText(aOrdinal, aResult);
case NS_STYLE_LIST_STYLE_ETHIOPIC_NUMERIC:
case ListStyle::EthiopicNumeric:
return EthiopicToText(aOrdinal, aResult);
default:
@ -858,23 +858,24 @@ bool BuiltinCounterStyle::GetInitialCounterText(CounterValue aOrdinal,
static constexpr BuiltinCounterStyle gBuiltinStyleTable[] = {
#define BUILTIN_COUNTER_STYLE(value_, atom_) \
{NS_STYLE_LIST_STYLE_##value_, nsGkAtoms::atom_},
{ListStyle::value_, nsGkAtoms::atom_},
#include "BuiltinCounterStyleList.h"
#undef BUILTIN_COUNTER_STYLE
};
#define BUILTIN_COUNTER_STYLE(value_, atom_) \
static_assert(gBuiltinStyleTable[NS_STYLE_LIST_STYLE_##value_].GetStyle() == \
NS_STYLE_LIST_STYLE_##value_, \
"Builtin counter style " #atom_ \
" has unmatched index and value.");
static_assert( \
gBuiltinStyleTable[static_cast<size_t>(ListStyle::value_)].GetStyle() == \
ListStyle::value_, \
"Builtin counter style " #atom_ " has unmatched index and value.");
#include "BuiltinCounterStyleList.h"
#undef BUILTIN_COUNTER_STYLE
class DependentBuiltinCounterStyle final : public BuiltinCounterStyle {
public:
DependentBuiltinCounterStyle(int32_t aStyle, CounterStyleManager* aManager)
: BuiltinCounterStyle(gBuiltinStyleTable[aStyle]), mManager(aManager) {
DependentBuiltinCounterStyle(ListStyle aStyle, CounterStyleManager* aManager)
: BuiltinCounterStyle(gBuiltinStyleTable[static_cast<size_t>(aStyle)]),
mManager(aManager) {
NS_ASSERTION(IsDependentStyle(), "Not a dependent builtin style");
MOZ_ASSERT(!IsCustomStyle(), "Not a builtin style");
}
@ -902,15 +903,15 @@ class DependentBuiltinCounterStyle final : public BuiltinCounterStyle {
/* virtual */
CounterStyle* DependentBuiltinCounterStyle::GetFallback() {
switch (GetStyle()) {
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
case ListStyle::JapaneseInformal:
case ListStyle::JapaneseFormal:
case ListStyle::KoreanHangulFormal:
case ListStyle::KoreanHanjaInformal:
case ListStyle::KoreanHanjaFormal:
case ListStyle::SimpChineseInformal:
case ListStyle::SimpChineseFormal:
case ListStyle::TradChineseInformal:
case ListStyle::TradChineseFormal:
// These styles all have a larger range than cjk-decimal, so the
// only case fallback is accessed is that they are extended.
// Since extending styles will cache the data themselves, we need
@ -926,7 +927,7 @@ class CustomCounterStyle final : public CounterStyle {
public:
CustomCounterStyle(CounterStyleManager* aManager,
const RawServoCounterStyleRule* aRule)
: CounterStyle(NS_STYLE_LIST_STYLE_CUSTOM),
: CounterStyle(ListStyle::Custom),
mManager(aManager),
mRule(aRule),
mRuleGeneration(Servo_CounterStyleRule_GetGeneration(aRule)),
@ -1504,7 +1505,7 @@ CounterStyle* CustomCounterStyle::GetExtendsRoot() {
}
AnonymousCounterStyle::AnonymousCounterStyle(const nsAString& aContent)
: CounterStyle(NS_STYLE_LIST_STYLE_CUSTOM),
: CounterStyle(ListStyle::Custom),
mSingleString(true),
mSymbolsType(StyleSymbolsType::Cyclic) {
mSymbols.SetCapacity(1);
@ -1513,7 +1514,7 @@ AnonymousCounterStyle::AnonymousCounterStyle(const nsAString& aContent)
AnonymousCounterStyle::AnonymousCounterStyle(StyleSymbolsType aType,
nsTArray<nsString> aSymbols)
: CounterStyle(NS_STYLE_LIST_STYLE_CUSTOM),
: CounterStyle(ListStyle::Custom),
mSingleString(false),
mSymbolsType(aType),
mSymbols(std::move(aSymbols)) {}
@ -1627,17 +1628,17 @@ bool AnonymousCounterStyle::GetInitialCounterText(CounterValue aOrdinal,
bool CounterStyle::IsDependentStyle() const {
switch (mStyle) {
// CustomCounterStyle
case NS_STYLE_LIST_STYLE_CUSTOM:
case ListStyle::Custom:
// DependentBuiltinCounterStyle
case NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL:
case NS_STYLE_LIST_STYLE_JAPANESE_FORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL:
case NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL:
case NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL:
case ListStyle::JapaneseInformal:
case ListStyle::JapaneseFormal:
case ListStyle::KoreanHangulFormal:
case ListStyle::KoreanHanjaInformal:
case ListStyle::KoreanHanjaFormal:
case ListStyle::SimpChineseInformal:
case ListStyle::SimpChineseFormal:
case ListStyle::TradChineseInformal:
case ListStyle::TradChineseFormal:
return true;
// BuiltinCounterStyle
@ -1795,7 +1796,7 @@ CounterStyle* CounterStyleManager::ResolveCounterStyle(nsAtom* aName) {
} else {
for (const BuiltinCounterStyle& item : gBuiltinStyleTable) {
if (item.GetStyleName() == aName) {
int32_t style = item.GetStyle();
const auto style = item.GetStyle();
data = item.IsDependentStyle()
? new (mPresContext)
DependentBuiltinCounterStyle(style, this)
@ -1812,14 +1813,14 @@ CounterStyle* CounterStyleManager::ResolveCounterStyle(nsAtom* aName) {
}
/* static */
CounterStyle* CounterStyleManager::GetBuiltinStyle(int32_t aStyle) {
MOZ_ASSERT(0 <= aStyle && size_t(aStyle) < sizeof(gBuiltinStyleTable),
CounterStyle* CounterStyleManager::GetBuiltinStyle(ListStyle aStyle) {
MOZ_ASSERT(0 <= size_t(aStyle) && size_t(aStyle) < sizeof(gBuiltinStyleTable),
"Require a valid builtin style constant");
MOZ_ASSERT(!gBuiltinStyleTable[aStyle].IsDependentStyle(),
MOZ_ASSERT(!gBuiltinStyleTable[size_t(aStyle)].IsDependentStyle(),
"Cannot get dependent builtin style");
// No method of BuiltinCounterStyle mutates the struct itself, so it
// should be fine to cast const away.
return const_cast<BuiltinCounterStyle*>(&gBuiltinStyleTable[aStyle]);
return const_cast<BuiltinCounterStyle*>(&gBuiltinStyleTable[size_t(aStyle)]);
}
bool CounterStyleManager::NotifyRuleChanged() {

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

@ -40,16 +40,16 @@ struct PadType;
class CounterStyle {
protected:
explicit constexpr CounterStyle(int32_t aStyle) : mStyle(aStyle) {}
explicit constexpr CounterStyle(ListStyle aStyle) : mStyle(aStyle) {}
private:
CounterStyle(const CounterStyle& aOther) = delete;
void operator=(const CounterStyle& other) = delete;
public:
constexpr int32_t GetStyle() const { return mStyle; }
bool IsNone() const { return mStyle == NS_STYLE_LIST_STYLE_NONE; }
bool IsCustomStyle() const { return mStyle == NS_STYLE_LIST_STYLE_CUSTOM; }
constexpr ListStyle GetStyle() const { return mStyle; }
bool IsNone() const { return mStyle == ListStyle::None; }
bool IsCustomStyle() const { return mStyle == ListStyle::Custom; }
// A style is dependent if it depends on the counter style manager.
// Custom styles are certainly dependent. In addition, some builtin
// styles are dependent for fallback.
@ -95,7 +95,7 @@ class CounterStyle {
virtual AnonymousCounterStyle* AsAnonymous() { return nullptr; }
protected:
const int32_t mStyle;
const ListStyle mStyle;
};
class AnonymousCounterStyle final : public CounterStyle {
@ -318,15 +318,15 @@ class CounterStyleManager final {
return aPtr.AsAnonymous();
}
static CounterStyle* GetBuiltinStyle(int32_t aStyle);
static CounterStyle* GetBuiltinStyle(ListStyle aStyle);
static CounterStyle* GetNoneStyle() {
return GetBuiltinStyle(NS_STYLE_LIST_STYLE_NONE);
return GetBuiltinStyle(ListStyle::None);
}
static CounterStyle* GetDecimalStyle() {
return GetBuiltinStyle(NS_STYLE_LIST_STYLE_DECIMAL);
return GetBuiltinStyle(ListStyle::Decimal);
}
static CounterStyle* GetDiscStyle() {
return GetBuiltinStyle(NS_STYLE_LIST_STYLE_DISC);
return GetBuiltinStyle(ListStyle::Disc);
}
// This method will scan all existing counter styles generated by this

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

@ -412,31 +412,33 @@ enum class ScrollingAttribute : uint8_t {
};
// See nsStyleList
#define NS_STYLE_LIST_STYLE_CUSTOM -1 // for @counter-style
#define NS_STYLE_LIST_STYLE_NONE 0
#define NS_STYLE_LIST_STYLE_DECIMAL 1
#define NS_STYLE_LIST_STYLE_DISC 2
#define NS_STYLE_LIST_STYLE_CIRCLE 3
#define NS_STYLE_LIST_STYLE_SQUARE 4
#define NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED 5
#define NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN 6
#define NS_STYLE_LIST_STYLE_HEBREW 7
#define NS_STYLE_LIST_STYLE_JAPANESE_INFORMAL 8
#define NS_STYLE_LIST_STYLE_JAPANESE_FORMAL 9
#define NS_STYLE_LIST_STYLE_KOREAN_HANGUL_FORMAL 10
#define NS_STYLE_LIST_STYLE_KOREAN_HANJA_INFORMAL 11
#define NS_STYLE_LIST_STYLE_KOREAN_HANJA_FORMAL 12
#define NS_STYLE_LIST_STYLE_SIMP_CHINESE_INFORMAL 13
#define NS_STYLE_LIST_STYLE_SIMP_CHINESE_FORMAL 14
#define NS_STYLE_LIST_STYLE_TRAD_CHINESE_INFORMAL 15
#define NS_STYLE_LIST_STYLE_TRAD_CHINESE_FORMAL 16
#define NS_STYLE_LIST_STYLE_ETHIOPIC_NUMERIC 17
// These styles are handled as custom styles defined in counterstyles.css.
// They are preserved here only for html attribute map.
#define NS_STYLE_LIST_STYLE_LOWER_ROMAN 100
#define NS_STYLE_LIST_STYLE_UPPER_ROMAN 101
#define NS_STYLE_LIST_STYLE_LOWER_ALPHA 102
#define NS_STYLE_LIST_STYLE_UPPER_ALPHA 103
enum class ListStyle : uint8_t {
Custom = 255, // for @counter-style
None = 0,
Decimal,
Disc,
Circle,
Square,
DisclosureClosed,
DisclosureOpen,
Hebrew,
JapaneseInformal,
JapaneseFormal,
KoreanHangulFormal,
KoreanHanjaInformal,
KoreanHanjaFormal,
SimpChineseInformal,
SimpChineseFormal,
TradChineseInformal,
TradChineseFormal,
EthiopicNumeric,
// These styles are handled as custom styles defined in counterstyles.css.
// They are preserved here only for html attribute map.
LowerRoman = 100,
UpperRoman,
LowerAlpha,
UpperAlpha
};
// See nsStyleList
#define NS_STYLE_LIST_STYLE_POSITION_INSIDE 0

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

@ -50,20 +50,21 @@ impl ListStyleType {
/// attribute is considered here.
pub fn from_gecko_keyword(value: u32) -> Self {
use crate::gecko_bindings::structs;
let v8 = value as u8;
if value == structs::NS_STYLE_LIST_STYLE_NONE {
if v8 == structs::ListStyle_None {
return ListStyleType::None;
}
ListStyleType::CounterStyle(CounterStyle::Name(CustomIdent(match value {
structs::NS_STYLE_LIST_STYLE_DISC => atom!("disc"),
structs::NS_STYLE_LIST_STYLE_CIRCLE => atom!("circle"),
structs::NS_STYLE_LIST_STYLE_SQUARE => atom!("square"),
structs::NS_STYLE_LIST_STYLE_DECIMAL => atom!("decimal"),
structs::NS_STYLE_LIST_STYLE_LOWER_ROMAN => atom!("lower-roman"),
structs::NS_STYLE_LIST_STYLE_UPPER_ROMAN => atom!("upper-roman"),
structs::NS_STYLE_LIST_STYLE_LOWER_ALPHA => atom!("lower-alpha"),
structs::NS_STYLE_LIST_STYLE_UPPER_ALPHA => atom!("upper-alpha"),
ListStyleType::CounterStyle(CounterStyle::Name(CustomIdent(match v8 {
structs::ListStyle_Disc => atom!("disc"),
structs::ListStyle_Circle => atom!("circle"),
structs::ListStyle_Square => atom!("square"),
structs::ListStyle_Decimal => atom!("decimal"),
structs::ListStyle_LowerRoman => atom!("lower-roman"),
structs::ListStyle_UpperRoman => atom!("upper-roman"),
structs::ListStyle_LowerAlpha => atom!("lower-alpha"),
structs::ListStyle_UpperAlpha => atom!("upper-alpha"),
_ => unreachable!("Unknown counter style keyword value"),
})))
}