Diagnostic map semantics.

MozReview-Commit-ID: C0a5g6xMPY0
This commit is contained in:
Bobby Holley 2017-09-28 19:10:46 -05:00
parent 438b9df00c
commit f5c5be00a7
11 changed files with 296 additions and 69 deletions

View file

@ -178,18 +178,6 @@ impl InvalidationMap {
}
}
/// Returns the number of dependencies stored in the invalidation map.
pub fn len(&self) -> usize {
self.state_affecting_selectors.len() +
self.other_attribute_affecting_selectors.len() +
self.id_to_selector.iter().fold(0, |accum, (_, ref v)| {
accum + v.len()
}) +
self.class_to_selector.iter().fold(0, |accum, (_, ref v)| {
accum + v.len()
})
}
/// Adds a selector to this `InvalidationMap`. Returns Err(..) to
/// signify OOM.
pub fn note_selector(
@ -252,8 +240,7 @@ impl InvalidationMap {
for class in compound_visitor.classes {
self.class_to_selector
.entry(class, quirks_mode)
.or_insert_with(SmallVec::new)
.try_get_or_insert_with(class, quirks_mode, SmallVec::new)?
.try_push(Dependency {
selector: selector.clone(),
selector_offset: sequence_start,
@ -262,8 +249,7 @@ impl InvalidationMap {
for id in compound_visitor.ids {
self.id_to_selector
.entry(id, quirks_mode)
.or_insert_with(SmallVec::new)
.try_get_or_insert_with(id, quirks_mode, SmallVec::new)?
.try_push(Dependency {
selector: selector.clone(),
selector_offset: sequence_start,
@ -299,6 +285,22 @@ impl InvalidationMap {
Ok(())
}
/// Allows mutation of this InvalidationMap.
pub fn begin_mutation(&mut self) {
self.class_to_selector.begin_mutation();
self.id_to_selector.begin_mutation();
self.state_affecting_selectors.begin_mutation();
self.other_attribute_affecting_selectors.begin_mutation();
}
/// Disallows mutation of this InvalidationMap.
pub fn end_mutation(&mut self) {
self.class_to_selector.end_mutation();
self.id_to_selector.end_mutation();
self.state_affecting_selectors.end_mutation();
self.other_attribute_affecting_selectors.end_mutation();
}
}
/// A struct that collects invalidations for a given compound selector.