mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
parent
d6bafde971
commit
b118ba72d0
11 changed files with 70 additions and 298 deletions
|
@ -172,6 +172,18 @@ 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(
|
||||
|
@ -234,7 +246,8 @@ impl InvalidationMap {
|
|||
|
||||
for class in compound_visitor.classes {
|
||||
self.class_to_selector
|
||||
.try_get_or_insert_with(class, quirks_mode, SmallVec::new)?
|
||||
.entry(class, quirks_mode)
|
||||
.or_insert_with(SmallVec::new)
|
||||
.try_push(Dependency {
|
||||
selector: selector.clone(),
|
||||
selector_offset: sequence_start,
|
||||
|
@ -243,7 +256,8 @@ impl InvalidationMap {
|
|||
|
||||
for id in compound_visitor.ids {
|
||||
self.id_to_selector
|
||||
.try_get_or_insert_with(id, quirks_mode, SmallVec::new)?
|
||||
.entry(id, quirks_mode)
|
||||
.or_insert_with(SmallVec::new)
|
||||
.try_push(Dependency {
|
||||
selector: selector.clone(),
|
||||
selector_offset: sequence_start,
|
||||
|
@ -279,22 +293,6 @@ 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