mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Diagnostic map semantics.
MozReview-Commit-ID: C0a5g6xMPY0
This commit is contained in:
parent
438b9df00c
commit
f5c5be00a7
11 changed files with 296 additions and 69 deletions
|
@ -478,12 +478,6 @@ impl Stylist {
|
|||
.map(|(d, _)| d.selectors_for_cache_revalidation.len()).sum()
|
||||
}
|
||||
|
||||
/// Returns the number of entries in invalidation maps.
|
||||
pub fn num_invalidations(&self) -> usize {
|
||||
self.cascade_data.iter_origins()
|
||||
.map(|(d, _)| d.invalidation_map.len()).sum()
|
||||
}
|
||||
|
||||
/// Invokes `f` with the `InvalidationMap` for each origin.
|
||||
///
|
||||
/// NOTE(heycam) This might be better as an `iter_invalidation_maps`, once
|
||||
|
@ -1870,6 +1864,32 @@ impl CascadeData {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
fn begin_mutation(&mut self, rebuild_kind: &SheetRebuildKind) {
|
||||
self.element_map.begin_mutation();
|
||||
self.pseudos_map.for_each(|m| m.begin_mutation());
|
||||
if rebuild_kind.should_rebuild_invalidation() {
|
||||
self.invalidation_map.begin_mutation();
|
||||
self.selectors_for_cache_revalidation.begin_mutation();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
fn begin_mutation(&mut self, _: &SheetRebuildKind) {}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
fn end_mutation(&mut self, rebuild_kind: &SheetRebuildKind) {
|
||||
self.element_map.end_mutation();
|
||||
self.pseudos_map.for_each(|m| m.end_mutation());
|
||||
if rebuild_kind.should_rebuild_invalidation() {
|
||||
self.invalidation_map.end_mutation();
|
||||
self.selectors_for_cache_revalidation.end_mutation();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
fn end_mutation(&mut self, _: &SheetRebuildKind) {}
|
||||
|
||||
/// Collects all the applicable media query results into `results`.
|
||||
///
|
||||
/// This duplicates part of the logic in `add_stylesheet`, which is
|
||||
|
@ -1933,6 +1953,7 @@ impl CascadeData {
|
|||
self.effective_media_query_results.saw_effective(stylesheet);
|
||||
}
|
||||
|
||||
self.begin_mutation(&rebuild_kind);
|
||||
for rule in stylesheet.effective_rules(device, guard) {
|
||||
match *rule {
|
||||
CssRule::Style(ref locked) => {
|
||||
|
@ -1969,8 +1990,11 @@ impl CascadeData {
|
|||
None => &mut self.element_map,
|
||||
Some(pseudo) => {
|
||||
self.pseudos_map
|
||||
.get_or_insert_with(&pseudo.canonical(), || Box::new(SelectorMap::new()))
|
||||
.expect("Unexpected tree pseudo-element?")
|
||||
.get_or_insert_with(&pseudo.canonical(), || {
|
||||
let mut map = Box::new(SelectorMap::new());
|
||||
map.begin_mutation();
|
||||
map
|
||||
}).expect("Unexpected tree pseudo-element?")
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2064,6 +2088,7 @@ impl CascadeData {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
self.end_mutation(&rebuild_kind);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue