Bug 1418433 - increment RestyleGeneration for undisplayed elements when updating servo stylist. r=heycam

In the current implementation, we call SetStylistStyleSheetsDirty() every time
a style sheet is changed. However, the dirty bit setting may or may not always
update the style data. For example, the style data for undisplayed elements are
deliberately not updated in Stylo. However, the getComputedStyle API is supposed
to provide a way to get the up-to-date computed style data, even for undisplayed
elements.

In this patch, we increment RestyleGeneration for undisplayed elements when we
decide to update style data (i.e., calling ServoStyleSet::UpdateStylist()) due
to (XBL)StyleSheet is dirty. This could flush the cached data that getComputedStyle
API holds, and ensures the getComputedStyle API computes a new one.

MozReview-Commit-ID: JDDhACOG3z4

--HG--
extra : rebase_source : 51d37757b5449d315aa7c2e0aedb4a4622e2a859
This commit is contained in:
Jeremy Chen 2017-11-26 11:47:27 +08:00
parent b44b5ae893
commit 52cf386fc1

View File

@ -1330,6 +1330,11 @@ ServoStyleSet::UpdateStylist()
mBindingManager->UpdateBoundContentBindingsForServo(mPresContext);
}
// We need to invalidate cached style in getComputedStyle for undisplayed
// elements, since we don't know if any of the style sheet change that we
// do would affect undisplayed elements.
mPresContext->RestyleManager()->AsServo()->IncrementUndisplayedRestyleGeneration();
mStylistState = StylistState::NotDirty;
}