Add a runtime-wide initialization hook for Geckolib.

This commit is contained in:
Bobby Holley 2016-05-03 11:48:44 -07:00
parent 9fdb791e93
commit aa0e3e25e2
2 changed files with 11 additions and 2 deletions

View file

@ -104,6 +104,7 @@ extern "C" {
-> *const u16;
pub fn Gecko_Namespace(element: *mut RawGeckoElement, length: *mut u32)
-> *const u16;
pub fn Servo_Initialize();
pub fn Servo_RestyleDocument(doc: *mut RawGeckoDocument,
set: *mut RawServoStyleSet);
pub fn Gecko_Construct_nsStyleFont(ptr: *mut nsStyleFont);

View file

@ -61,6 +61,10 @@ pub fn pseudo_element_from_atom(pseudo: *mut nsIAtom,
* depend on but good enough for our purposes.
*/
#[no_mangle]
pub extern "C" fn Servo_Initialize() -> () {
}
#[no_mangle]
pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *mut RawServoStyleSet) -> () {
let document = unsafe { GeckoDocument::from_raw(doc) };
@ -71,8 +75,12 @@ pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *m
let data = unsafe { &mut *(raw_data as *mut PerDocumentStyleData) };
// Force the creation of our lazily-constructed initial computed values on
// the main thread, since it's not safe to call elsewhere. This should move
// into a runtime-wide init hook at some point.
// the main thread, since it's not safe to call elsewhere.
//
// FIXME(bholley): this should move into Servo_Initialize as soon as we get
// rid of the HackilyFindSomeDeviceContext stuff that happens during
// initial_values computation, since that stuff needs to be called further
// along in startup than the sensible place to call Servo_Initialize.
GeckoComputedValues::initial_values();
let _needs_dirtying = Arc::get_mut(&mut data.stylist).unwrap()