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

@ -74,6 +74,7 @@ use style::gecko_bindings::structs::IterationCompositeOperation;
use style::gecko_bindings::structs::MallocSizeOf;
use style::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
use style::gecko_bindings::structs::SeenPtrs;
use style::gecko_bindings::structs::ServoElementSnapshotTable;
use style::gecko_bindings::structs::ServoTraversalFlags;
use style::gecko_bindings::structs::StyleRuleInclusion;
@ -107,8 +108,9 @@ use style::shared_lock::{SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard
use style::string_cache::Atom;
use style::style_adjuster::StyleAdjuster;
use style::stylesheets::{CssRule, CssRules, CssRuleType, CssRulesHelpers, DocumentRule};
use style::stylesheets::{FontFeatureValuesRule, ImportRule, KeyframesRule, MallocSizeOfWithGuard, MediaRule};
use style::stylesheets::{NamespaceRule, Origin, PageRule, StyleRule, SupportsRule};
use style::stylesheets::{FontFeatureValuesRule, ImportRule, KeyframesRule, MallocSizeOfWithGuard};
use style::stylesheets::{MallocSizeOfWithRepeats, MediaRule};
use style::stylesheets::{NamespaceRule, Origin, PageRule, SizeOfState, StyleRule, SupportsRule};
use style::stylesheets::StylesheetContents;
use style::stylesheets::StylesheetLoader as StyleStylesheetLoader;
use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelector, KeyframesStepValue};
@ -744,6 +746,24 @@ pub extern "C" fn Servo_Element_ClearData(element: RawGeckoElementBorrowed) {
unsafe { GeckoElement(element).clear_data() };
}
#[no_mangle]
pub extern "C" fn Servo_Element_SizeOfExcludingThis(malloc_size_of: MallocSizeOf,
seen_ptrs: *mut SeenPtrs,
element: RawGeckoElementBorrowed) -> usize {
let malloc_size_of = malloc_size_of.unwrap();
let element = GeckoElement(element);
let borrow = element.borrow_data();
if let Some(data) = borrow {
let mut state = SizeOfState {
malloc_size_of: malloc_size_of,
seen_ptrs: seen_ptrs,
};
(*data).malloc_size_of_children(&mut state)
} else {
0
}
}
#[no_mangle]
pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyleSheetContentsStrong {
let global_style_data = &*GLOBAL_STYLE_DATA;