diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index b95929bf6be2..6869ba4fdd04 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -10272,6 +10272,14 @@ nsIFrame::UpdateStyleOfOwnedChildFrame( aNewStyleContext, &equalStructs, &samePointerStructs); + + // CalcStyleDifference will handle caching structs on the new style context, + // but only if we're not on a style worker thread. + MOZ_ASSERT(!ServoStyleSet::IsInServoTraversal(), + "if we can get in here from style worker threads, then we need " + "a ResolveSameStructsAs call to ensure structs are cached on " + "aNewStyleContext"); + // If aChildFrame is out of flow, then aRestyleState's "changes handled by the // parent" doesn't apply to it, because it may have some other parent in the // frame tree. diff --git a/layout/style/nsStyleContext.cpp b/layout/style/nsStyleContext.cpp index b610cde4bfdb..d8317d61a899 100644 --- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -258,7 +258,8 @@ nsStyleContext::CalcStyleDifferenceInternal(StyleContextLike* aNewContext, unrequestedStruct = false; \ } \ if (this##struct_) { \ - const nsStyle##struct_* other##struct_ = aNewContext->Style##struct_(); \ + const nsStyle##struct_* other##struct_ = \ + aNewContext->ThreadsafeStyle##struct_(); \ if (this##struct_ == other##struct_) { \ /* The very same struct, so we know that there will be no */ \ /* differences. */ \ @@ -338,7 +339,7 @@ nsStyleContext::CalcStyleDifferenceInternal(StyleContextLike* aNewContext, #define STYLE_STRUCT(name_, callback_) \ { \ const nsStyle##name_* data = PeekStyle##name_(); \ - if (!data || data == aNewContext->Style##name_()) { \ + if (!data || data == aNewContext->ThreadsafeStyle##name_()) { \ *aSamePointerStructs |= NS_STYLE_INHERIT_BIT(name_); \ } \ } @@ -387,8 +388,10 @@ nsStyleContext::CalcStyleDifferenceInternal(StyleContextLike* aNewContext, #define STYLE_FIELD(name_) thisVisStruct->name_ != otherVisStruct->name_ #define STYLE_STRUCT(name_, fields_) \ if (!change && PeekStyle##name_()) { \ - const nsStyle##name_* thisVisStruct = thisVis->Style##name_(); \ - const nsStyle##name_* otherVisStruct = otherVis->Style##name_(); \ + const nsStyle##name_* thisVisStruct = \ + thisVis->ThreadsafeStyle##name_(); \ + const nsStyle##name_* otherVisStruct = \ + otherVis->ThreadsafeStyle##name_(); \ if (MOZ_FOR_EACH_SEPARATED(STYLE_FIELD, (||), (), fields_)) { \ change = true; \ } \ diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index d83cac961a0b..85906efb9244 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -8067,6 +8067,14 @@ nsTableFrame::UpdateStyleOfOwnedAnonBoxesForTableWrapper( newContext, &equalStructs, &samePointerStructs); + + // CalcStyleDifference will handle caching structs on the new style context, + // but only if we're not on a style worker thread. + MOZ_ASSERT(!ServoStyleSet::IsInServoTraversal(), + "if we can get in here from style worker threads, then we need " + "a ResolveSameStructsAs call to ensure structs are cached on " + "aNewStyleContext"); + if (wrapperHint) { aRestyleState.ChangeList().AppendChange( aWrapperFrame, aWrapperFrame->GetContent(), wrapperHint);