stylo: Measure Elements and ComputedValues.

The patch provides FFI access to Gecko's SeenPtrs type from Rust, in
order to record what has already been measured when measuring Arcs. (The
SeenPtrs must be initialized on the Gecko side because the same table is
reused for measuring all Elements within a window, because Elements can
share ComputedValues.) I have confirmed with DMD that this is working
correctly.

The patch also introduces MallocSizeOfRepeats, which is like
MallocSizeOf but takes a SizeOfState, which holds a SeenPtrs table.
This commit is contained in:
Nicholas Nethercote 2017-08-02 16:42:09 +10:00
parent e07beacd4d
commit 526e9691f8
9 changed files with 161 additions and 5 deletions

View file

@ -15,6 +15,8 @@ use servo_arc::Arc;
use shared_lock::StylesheetGuards;
use std::fmt;
use std::ops::{Deref, DerefMut};
#[cfg(feature = "gecko")]
use stylesheets::{MallocSizeOfWithRepeats, SizeOfState};
bitflags! {
flags RestyleFlags: u8 {
@ -242,6 +244,20 @@ impl fmt::Debug for ElementStyles {
}
}
#[cfg(feature = "gecko")]
impl MallocSizeOfWithRepeats for ElementStyles {
fn malloc_size_of_children(&self, state: &mut SizeOfState) -> usize {
let mut n = 0;
if let Some(ref primary) = self.primary {
n += primary.malloc_size_of_children(state)
};
// We may measure more fields in the future if DMD says it's worth it.
n
}
}
/// Style system data associated with an Element.
///
/// In Gecko, this hangs directly off the Element. Servo, this is embedded
@ -392,3 +408,14 @@ impl ElementData {
self.restyle.clear_flags_and_damage();
}
}
#[cfg(feature = "gecko")]
impl MallocSizeOfWithRepeats for ElementData {
fn malloc_size_of_children(&self, state: &mut SizeOfState) -> usize {
let n = self.styles.malloc_size_of_children(state);
// We may measure more fields in the future if DMD says it's worth it.
n
}
}