Mark the Gecko main thread as a Servo layout thread. r=bholley draft
authorCameron McCormack <cam@mcc.id.au>
Fri, 18 Nov 2016 16:50:23 +0800
changeset 441038 d8ad2c330d69387f4c20e36857658874caedb017
parent 441037 452eb331b86b2b7fc15b491d434fe864c4b92ce5
child 537475 3e8def40cc675a3332f68fed7ea1228f6f558910
push id36338
push userbmo:cam@mcc.id.au
push dateFri, 18 Nov 2016 08:50:53 +0000
reviewersbholley
milestone53.0a1
Mark the Gecko main thread as a Servo layout thread. r=bholley This is needed to keep the assertion in the RuleTree GC functions that checks we're being called on the non-worker layout thread. MozReview-Commit-ID: IubxjORy85V
servo/ports/geckolib/glue.rs
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -41,16 +41,17 @@ use style::parser::{ParserContext, Parse
 use style::properties::{CascadeFlags, ComputedValues, Importance, PropertyDeclaration};
 use style::properties::{PropertyDeclarationParseResult, PropertyDeclarationBlock};
 use style::properties::{apply_declarations, parse_one_declaration};
 use style::selector_impl::PseudoElementCascadeType;
 use style::sequential;
 use style::string_cache::Atom;
 use style::stylesheets::{Origin, Stylesheet};
 use style::timer::Timer;
+use style::thread_state;
 use style_traits::ToCss;
 use url::Url;
 
 /*
  * For Gecko->Servo function calls, we need to redeclare the same signature that was declared in
  * the C header in Gecko. In order to catch accidental mismatches, we run rust-bindgen against
  * those signatures as well, giving us a second declaration of all the Servo_* functions in this
  * crate. If there's a mismatch, LLVM will assert and abort, which is a rather awful thing to
@@ -61,16 +62,19 @@ use url::Url;
 pub extern "C" fn Servo_Initialize() -> () {
     // Enable standard Rust logging.
     //
     // See https://doc.rust-lang.org/log/env_logger/index.html for instructions.
     env_logger::init().unwrap();
 
     // Allocate our default computed values.
     unsafe { ComputedValues::initialize(); }
+
+    // Pretend that we're a Servo Layout thread, to make some assertions happy.
+    thread_state::initialize(thread_state::LAYOUT);
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_Shutdown() -> () {
     // Destroy our default computed values.
     unsafe { ComputedValues::shutdown(); }
 }