author | Cameron McCormack <cam@mcc.id.au> |
Tue, 12 Apr 2016 11:35:26 +1000 | |
changeset 349672 | 782bc72d52df922c5527fa67abf02cca247807ab |
parent 349671 | 67e34ee48f8398804bb850b88a24464a9be90b8c |
child 349673 | 9fd976f0cc659230ba8bd7f669d20a7dc07bb727 |
push id | 15154 |
push user | cmccormack@mozilla.com |
push date | Tue, 12 Apr 2016 01:46:39 +0000 |
reviewers | dholbert |
bugs | 1261754 |
milestone | 48.0a1 |
--- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -7658,17 +7658,17 @@ nsLayoutUtils::Shutdown() Preferences::UnregisterCallback(GridEnabledPrefChangeCallback, GRID_ENABLED_PREF_NAME); Preferences::UnregisterCallback(WebkitPrefixEnabledPrefChangeCallback, WEBKIT_PREFIXES_ENABLED_PREF_NAME); nsComputedDOMStyle::UnregisterPrefChangeCallbacks(); // so the cached initial quotes array doesn't appear to be a leak - nsStyleQuotes::Shutdown(); + nsStyleList::Shutdown(); } /* static */ void nsLayoutUtils::RegisterImageRequest(nsPresContext* aPresContext, imgIRequest* aRequest, bool* aRequestRegistered) {
--- a/layout/base/nsQuoteList.cpp +++ b/layout/base/nsQuoteList.cpp @@ -33,17 +33,17 @@ nsQuoteNode::InitTextFrame(nsGenConList* const nsString* nsQuoteNode::Text() { NS_ASSERTION(mType == eStyleContentType_OpenQuote || mType == eStyleContentType_CloseQuote, "should only be called when mText should be non-null"); const nsStyleQuoteValues::Array& quotePairs = - mPseudoFrame->StyleQuotes()->GetQuotePairs(); + mPseudoFrame->StyleList()->GetQuotePairs(); int32_t quotesCount = quotePairs.Length(); // 0 if 'quotes:none' int32_t quoteDepth = Depth(); // Reuse the last pair when the depth is greater than the number of // pairs of quotes. (Also make 'quotes: none' and close-quote from // a depth of 0 equivalent for the next test.) if (quoteDepth >= quotesCount) quoteDepth = quotesCount - 1;
--- a/layout/style/generate-stylestructlist.py +++ b/layout/style/generate-stylestructlist.py @@ -23,17 +23,16 @@ LENGTH_DEP = ["Font", "Visibility"] # if any. STYLE_STRUCTS = [("INHERITED",) + x for x in [ # Inherited style structs. ("Font", "CheckFontCallback", NORMAL_DEP + ["Visibility"]), ("Color", "CheckColorCallback", NORMAL_DEP), ("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), ("Variables", "CheckVariablesCallback",[]), ]] + [("RESET",) + x for x in [ # Reset style structs. ("Background", "nullptr", NORMAL_DEP + LENGTH_DEP + COLOR_DEP), ("Position", "nullptr", NORMAL_DEP + LENGTH_DEP),
--- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -138,17 +138,16 @@ #define CSS_PROP_BACKGROUND(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Background, stylestructoffset_, animtype_) #define CSS_PROP_LIST(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, List, stylestructoffset_, animtype_) #define CSS_PROP_POSITION(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Position, stylestructoffset_, animtype_) #define CSS_PROP_TEXT(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Text, stylestructoffset_, animtype_) #define CSS_PROP_TEXTRESET(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, TextReset, stylestructoffset_, animtype_) #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_) #define CSS_PROP_TABLEBORDER(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, TableBorder, stylestructoffset_, animtype_) #define CSS_PROP_MARGIN(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Margin, stylestructoffset_, animtype_) #define CSS_PROP_PADDING(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Padding, stylestructoffset_, animtype_) #define CSS_PROP_BORDER(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Border, stylestructoffset_, animtype_) #define CSS_PROP_OUTLINE(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, Outline, stylestructoffset_, animtype_) @@ -223,20 +222,16 @@ #ifndef CSS_PROP_VISIBILITY #define CSS_PROP_VISIBILITY(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) /* nothing */ #define DEFINED_CSS_PROP_VISIBILITY #endif #ifndef CSS_PROP_CONTENT #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 #endif #ifndef CSS_PROP_UIRESET #define CSS_PROP_UIRESET(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, stylestructoffset_, animtype_) /* nothing */ #define DEFINED_CSS_PROP_UIRESET #endif @@ -3060,17 +3055,17 @@ CSS_PROP_DISPLAY( // For position: sticky/fixed CSS_PROPERTY_CREATES_STACKING_CONTEXT | CSS_PROPERTY_ABSPOS_CB, "", VARIANT_HK, kPositionKTable, CSS_PROP_NO_OFFSET, eStyleAnimType_None) -CSS_PROP_QUOTES( +CSS_PROP_LIST( quotes, quotes, Quotes, CSS_PROPERTY_PARSE_FUNCTION, "", 0, nullptr, CSS_PROP_NO_OFFSET, @@ -4450,17 +4445,16 @@ CSS_PROP_FONT( #undef CSS_PROP_BACKGROUND #undef CSS_PROP_LIST #undef CSS_PROP_POSITION #undef CSS_PROP_TEXT #undef CSS_PROP_TEXTRESET #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 #undef CSS_PROP_TABLEBORDER #undef CSS_PROP_MARGIN #undef CSS_PROP_PADDING #undef CSS_PROP_BORDER #undef CSS_PROP_OUTLINE @@ -4507,20 +4501,16 @@ CSS_PROP_FONT( #ifdef DEFINED_CSS_PROP_VISIBILITY #undef CSS_PROP_VISIBILITY #undef DEFINED_CSS_PROP_VISIBILITY #endif #ifdef DEFINED_CSS_PROP_CONTENT #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 #endif #ifdef DEFINED_CSS_PROP_UIRESET #undef CSS_PROP_UIRESET #undef DEFINED_CSS_PROP_UIRESET #endif
--- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -3140,23 +3140,16 @@ enum TableBorderCheckCounter { enum ContentCheckCounter { #define CSS_PROP_CONTENT ENUM_DATA_FOR_PROPERTY #include "nsCSSPropList.h" #undef CSS_PROP_CONTENT 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" #undef CSS_PROP_TEXT ePropertyCount_for_Text }; enum TextResetCheckCounter {
--- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -1466,17 +1466,17 @@ nsComputedDOMStyle::DoGetCounterReset() } return valueList.forget(); } already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetQuotes() { - const auto& quotePairs = StyleQuotes()->GetQuotePairs(); + const auto& quotePairs = StyleList()->GetQuotePairs(); if (quotePairs.IsEmpty()) { RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue; val->SetIdent(eCSSKeyword_none); return val.forget(); } RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
--- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -1911,22 +1911,16 @@ static const uint32_t gTableBorderFlags[ }; static const uint32_t gContentFlags[] = { #define CSS_PROP_CONTENT FLAG_DATA_FOR_PROPERTY #include "nsCSSPropList.h" #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" #undef CSS_PROP_TEXT }; static const uint32_t gTextResetFlags[] = { #define CSS_PROP_TEXTRESET FLAG_DATA_FOR_PROPERTY @@ -2534,22 +2528,16 @@ nsRuleNode::SetDefaultOnRoot(const nsSty return table; } case eStyleStruct_Content: { nsStyleContent* content = new (mPresContext) nsStyleContent(mPresContext); 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); aContext->SetStyle(eStyleStruct_UserInterface, ui); return ui; } case eStyleStruct_UIReset: { @@ -7686,16 +7674,57 @@ nsRuleNode::ComputeListData(void* aStart const nsRuleData* aRuleData, nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail aRuleDetail, const RuleNodeCacheConditions aConditions) { 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::Array 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()) { case eCSSUnit_Unset: case eCSSUnit_Inherit: { conditions.SetUncacheable(); nsString type; parentList->GetListStyleType(type); @@ -8838,70 +8867,16 @@ nsRuleNode::ComputeContentData(void* aSt content->ContentAt(i).TrackImage(aContext->PresContext()); } } 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::Array 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, nsStyleContext* aContext, nsRuleNode* aHighestNode, const RuleDetail aRuleDetail, const RuleNodeCacheConditions aConditions) { COMPUTE_START_RESET(XUL, xul, parentXUL)
--- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -678,23 +678,16 @@ protected: const void* ComputeContentData(void* aStartStruct, const nsRuleData* aRuleData, nsStyleContext* aContext, nsRuleNode* aHighestNode, 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, nsStyleContext* aContext, nsRuleNode* aHighestNode, RuleDetail aRuleDetail, const mozilla::RuleNodeCacheConditions aConditions); const void* ComputeTextResetData(void* aStartStruct,
--- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -955,17 +955,16 @@ nsStyleContext::CalcStyleDifference(nsSt DO_STRUCT_DIFFERENCE(UserInterface); DO_STRUCT_DIFFERENCE(Visibility); DO_STRUCT_DIFFERENCE(Outline); DO_STRUCT_DIFFERENCE(TableBorder); DO_STRUCT_DIFFERENCE(Table); 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 #define EXTRA_DIFF_ARGS , PeekStyleVisibility() DO_STRUCT_DIFFERENCE(Position); #undef EXTRA_DIFF_ARGS #define EXTRA_DIFF_ARGS /* nothing */ DO_STRUCT_DIFFERENCE(Font);
--- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -676,51 +676,119 @@ nsChangeHint nsStyleOutline::CalcDiffere // nsStyleList // nsStyleList::nsStyleList(StyleStructContext aContext) : mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE), mListStyleType(NS_LITERAL_STRING("disc")), mCounterStyle(aContext.BuildCounterStyle(mListStyleType)) { MOZ_COUNT_CTOR(nsStyleList); + SetQuotesInitial(); } nsStyleList::~nsStyleList() { MOZ_COUNT_DTOR(nsStyleList); } 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::Array&& aValues) +{ + mQuotes = new nsStyleQuoteValues; + mQuotes->mQuotePairs = Move(aValues); +} + +const nsStyleQuoteValues::Array& +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) && mCounterStyle == aOther.mCounterStyle) { if (mImageRegion.IsEqualInterior(aOther.mImageRegion)) { if (mListStyleType != aOther.mListStyleType) return nsChangeHint_NeutralChange; return NS_STYLE_HINT_NONE; } if (mImageRegion.width == aOther.mImageRegion.width && mImageRegion.height == aOther.mImageRegion.height) return NS_STYLE_HINT_VISUAL; } return NS_STYLE_HINT_REFLOW; } +StaticRefPtr<nsStyleQuoteValues> +nsStyleList::sInitialQuotes; + +StaticRefPtr<nsStyleQuoteValues> +nsStyleList::sNoneQuotes; + + // -------------------- // nsStyleXUL // nsStyleXUL::nsStyleXUL(StyleStructContext aContext) { MOZ_COUNT_CTOR(nsStyleXUL); mBoxAlign = NS_STYLE_BOX_ALIGN_STRETCH; mBoxDirection = NS_STYLE_BOX_DIRECTION_NORMAL; @@ -3487,107 +3555,16 @@ nsresult nsStyleContent::AllocateContent mContentCount = 0; return NS_ERROR_OUT_OF_MEMORY; } } mContentCount = 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::Array&& aValues) -{ - mQuotes = new nsStyleQuoteValues; - mQuotes->mQuotePairs = Move(aValues); -} - -const nsStyleQuoteValues::Array& -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<nsStyleQuoteValues> -nsStyleQuotes::sInitialQuotes; - -StaticRefPtr<nsStyleQuoteValues> -nsStyleQuotes::sNoneQuotes; - // -------------------- // nsStyleTextReset // nsStyleTextReset::nsStyleTextReset(StyleStructContext aContext) { MOZ_COUNT_CTOR(nsStyleTextReset);
--- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -43,27 +43,28 @@ class nsTextFrame; class imgIContainer; struct nsStyleVisibility; // Includes nsStyleStructID. #include "nsStyleStructFwd.h" // 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 \ ((nsStyleStructID_size_t(1) << nsStyleStructID_Inherited_Count) - 1) // Bits for reset structs. #define NS_STYLE_RESET_STRUCT_MASK \ (((nsStyleStructID_size_t(1) << nsStyleStructID_Reset_Count) - 1) \ << 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. #define NS_STYLE_HAS_PSEUDO_ELEMENT_DATA 0x002000000 // See nsStyleContext::RelevantLinkIsVisited #define NS_STYLE_RELEVANT_LINK_VISITED 0x004000000 // See nsStyleContext::IsStyleIfVisited #define NS_STYLE_IS_STYLE_IF_VISITED 0x008000000 @@ -81,18 +82,19 @@ struct nsStyleVisibility; // See nsStyleContext::FindChildWithRules #define NS_STYLE_INELIGIBLE_FOR_SHARING 0x200000000 // See nsStyleContext::HasChildThatUsesResetStyle #define NS_STYLE_HAS_CHILD_THAT_USES_RESET_STYLE 0x400000000 // See nsStyleContext::GetPseudoEnum #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 #define NS_RULE_NODE_LEVEL_SHIFT 28 // Additional bits for nsRuleNode's mNoneBits: #define NS_RULE_NODE_HAS_ANIMATION_DATA 0x80000000 @@ -1347,16 +1349,32 @@ protected: bool mHasCachedOutline; uint8_t mOutlineStyle; // [reset] See nsStyleConsts.h nscoord mTwipsPerPixel; }; +/** + * 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<std::pair<nsString, nsString>> Array; + NS_INLINE_DECL_REFCOUNTING(nsStyleQuoteValues); + Array mQuotePairs; + +private: + ~nsStyleQuoteValues() {} +}; + struct nsStyleList { explicit nsStyleList(StyleStructContext aContext); nsStyleList(const nsStyleList& aStyleList); ~nsStyleList(void); void* operator new(size_t sz, nsStyleList* aSelf) CPP_THROW_NEW { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW { @@ -1377,16 +1395,21 @@ struct nsStyleList 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; + } + imgRequestProxy* GetListStyleImage() const { return mListStyleImage; } void SetListStyleImage(imgRequestProxy* aReq) { if (mListStyleImage) mListStyleImage->UnlockImage(); mListStyleImage = aReq; if (mListStyleImage) mListStyleImage->LockImage(); @@ -1405,24 +1428,36 @@ struct nsStyleList } void SetListStyleType(const nsSubstring& aType, nsPresContext* aPresContext) { SetListStyleType(aType, aPresContext-> CounterStyleManager()->BuildCounterStyle(aType)); } + const nsStyleQuoteValues::Array& GetQuotePairs() const; + + void SetQuotesInherit(const nsStyleList* aOther); + void SetQuotesInitial(); + void SetQuotesNone(); + void SetQuotes(nsStyleQuoteValues::Array&& aValues); + uint8_t mListStylePosition; // [inherited] private: nsString mListStyleType; // [inherited] RefPtr<mozilla::CounterStyle> mCounterStyle; // [inherited] RefPtr<imgRequestProxy> mListStyleImage; // [inherited] + RefPtr<nsStyleQuoteValues> mQuotes; // [inherited] nsStyleList& operator=(const nsStyleList& aOther) = delete; public: nsRect mImageRegion; // [inherited] the rect to use within an image + +private: + static mozilla::StaticRefPtr<nsStyleQuoteValues> sInitialQuotes; + static mozilla::StaticRefPtr<nsStyleQuoteValues> sNoneQuotes; }; struct nsStyleGridLine { // http://dev.w3.org/csswg/css-grid/#typedef-grid-line // XXXmats we could optimize memory size here bool mHasSpan; int32_t mInteger; // 0 means not provided @@ -2793,79 +2828,16 @@ struct nsStyleCounterData { nsString mCounter; int32_t mValue; }; #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<std::pair<nsString, nsString>> Array; - NS_INLINE_DECL_REFCOUNTING(nsStyleQuoteValues); - Array 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::Array& GetQuotePairs() const; - - void SetQuotesInherit(const nsStyleQuotes* aOther); - void SetQuotesInitial(); - void SetQuotesNone(); - void SetQuotes(nsStyleQuoteValues::Array&& aValues); - -private: - RefPtr<nsStyleQuoteValues> mQuotes; // [inherited] - - static mozilla::StaticRefPtr<nsStyleQuoteValues> sInitialQuotes; - static mozilla::StaticRefPtr<nsStyleQuoteValues> sNoneQuotes; -}; - struct nsStyleContent { explicit nsStyleContent(StyleStructContext aContext); nsStyleContent(const nsStyleContent& aContent); ~nsStyleContent(void); void* operator new(size_t sz, nsStyleContent* aSelf) CPP_THROW_NEW { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {