From 4b44df794bb55ab1496c5324e4bfe6d4054fb32b Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Mon, 25 Mar 2024 21:11:28 +0800 Subject: [PATCH] Issue #2112 - Part 11: Remove dead off-thread Stylo functions in nsStyleStruct --- layout/style/nsStyleStruct.cpp | 80 ----------------------------- layout/style/nsStyleStruct.h | 94 ++-------------------------------- 2 files changed, 3 insertions(+), 171 deletions(-) diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 2c0a4a40ee..c9f3a2cc5a 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -449,14 +449,6 @@ nsStyleBorder::~nsStyleBorder() } } -void -nsStyleBorder::FinishStyle(nsPresContext* aPresContext) -{ - MOZ_ASSERT(NS_IsMainThread()); - - mBorderImageSource.ResolveImage(aPresContext); -} - nsMargin nsStyleBorder::GetImageOutset() const { @@ -671,16 +663,6 @@ nsStyleList::nsStyleList(const nsStyleList& aSource) MOZ_COUNT_CTOR(nsStyleList); } -void -nsStyleList::FinishStyle(nsPresContext* aPresContext) -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (mListStyleImage && !mListStyleImage->IsResolved()) { - mListStyleImage->Resolve(aPresContext); - } -} - void nsStyleList::SetQuotesInherit(const nsStyleList* aOther) { @@ -1202,13 +1184,6 @@ nsStyleSVGReset::Destroy(nsPresContext* aContext) FreeByObjectID(mozilla::eArenaObjectID_nsStyleSVGReset, this); } -void -nsStyleSVGReset::FinishStyle(nsPresContext* aPresContext) -{ - MOZ_ASSERT(NS_IsMainThread()); - - mMask.ResolveImages(aPresContext); -} nsChangeHint nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aNewData) const @@ -1965,7 +1940,6 @@ nsStyleImageRequest::nsStyleImageRequest(Mode aModeFlags, , mImageValue(aImageValue) , mImageTracker(aImageTracker) , mModeFlags(aModeFlags) - , mResolved(true) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aRequestProxy); @@ -1975,19 +1949,6 @@ nsStyleImageRequest::nsStyleImageRequest(Mode aModeFlags, MaybeTrackAndLock(); } -nsStyleImageRequest::nsStyleImageRequest( - Mode aModeFlags, - nsStringBuffer* aURLBuffer, - already_AddRefed> aBaseURI, - already_AddRefed> aReferrer, - already_AddRefed> aPrincipal) - : mModeFlags(aModeFlags) - , mResolved(false) -{ - mImageValue = new css::ImageValue(aURLBuffer, Move(aBaseURI), - Move(aReferrer), Move(aPrincipal)); -} - nsStyleImageRequest::~nsStyleImageRequest() { // We may or may not be being destroyed on the main thread. To clean @@ -2011,43 +1972,10 @@ nsStyleImageRequest::~nsStyleImageRequest() MOZ_ASSERT(!mImageTracker); } -bool -nsStyleImageRequest::Resolve(nsPresContext* aPresContext) -{ - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(!IsResolved(), "already resolved"); - - mResolved = true; - - // For now, just have unique nsCSSValue/ImageValue objects. We should - // really store the ImageValue on the Servo specified value, so that we can - // share imgRequestProxys that come from the same rule in the same - // document. - mImageValue->Initialize(aPresContext->Document()); - - nsCSSValue value; - value.SetImageValue(mImageValue); - mRequestProxy = value.GetPossiblyStaticImageValue(aPresContext->Document(), - aPresContext); - - if (!mRequestProxy) { - // The URL resolution or image load failed. - return false; - } - - if (mModeFlags & Mode::Track) { - mImageTracker = aPresContext->Document()->ImageTracker(); - } - - MaybeTrackAndLock(); - return true; -} - void nsStyleImageRequest::MaybeTrackAndLock() { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(IsResolved()); MOZ_ASSERT(mRequestProxy); if (mModeFlags & Mode::Track) { @@ -2938,14 +2866,6 @@ nsStyleBackground::Destroy(nsPresContext* aContext) FreeByObjectID(eArenaObjectID_nsStyleBackground, this); } -void -nsStyleBackground::FinishStyle(nsPresContext* aPresContext) -{ - MOZ_ASSERT(NS_IsMainThread()); - - mImage.ResolveImages(aPresContext); -} - nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aNewData) const { diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index da9643594e..bd9d80ca18 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -160,7 +160,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont ~nsStyleFont() { MOZ_COUNT_DTOR(nsStyleFont); } - void FinishStyle(nsPresContext* aPresContext) {} nsChangeHint CalcDifference(const nsStyleFont& aNewData) const; static nsChangeHint MaxDifference() { @@ -286,19 +285,9 @@ private: * A wrapper for an imgRequestProxy that supports off-main-thread creation * and equality comparison. * - * An nsStyleImageRequest can be created in two ways: - * - * 1. Using the constructor that takes an imgRequestProxy. This must - * be called from the main thread. The nsStyleImageRequest is - * immediately considered "resolved", and the get() method that - * returns the imgRequestProxy can be called. - * - * 2. Using the constructor that takes the URL, base URI, referrer - * and principal that can be used to inititiate an image load and - * produce an imgRequestProxy later. This can be called from - * any thread. The nsStyleImageRequest is not considered "resolved" - * at this point, and the Resolve() method must be called later - * to initiate the image load and make calls to get() valid. + * An nsStyleImageRequest can be created using the constructor that takes an + * imgRequestProxy. This must be called from the main thread. The get() + * method that returns the imgRequestProxy can be called immediately. * * Calls to TrackImage(), UntrackImage(), LockImage(), UnlockImage() and * RequestDiscard() are made to the imgRequestProxy and ImageTracker as @@ -343,20 +332,7 @@ public: mozilla::css::ImageValue* aImageValue, mozilla::dom::ImageTracker* aImageTracker); - // Can be called from any thread, but Resolve() must be called later - // on the main thread before get() can be used. - nsStyleImageRequest( - Mode aModeFlags, - nsStringBuffer* aURLBuffer, - already_AddRefed> aBaseURI, - already_AddRefed> aReferrer, - already_AddRefed> aPrincipal); - - bool Resolve(nsPresContext* aPresContext); - bool IsResolved() const { return mResolved; } - imgRequestProxy* get() { - MOZ_ASSERT(IsResolved(), "Resolve() must be called first"); MOZ_ASSERT(NS_IsMainThread()); return mRequestProxy.get(); } @@ -381,7 +357,6 @@ private: RefPtr mImageTracker; Mode mModeFlags; - bool mResolved; }; MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsStyleImageRequest::Mode) @@ -434,13 +409,6 @@ struct nsStyleImage void SetElementId(const char16_t* aElementId); void SetCropRect(mozilla::UniquePtr aCropRect); - void ResolveImage(nsPresContext* aContext) { - MOZ_ASSERT(mType != eStyleImageType_Image || mImage); - if (mType == eStyleImageType_Image && !mImage->IsResolved()) { - mImage->Resolve(aContext); - } - } - nsStyleImageType GetType() const { return mType; } @@ -560,7 +528,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColor ~nsStyleColor() { MOZ_COUNT_DTOR(nsStyleColor); } - void FinishStyle(nsPresContext* aPresContext) {} nscolor CalcComplexColor(const mozilla::StyleComplexColor& aColor) const { return mozilla::LinearBlendColors(aColor.mColor, mColor, @@ -831,12 +798,6 @@ struct nsStyleImageLayers { // Initialize mRepeat and mOrigin by specified layer type void Initialize(LayerType aType); - void ResolveImage(nsPresContext* aContext) { - if (mImage.GetType() == eStyleImageType_Image) { - mImage.ResolveImage(aContext); - } - } - // True if the rendering of this layer might change when the size // of the background positioning area changes. This is true for any // non-solid-color background whose position or size depends on @@ -883,12 +844,6 @@ struct nsStyleImageLayers { const Layer& BottomLayer() const { return mLayers[mImageCount - 1]; } - void ResolveImages(nsPresContext* aContext) { - for (uint32_t i = 0; i < mImageCount; ++i) { - mLayers[i].ResolveImage(aContext); - } - } - nsChangeHint CalcDifference(const nsStyleImageLayers& aNewLayers, nsStyleImageLayers::LayerType aType) const; @@ -911,11 +866,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBackground { nsStyleBackground(const nsStyleBackground& aOther); ~nsStyleBackground(); - // Resolves and tracks the images in mImage. Only called with a Servo-backed - // style system, where those images must be resolved later than the OMT - // nsStyleBackground constructor call. - void FinishStyle(nsPresContext* aPresContext); - void* operator new(size_t sz, nsStyleBackground* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { return aContext->PresShell()-> @@ -967,7 +917,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleMargin ~nsStyleMargin() { MOZ_COUNT_DTOR(nsStyleMargin); } - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleMargin* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -1015,7 +964,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePadding ~nsStylePadding() { MOZ_COUNT_DTOR(nsStylePadding); } - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStylePadding* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -1227,11 +1175,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder nsStyleBorder(const nsStyleBorder& aBorder); ~nsStyleBorder(); - // Resolves and tracks mBorderImageSource. Only called with a Servo-backed - // style system, where those images must be resolved later than the OMT - // nsStyleBorder constructor call. - void FinishStyle(nsPresContext* aPresContext); - void* operator new(size_t sz, nsStyleBorder* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { return aContext->PresShell()-> @@ -1334,13 +1277,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder return mBorderImageSource.IsLoaded(); } - void ResolveImage(nsPresContext* aContext) - { - if (mBorderImageSource.GetType() == eStyleImageType_Image) { - mBorderImageSource.ResolveImage(aContext); - } - } - nsMargin GetImageOutset() const; void GetCompositeColors(int32_t aIndex, nsBorderColors** aColors) const @@ -1454,7 +1390,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleOutline ~nsStyleOutline() { MOZ_COUNT_DTOR(nsStyleOutline); } - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleOutline* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -1529,8 +1464,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList nsStyleList(const nsStyleList& aStyleList); ~nsStyleList(); - void FinishStyle(nsPresContext* aPresContext); - void* operator new(size_t sz, nsStyleList* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { return aContext->PresShell()-> @@ -1754,7 +1687,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition explicit nsStylePosition(StyleStructContext aContext); nsStylePosition(const nsStylePosition& aOther); ~nsStylePosition(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStylePosition* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -1992,7 +1924,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTextReset explicit nsStyleTextReset(StyleStructContext aContext); nsStyleTextReset(const nsStyleTextReset& aOther); ~nsStyleTextReset(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleTextReset* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -2041,7 +1972,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText explicit nsStyleText(StyleStructContext aContext); nsStyleText(const nsStyleText& aOther); ~nsStyleText(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleText* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -2269,7 +2199,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility ~nsStyleVisibility() { MOZ_COUNT_DTOR(nsStyleVisibility); } - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleVisibility* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -2777,7 +2706,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay ~nsStyleDisplay() { MOZ_COUNT_DTOR(nsStyleDisplay); } - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleDisplay* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3091,7 +3019,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTable explicit nsStyleTable(StyleStructContext aContext); nsStyleTable(const nsStyleTable& aOther); ~nsStyleTable(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleTable* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3123,7 +3050,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTableBorder explicit nsStyleTableBorder(StyleStructContext aContext); nsStyleTableBorder(const nsStyleTableBorder& aOther); ~nsStyleTableBorder(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleTableBorder* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3232,7 +3158,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleContent explicit nsStyleContent(StyleStructContext aContext); nsStyleContent(const nsStyleContent& aContent); ~nsStyleContent(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleContent* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3313,7 +3238,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUIReset explicit nsStyleUIReset(StyleStructContext aContext); nsStyleUIReset(const nsStyleUIReset& aOther); ~nsStyleUIReset(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleUIReset* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3386,7 +3310,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUserInterface explicit nsStyleUserInterface(StyleStructContext aContext); nsStyleUserInterface(const nsStyleUserInterface& aOther); ~nsStyleUserInterface(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleUserInterface* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3432,7 +3355,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleXUL explicit nsStyleXUL(StyleStructContext aContext); nsStyleXUL(const nsStyleXUL& aSource); ~nsStyleXUL(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleXUL* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3472,7 +3394,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColumn explicit nsStyleColumn(StyleStructContext aContext); nsStyleColumn(const nsStyleColumn& aSource); ~nsStyleColumn(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleColumn* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3596,7 +3517,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVG explicit nsStyleSVG(StyleStructContext aContext); nsStyleSVG(const nsStyleSVG& aSource); ~nsStyleSVG(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleSVG* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3730,7 +3650,6 @@ struct nsStyleFilter nsStyleFilter(); nsStyleFilter(const nsStyleFilter& aSource); ~nsStyleFilter(); - void FinishStyle(nsPresContext* aPresContext) {} nsStyleFilter& operator=(const nsStyleFilter& aOther); @@ -3788,11 +3707,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVGReset nsStyleSVGReset(const nsStyleSVGReset& aSource); ~nsStyleSVGReset(); - // Resolves and tracks the images in mMask. Only called with a Servo-backed - // style system, where those images must be resolved later than the OMT - // nsStyleSVGReset constructor call. - void FinishStyle(nsPresContext* aPresContext); - void* operator new(size_t sz, nsStyleSVGReset* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { return aContext->PresShell()-> @@ -3844,7 +3758,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVariables explicit nsStyleVariables(StyleStructContext aContext); nsStyleVariables(const nsStyleVariables& aSource); ~nsStyleVariables(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleVariables* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) { @@ -3875,7 +3788,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleEffects explicit nsStyleEffects(StyleStructContext aContext); nsStyleEffects(const nsStyleEffects& aSource); ~nsStyleEffects(); - void FinishStyle(nsPresContext* aPresContext) {} void* operator new(size_t sz, nsStyleEffects* aSelf) { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) {