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
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue