style: Invalidate for CSSOM changes in a more fine-grained way.

Also, for changes in CSS declarations, like changing
cssRules[i].style.color or something, we end up avoiding a lot of the
work we were doing.

This page still trips us in the sense that they add a stylesheet, then
call getBoundingClientRect(), then insert more rules in the stylesheet,
which causes us to rebuild a lot of the cascade data.

We could try to detect appends to the last stylesheet on the list or
something I guess, and avoid rebuilding the cascade data in some cases.

Depends on D85615

Differential Revision: https://phabricator.services.mozilla.com/D85616
This commit is contained in:
Emilio Cobos Álvarez 2020-08-10 18:00:44 +00:00
parent dfa715a8d8
commit ca7e1ecfd8
6 changed files with 273 additions and 74 deletions

View file

@ -13,6 +13,7 @@ use crate::font_metrics::FontMetricsProvider;
use crate::gecko_bindings::structs::{ServoStyleSetSizes, StyleRuleInclusion};
use crate::invalidation::element::invalidation_map::InvalidationMap;
use crate::invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey};
use crate::invalidation::stylesheets::RuleChangeKind;
use crate::media_queries::Device;
use crate::properties::{self, CascadeMode, ComputedValues};
use crate::properties::{AnimationDeclarations, PropertyDeclarationBlock};
@ -605,6 +606,18 @@ impl Stylist {
.remove_stylesheet(Some(&self.device), sheet, guard)
}
/// Notify of a change of a given rule.
pub fn rule_changed(
&mut self,
sheet: &StylistSheet,
rule: &CssRule,
guard: &SharedRwLockReadGuard,
change_kind: RuleChangeKind,
) {
self.stylesheets
.rule_changed(Some(&self.device), sheet, rule, guard, change_kind)
}
/// Appends a new stylesheet to the current set.
#[inline]
pub fn sheet_count(&self, origin: Origin) -> usize {