From 8769d0227e5174dde14571a2c94548b254765bca Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 3 Apr 2017 16:16:07 -0500 Subject: [PATCH] servo: Merge #16246 - Revert to per-process shared lock for author-origin stylesheets (from servo:revert-per-doc); r=jdm Fixes https://github.com/servo/servo/issues/16097 Reopens https://github.com/servo/servo/issues/16027 Source-Repo: https://github.com/servo/servo Source-Revision: b6b6608ca3a46113bb488e4da835b4ee743299fd --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : c8b45f3883847d325c30ab9a95193a8eb530bc5c --- servo/Cargo.lock | 1 + servo/components/script/Cargo.toml | 1 + servo/components/script/dom/document.rs | 16 +++++++++++++++- servo/components/script/lib.rs | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/servo/Cargo.lock b/servo/Cargo.lock index 667df1af7f5d..022304ab836d 100644 --- a/servo/Cargo.lock +++ b/servo/Cargo.lock @@ -2250,6 +2250,7 @@ dependencies = [ "ipc-channel 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js 0.1.4 (git+https://github.com/servo/rust-mozjs)", "jstraceable_derive 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)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/servo/components/script/Cargo.toml b/servo/components/script/Cargo.toml index cb4418b94df7..de9456ec1e7f 100644 --- a/servo/components/script/Cargo.toml +++ b/servo/components/script/Cargo.toml @@ -54,6 +54,7 @@ image = "0.12" ipc-channel = "0.7" js = {git = "https://github.com/servo/rust-mozjs", features = ["promises"]} jstraceable_derive = {path = "../jstraceable_derive"} +lazy_static = "0.2" libc = "0.2" log = "0.3.5" mime = "0.2.1" diff --git a/servo/components/script/dom/document.rs b/servo/components/script/dom/document.rs index fe1065104f42..8dd3cd17aecb 100644 --- a/servo/components/script/dom/document.rs +++ b/servo/components/script/dom/document.rs @@ -2132,7 +2132,21 @@ impl Document { scripts: Default::default(), anchors: Default::default(), applets: Default::default(), - style_shared_lock: StyleSharedRwLock::new(), + style_shared_lock: { + lazy_static! { + /// Per-process shared lock for author-origin stylesheets + /// + /// FIXME: make it per-document or per-pipeline instead: + /// https://github.com/servo/servo/issues/16027 + /// (Need to figure out what to do with the style attribute + /// of elements adopted into another document.) + static ref PER_PROCESS_AUTHOR_SHARED_LOCK: StyleSharedRwLock = { + StyleSharedRwLock::new() + }; + } + PER_PROCESS_AUTHOR_SHARED_LOCK.clone() + //StyleSharedRwLock::new() + }, stylesheets: DOMRefCell::new(None), stylesheets_changed_since_reflow: Cell::new(false), stylesheet_list: MutNullableJS::new(None), diff --git a/servo/components/script/lib.rs b/servo/components/script/lib.rs index ade3543bbe82..2de2e37ea38f 100644 --- a/servo/components/script/lib.rs +++ b/servo/components/script/lib.rs @@ -60,6 +60,8 @@ extern crate ipc_channel; extern crate js; #[macro_use] extern crate jstraceable_derive; +#[macro_use] +extern crate lazy_static; extern crate libc; #[macro_use] extern crate log;