mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Remove hashes from style rules and dependencies.
Dependencies are very numerous, and now we shouldn't be getting so many of them. Style rules just don't need them, so it's a waste of memory.
This commit is contained in:
parent
9394ea9644
commit
dee4aea264
8 changed files with 61 additions and 84 deletions
|
@ -10,8 +10,8 @@ use element_state::ElementState;
|
|||
use selector_map::{MaybeCaseInsensitiveHashMap, SelectorMap, SelectorMapEntry};
|
||||
use selector_parser::SelectorImpl;
|
||||
use selectors::attr::NamespaceConstraint;
|
||||
use selectors::parser::{AncestorHashes, Combinator, Component};
|
||||
use selectors::parser::{Selector, SelectorAndHashes, SelectorIter, SelectorMethods};
|
||||
use selectors::parser::{Combinator, Component};
|
||||
use selectors::parser::{Selector, SelectorIter, SelectorMethods};
|
||||
use selectors::visitor::SelectorVisitor;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
|
@ -59,10 +59,6 @@ pub struct Dependency {
|
|||
/// The dependency selector.
|
||||
#[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
|
||||
pub selector: Selector<SelectorImpl>,
|
||||
/// The ancestor hashes associated with the above selector at the given
|
||||
/// offset.
|
||||
#[cfg_attr(feature = "servo", ignore_heap_size_of = "No heap data")]
|
||||
pub hashes: AncestorHashes,
|
||||
/// The offset into the selector that we should match on.
|
||||
pub selector_offset: usize,
|
||||
}
|
||||
|
@ -188,10 +184,10 @@ impl InvalidationMap {
|
|||
/// Adds a selector to this `InvalidationMap`.
|
||||
pub fn note_selector(
|
||||
&mut self,
|
||||
selector_and_hashes: &SelectorAndHashes<SelectorImpl>,
|
||||
selector: &Selector<SelectorImpl>,
|
||||
quirks_mode: QuirksMode)
|
||||
{
|
||||
self.collect_invalidations_for(selector_and_hashes, quirks_mode)
|
||||
self.collect_invalidations_for(selector, quirks_mode)
|
||||
}
|
||||
|
||||
/// Clears this map, leaving it empty.
|
||||
|
@ -206,13 +202,12 @@ impl InvalidationMap {
|
|||
|
||||
fn collect_invalidations_for(
|
||||
&mut self,
|
||||
selector_and_hashes: &SelectorAndHashes<SelectorImpl>,
|
||||
selector: &Selector<SelectorImpl>,
|
||||
quirks_mode: QuirksMode)
|
||||
{
|
||||
debug!("InvalidationMap::collect_invalidations_for({:?})",
|
||||
selector_and_hashes.selector);
|
||||
debug!("InvalidationMap::collect_invalidations_for({:?})", selector);
|
||||
|
||||
let mut iter = selector_and_hashes.selector.iter();
|
||||
let mut iter = selector.iter();
|
||||
let mut combinator;
|
||||
let mut index = 0;
|
||||
|
||||
|
@ -241,22 +236,6 @@ impl InvalidationMap {
|
|||
index += 1; // Account for the simple selector.
|
||||
}
|
||||
|
||||
// Reuse the bloom hashes if this is the base selector. Otherwise,
|
||||
// rebuild them.
|
||||
let mut hashes = None;
|
||||
|
||||
let mut get_hashes = || -> AncestorHashes {
|
||||
if hashes.is_none() {
|
||||
hashes = Some(if sequence_start == 0 {
|
||||
selector_and_hashes.hashes.clone()
|
||||
} else {
|
||||
let seq_iter = selector_and_hashes.selector.iter_from(sequence_start);
|
||||
AncestorHashes::from_iter(seq_iter)
|
||||
});
|
||||
}
|
||||
hashes.clone().unwrap()
|
||||
};
|
||||
|
||||
self.has_id_attribute_selectors |= compound_visitor.has_id_attribute_selectors;
|
||||
self.has_class_attribute_selectors |= compound_visitor.has_class_attribute_selectors;
|
||||
|
||||
|
@ -265,9 +244,8 @@ impl InvalidationMap {
|
|||
.entry(class, quirks_mode)
|
||||
.or_insert_with(SelectorMap::new)
|
||||
.insert(Dependency {
|
||||
selector: selector_and_hashes.selector.clone(),
|
||||
selector: selector.clone(),
|
||||
selector_offset: sequence_start,
|
||||
hashes: get_hashes(),
|
||||
}, quirks_mode);
|
||||
}
|
||||
|
||||
|
@ -276,9 +254,8 @@ impl InvalidationMap {
|
|||
.entry(id, quirks_mode)
|
||||
.or_insert_with(SelectorMap::new)
|
||||
.insert(Dependency {
|
||||
selector: selector_and_hashes.selector.clone(),
|
||||
selector: selector.clone(),
|
||||
selector_offset: sequence_start,
|
||||
hashes: get_hashes(),
|
||||
}, quirks_mode);
|
||||
}
|
||||
|
||||
|
@ -286,9 +263,8 @@ impl InvalidationMap {
|
|||
self.state_affecting_selectors
|
||||
.insert(StateDependency {
|
||||
dep: Dependency {
|
||||
selector: selector_and_hashes.selector.clone(),
|
||||
selector: selector.clone(),
|
||||
selector_offset: sequence_start,
|
||||
hashes: get_hashes(),
|
||||
},
|
||||
state: compound_visitor.state,
|
||||
}, quirks_mode);
|
||||
|
@ -297,9 +273,8 @@ impl InvalidationMap {
|
|||
if compound_visitor.other_attributes {
|
||||
self.other_attribute_affecting_selectors
|
||||
.insert(Dependency {
|
||||
selector: selector_and_hashes.selector.clone(),
|
||||
selector: selector.clone(),
|
||||
selector_offset: sequence_start,
|
||||
hashes: get_hashes(),
|
||||
}, quirks_mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -762,14 +762,14 @@ impl<'a, 'b: 'a, E> InvalidationCollector<'a, 'b, E>
|
|||
let matched_then =
|
||||
matches_selector(&dependency.selector,
|
||||
dependency.selector_offset,
|
||||
&dependency.hashes,
|
||||
None,
|
||||
&self.wrapper,
|
||||
&mut then_context,
|
||||
&mut |_, _| {});
|
||||
let matches_now =
|
||||
matches_selector(&dependency.selector,
|
||||
dependency.selector_offset,
|
||||
&dependency.hashes,
|
||||
None,
|
||||
&self.element,
|
||||
&mut now_context,
|
||||
&mut |_, _| {});
|
||||
|
@ -802,7 +802,7 @@ impl<'a, 'b: 'a, E> InvalidationCollector<'a, 'b, E>
|
|||
let matched_then =
|
||||
matches_selector(&dependency.selector,
|
||||
dependency.selector_offset,
|
||||
&dependency.hashes,
|
||||
None,
|
||||
&self.wrapper,
|
||||
&mut then_context,
|
||||
&mut |_, _| {});
|
||||
|
@ -811,7 +811,7 @@ impl<'a, 'b: 'a, E> InvalidationCollector<'a, 'b, E>
|
|||
let matches_now =
|
||||
matches_selector(&dependency.selector,
|
||||
dependency.selector_offset,
|
||||
&dependency.hashes,
|
||||
None,
|
||||
&self.element,
|
||||
&mut now_context,
|
||||
&mut |_, _| {});
|
||||
|
|
|
@ -282,8 +282,8 @@ impl StylesheetInvalidationSet {
|
|||
match *rule {
|
||||
Style(ref lock) => {
|
||||
let style_rule = lock.read_with(guard);
|
||||
for selector_and_hashes in &style_rule.selectors.0 {
|
||||
self.collect_scopes(&selector_and_hashes.selector);
|
||||
for selector in &style_rule.selectors.0 {
|
||||
self.collect_scopes(selector);
|
||||
if self.fully_invalid {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue