Mark the Gecko main thread as a Servo layout thread. r=bholley
draft
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
--- 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(); }
}