mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +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
|
@ -14,6 +14,7 @@ use gecko_bindings::structs::mozilla::css::ImageValue;
|
|||
use gecko_bindings::structs::mozilla::css::URLValue;
|
||||
use gecko_bindings::structs::mozilla::css::URLValueData;
|
||||
use gecko_bindings::structs::mozilla::MallocSizeOf;
|
||||
use gecko_bindings::structs::mozilla::SeenPtrs;
|
||||
use gecko_bindings::structs::mozilla::Side;
|
||||
use gecko_bindings::structs::nsIContent;
|
||||
use gecko_bindings::structs::nsIDocument;
|
||||
|
@ -1081,6 +1082,10 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_DropElementSnapshot(snapshot: ServoElementSnapshotOwned);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_HaveSeenPtr(table: *mut SeenPtrs, ptr: *const ::std::os::raw::c_void)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ResizeTArrayForStrings(array: *mut nsTArray<nsStringRepr>,
|
||||
length: u32);
|
||||
|
@ -1878,6 +1883,11 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_Element_ClearData(node: RawGeckoElementBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_Element_SizeOfExcludingThis(malloc_size_of: MallocSizeOf,
|
||||
seen_ptrs: *mut SeenPtrs,
|
||||
node: RawGeckoElementBorrowed) -> usize;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSheet_FromUTF8Bytes(loader: *mut Loader,
|
||||
gecko_stylesheet:
|
||||
|
|
|
@ -6024,6 +6024,21 @@ pub mod root {
|
|||
MAX = 29,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy)]
|
||||
pub struct SeenPtrs {
|
||||
pub _bindgen_opaque_blob: [u64; 6usize],
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_SeenPtrs() {
|
||||
assert_eq!(::std::mem::size_of::<SeenPtrs>() , 48usize , concat !
|
||||
( "Size of: " , stringify ! ( SeenPtrs ) ));
|
||||
assert_eq! (::std::mem::align_of::<SeenPtrs>() , 8usize , concat !
|
||||
( "Alignment of " , stringify ! ( SeenPtrs ) ));
|
||||
}
|
||||
impl Clone for SeenPtrs {
|
||||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct URLExtraData {
|
||||
pub mRefCnt: root::mozilla::ThreadSafeAutoRefCnt,
|
||||
|
|
|
@ -5906,6 +5906,21 @@ pub mod root {
|
|||
MAX = 29,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy)]
|
||||
pub struct SeenPtrs {
|
||||
pub _bindgen_opaque_blob: [u64; 5usize],
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_SeenPtrs() {
|
||||
assert_eq!(::std::mem::size_of::<SeenPtrs>() , 40usize , concat !
|
||||
( "Size of: " , stringify ! ( SeenPtrs ) ));
|
||||
assert_eq! (::std::mem::align_of::<SeenPtrs>() , 8usize , concat !
|
||||
( "Alignment of " , stringify ! ( SeenPtrs ) ));
|
||||
}
|
||||
impl Clone for SeenPtrs {
|
||||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct URLExtraData {
|
||||
pub mRefCnt: root::mozilla::ThreadSafeAutoRefCnt,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue