Auto merge of #16282 - upsuper:bug1343964, r=heycam

Move dummy url data to be a static member of URLExtraData

This is the Servo side change of [bug 1343964](https://bugzilla.mozilla.org/show_bug.cgi?id=1343964) which has been reviewed on Bugzilla.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16282)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-04-06 19:33:35 -05:00 committed by GitHub
commit 9ad95a5dc7
7 changed files with 394 additions and 378 deletions

2
Cargo.lock generated
View file

@ -2787,12 +2787,10 @@ dependencies = [
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"geckoservo 0.0.1", "geckoservo 0.0.1",
"lazy_static 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.18.0", "selectors 0.18.0",
"servo_url 0.0.1",
"style 0.0.1", "style 0.0.1",
"style_traits 0.0.1", "style_traits 0.0.1",
] ]

View file

@ -444,9 +444,6 @@ extern "C" {
url_bytes: *const u8, url_length: u32, url_bytes: *const u8, url_length: u32,
media_bytes: *const u8, media_length: u32); media_bytes: *const u8, media_length: u32);
} }
extern "C" {
pub fn Gecko_URLExtraData_CreateDummy() -> *mut RawGeckoURLExtraData;
}
extern "C" { extern "C" {
pub fn Gecko_MaybeCreateStyleChildrenIterator(node: RawGeckoNodeBorrowed) pub fn Gecko_MaybeCreateStyleChildrenIterator(node: RawGeckoNodeBorrowed)
-> StyleChildrenIteratorOwnedOrNull; -> StyleChildrenIteratorOwnedOrNull;
@ -1859,7 +1856,7 @@ extern "C" {
-> ServoComputedValuesStrong; -> ServoComputedValuesStrong;
} }
extern "C" { extern "C" {
pub fn Servo_Initialize(); pub fn Servo_Initialize(dummy_url_data: *mut RawGeckoURLExtraData);
} }
extern "C" { extern "C" {
pub fn Servo_Shutdown(); pub fn Servo_Shutdown();

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -100,10 +100,10 @@ use super::stylesheet_loader::StylesheetLoader;
// A dummy url data for where we don't pass url data in. // A dummy url data for where we don't pass url data in.
// We need to get rid of this sooner than later. // We need to get rid of this sooner than later.
static mut DUMMY_URL_DATA: Option<*mut URLExtraData> = None; static mut DUMMY_URL_DATA: *mut URLExtraData = 0 as *mut URLExtraData;
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_Initialize() { pub extern "C" fn Servo_Initialize(dummy_url_data: *mut URLExtraData) {
// Initialize logging. // Initialize logging.
let mut builder = LogBuilder::new(); let mut builder = LogBuilder::new();
let default_level = if cfg!(debug_assertions) { "warn" } else { "error" }; let default_level = if cfg!(debug_assertions) { "warn" } else { "error" };
@ -122,9 +122,7 @@ pub extern "C" fn Servo_Initialize() {
gecko_properties::initialize(); gecko_properties::initialize();
// Initialize the dummy url data // Initialize the dummy url data
unsafe { unsafe { DUMMY_URL_DATA = dummy_url_data; }
DUMMY_URL_DATA = Some(bindings::Gecko_URLExtraData_CreateDummy());
}
} }
#[no_mangle] #[no_mangle]
@ -132,12 +130,13 @@ pub extern "C" fn Servo_Shutdown() {
// Clear some static data to avoid shutdown leaks. // Clear some static data to avoid shutdown leaks.
gecko_properties::shutdown(); gecko_properties::shutdown();
// Clear the dummy url data to avoid shutdown leaks. // The dummy url will be released after shutdown, so clear the
unsafe { RefPtr::from_addrefed(DUMMY_URL_DATA.take().unwrap()) }; // reference to avoid use-after-free.
unsafe { DUMMY_URL_DATA = ptr::null_mut(); }
} }
unsafe fn dummy_url_data() -> &'static RefPtr<URLExtraData> { unsafe fn dummy_url_data() -> &'static RefPtr<URLExtraData> {
RefPtr::from_ptr_ref(DUMMY_URL_DATA.as_ref().unwrap()) RefPtr::from_ptr_ref(&DUMMY_URL_DATA)
} }
fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard, fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard,

View file

@ -19,12 +19,10 @@ atomic_refcell = "0.1"
cssparser = "0.12" cssparser = "0.12"
env_logger = "0.4" env_logger = "0.4"
euclid = "0.11" euclid = "0.11"
lazy_static = "0.2"
libc = "0.2" libc = "0.2"
log = {version = "0.3.5", features = ["release_max_level_info"]} log = {version = "0.3.5", features = ["release_max_level_info"]}
parking_lot = "0.3" parking_lot = "0.3"
selectors = {path = "../../../components/selectors"} selectors = {path = "../../../components/selectors"}
servo_url = {path = "../../../components/url"}
style_traits = {path = "../../../components/style_traits"} style_traits = {path = "../../../components/style_traits"}
geckoservo = {path = "../../../ports/geckolib"} geckoservo = {path = "../../../ports/geckolib"}
style = {path = "../../../components/style", features = ["gecko"]} style = {path = "../../../components/style", features = ["gecko"]}

View file

@ -6,11 +6,9 @@ extern crate atomic_refcell;
extern crate cssparser; extern crate cssparser;
extern crate env_logger; extern crate env_logger;
extern crate geckoservo; extern crate geckoservo;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate parking_lot; extern crate parking_lot;
extern crate selectors; extern crate selectors;
extern crate servo_url;
#[macro_use] extern crate style; #[macro_use] extern crate style;
extern crate style_traits; extern crate style_traits;