mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
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:
parent
e07beacd4d
commit
526e9691f8
9 changed files with 161 additions and 5 deletions
|
@ -60,6 +60,7 @@ use selector_parser::PseudoElement;
|
|||
use servo_arc::{Arc, RawOffsetArc};
|
||||
use std::mem::{forget, uninitialized, transmute, zeroed};
|
||||
use std::{cmp, ops, ptr};
|
||||
use stylesheets::{MallocSizeOfWithRepeats, SizeOfState};
|
||||
use values::{self, Auto, CustomIdent, Either, KeyframesName};
|
||||
use values::computed::ToComputedValue;
|
||||
use values::computed::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
|
@ -308,6 +309,11 @@ impl ComputedValuesInner {
|
|||
self.visited_style.as_ref().map(|x| &**x)
|
||||
}
|
||||
|
||||
/// Gets the raw visited style. Useful for memory reporting.
|
||||
pub fn get_raw_visited_style(&self) -> &Option<RawOffsetArc<ComputedValues>> {
|
||||
&self.visited_style
|
||||
}
|
||||
|
||||
/// Gets a reference to the visited style. Panic if no visited style exists.
|
||||
pub fn visited_style(&self) -> &ComputedValues {
|
||||
self.get_visited_style().unwrap()
|
||||
|
@ -364,6 +370,18 @@ impl ComputedValuesInner {
|
|||
}
|
||||
}
|
||||
|
||||
impl MallocSizeOfWithRepeats for ComputedValues {
|
||||
fn malloc_size_of_children(&self, state: &mut SizeOfState) -> usize {
|
||||
let mut n = 0;
|
||||
if let Some(ref raw_offset_arc) = *self.get_raw_visited_style() {
|
||||
n += raw_offset_arc.with_arc(|a: &Arc<ComputedValues>| {
|
||||
a.malloc_size_of_children(state)
|
||||
})
|
||||
}
|
||||
n
|
||||
}
|
||||
}
|
||||
|
||||
<%def name="declare_style_struct(style_struct)">
|
||||
pub use ::gecko_bindings::structs::mozilla::Gecko${style_struct.gecko_name} as ${style_struct.gecko_struct_name};
|
||||
impl ${style_struct.gecko_struct_name} {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue