From 98f239480d1666a95e015788a4bcef780402a31f Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Sat, 6 May 2017 11:34:35 +1000 Subject: [PATCH] Bug 1362302 part 1 - Use nsIAtom for counter style names. r=dbaron MozReview-Commit-ID: 5VK6BgGRVRs --HG-- extra : rebase_source : 104a28eddeb7984bd9f691693cf8debc1387fb87 --- dom/base/nsGkAtomList.h | 7 ++++ layout/base/nsCounterManager.cpp | 6 +-- layout/style/CounterStyleManager.cpp | 39 +++++++++--------- layout/style/CounterStyleManager.h | 4 +- layout/style/nsCSSParser.cpp | 60 +++++++++++++--------------- layout/style/nsCSSParser.h | 8 ++-- layout/style/nsCSSRuleProcessor.cpp | 10 +++-- layout/style/nsCSSRuleProcessor.h | 2 +- layout/style/nsCSSRules.cpp | 19 ++++++--- layout/style/nsCSSRules.h | 7 ++-- layout/style/nsCSSValue.cpp | 8 ++++ layout/style/nsCSSValue.h | 1 + layout/style/nsRuleNode.cpp | 22 +++++----- layout/style/nsStyleSet.cpp | 2 +- layout/style/nsStyleSet.h | 2 +- layout/style/nsStyleStruct.cpp | 4 +- layout/style/nsStyleStruct.h | 3 +- 17 files changed, 113 insertions(+), 91 deletions(-) diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 988cfd85d631..780d6dec3df7 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -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") diff --git a/layout/base/nsCounterManager.cpp b/layout/base/nsCounterManager.cpp index 2d998abd08bd..fe47f733bf4e 100644 --- a/layout/base/nsCounterManager.cpp +++ b/layout/base/nsCounterManager.cpp @@ -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 { diff --git a/layout/style/CounterStyleManager.cpp b/layout/style/CounterStyleManager.cpp index f74375690d48..a1795a8b0844 100644 --- a/layout/style/CounterStyleManager.cpp +++ b/layout/style/CounterStyleManager.cpp @@ -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 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); diff --git a/layout/style/CounterStyleManager.h b/layout/style/CounterStyleManager.h index 3fb8d39476fc..5434f73becf4 100644 --- a/layout/style/CounterStyleManager.h +++ b/layout/style/CounterStyleManager.h @@ -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 mCacheTable; + nsRefPtrHashtable, CounterStyle> mCacheTable; }; } // namespace mozilla diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index f400bf29c9e0..f7b869a7147e 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -263,9 +263,8 @@ public: nsIURI* aBaseURL, nsIPrincipal* aDocPrincipal); - bool ParseCounterStyleName(const nsAString& aBuffer, - nsIURI* aURL, - nsAString& aName); + already_AddRefed 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 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 +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 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 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 +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 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 +nsCSSParser::ParseCounterStyleName(const nsAString& aBuffer, nsIURI* aURL) { return static_cast(mImpl)-> - ParseCounterStyleName(aBuffer, aURL, aName); + ParseCounterStyleName(aBuffer, aURL); } bool diff --git a/layout/style/nsCSSParser.h b/layout/style/nsCSSParser.h index 3998daac7f1b..44eaf25bbb69 100644 --- a/layout/style/nsCSSParser.h +++ b/layout/style/nsCSSParser.h @@ -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 ParseCounterStyleName(const nsAString& aBuffer, + nsIURI* aURL); bool ParseCounterDescriptor(nsCSSCounterDesc aDescID, const nsAString& aBuffer, diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 8745f4481b1d..cfc2a16be89d 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -893,7 +893,11 @@ struct RuleCascadeData { nsTArray mCounterStyleRules; nsDataHashtable mKeyframesRuleTable; - nsDataHashtable 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, + 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::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 diff --git a/layout/style/nsCSSRuleProcessor.h b/layout/style/nsCSSRuleProcessor.h index 3b28cbf99e5e..a036dc6f9357 100644 --- a/layout/style/nsCSSRuleProcessor.h +++ b/layout/style/nsCSSRuleProcessor.h @@ -210,7 +210,7 @@ public: const nsString& aName); nsCSSCounterStyleRule* CounterStyleRuleForName(nsPresContext* aPresContext, - const nsAString& aName); + nsIAtom* aName); bool AppendPageRules(nsPresContext* aPresContext, nsTArray& aArray); diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index ad7e618dbba2..e5c7cf4b7bbc 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -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 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; diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index 0f34957c7cba..79f6eeef5f11 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -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 mName; nsCSSValue mValues[eCSSCounterDesc_COUNT]; uint32_t mGeneration; }; diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index d6ac94314d97..772a871d2181 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -507,6 +507,14 @@ void nsCSSValue::SetStringValue(const nsString& aValue, mUnit = eCSSUnit_Null; } +void +nsCSSValue::SetAtomIdentValue(already_AddRefed aValue) +{ + Reset(); + mUnit = eCSSUnit_AtomIdent; + mValue.mAtom = aValue.take(); +} + void nsCSSValue::SetColorValue(nscolor aValue) { SetIntegerColorValue(aValue, eCSSUnit_RGBAColor); diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index daecbf4753f9..f76a47ab2d02 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -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 aValue); void SetColorValue(nscolor aValue); void SetIntegerColorValue(nscolor aValue, nsCSSUnit aUnit); // converts the nscoord to pixels diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 3cb1f0303bb5..5cf1da669c49 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -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 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); diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 26c106fc2410..94d37515e309 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -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"); diff --git a/layout/style/nsStyleSet.h b/layout/style/nsStyleSet.h index 664c18417353..19dd5b1ce8f6 100644 --- a/layout/style/nsStyleSet.h +++ b/layout/style/nsStyleSet.h @@ -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 GetFontFeatureValuesLookup(); diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 34ed23b70cb4..0599bf8e68ae 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -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(); } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 29c74841ff33..43b8a6199308 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -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)); }