Measure selectors.

This patch adds measurement of Selectors within StyleRule. This requires
exposing the pointer within ThinArc.

The patch also adds measurement of the several CssRule variants, in order to
measure nested CssRules (and PropertyDeclarationBlocks) within them:
DocumentRule, MediaRule, PageRule, SupportsRule.
This commit is contained in:
Nicholas Nethercote 2017-09-07 13:24:40 +10:00
parent 812cac78f0
commit 61877b7316
8 changed files with 95 additions and 15 deletions

View file

@ -13,7 +13,7 @@ use servo_arc::Arc;
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
use std::fmt;
use style_traits::{ToCss, ParseError, StyleParseError};
use stylesheets::CssRules;
use stylesheets::{CssRules, MallocSizeOfFn, MallocSizeOfWithGuard};
use values::specified::url::SpecifiedUrl;
#[derive(Debug)]
@ -27,6 +27,15 @@ pub struct DocumentRule {
pub source_location: SourceLocation,
}
impl DocumentRule {
/// Measure heap usage.
pub fn malloc_size_of_children(&self, guard: &SharedRwLockReadGuard,
malloc_size_of: MallocSizeOfFn) -> usize {
// Measurement of other fields may be added later.
self.rules.read_with(guard).malloc_size_of_children(guard, malloc_size_of)
}
}
impl ToCssWithGuard for DocumentRule {
fn to_css<W>(&self, guard: &SharedRwLockReadGuard, dest: &mut W) -> fmt::Result
where W: fmt::Write {