mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +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.
|
||||
|
|
|
@ -8,8 +8,8 @@ use context::QuirksMode;
|
|||
use fnv::FnvHashSet;
|
||||
use media_queries::Device;
|
||||
use shared_lock::SharedRwLockReadGuard;
|
||||
use stylesheets::{DocumentRule, ImportRule, MediaRule, SupportsRule};
|
||||
use stylesheets::{NestedRuleIterationCondition, Stylesheet};
|
||||
use stylesheets::{DocumentRule, ImportRule, MallocEnclosingSizeOfFn, MallocSizeOfHash, MediaRule};
|
||||
use stylesheets::{NestedRuleIterationCondition, Stylesheet, SupportsRule};
|
||||
|
||||
/// A key for a given media query result.
|
||||
///
|
||||
|
@ -88,6 +88,12 @@ impl EffectiveMediaQueryResults {
|
|||
// because of stylesheet reusing... shrug.
|
||||
self.set.insert(item.to_media_list_key());
|
||||
}
|
||||
|
||||
/// Measure heap usage.
|
||||
pub fn malloc_size_of_children(&self, malloc_enclosing_size_of: MallocEnclosingSizeOfFn)
|
||||
-> usize {
|
||||
self.set.malloc_shallow_size_of_hash(malloc_enclosing_size_of)
|
||||
}
|
||||
}
|
||||
|
||||
/// A filter that filters over effective rules, but allowing all potentially
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue