From aa0e3e25e2fc6f998a2717c6fef9e785ca6fcaa4 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 3 May 2016 11:48:44 -0700 Subject: [PATCH] Add a runtime-wide initialization hook for Geckolib. --- ports/geckolib/bindings.rs | 1 + ports/geckolib/glue.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ports/geckolib/bindings.rs b/ports/geckolib/bindings.rs index 16724678a80..56785694d77 100644 --- a/ports/geckolib/bindings.rs +++ b/ports/geckolib/bindings.rs @@ -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); diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 27edf4ed357..eb456937f6f 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -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()