Bug 1380133 - Part 4: Make CalcStyleDifferenceInternal not cache any new structs on ServoStyleContexts when in a traversal. r=emilio

MozReview-Commit-ID: Eu4MvdQUBor
---
 layout/generic/nsFrame.cpp      |  8 ++++++++
 layout/style/nsStyleContext.cpp | 11 +++++++----
 layout/tables/nsTableFrame.cpp  |  8 ++++++++
 3 files changed, 23 insertions(+), 4 deletions(-)

--HG--
extra : rebase_source : b77d33b5823eca4a57e568881c00959ddecf9089
This commit is contained in:
Cameron McCormack 2017-07-21 11:42:43 +08:00
parent d77c5d77d8
commit 350253019b
3 changed files with 23 additions and 4 deletions

View File

@ -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.

View File

@ -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; \
} \

View File

@ -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);