Bug 1328319 part 6 - Make it possible to delay resolving counter style. r?heycam
MozReview-Commit-ID: 5rlGBf9Asu4
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -598,50 +598,55 @@ nsStyleOutline::CalcDifference(const nsS
// --------------------
// nsStyleList
//
nsStyleList::nsStyleList(const nsPresContext* aContext)
: mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE)
{
MOZ_COUNT_CTOR(nsStyleList);
if (aContext->StyleSet()->IsServo()) {
- // FIXME: bug 1328319.
- mCounterStyle =
- CounterStyleManager::GetBuiltinStyle(NS_STYLE_LIST_STYLE_DISC);
+ mListStyleType = nsGkAtoms::disc;
} else {
mCounterStyle = aContext->
CounterStyleManager()->BuildCounterStyle(nsGkAtoms::disc);
}
SetQuotesInitial();
}
nsStyleList::~nsStyleList()
{
MOZ_COUNT_DTOR(nsStyleList);
}
nsStyleList::nsStyleList(const nsStyleList& aSource)
: mListStylePosition(aSource.mListStylePosition)
, mListStyleImage(aSource.mListStyleImage)
+ , mListStyleType(aSource.mListStyleType)
, mCounterStyle(aSource.mCounterStyle)
, mQuotes(aSource.mQuotes)
, mImageRegion(aSource.mImageRegion)
{
MOZ_COUNT_CTOR(nsStyleList);
}
void
nsStyleList::FinishStyle(nsPresContext* aPresContext)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
if (mListStyleImage && !mListStyleImage->IsResolved()) {
mListStyleImage->Resolve(aPresContext);
}
+ if (mListStyleType) {
+ MOZ_ASSERT(!mCounterStyle);
+ mCounterStyle = aPresContext->
+ CounterStyleManager()->BuildCounterStyle(mListStyleType);
+ mListStyleType = nullptr;
+ }
}
void
nsStyleList::SetQuotesInherit(const nsStyleList* aOther)
{
mQuotes = aOther->mQuotes;
}
@@ -699,17 +704,18 @@ nsStyleList::CalcDifference(const nsStyl
(mQuotes || aNewData.mQuotes) &&
GetQuotePairs() != aNewData.GetQuotePairs()) {
return nsChangeHint_ReconstructFrame;
}
if (mListStylePosition != aNewData.mListStylePosition) {
return nsChangeHint_ReconstructFrame;
}
if (DefinitelyEqualImages(mListStyleImage, aNewData.mListStyleImage) &&
- mCounterStyle == aNewData.mCounterStyle) {
+ (mCounterStyle == aNewData.mCounterStyle ||
+ mListStyleType != aNewData.mListStyleType)) {
if (mImageRegion.IsEqualInterior(aNewData.mImageRegion)) {
return nsChangeHint(0);
}
if (mImageRegion.width == aNewData.mImageRegion.width &&
mImageRegion.height == aNewData.mImageRegion.height) {
return NS_STYLE_HINT_VISUAL;
}
}
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1471,26 +1471,47 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
imgRequestProxy* GetListStyleImage() const
{
return mListStyleImage ? mListStyleImage->get() : nullptr;
}
already_AddRefed<nsIURI> GetListStyleImageURI() const;
+ // The following two methods are called from Servo code to maintain
+ // list-style-type off main thread.
+ void SetListStyleType(nsIAtom* aType)
+ {
+ mListStyleType = aType;
+ mCounterStyle = nullptr;
+ }
+ void CopyListStyleTypeFrom(const nsStyleList& aOther)
+ {
+ mListStyleType = aOther.mListStyleType;
+ mCounterStyle = aOther.mCounterStyle;
+ }
+
const nsStyleQuoteValues::QuotePairArray& GetQuotePairs() const;
void SetQuotesInherit(const nsStyleList* aOther);
void SetQuotesInitial();
void SetQuotesNone();
void SetQuotes(nsStyleQuoteValues::QuotePairArray&& aValues);
uint8_t mListStylePosition; // [inherited]
RefPtr<nsStyleImageRequest> mListStyleImage; // [inherited]
+
+ // mCounterStyle is the actual field for computed list-style-type.
+ // mListStyleType is only used when we are off the main thread, so we
+ // cannot safely construct CounterStyle object. FinishStyle() will
+ // use it to setup mCounterStyle and then clear it. At any time, only
+ // one of the following two fields should be non-null.
+ nsCOMPtr<nsIAtom> mListStyleType;
mozilla::CounterStylePtr mCounterStyle; // [inherited]
+
private:
RefPtr<nsStyleQuoteValues> 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.