mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Measure the stylist during memory reporting.
This commit is contained in:
parent
f648e12935
commit
d880efcab3
14 changed files with 356 additions and 28 deletions
|
@ -14,6 +14,8 @@ use selectors::parser::{Combinator, Component};
|
|||
use selectors::parser::{Selector, SelectorIter, SelectorMethods};
|
||||
use selectors::visitor::SelectorVisitor;
|
||||
use smallvec::SmallVec;
|
||||
#[cfg(feature = "gecko")]
|
||||
use stylesheets::{MallocEnclosingSizeOfFn, MallocSizeOfHash};
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
/// Gets the element state relevant to the given `:dir` pseudo-class selector.
|
||||
|
@ -287,6 +289,31 @@ impl InvalidationMap {
|
|||
index += 1; // Account for the combinator.
|
||||
}
|
||||
}
|
||||
|
||||
/// Measures heap usage.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn malloc_size_of_children(&self, malloc_enclosing_size_of: MallocEnclosingSizeOfFn)
|
||||
-> usize {
|
||||
// Currently we measure the HashMap storage, but not things pointed to
|
||||
// by keys and values.
|
||||
let mut n = 0;
|
||||
|
||||
n += self.class_to_selector.malloc_shallow_size_of_hash(malloc_enclosing_size_of);
|
||||
for (_, val) in self.class_to_selector.iter() {
|
||||
n += val.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
}
|
||||
|
||||
n += self.id_to_selector.malloc_shallow_size_of_hash(malloc_enclosing_size_of);
|
||||
for (_, val) in self.id_to_selector.iter() {
|
||||
n += val.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
}
|
||||
|
||||
n += self.state_affecting_selectors.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
|
||||
n += self.other_attribute_affecting_selectors.malloc_size_of_children(
|
||||
malloc_enclosing_size_of);
|
||||
n
|
||||
}
|
||||
}
|
||||
|
||||
/// A struct that collects invalidations for a given compound selector.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue