From 6883fc4b42e11d293f53d3891690e28cf23bbaaf Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Tue, 12 Apr 2016 15:52:40 +1000 Subject: [PATCH] Bug 1261754 - Part 3: Move quotes from nsStyleQuotes to nsStyleList and delete nsStyleQuotes. r=dholbert --- layout/base/nsLayoutUtils.cpp | 2 +- layout/base/nsQuoteList.cpp | 2 +- layout/style/generate-stylestructlist.py | 1 - layout/style/nsCSSPropList.h | 12 +- layout/style/nsCSSProps.cpp | 7 - layout/style/nsComputedDOMStyle.cpp | 2 +- layout/style/nsRuleNode.cpp | 107 ++++++--------- layout/style/nsRuleNode.h | 7 - layout/style/nsStyleContext.cpp | 1 - layout/style/nsStyleStruct.cpp | 161 ++++++++++------------- layout/style/nsStyleStruct.h | 104 ++++++--------- 11 files changed, 152 insertions(+), 254 deletions(-) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 549017d8b732..1ff26e8b9f2f 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -7663,7 +7663,7 @@ nsLayoutUtils::Shutdown() nsComputedDOMStyle::UnregisterPrefChangeCallbacks(); // so the cached initial quotes array doesn't appear to be a leak - nsStyleQuotes::Shutdown(); + nsStyleList::Shutdown(); } /* static */ diff --git a/layout/base/nsQuoteList.cpp b/layout/base/nsQuoteList.cpp index cbd6f0b55ba5..0d99fdbae5f3 100644 --- a/layout/base/nsQuoteList.cpp +++ b/layout/base/nsQuoteList.cpp @@ -38,7 +38,7 @@ nsQuoteNode::Text() mType == eStyleContentType_CloseQuote, "should only be called when mText should be non-null"); const nsStyleQuoteValues::QuotePairArray& quotePairs = - mPseudoFrame->StyleQuotes()->GetQuotePairs(); + mPseudoFrame->StyleList()->GetQuotePairs(); int32_t quotesCount = quotePairs.Length(); // 0 if 'quotes:none' int32_t quoteDepth = Depth(); diff --git a/layout/style/generate-stylestructlist.py b/layout/style/generate-stylestructlist.py index e9fa418ebc78..afd79d80296f 100755 --- a/layout/style/generate-stylestructlist.py +++ b/layout/style/generate-stylestructlist.py @@ -28,7 +28,6 @@ STYLE_STRUCTS = [("INHERITED",) + x for x in [ ("List", "nullptr", NORMAL_DEP + LENGTH_DEP), ("Text", "CheckTextCallback", NORMAL_DEP + LENGTH_DEP + COLOR_DEP), ("Visibility", "nullptr", NORMAL_DEP), - ("Quotes", "nullptr", NORMAL_DEP), ("UserInterface", "nullptr", NORMAL_DEP), ("TableBorder", "nullptr", NORMAL_DEP + LENGTH_DEP), ("SVG", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP), diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index c0253df47615..e24cf4d033e8 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -143,7 +143,6 @@ #define CSS_PROP_DISPLAY(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Display, stylestructoffset_, animtype_) #define CSS_PROP_VISIBILITY(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Visibility, stylestructoffset_, animtype_) #define CSS_PROP_CONTENT(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Content, stylestructoffset_, animtype_) -#define CSS_PROP_QUOTES(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Quotes, stylestructoffset_, animtype_) #define CSS_PROP_USERINTERFACE(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, UserInterface, stylestructoffset_, animtype_) #define CSS_PROP_UIRESET(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, UIReset, stylestructoffset_, animtype_) #define CSS_PROP_TABLE(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Table, stylestructoffset_, animtype_) @@ -228,10 +227,6 @@ #define CSS_PROP_CONTENT(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) /* nothing */ #define DEFINED_CSS_PROP_CONTENT #endif -#ifndef CSS_PROP_QUOTES -#define CSS_PROP_QUOTES(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) /* nothing */ -#define DEFINED_CSS_PROP_QUOTES -#endif #ifndef CSS_PROP_USERINTERFACE #define CSS_PROP_USERINTERFACE(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) /* nothing */ #define DEFINED_CSS_PROP_USERINTERFACE @@ -3065,7 +3060,7 @@ CSS_PROP_DISPLAY( kPositionKTable, CSS_PROP_NO_OFFSET, eStyleAnimType_None) -CSS_PROP_QUOTES( +CSS_PROP_LIST( quotes, quotes, Quotes, @@ -4455,7 +4450,6 @@ CSS_PROP_FONT( #undef CSS_PROP_DISPLAY #undef CSS_PROP_VISIBILITY #undef CSS_PROP_CONTENT -#undef CSS_PROP_QUOTES #undef CSS_PROP_USERINTERFACE #undef CSS_PROP_UIRESET #undef CSS_PROP_TABLE @@ -4512,10 +4506,6 @@ CSS_PROP_FONT( #undef CSS_PROP_CONTENT #undef DEFINED_CSS_PROP_CONTENT #endif -#ifdef DEFINED_CSS_PROP_QUOTES -#undef CSS_PROP_QUOTES -#undef DEFINED_CSS_PROP_QUOTES -#endif #ifdef DEFINED_CSS_PROP_USERINTERFACE #undef CSS_PROP_USERINTERFACE #undef DEFINED_CSS_PROP_USERINTERFACE diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index e52e897933ad..536151f38c5e 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -3145,13 +3145,6 @@ enum ContentCheckCounter { ePropertyCount_for_Content }; -enum QuotesCheckCounter { - #define CSS_PROP_QUOTES ENUM_DATA_FOR_PROPERTY - #include "nsCSSPropList.h" - #undef CSS_PROP_QUOTES - ePropertyCount_for_Quotes -}; - enum TextCheckCounter { #define CSS_PROP_TEXT ENUM_DATA_FOR_PROPERTY #include "nsCSSPropList.h" diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 9437d9d5d88b..02bc7f207f59 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -1471,7 +1471,7 @@ nsComputedDOMStyle::DoGetCounterReset() already_AddRefed nsComputedDOMStyle::DoGetQuotes() { - const auto& quotePairs = StyleQuotes()->GetQuotePairs(); + const auto& quotePairs = StyleList()->GetQuotePairs(); if (quotePairs.IsEmpty()) { RefPtr val = new nsROCSSPrimitiveValue; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 5fcd5d87b373..48bda27c70e7 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -1916,12 +1916,6 @@ static const uint32_t gContentFlags[] = { #undef CSS_PROP_CONTENT }; -static const uint32_t gQuotesFlags[] = { -#define CSS_PROP_QUOTES FLAG_DATA_FOR_PROPERTY -#include "nsCSSPropList.h" -#undef CSS_PROP_QUOTES -}; - static const uint32_t gTextFlags[] = { #define CSS_PROP_TEXT FLAG_DATA_FOR_PROPERTY #include "nsCSSPropList.h" @@ -2539,12 +2533,6 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContex aContext->SetStyle(eStyleStruct_Content, content); return content; } - case eStyleStruct_Quotes: - { - nsStyleQuotes* quotes = new (mPresContext) nsStyleQuotes(mPresContext); - aContext->SetStyle(eStyleStruct_Quotes, quotes); - return quotes; - } case eStyleStruct_UserInterface: { nsStyleUserInterface* ui = new (mPresContext) nsStyleUserInterface(mPresContext); @@ -7685,6 +7673,47 @@ nsRuleNode::ComputeListData(void* aStartStruct, { COMPUTE_START_INHERITED(List, list, parentList) + // quotes: inherit, initial, none, [string string]+ + const nsCSSValue* quotesValue = aRuleData->ValueForQuotes(); + switch (quotesValue->GetUnit()) { + case eCSSUnit_Null: + break; + case eCSSUnit_Inherit: + case eCSSUnit_Unset: + conditions.SetUncacheable(); + list->SetQuotesInherit(parentList); + break; + case eCSSUnit_Initial: + list->SetQuotesInitial(); + break; + case eCSSUnit_None: + list->SetQuotesNone(); + break; + case eCSSUnit_PairList: + case eCSSUnit_PairListDep: { + const nsCSSValuePairList* ourQuotes = quotesValue->GetPairListValue(); + + nsStyleQuoteValues::QuotePairArray quotePairs; + quotePairs.SetLength(ListLength(ourQuotes)); + + size_t index = 0; + nsAutoString buffer; + while (ourQuotes) { + MOZ_ASSERT(ourQuotes->mXValue.GetUnit() == eCSSUnit_String && + ourQuotes->mYValue.GetUnit() == eCSSUnit_String, + "improper list contents for quotes"); + quotePairs[index].first = ourQuotes->mXValue.GetStringValue(buffer); + quotePairs[index].second = ourQuotes->mYValue.GetStringValue(buffer); + ++index; + ourQuotes = ourQuotes->mNext; + } + list->SetQuotes(Move(quotePairs)); + break; + } + default: + MOZ_ASSERT(false, "unexpected value unit"); + } + // list-style-type: string, none, inherit, initial const nsCSSValue* typeValue = aRuleData->ValueForListStyleType(); switch (typeValue->GetUnit()) { @@ -8836,60 +8865,6 @@ nsRuleNode::ComputeContentData(void* aStartStruct, COMPUTE_END_RESET(Content, content) } -const void* -nsRuleNode::ComputeQuotesData(void* aStartStruct, - const nsRuleData* aRuleData, - nsStyleContext* aContext, - nsRuleNode* aHighestNode, - const RuleDetail aRuleDetail, - const RuleNodeCacheConditions aConditions) -{ - COMPUTE_START_INHERITED(Quotes, quotes, parentQuotes) - - // quotes: inherit, initial, none, [string string]+ - const nsCSSValue* quotesValue = aRuleData->ValueForQuotes(); - switch (quotesValue->GetUnit()) { - case eCSSUnit_Null: - break; - case eCSSUnit_Inherit: - case eCSSUnit_Unset: - conditions.SetUncacheable(); - quotes->SetQuotesInherit(parentQuotes); - break; - case eCSSUnit_Initial: - quotes->SetQuotesInitial(); - break; - case eCSSUnit_None: - quotes->SetQuotesNone(); - break; - case eCSSUnit_PairList: - case eCSSUnit_PairListDep: { - const nsCSSValuePairList* ourQuotes = quotesValue->GetPairListValue(); - - nsStyleQuoteValues::QuotePairArray quotePairs; - quotePairs.SetLength(ListLength(ourQuotes)); - - size_t index = 0; - nsAutoString buffer; - while (ourQuotes) { - MOZ_ASSERT(ourQuotes->mXValue.GetUnit() == eCSSUnit_String && - ourQuotes->mYValue.GetUnit() == eCSSUnit_String, - "improper list contents for quotes"); - quotePairs[index].first = ourQuotes->mXValue.GetStringValue(buffer); - quotePairs[index].second = ourQuotes->mYValue.GetStringValue(buffer); - ++index; - ourQuotes = ourQuotes->mNext; - } - quotes->SetQuotes(Move(quotePairs)); - break; - } - default: - MOZ_ASSERT(false, "unexpected value unit"); - } - - COMPUTE_END_INHERITED(Quotes, quotes) -} - const void* nsRuleNode::ComputeXULData(void* aStartStruct, const nsRuleData* aRuleData, diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index fefd89c7c202..4c51f33ad81d 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -682,13 +682,6 @@ protected: RuleDetail aRuleDetail, const mozilla::RuleNodeCacheConditions aConditions); - const void* - ComputeQuotesData(void* aStartStruct, - const nsRuleData* aRuleData, - nsStyleContext* aContext, nsRuleNode* aHighestNode, - RuleDetail aRuleDetail, - const mozilla::RuleNodeCacheConditions aConditions); - const void* ComputeTextData(void* aStartStruct, const nsRuleData* aRuleData, diff --git a/layout/style/nsStyleContext.cpp b/layout/style/nsStyleContext.cpp index ec64716ca92d..f65d284d6048 100644 --- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -966,7 +966,6 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther, DO_STRUCT_DIFFERENCE(UIReset); DO_STRUCT_DIFFERENCE(Text); DO_STRUCT_DIFFERENCE(List); - DO_STRUCT_DIFFERENCE(Quotes); DO_STRUCT_DIFFERENCE(SVGReset); DO_STRUCT_DIFFERENCE(SVG); #undef EXTRA_DIFF_ARGS diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index e75e68f3a495..3c8675cd7edf 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -681,6 +681,7 @@ nsStyleList::nsStyleList(StyleStructContext aContext) mCounterStyle(aContext.BuildCounterStyle(mListStyleType)) { MOZ_COUNT_CTOR(nsStyleList); + SetQuotesInitial(); } nsStyleList::~nsStyleList() @@ -692,14 +693,74 @@ nsStyleList::nsStyleList(const nsStyleList& aSource) : mListStylePosition(aSource.mListStylePosition), mListStyleType(aSource.mListStyleType), mCounterStyle(aSource.mCounterStyle), + mQuotes(aSource.mQuotes), mImageRegion(aSource.mImageRegion) { SetListStyleImage(aSource.GetListStyleImage()); MOZ_COUNT_CTOR(nsStyleList); } -nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const +void +nsStyleList::SetQuotesInherit(const nsStyleList* aOther) { + mQuotes = aOther->mQuotes; +} + +void +nsStyleList::SetQuotesInitial() +{ + if (!sInitialQuotes) { + // The initial value for quotes is the en-US typographic convention: + // outermost are LEFT and RIGHT DOUBLE QUOTATION MARK, alternating + // with LEFT and RIGHT SINGLE QUOTATION MARK. + static const char16_t initialQuotes[8] = { + 0x201C, 0, 0x201D, 0, 0x2018, 0, 0x2019, 0 + }; + + sInitialQuotes = new nsStyleQuoteValues; + sInitialQuotes->mQuotePairs.AppendElement( + std::make_pair(nsDependentString(&initialQuotes[0], 1), + nsDependentString(&initialQuotes[2], 1))); + sInitialQuotes->mQuotePairs.AppendElement( + std::make_pair(nsDependentString(&initialQuotes[4], 1), + nsDependentString(&initialQuotes[6], 1))); + } + + mQuotes = sInitialQuotes; +} + +void +nsStyleList::SetQuotesNone() +{ + if (!sNoneQuotes) { + sNoneQuotes = new nsStyleQuoteValues; + } + mQuotes = sNoneQuotes; +} + +void +nsStyleList::SetQuotes(nsStyleQuoteValues::QuotePairArray&& aValues) +{ + mQuotes = new nsStyleQuoteValues; + mQuotes->mQuotePairs = Move(aValues); +} + +const nsStyleQuoteValues::QuotePairArray& +nsStyleList::GetQuotePairs() const +{ + return mQuotes->mQuotePairs; +} + +nsChangeHint +nsStyleList::CalcDifference(const nsStyleList& aOther) const +{ + // If the quotes implementation is ever going to change we might not need + // a framechange here and a reflow should be sufficient. See bug 35768. + if (mQuotes != aOther.mQuotes && + (mQuotes || aOther.mQuotes) && + GetQuotePairs() != aOther.GetQuotePairs()) { + return NS_STYLE_HINT_FRAMECHANGE; + } if (mListStylePosition != aOther.mListStylePosition) return NS_STYLE_HINT_FRAMECHANGE; if (EqualImages(mListStyleImage, aOther.mListStyleImage) && @@ -716,6 +777,13 @@ nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const return NS_STYLE_HINT_REFLOW; } +StaticRefPtr +nsStyleList::sInitialQuotes; + +StaticRefPtr +nsStyleList::sNoneQuotes; + + // -------------------- // nsStyleXUL // @@ -3492,97 +3560,6 @@ nsresult nsStyleContent::AllocateContents(uint32_t aCount) return NS_OK; } -// --------------------- -// nsStyleQuotes -// - -nsStyleQuotes::nsStyleQuotes(StyleStructContext aContext) -{ - MOZ_COUNT_CTOR(nsStyleQuotes); - SetQuotesInitial(); -} - -nsStyleQuotes::~nsStyleQuotes() -{ - MOZ_COUNT_DTOR(nsStyleQuotes); -} - -nsStyleQuotes::nsStyleQuotes(const nsStyleQuotes& aSource) - : mQuotes(aSource.mQuotes) -{ - MOZ_COUNT_CTOR(nsStyleQuotes); -} - -void -nsStyleQuotes::SetQuotesInherit(const nsStyleQuotes* aOther) -{ - mQuotes = aOther->mQuotes; -} - -void -nsStyleQuotes::SetQuotesInitial() -{ - if (!sInitialQuotes) { - // The initial value for quotes is the en-US typographic convention: - // outermost are LEFT and RIGHT DOUBLE QUOTATION MARK, alternating - // with LEFT and RIGHT SINGLE QUOTATION MARK. - static const char16_t initialQuotes[8] = { - 0x201C, 0, 0x201D, 0, 0x2018, 0, 0x2019, 0 - }; - - sInitialQuotes = new nsStyleQuoteValues; - sInitialQuotes->mQuotePairs.AppendElement( - std::make_pair(nsDependentString(&initialQuotes[0], 1), - nsDependentString(&initialQuotes[2], 1))); - sInitialQuotes->mQuotePairs.AppendElement( - std::make_pair(nsDependentString(&initialQuotes[4], 1), - nsDependentString(&initialQuotes[6], 1))); - } - - mQuotes = sInitialQuotes; -} - -void -nsStyleQuotes::SetQuotesNone() -{ - if (!sNoneQuotes) { - sNoneQuotes = new nsStyleQuoteValues; - } - mQuotes = sNoneQuotes; -} - -void -nsStyleQuotes::SetQuotes(nsStyleQuoteValues::QuotePairArray&& aValues) -{ - mQuotes = new nsStyleQuoteValues; - mQuotes->mQuotePairs = Move(aValues); -} - -const nsStyleQuoteValues::QuotePairArray& -nsStyleQuotes::GetQuotePairs() const -{ - return mQuotes->mQuotePairs; -} - -nsChangeHint -nsStyleQuotes::CalcDifference(const nsStyleQuotes& aOther) const -{ - // If the quotes implementation is ever going to change we might not need - // a framechange here and a reflow should be sufficient. See bug 35768. - if (mQuotes != aOther.mQuotes && - mQuotes->mQuotePairs != aOther.mQuotes->mQuotePairs) { - return NS_STYLE_HINT_FRAMECHANGE; - } - - return NS_STYLE_HINT_NONE; -} - -StaticRefPtr -nsStyleQuotes::sInitialQuotes; - -StaticRefPtr -nsStyleQuotes::sNoneQuotes; - // -------------------- // nsStyleTextReset diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 2085d33441f7..cb2484e2cdf9 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -48,7 +48,7 @@ struct nsStyleVisibility; // Bits for each struct. // NS_STYLE_INHERIT_BIT defined in nsStyleStructFwd.h -#define NS_STYLE_INHERIT_MASK 0x000ffffff +#define NS_STYLE_INHERIT_MASK 0x0007fffff // Bits for inherited structs. #define NS_STYLE_INHERITED_STRUCT_MASK \ @@ -59,6 +59,7 @@ struct nsStyleVisibility; << nsStyleStructID_Inherited_Count) // Additional bits for nsStyleContext's mBits: +// Free bit 0x000800000 // See nsStyleContext::HasTextDecorationLines #define NS_STYLE_HAS_TEXT_DECORATION_LINES 0x001000000 // See nsStyleContext::HasPseudoElementData. @@ -86,8 +87,9 @@ struct nsStyleVisibility; #define NS_STYLE_CONTEXT_TYPE_SHIFT 35 // Additional bits for nsRuleNode's mDependentBits: +// Free bit 0x00800000 #define NS_RULE_NODE_IS_ANIMATION_RULE 0x01000000 -// Free bit here! +// Free bit 0x02000000 #define NS_RULE_NODE_USED_DIRECTLY 0x04000000 #define NS_RULE_NODE_IS_IMPORTANT 0x08000000 #define NS_RULE_NODE_LEVEL_MASK 0xf0000000 @@ -1352,6 +1354,22 @@ protected: }; +/** + * An object that allows sharing of arrays that store 'quotes' property + * values. This is particularly important for inheritance, where we want + * to share the same 'quotes' value with a parent style context. + */ +class nsStyleQuoteValues +{ +public: + typedef nsTArray> QuotePairArray; + NS_INLINE_DECL_REFCOUNTING(nsStyleQuoteValues); + QuotePairArray mQuotePairs; + +private: + ~nsStyleQuoteValues() {} +}; + struct nsStyleList { explicit nsStyleList(StyleStructContext aContext); @@ -1382,6 +1400,11 @@ struct nsStyleList nsChangeHint_ClearAncestorIntrinsics; } + static void Shutdown() { + sInitialQuotes = nullptr; + sNoneQuotes = nullptr; + } + imgRequestProxy* GetListStyleImage() const { return mListStyleImage; } void SetListStyleImage(imgRequestProxy* aReq) { @@ -1410,14 +1433,27 @@ struct nsStyleList CounterStyleManager()->BuildCounterStyle(aType)); } + const nsStyleQuoteValues::QuotePairArray& GetQuotePairs() const; + + void SetQuotesInherit(const nsStyleList* aOther); + void SetQuotesInitial(); + void SetQuotesNone(); + void SetQuotes(nsStyleQuoteValues::QuotePairArray&& aValues); + uint8_t mListStylePosition; // [inherited] private: nsString mListStyleType; // [inherited] RefPtr mCounterStyle; // [inherited] RefPtr mListStyleImage; // [inherited] + RefPtr mQuotes; // [inherited] nsStyleList& operator=(const nsStyleList& aOther) = delete; public: nsRect mImageRegion; // [inherited] the rect to use within an image + +private: + // nsStyleQuoteValues objects representing two common values, for sharing. + static mozilla::StaticRefPtr sInitialQuotes; + static mozilla::StaticRefPtr sNoneQuotes; }; struct nsStyleGridLine @@ -2798,70 +2834,6 @@ struct nsStyleCounterData #define DELETE_ARRAY_IF(array) if (array) { delete[] array; array = nullptr; } -/** - * An object that allows sharing of arrays that store 'quotes' property - * values. This is particularly important for inheritance, where we want - * to share the same 'quotes' value with a parent style context. - */ -class nsStyleQuoteValues -{ -public: - typedef nsTArray> QuotePairArray; - NS_INLINE_DECL_REFCOUNTING(nsStyleQuoteValues); - QuotePairArray mQuotePairs; - -private: - ~nsStyleQuoteValues() {} -}; - -struct nsStyleQuotes -{ - explicit nsStyleQuotes(StyleStructContext aContext); - nsStyleQuotes(const nsStyleQuotes& aQuotes); - ~nsStyleQuotes(); - - void* operator new(size_t sz, nsStyleQuotes* aSelf) CPP_THROW_NEW { return aSelf; } - void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW { - return aContext->PresShell()-> - AllocateByObjectID(mozilla::eArenaObjectID_nsStyleQuotes, sz); - } - void Destroy(nsPresContext* aContext) { - this->~nsStyleQuotes(); - aContext->PresShell()-> - FreeByObjectID(mozilla::eArenaObjectID_nsStyleQuotes, this); - } - nsChangeHint CalcDifference(const nsStyleQuotes& aOther) const; - static nsChangeHint MaxDifference() { - return NS_STYLE_HINT_FRAMECHANGE; - } - static nsChangeHint DifferenceAlwaysHandledForDescendants() { - // CalcDifference never returns the reflow hints that are sometimes - // handled for descendants as hints not handled for descendants. - return nsChangeHint_NeedReflow | - nsChangeHint_ReflowChangesSizeOrPosition | - nsChangeHint_ClearAncestorIntrinsics; - } - - static void Shutdown() { - sInitialQuotes = nullptr; - sNoneQuotes = nullptr; - } - - const nsStyleQuoteValues::QuotePairArray& GetQuotePairs() const; - - void SetQuotesInherit(const nsStyleQuotes* aOther); - void SetQuotesInitial(); - void SetQuotesNone(); - void SetQuotes(nsStyleQuoteValues::QuotePairArray&& aValues); - -private: - RefPtr mQuotes; // [inherited] - - // nsStyleQuoteValues objects representing two common values, for sharing. - static mozilla::StaticRefPtr sInitialQuotes; - static mozilla::StaticRefPtr sNoneQuotes; -}; - struct nsStyleContent { explicit nsStyleContent(StyleStructContext aContext);