Bug 1854744 - Document::RecordShadowStyleChange doesn't need to invalidate global stylesheet state. r=jrmuizel

Things like @font-face / @font-pallete-values etc don't look into those
stylesheets.

This prevents bugs in invalidation like bug 1854742 from triggering on
shadow root style changes like when changing AdoptedStyleSheets and so
on.

Differential Revision: https://phabricator.services.mozilla.com/D189034
This commit is contained in:
Emilio Cobos Álvarez 2023-09-24 09:52:04 +00:00
parent 3dc6795b84
commit ea1452eb90
3 changed files with 18 additions and 10 deletions

View file

@ -7343,17 +7343,18 @@ void Document::AddStyleSheetToStyleSets(StyleSheet& aSheet) {
void Document::RecordShadowStyleChange(ShadowRoot& aShadowRoot) {
mStyleSet->RecordShadowStyleChange(aShadowRoot);
ApplicableStylesChanged();
ApplicableStylesChanged(/* aKnownInShadowTree= */ true);
}
void Document::ApplicableStylesChanged() {
void Document::ApplicableStylesChanged(bool aKnownInShadowTree) {
// TODO(emilio): if we decide to resolve style in display: none iframes, then
// we need to always track style changes and remove the mStyleSetFilled.
if (!mStyleSetFilled) {
return;
}
MarkUserFontSetDirty();
if (!aKnownInShadowTree) {
MarkUserFontSetDirty();
}
PresShell* ps = GetPresShell();
if (!ps) {
return;
@ -7365,9 +7366,11 @@ void Document::ApplicableStylesChanged() {
return;
}
pc->MarkCounterStylesDirty();
pc->MarkFontFeatureValuesDirty();
pc->MarkFontPaletteValuesDirty();
if (!aKnownInShadowTree) {
pc->MarkCounterStylesDirty();
pc->MarkFontFeatureValuesDirty();
pc->MarkFontPaletteValuesDirty();
}
pc->RestyleManager()->NextRestyleIsForCSSRuleChanges();
}

View file

@ -1646,7 +1646,11 @@ class Document : public nsINode,
// Needs to be called any time the applicable style can has changed, in order
// to schedule a style flush and setup all the relevant state.
void ApplicableStylesChanged();
//
// If we know the stylesheet change applies only to a shadow tree we can avoid
// some work (like updating the font-face-set / counter-styles / etc, as those
// are global).
void ApplicableStylesChanged(bool aKnownInShadowTree = false);
// Whether we filled the style set with any style sheet. Only meant to be used
// from DocumentOrShadowRoot::Traverse.

View file

@ -328,11 +328,12 @@ void ServoStyleSet::PreTraverseSync() {
// is necessary to avoid a data race when updating the cache.
Unused << mDocument->GetRootElement();
// FIXME(emilio): This shouldn't be needed in theory, the call to the same
// function in PresShell should do the work, but as it turns out we
// FIXME(emilio): These two shouldn't be needed in theory, the call to the
// same function in PresShell should do the work, but as it turns out we
// ProcessPendingRestyles() twice, and runnables from frames just constructed
// can end up doing editing stuff, which adds stylesheets etc...
mDocument->FlushUserFontSet();
UpdateStylistIfNeeded();
mDocument->ResolveScheduledPresAttrs();