Measure memory usage of Stylo's Rule Tree.

This commit is contained in:
Nicholas Nethercote 2017-08-30 21:46:15 +10:00
parent 5dee83d54d
commit e08829703a
7 changed files with 126 additions and 10 deletions

View file

@ -7,8 +7,8 @@
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use dom::TElement;
use gecko_bindings::bindings::{self, RawServoStyleSet};
use gecko_bindings::structs::{ServoStyleSheet, StyleSheetInfo, ServoStyleSheetInner};
use gecko_bindings::structs::RawGeckoPresContextOwned;
use gecko_bindings::structs::{RawGeckoPresContextOwned, ServoStyleSetSizes, ServoStyleSheet};
use gecko_bindings::structs::{StyleSheetInfo, ServoStyleSheetInner};
use gecko_bindings::structs::nsIDocument;
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
@ -16,7 +16,7 @@ use media_queries::{Device, MediaList};
use properties::ComputedValues;
use servo_arc::Arc;
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
use stylesheets::{PerOrigin, StylesheetContents, StylesheetInDocument};
use stylesheets::{MallocSizeOfFn, PerOrigin, StylesheetContents, StylesheetInDocument};
use stylist::{ExtraStyleData, Stylist};
/// Little wrapper to a Gecko style sheet.
@ -184,6 +184,14 @@ impl PerDocumentStyleDataImpl {
pub fn visited_styles_enabled(&self) -> bool {
self.visited_links_enabled() && !self.is_private_browsing_enabled()
}
/// Measures heap usage.
pub fn malloc_add_size_of_children(&self, malloc_size_of: MallocSizeOfFn,
sizes: &mut ServoStyleSetSizes) {
self.stylist.malloc_add_size_of_children(malloc_size_of, sizes);
// We may measure more fields in the future if DMD says it's worth it.
}
}
unsafe impl HasFFI for PerDocumentStyleData {