Bug 1207734 - Part 1.a. Implement ReleaseSharedListOnMainThread to reuse the code of releasing nsCSSValueSharedList objects hold by a style struct.
MozReview-Commit-ID: IBfqulFXimi
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3687,39 +3687,46 @@ nsStyleDisplay::nsStyleDisplay(const nsS
, mAnimationPlayStateCount(aSource.mAnimationPlayStateCount)
, mAnimationIterationCountCount(aSource.mAnimationIterationCountCount)
, mShapeImageThreshold(aSource.mShapeImageThreshold)
, mShapeOutside(aSource.mShapeOutside)
{
MOZ_COUNT_CTOR(nsStyleDisplay);
}
-nsStyleDisplay::~nsStyleDisplay()
+
+static
+void ReleaseSharedListOnMainThread(const char* aName,
+ RefPtr<nsCSSValueSharedList>& aList)
{
// We don't allow releasing nsCSSValues with refcounted data in the Servo
// traversal, since the refcounts aren't threadsafe. Since Servo may trigger
// the deallocation of style structs during styling, we need to handle it
// here.
- if (mSpecifiedTransform && ServoStyleSet::IsInServoTraversal()) {
+ if (aList && ServoStyleSet::IsInServoTraversal()) {
// The default behavior of NS_ReleaseOnMainThreadSystemGroup is to only
// proxy the release if we're not already on the main thread. This is a nice
// optimization for the cases we happen to be doing a sequential traversal
// (i.e. a single-core machine), but it trips our assertions which check
// whether we're in a Servo traversal, parallel or not. So we
// unconditionally proxy in debug builds.
bool alwaysProxy =
#ifdef DEBUG
true;
#else
false;
#endif
- NS_ReleaseOnMainThreadSystemGroup(
- "nsStyleDisplay::mSpecifiedTransform",
- mSpecifiedTransform.forget(), alwaysProxy);
- }
+ NS_ReleaseOnMainThreadSystemGroup(aName, aList.forget(), alwaysProxy);
+ }
+}
+
+nsStyleDisplay::~nsStyleDisplay()
+{
+ ReleaseSharedListOnMainThread("nsStyleDisplay::mSpecifiedTransform",
+ mSpecifiedTransform);
MOZ_COUNT_DTOR(nsStyleDisplay);
}
void
nsStyleDisplay::FinishStyle(nsPresContext* aPresContext)
{
MOZ_ASSERT(NS_IsMainThread());
@@ -4639,28 +4646,18 @@ nsStyleUIReset::nsStyleUIReset(const nsS
{
MOZ_COUNT_CTOR(nsStyleUIReset);
}
nsStyleUIReset::~nsStyleUIReset()
{
MOZ_COUNT_DTOR(nsStyleUIReset);
- // See the nsStyleDisplay destructor for why we're doing this.
- if (mSpecifiedWindowTransform && ServoStyleSet::IsInServoTraversal()) {
- bool alwaysProxy =
-#ifdef DEBUG
- true;
-#else
- false;
-#endif
- NS_ReleaseOnMainThreadSystemGroup(
- "nsStyleUIReset::mSpecifiedWindowTransform",
- mSpecifiedWindowTransform.forget(), alwaysProxy);
- }
+ ReleaseSharedListOnMainThread("nsStyleUIReset::mSpecifiedWindowTransform",
+ mSpecifiedWindowTransform);
}
nsChangeHint
nsStyleUIReset::CalcDifference(const nsStyleUIReset& aNewData) const
{
nsChangeHint hint = nsChangeHint(0);
if (mForceBrokenImageIcon != aNewData.mForceBrokenImageIcon) {