зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1362302 part 1 - Use nsIAtom for counter style names. r=dbaron
MozReview-Commit-ID: 5VK6BgGRVRs --HG-- extra : rebase_source : 104a28eddeb7984bd9f691693cf8debc1387fb87
This commit is contained in:
Родитель
419312acef
Коммит
98f239480d
|
@ -200,6 +200,7 @@ GK_ATOM(exposeToUntrustedContent, "exposeToUntrustedContent")
|
|||
GK_ATOM(circ, "circ")
|
||||
GK_ATOM(circle, "circle")
|
||||
GK_ATOM(cite, "cite")
|
||||
GK_ATOM(cjkDecimal, "cjk-decimal")
|
||||
GK_ATOM(_class, "class")
|
||||
GK_ATOM(classid, "classid")
|
||||
GK_ATOM(clear, "clear")
|
||||
|
@ -273,6 +274,7 @@ GK_ATOM(datetimebox, "datetimebox")
|
|||
GK_ATOM(dblclick, "dblclick")
|
||||
GK_ATOM(dd, "dd")
|
||||
GK_ATOM(debug, "debug")
|
||||
GK_ATOM(decimal, "decimal")
|
||||
GK_ATOM(decimalFormat, "decimal-format")
|
||||
GK_ATOM(decimalSeparator, "decimal-separator")
|
||||
GK_ATOM(deck, "deck")
|
||||
|
@ -562,7 +564,9 @@ GK_ATOM(localName, "local-name")
|
|||
GK_ATOM(longdesc, "longdesc")
|
||||
GK_ATOM(loop, "loop")
|
||||
GK_ATOM(low, "low")
|
||||
GK_ATOM(lowerAlpha, "lower-alpha")
|
||||
GK_ATOM(lowerFirst, "lower-first")
|
||||
GK_ATOM(lowerRoman, "lower-roman")
|
||||
GK_ATOM(lowest, "lowest")
|
||||
GK_ATOM(lowsrc, "lowsrc")
|
||||
GK_ATOM(ltr, "ltr")
|
||||
|
@ -1288,7 +1292,9 @@ GK_ATOM(underflow, "underflow")
|
|||
GK_ATOM(undetermined, "undetermined")
|
||||
GK_ATOM(unload, "unload")
|
||||
GK_ATOM(unparsedEntityUri, "unparsed-entity-uri")
|
||||
GK_ATOM(upperAlpha, "upper-alpha")
|
||||
GK_ATOM(upperFirst, "upper-first")
|
||||
GK_ATOM(upperRoman, "upper-roman")
|
||||
GK_ATOM(uri, "uri")
|
||||
GK_ATOM(use, "use")
|
||||
GK_ATOM(useAttributeSets, "use-attribute-sets")
|
||||
|
@ -1392,6 +1398,7 @@ GK_ATOM(diffuseConstant, "diffuseConstant")
|
|||
GK_ATOM(dilate, "dilate")
|
||||
GK_ATOM(direction, "direction")
|
||||
GK_ATOM(disable, "disable")
|
||||
GK_ATOM(disc, "disc")
|
||||
GK_ATOM(discrete, "discrete")
|
||||
GK_ATOM(divisor, "divisor")
|
||||
GK_ATOM(dominant_baseline, "dominant-baseline")
|
||||
|
|
|
@ -49,10 +49,8 @@ nsCounterUseNode::GetCounterStyle()
|
|||
if (!mCounterStyle) {
|
||||
const nsCSSValue& style = mCounterFunction->Item(mAllCounters ? 2 : 1);
|
||||
CounterStyleManager* manager = mPresContext->CounterStyleManager();
|
||||
if (style.GetUnit() == eCSSUnit_Ident) {
|
||||
nsString ident;
|
||||
style.GetStringValue(ident);
|
||||
mCounterStyle = manager->BuildCounterStyle(ident);
|
||||
if (style.GetUnit() == eCSSUnit_AtomIdent) {
|
||||
mCounterStyle = manager->BuildCounterStyle(style.GetAtomValue());
|
||||
} else if (style.GetUnit() == eCSSUnit_Symbols) {
|
||||
mCounterStyle = new AnonymousCounterStyle(style.GetArrayValue());
|
||||
} else {
|
||||
|
|
|
@ -1020,7 +1020,7 @@ DependentBuiltinCounterStyle::GetFallback()
|
|||
// only case fallback is accessed is that they are extended.
|
||||
// Since extending styles will cache the data themselves, we need
|
||||
// not cache it here.
|
||||
return mManager->BuildCounterStyle(NS_LITERAL_STRING("cjk-decimal"));
|
||||
return mManager->BuildCounterStyle(nsGkAtoms::cjkDecimal);
|
||||
default:
|
||||
NS_NOTREACHED("Not a valid dependent builtin style");
|
||||
return BuiltinCounterStyle::GetFallback();
|
||||
|
@ -1032,7 +1032,7 @@ class CustomCounterStyle final : public CounterStyle
|
|||
private:
|
||||
~CustomCounterStyle() {}
|
||||
public:
|
||||
CustomCounterStyle(const nsAString& aName,
|
||||
CustomCounterStyle(nsIAtom* aName,
|
||||
CounterStyleManager* aManager,
|
||||
nsCSSCounterStyleRule* aRule)
|
||||
: CounterStyle(NS_STYLE_LIST_STYLE_CUSTOM),
|
||||
|
@ -1134,7 +1134,7 @@ private:
|
|||
CounterStyle* GetExtends();
|
||||
CounterStyle* GetExtendsRoot();
|
||||
|
||||
nsString mName;
|
||||
nsCOMPtr<nsIAtom> mName;
|
||||
|
||||
// CounterStyleManager should always overlive any CounterStyle as it
|
||||
// is owned by nsPresContext, and will be released after all nodes and
|
||||
|
@ -1234,7 +1234,8 @@ CustomCounterStyle::ResetDependentData()
|
|||
/* virtual */ void
|
||||
CustomCounterStyle::GetStyleName(nsSubstring& aResult)
|
||||
{
|
||||
aResult.Assign(mName);
|
||||
nsDependentAtomString name(mName);
|
||||
aResult.Assign(name);
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
|
@ -1412,13 +1413,15 @@ CustomCounterStyle::GetFallback()
|
|||
{
|
||||
if (!mFallback) {
|
||||
const nsCSSValue& value = mRule->GetDesc(eCSSCounterDesc_Fallback);
|
||||
if (value.UnitHasStringValue()) {
|
||||
mFallback = mManager->BuildCounterStyle(
|
||||
nsDependentString(value.GetStringBufferValue()));
|
||||
mFallback = CounterStyleManager::GetDecimalStyle();
|
||||
if (value.GetUnit() != eCSSUnit_Null) {
|
||||
if (value.GetUnit() == eCSSUnit_AtomIdent) {
|
||||
mFallback = mManager->BuildCounterStyle(value.GetAtomValue());
|
||||
} else {
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown unit!");
|
||||
}
|
||||
} else if (IsExtendsSystem()) {
|
||||
mFallback = GetExtends()->GetFallback();
|
||||
} else {
|
||||
mFallback = CounterStyleManager::GetDecimalStyle();
|
||||
}
|
||||
}
|
||||
return mFallback;
|
||||
|
@ -1554,10 +1557,9 @@ CustomCounterStyle::ComputeRawSpeakAs(uint8_t& aSpeakAs,
|
|||
case eCSSUnit_Enumerated:
|
||||
aSpeakAs = value.GetIntValue();
|
||||
break;
|
||||
case eCSSUnit_Ident:
|
||||
case eCSSUnit_AtomIdent:
|
||||
aSpeakAs = NS_STYLE_COUNTER_SPEAKAS_OTHER;
|
||||
aSpeakAsCounter = mManager->BuildCounterStyle(
|
||||
nsDependentString(value.GetStringBufferValue()));
|
||||
aSpeakAsCounter = mManager->BuildCounterStyle(value.GetAtomValue());
|
||||
break;
|
||||
case eCSSUnit_Null: {
|
||||
if (!IsExtendsSystem()) {
|
||||
|
@ -1664,8 +1666,7 @@ CustomCounterStyle::ComputeExtends()
|
|||
}
|
||||
|
||||
const nsCSSValue& value = mRule->GetSystemArgument();
|
||||
CounterStyle* nextCounter = mManager->BuildCounterStyle(
|
||||
nsDependentString(value.GetStringBufferValue()));
|
||||
CounterStyle* nextCounter = mManager->BuildCounterStyle(value.GetAtomValue());
|
||||
CounterStyle* target = nextCounter;
|
||||
if (nextCounter->IsCustomStyle()) {
|
||||
mFlags |= FLAG_EXTENDS_VISITED;
|
||||
|
@ -1986,8 +1987,8 @@ CounterStyleManager::CounterStyleManager(nsPresContext* aPresContext)
|
|||
: mPresContext(aPresContext)
|
||||
{
|
||||
// Insert the static styles into cache table
|
||||
mCacheTable.Put(NS_LITERAL_STRING("none"), GetNoneStyle());
|
||||
mCacheTable.Put(NS_LITERAL_STRING("decimal"), GetDecimalStyle());
|
||||
mCacheTable.Put(nsGkAtoms::none, GetNoneStyle());
|
||||
mCacheTable.Put(nsGkAtoms::decimal, GetDecimalStyle());
|
||||
}
|
||||
|
||||
CounterStyleManager::~CounterStyleManager()
|
||||
|
@ -2020,7 +2021,7 @@ CounterStyleManager::Disconnect()
|
|||
}
|
||||
|
||||
CounterStyle*
|
||||
CounterStyleManager::BuildCounterStyle(const nsSubstring& aName)
|
||||
CounterStyleManager::BuildCounterStyle(nsIAtom* aName)
|
||||
{
|
||||
CounterStyle* data = mCacheTable.GetWeak(aName);
|
||||
if (data) {
|
||||
|
@ -2040,10 +2041,12 @@ CounterStyleManager::BuildCounterStyle(const nsSubstring& aName)
|
|||
nsCSSCounterStyleRule* rule = styleSet->IsGecko() ?
|
||||
styleSet->AsGecko()->CounterStyleRuleForName(aName) : nullptr;
|
||||
if (rule) {
|
||||
MOZ_ASSERT(rule->Name() == aName);
|
||||
data = new (mPresContext) CustomCounterStyle(aName, this, rule);
|
||||
} else {
|
||||
int32_t type;
|
||||
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(aName);
|
||||
nsDependentAtomString name(aName);
|
||||
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(name);
|
||||
if (nsCSSProps::FindKeyword(keyword, nsCSSProps::kListStyleKTable, type)) {
|
||||
if (gBuiltinStyleTable[type].IsDependentStyle()) {
|
||||
data = new (mPresContext) DependentBuiltinCounterStyle(type, this);
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
return mCacheTable.Count() == 2;
|
||||
}
|
||||
|
||||
CounterStyle* BuildCounterStyle(const nsSubstring& aName);
|
||||
CounterStyle* BuildCounterStyle(nsIAtom* aName);
|
||||
|
||||
static CounterStyle* GetBuiltinStyle(int32_t aStyle);
|
||||
static CounterStyle* GetNoneStyle()
|
||||
|
@ -183,7 +183,7 @@ public:
|
|||
|
||||
private:
|
||||
nsPresContext* mPresContext;
|
||||
nsRefPtrHashtable<nsStringHashKey, CounterStyle> mCacheTable;
|
||||
nsRefPtrHashtable<nsRefPtrHashKey<nsIAtom>, CounterStyle> mCacheTable;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -263,9 +263,8 @@ public:
|
|||
nsIURI* aBaseURL,
|
||||
nsIPrincipal* aDocPrincipal);
|
||||
|
||||
bool ParseCounterStyleName(const nsAString& aBuffer,
|
||||
nsIURI* aURL,
|
||||
nsAString& aName);
|
||||
already_AddRefed<nsIAtom> ParseCounterStyleName(const nsAString& aBuffer,
|
||||
nsIURI* aURL);
|
||||
|
||||
bool ParseCounterDescriptor(nsCSSCounterDesc aDescID,
|
||||
const nsAString& aBuffer,
|
||||
|
@ -707,7 +706,7 @@ protected:
|
|||
SupportsConditionTermOperator aOperator);
|
||||
|
||||
bool ParseCounterStyleRule(RuleAppendFunc aAppendFunc, void* aProcessData);
|
||||
bool ParseCounterStyleName(nsAString& aName, bool aForDefinition);
|
||||
already_AddRefed<nsIAtom> ParseCounterStyleName(bool aForDefinition);
|
||||
bool ParseCounterStyleNameValue(nsCSSValue& aValue);
|
||||
bool ParseCounterDescriptor(nsCSSCounterStyleRule *aRule);
|
||||
bool ParseCounterDescriptorValue(nsCSSCounterDesc aDescID,
|
||||
|
@ -3043,21 +3042,20 @@ CSSParserImpl::ParsePropertyWithVariableReferences(
|
|||
mTempData.AssertInitialState();
|
||||
}
|
||||
|
||||
bool
|
||||
CSSParserImpl::ParseCounterStyleName(const nsAString& aBuffer,
|
||||
nsIURI* aURL,
|
||||
nsAString& aName)
|
||||
already_AddRefed<nsIAtom>
|
||||
CSSParserImpl::ParseCounterStyleName(const nsAString& aBuffer, nsIURI* aURL)
|
||||
{
|
||||
nsCSSScanner scanner(aBuffer, 0);
|
||||
css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURL);
|
||||
InitScanner(scanner, reporter, aURL, aURL, nullptr);
|
||||
|
||||
bool success = ParseCounterStyleName(aName, true) && !GetToken(true);
|
||||
nsCOMPtr<nsIAtom> name = ParseCounterStyleName(true);
|
||||
bool success = name && !GetToken(true);
|
||||
|
||||
OUTPUT_ERROR();
|
||||
ReleaseScanner();
|
||||
|
||||
return success;
|
||||
return success ? name.forget() : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -4829,10 +4827,10 @@ CSSParserImpl::ParseSupportsConditionTermsAfterOperator(
|
|||
bool
|
||||
CSSParserImpl::ParseCounterStyleRule(RuleAppendFunc aAppendFunc, void* aData)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
uint32_t linenum, colnum;
|
||||
if (!GetNextTokenLocation(true, &linenum, &colnum) ||
|
||||
!ParseCounterStyleName(name, true)) {
|
||||
!(name = ParseCounterStyleName(true))) {
|
||||
REPORT_UNEXPECTED_TOKEN(PECounterStyleNotIdent);
|
||||
return false;
|
||||
}
|
||||
|
@ -4914,16 +4912,16 @@ CSSParserImpl::ParseCounterStyleRule(RuleAppendFunc aAppendFunc, void* aData)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CSSParserImpl::ParseCounterStyleName(nsAString& aName, bool aForDefinition)
|
||||
already_AddRefed<nsIAtom>
|
||||
CSSParserImpl::ParseCounterStyleName(bool aForDefinition)
|
||||
{
|
||||
if (!GetToken(true)) {
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mToken.mType != eCSSToken_Ident) {
|
||||
UngetToken();
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const nsCSSKeyword kReservedNames[] = {
|
||||
|
@ -4937,22 +4935,21 @@ CSSParserImpl::ParseCounterStyleName(nsAString& aName, bool aForDefinition)
|
|||
aForDefinition ? kReservedNames : nullptr)) {
|
||||
REPORT_UNEXPECTED_TOKEN(PECounterStyleBadName);
|
||||
UngetToken();
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aName = mToken.mIdent;
|
||||
if (nsCSSProps::IsPredefinedCounterStyle(aName)) {
|
||||
ToLowerCase(aName);
|
||||
nsString name = mToken.mIdent;
|
||||
if (nsCSSProps::IsPredefinedCounterStyle(name)) {
|
||||
ToLowerCase(name);
|
||||
}
|
||||
return true;
|
||||
return NS_Atomize(name);
|
||||
}
|
||||
|
||||
bool
|
||||
CSSParserImpl::ParseCounterStyleNameValue(nsCSSValue& aValue)
|
||||
{
|
||||
nsString name;
|
||||
if (ParseCounterStyleName(name, false)) {
|
||||
aValue.SetStringValue(name, eCSSUnit_Ident);
|
||||
if (nsCOMPtr<nsIAtom> name = ParseCounterStyleName(false)) {
|
||||
aValue.SetAtomIdentValue(name.forget());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -8046,7 +8043,7 @@ CSSParserImpl::ParseCounter(nsCSSValue& aValue)
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
type.SetStringValue(NS_LITERAL_STRING("decimal"), eCSSUnit_Ident);
|
||||
type.SetAtomIdentValue(do_AddRef(nsGkAtoms::decimal));
|
||||
}
|
||||
|
||||
if (!ExpectSymbol(')', true)) {
|
||||
|
@ -15281,9 +15278,8 @@ CSSParserImpl::ParseListStyle()
|
|||
}
|
||||
if ((found & 4) == 0) {
|
||||
// Provide default values
|
||||
nsString type = (found & 1) ?
|
||||
NS_LITERAL_STRING("none") : NS_LITERAL_STRING("disc");
|
||||
values[2].SetStringValue(type, eCSSUnit_Ident);
|
||||
nsIAtom* type = (found & 1) ? nsGkAtoms::none : nsGkAtoms::disc;
|
||||
values[2].SetAtomIdentValue(do_AddRef(type));
|
||||
}
|
||||
if ((found & 8) == 0) {
|
||||
values[3].SetNoneValue();
|
||||
|
@ -18222,13 +18218,11 @@ nsCSSParser::ParsePropertyWithVariableReferences(
|
|||
aLineNumber, aLineOffset);
|
||||
}
|
||||
|
||||
bool
|
||||
nsCSSParser::ParseCounterStyleName(const nsAString& aBuffer,
|
||||
nsIURI* aURL,
|
||||
nsAString& aName)
|
||||
already_AddRefed<nsIAtom>
|
||||
nsCSSParser::ParseCounterStyleName(const nsAString& aBuffer, nsIURI* aURL)
|
||||
{
|
||||
return static_cast<CSSParserImpl*>(mImpl)->
|
||||
ParseCounterStyleName(aBuffer, aURL, aName);
|
||||
ParseCounterStyleName(aBuffer, aURL);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -304,9 +304,11 @@ public:
|
|||
uint32_t aLineNumber,
|
||||
uint32_t aLineOffset);
|
||||
|
||||
bool ParseCounterStyleName(const nsAString& aBuffer,
|
||||
nsIURI* aURL,
|
||||
nsAString& aName);
|
||||
/**
|
||||
* Parses a string as a counter-style name. Returns nullptr if fails.
|
||||
*/
|
||||
already_AddRefed<nsIAtom> ParseCounterStyleName(const nsAString& aBuffer,
|
||||
nsIURI* aURL);
|
||||
|
||||
bool ParseCounterDescriptor(nsCSSCounterDesc aDescID,
|
||||
const nsAString& aBuffer,
|
||||
|
|
|
@ -893,7 +893,11 @@ struct RuleCascadeData {
|
|||
nsTArray<nsCSSCounterStyleRule*> mCounterStyleRules;
|
||||
|
||||
nsDataHashtable<nsStringHashKey, nsCSSKeyframesRule*> mKeyframesRuleTable;
|
||||
nsDataHashtable<nsStringHashKey, nsCSSCounterStyleRule*> mCounterStyleRuleTable;
|
||||
// The hashtable doesn't need to hold a strong reference to the name
|
||||
// atom, because nsCSSCounterStyleRule always does. If the name changes
|
||||
// we need to discard this table and rebuild it anyway.
|
||||
nsDataHashtable<nsPtrHashKey<nsIAtom>,
|
||||
nsCSSCounterStyleRule*> mCounterStyleRuleTable;
|
||||
|
||||
// Looks up or creates the appropriate list in |mAttributeSelectors|.
|
||||
// Returns null only on allocation failure.
|
||||
|
@ -3118,7 +3122,7 @@ nsCSSRuleProcessor::KeyframesRuleForName(nsPresContext* aPresContext,
|
|||
|
||||
nsCSSCounterStyleRule*
|
||||
nsCSSRuleProcessor::CounterStyleRuleForName(nsPresContext* aPresContext,
|
||||
const nsAString& aName)
|
||||
nsIAtom* aName)
|
||||
{
|
||||
RuleCascadeData* cascade = GetRuleCascade(aPresContext);
|
||||
|
||||
|
@ -3837,7 +3841,7 @@ nsCSSRuleProcessor::RefreshRuleCascade(nsPresContext* aPresContext)
|
|||
for (nsTArray<nsCSSCounterStyleRule*>::size_type i = 0,
|
||||
iEnd = newCascade->mCounterStyleRules.Length(); i < iEnd; ++i) {
|
||||
nsCSSCounterStyleRule* rule = newCascade->mCounterStyleRules[i];
|
||||
newCascade->mCounterStyleRuleTable.Put(rule->GetName(), rule);
|
||||
newCascade->mCounterStyleRuleTable.Put(rule->Name(), rule);
|
||||
}
|
||||
|
||||
// mMustGatherDocumentRules controls whether we build mDocumentRules
|
||||
|
|
|
@ -210,7 +210,7 @@ public:
|
|||
const nsString& aName);
|
||||
|
||||
nsCSSCounterStyleRule* CounterStyleRuleForName(nsPresContext* aPresContext,
|
||||
const nsAString& aName);
|
||||
nsIAtom* aName);
|
||||
|
||||
bool AppendPageRules(nsPresContext* aPresContext,
|
||||
nsTArray<nsCSSPageRule*>& aArray);
|
||||
|
|
|
@ -2425,8 +2425,9 @@ nsCSSCounterStyleRule::List(FILE* out, int32_t aIndent) const
|
|||
descInd = baseInd;
|
||||
descInd.AppendLiteral(" ");
|
||||
|
||||
nsDependentAtomString name(mName);
|
||||
fprintf_stderr(out, "%s@counter-style %s (rev.%u) {\n",
|
||||
baseInd.get(), NS_ConvertUTF16toUTF8(mName).get(),
|
||||
baseInd.get(), NS_ConvertUTF16toUTF8(name).get(),
|
||||
mGeneration);
|
||||
// TODO
|
||||
fprintf_stderr(out, "%s}\n", baseInd.get());
|
||||
|
@ -2449,7 +2450,8 @@ void
|
|||
nsCSSCounterStyleRule::GetCssTextImpl(nsAString& aCssText) const
|
||||
{
|
||||
aCssText.AssignLiteral(u"@counter-style ");
|
||||
nsStyleUtil::AppendEscapedCSSIdent(mName, aCssText);
|
||||
nsDependentAtomString name(mName);
|
||||
nsStyleUtil::AppendEscapedCSSIdent(name, aCssText);
|
||||
aCssText.AppendLiteral(u" {\n");
|
||||
for (nsCSSCounterDesc id = nsCSSCounterDesc(0);
|
||||
id < eCSSCounterDesc_COUNT;
|
||||
|
@ -2475,7 +2477,8 @@ NS_IMETHODIMP
|
|||
nsCSSCounterStyleRule::GetName(nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
nsStyleUtil::AppendEscapedCSSIdent(mName, aName);
|
||||
nsDependentAtomString name(mName);
|
||||
nsStyleUtil::AppendEscapedCSSIdent(name, aName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2483,8 +2486,7 @@ NS_IMETHODIMP
|
|||
nsCSSCounterStyleRule::SetName(const nsAString& aName)
|
||||
{
|
||||
nsCSSParser parser;
|
||||
nsAutoString name;
|
||||
if (parser.ParseCounterStyleName(aName, nullptr, name)) {
|
||||
if (nsCOMPtr<nsIAtom> name = parser.ParseCounterStyleName(aName, nullptr)) {
|
||||
nsIDocument* doc = GetDocument();
|
||||
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
|
||||
|
||||
|
@ -2675,13 +2677,18 @@ nsCSSCounterStyleRule::GetSpeakAs(nsAString& aSpeakAs)
|
|||
break;
|
||||
|
||||
case eCSSUnit_Auto:
|
||||
case eCSSUnit_Ident:
|
||||
case eCSSUnit_AtomIdent:
|
||||
aSpeakAs.Truncate();
|
||||
value.AppendToString(eCSSProperty_UNKNOWN,
|
||||
aSpeakAs, nsCSSValue::eNormalized);
|
||||
break;
|
||||
|
||||
case eCSSUnit_Null:
|
||||
aSpeakAs.Truncate();
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_NOTREACHED("Unknown speech synthesis");
|
||||
aSpeakAs.Truncate();
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
@ -486,12 +486,13 @@ class nsCSSCounterStyleRule final : public mozilla::css::Rule,
|
|||
public nsIDOMCSSCounterStyleRule
|
||||
{
|
||||
public:
|
||||
explicit nsCSSCounterStyleRule(const nsAString& aName,
|
||||
explicit nsCSSCounterStyleRule(nsIAtom* aName,
|
||||
uint32_t aLineNumber, uint32_t aColumnNumber)
|
||||
: mozilla::css::Rule(aLineNumber, aColumnNumber)
|
||||
, mName(aName)
|
||||
, mGeneration(0)
|
||||
{
|
||||
MOZ_ASSERT(aName, "Must have non-null name");
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -544,7 +545,7 @@ public:
|
|||
nsCSSCounterDesc aDescID,
|
||||
const nsCSSValue& aValue);
|
||||
|
||||
const nsString& GetName() const { return mName; }
|
||||
nsIAtom* Name() const { return mName; }
|
||||
|
||||
uint32_t GetGeneration() const { return mGeneration; }
|
||||
|
||||
|
@ -573,7 +574,7 @@ private:
|
|||
nsresult GetDescriptor(nsCSSCounterDesc aDescID, nsAString& aValue);
|
||||
nsresult SetDescriptor(nsCSSCounterDesc aDescID, const nsAString& aValue);
|
||||
|
||||
nsString mName;
|
||||
nsCOMPtr<nsIAtom> mName;
|
||||
nsCSSValue mValues[eCSSCounterDesc_COUNT];
|
||||
uint32_t mGeneration;
|
||||
};
|
||||
|
|
|
@ -507,6 +507,14 @@ void nsCSSValue::SetStringValue(const nsString& aValue,
|
|||
mUnit = eCSSUnit_Null;
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSValue::SetAtomIdentValue(already_AddRefed<nsIAtom> aValue)
|
||||
{
|
||||
Reset();
|
||||
mUnit = eCSSUnit_AtomIdent;
|
||||
mValue.mAtom = aValue.take();
|
||||
}
|
||||
|
||||
void nsCSSValue::SetColorValue(nscolor aValue)
|
||||
{
|
||||
SetIntegerColorValue(aValue, eCSSUnit_RGBAColor);
|
||||
|
|
|
@ -905,6 +905,7 @@ public:
|
|||
void SetPercentValue(float aValue);
|
||||
void SetFloatValue(float aValue, nsCSSUnit aUnit);
|
||||
void SetStringValue(const nsString& aValue, nsCSSUnit aUnit);
|
||||
void SetAtomIdentValue(already_AddRefed<nsIAtom> aValue);
|
||||
void SetColorValue(nscolor aValue);
|
||||
void SetIntegerColorValue(nscolor aValue, nsCSSUnit aUnit);
|
||||
// converts the nscoord to pixels
|
||||
|
|
|
@ -7962,12 +7962,10 @@ nsRuleNode::ComputeListData(void* aStartStruct,
|
|||
break;
|
||||
}
|
||||
case eCSSUnit_Initial:
|
||||
list->SetListStyleType(NS_LITERAL_STRING("disc"), mPresContext);
|
||||
list->SetListStyleType(nsGkAtoms::disc, mPresContext);
|
||||
break;
|
||||
case eCSSUnit_Ident: {
|
||||
nsString typeIdent;
|
||||
typeValue->GetStringValue(typeIdent);
|
||||
list->SetListStyleType(typeIdent, mPresContext);
|
||||
case eCSSUnit_AtomIdent: {
|
||||
list->SetListStyleType(typeValue->GetAtomValue(), mPresContext);
|
||||
break;
|
||||
}
|
||||
case eCSSUnit_String: {
|
||||
|
@ -7980,23 +7978,23 @@ nsRuleNode::ComputeListData(void* aStartStruct,
|
|||
// For compatibility with html attribute map.
|
||||
// This branch should never be called for value from CSS.
|
||||
int32_t intValue = typeValue->GetIntValue();
|
||||
nsAutoString name;
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
switch (intValue) {
|
||||
case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
|
||||
name.AssignLiteral(u"lower-roman");
|
||||
name = nsGkAtoms::lowerRoman;
|
||||
break;
|
||||
case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
|
||||
name.AssignLiteral(u"upper-roman");
|
||||
name = nsGkAtoms::upperRoman;
|
||||
break;
|
||||
case NS_STYLE_LIST_STYLE_LOWER_ALPHA:
|
||||
name.AssignLiteral(u"lower-alpha");
|
||||
name = nsGkAtoms::lowerAlpha;
|
||||
break;
|
||||
case NS_STYLE_LIST_STYLE_UPPER_ALPHA:
|
||||
name.AssignLiteral(u"upper-alpha");
|
||||
name = nsGkAtoms::upperAlpha;
|
||||
break;
|
||||
default:
|
||||
CopyASCIItoUTF16(nsCSSProps::ValueToKeyword(
|
||||
intValue, nsCSSProps::kListStyleKTable), name);
|
||||
name = NS_Atomize(nsCSSProps::ValueToKeyword(
|
||||
intValue, nsCSSProps::kListStyleKTable));
|
||||
break;
|
||||
}
|
||||
list->SetListStyleType(name, mPresContext);
|
||||
|
|
|
@ -2255,7 +2255,7 @@ nsStyleSet::KeyframesRuleForName(const nsString& aName)
|
|||
}
|
||||
|
||||
nsCSSCounterStyleRule*
|
||||
nsStyleSet::CounterStyleRuleForName(const nsAString& aName)
|
||||
nsStyleSet::CounterStyleRuleForName(nsIAtom* aName)
|
||||
{
|
||||
NS_ENSURE_FALSE(mInShutdown, nullptr);
|
||||
NS_ASSERTION(mBatching == 0, "rule processors out of date");
|
||||
|
|
|
@ -308,7 +308,7 @@ class nsStyleSet final
|
|||
nsCSSKeyframesRule* KeyframesRuleForName(const nsString& aName);
|
||||
|
||||
// Return the winning (in the cascade) @counter-style rule for the given name.
|
||||
nsCSSCounterStyleRule* CounterStyleRuleForName(const nsAString& aName);
|
||||
nsCSSCounterStyleRule* CounterStyleRuleForName(nsIAtom* aName);
|
||||
|
||||
// Fetch object for looking up font feature values
|
||||
already_AddRefed<gfxFontFeatureValueSet> GetFontFeatureValuesLookup();
|
||||
|
|
|
@ -605,8 +605,8 @@ nsStyleList::nsStyleList(const nsPresContext* aContext)
|
|||
mCounterStyle =
|
||||
CounterStyleManager::GetBuiltinStyle(NS_STYLE_LIST_STYLE_DISC);
|
||||
} else {
|
||||
mCounterStyle = aContext->CounterStyleManager()->
|
||||
BuildCounterStyle(NS_LITERAL_STRING("disc"));
|
||||
mCounterStyle = aContext->
|
||||
CounterStyleManager()->BuildCounterStyle(nsGkAtoms::disc);
|
||||
}
|
||||
SetQuotesInitial();
|
||||
}
|
||||
|
|
|
@ -1482,8 +1482,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList
|
|||
MOZ_ASSERT(NS_IsMainThread() || !aStyle->IsDependentStyle());
|
||||
mCounterStyle = aStyle;
|
||||
}
|
||||
void SetListStyleType(const nsSubstring& aType,
|
||||
nsPresContext* aPresContext)
|
||||
void SetListStyleType(nsIAtom* aType, nsPresContext* aPresContext)
|
||||
{
|
||||
SetCounterStyle(aPresContext->CounterStyleManager()->BuildCounterStyle(aType));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче