mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
Make style context use parking_lot::RwLock
This commit is contained in:
parent
070dee3542
commit
09cbe3bce0
11 changed files with 23 additions and 15 deletions
|
@ -27,6 +27,7 @@ log = "0.3.5"
|
||||||
msg = {path = "../msg"}
|
msg = {path = "../msg"}
|
||||||
net_traits = {path = "../net_traits"}
|
net_traits = {path = "../net_traits"}
|
||||||
ordered-float = "0.2.2"
|
ordered-float = "0.2.2"
|
||||||
|
parking_lot = {version = "0.3.3", features = ["nightly"]}
|
||||||
plugins = {path = "../plugins"}
|
plugins = {path = "../plugins"}
|
||||||
profile_traits = {path = "../profile_traits"}
|
profile_traits = {path = "../profile_traits"}
|
||||||
range = {path = "../range"}
|
range = {path = "../range"}
|
||||||
|
|
|
@ -16,11 +16,12 @@ use ipc_channel::ipc;
|
||||||
use net_traits::image::base::Image;
|
use net_traits::image::base::Image;
|
||||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
|
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
|
||||||
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
|
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
|
||||||
|
use parking_lot::RwLock;
|
||||||
use std::cell::{RefCell, RefMut};
|
use std::cell::{RefCell, RefMut};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::hash::BuildHasherDefault;
|
use std::hash::BuildHasherDefault;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::{Arc, Mutex, RwLock};
|
use std::sync::{Arc, Mutex};
|
||||||
use style::context::{LocalStyleContext, StyleContext, SharedStyleContext};
|
use style::context::{LocalStyleContext, StyleContext, SharedStyleContext};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::opts;
|
use util::opts;
|
||||||
|
@ -194,7 +195,6 @@ impl SharedLayoutContext {
|
||||||
-> Option<WebRenderImageInfo> {
|
-> Option<WebRenderImageInfo> {
|
||||||
if let Some(existing_webrender_image) = self.webrender_image_cache
|
if let Some(existing_webrender_image) = self.webrender_image_cache
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
|
||||||
.get(&((*url).clone(), use_placeholder)) {
|
.get(&((*url).clone(), use_placeholder)) {
|
||||||
return Some((*existing_webrender_image).clone())
|
return Some((*existing_webrender_image).clone())
|
||||||
}
|
}
|
||||||
|
@ -205,9 +205,7 @@ impl SharedLayoutContext {
|
||||||
if image_info.key.is_none() {
|
if image_info.key.is_none() {
|
||||||
Some(image_info)
|
Some(image_info)
|
||||||
} else {
|
} else {
|
||||||
let mut webrender_image_cache = self.webrender_image_cache
|
let mut webrender_image_cache = self.webrender_image_cache.write();
|
||||||
.write()
|
|
||||||
.unwrap();
|
|
||||||
webrender_image_cache.insert(((*url).clone(), use_placeholder),
|
webrender_image_cache.insert(((*url).clone(), use_placeholder),
|
||||||
image_info);
|
image_info);
|
||||||
Some(image_info)
|
Some(image_info)
|
||||||
|
|
|
@ -36,6 +36,7 @@ extern crate log;
|
||||||
extern crate msg;
|
extern crate msg;
|
||||||
extern crate net_traits;
|
extern crate net_traits;
|
||||||
extern crate ordered_float;
|
extern crate ordered_float;
|
||||||
|
extern crate parking_lot;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
#[no_link]
|
#[no_link]
|
||||||
extern crate plugins as servo_plugins;
|
extern crate plugins as servo_plugins;
|
||||||
|
|
|
@ -25,6 +25,7 @@ lazy_static = "0.2"
|
||||||
log = "0.3.5"
|
log = "0.3.5"
|
||||||
msg = {path = "../msg"}
|
msg = {path = "../msg"}
|
||||||
net_traits = {path = "../net_traits"}
|
net_traits = {path = "../net_traits"}
|
||||||
|
parking_lot = {version = "0.3.3", features = ["nightly"]}
|
||||||
plugins = {path = "../plugins"}
|
plugins = {path = "../plugins"}
|
||||||
profile_traits = {path = "../profile_traits"}
|
profile_traits = {path = "../profile_traits"}
|
||||||
script = {path = "../script"}
|
script = {path = "../script"}
|
||||||
|
|
|
@ -32,6 +32,7 @@ extern crate lazy_static;
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate msg;
|
extern crate msg;
|
||||||
extern crate net_traits;
|
extern crate net_traits;
|
||||||
|
extern crate parking_lot;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate profile_traits;
|
extern crate profile_traits;
|
||||||
extern crate script;
|
extern crate script;
|
||||||
|
@ -83,6 +84,7 @@ use layout_traits::LayoutThreadFactory;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
|
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
|
||||||
use net_traits::image_cache_thread::UsePlaceholder;
|
use net_traits::image_cache_thread::UsePlaceholder;
|
||||||
|
use parking_lot::RwLock;
|
||||||
use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
|
use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
|
||||||
use profile_traits::time::{self, TimerMetadata, profile};
|
use profile_traits::time::{self, TimerMetadata, profile};
|
||||||
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
|
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
|
||||||
|
@ -101,7 +103,7 @@ use std::collections::HashMap;
|
||||||
use std::hash::BuildHasherDefault;
|
use std::hash::BuildHasherDefault;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::sync::{Arc, Mutex, MutexGuard, RwLock};
|
use std::sync::{Arc, Mutex, MutexGuard};
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||||
use style::animation::Animation;
|
use style::animation::Animation;
|
||||||
|
@ -1316,7 +1318,7 @@ impl LayoutThread {
|
||||||
|
|
||||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||||
// Perform an abbreviated style recalc that operates without access to the DOM.
|
// Perform an abbreviated style recalc that operates without access to the DOM.
|
||||||
let animations = self.running_animations.read().unwrap();
|
let animations = self.running_animations.read();
|
||||||
profile(time::ProfilerCategory::LayoutStyleRecalc,
|
profile(time::ProfilerCategory::LayoutStyleRecalc,
|
||||||
self.profiler_metadata(),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|
@ -1368,8 +1370,8 @@ impl LayoutThread {
|
||||||
// Kick off animations if any were triggered, expire completed ones.
|
// Kick off animations if any were triggered, expire completed ones.
|
||||||
animation::update_animation_state(&self.constellation_chan,
|
animation::update_animation_state(&self.constellation_chan,
|
||||||
&self.script_chan,
|
&self.script_chan,
|
||||||
&mut *self.running_animations.write().unwrap(),
|
&mut *self.running_animations.write(),
|
||||||
&mut *self.expired_animations.write().unwrap(),
|
&mut *self.expired_animations.write(),
|
||||||
&self.new_animations_receiver,
|
&self.new_animations_receiver,
|
||||||
self.id,
|
self.id,
|
||||||
&self.timer);
|
&self.timer);
|
||||||
|
|
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -1149,6 +1149,7 @@ dependencies = [
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
"ordered-float 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ordered-float 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"range 0.0.1",
|
"range 0.0.1",
|
||||||
|
@ -1194,6 +1195,7 @@ dependencies = [
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
|
"parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"script 0.0.1",
|
"script 0.0.1",
|
||||||
|
|
|
@ -672,7 +672,7 @@ pub fn complete_expired_transitions(node: OpaqueNode, style: &mut Arc<ComputedVa
|
||||||
context: &SharedStyleContext) -> bool {
|
context: &SharedStyleContext) -> bool {
|
||||||
let had_animations_to_expire;
|
let had_animations_to_expire;
|
||||||
{
|
{
|
||||||
let all_expired_animations = context.expired_animations.read().unwrap();
|
let all_expired_animations = context.expired_animations.read();
|
||||||
let animations_to_expire = all_expired_animations.get(&node);
|
let animations_to_expire = all_expired_animations.get(&node);
|
||||||
had_animations_to_expire = animations_to_expire.is_some();
|
had_animations_to_expire = animations_to_expire.is_some();
|
||||||
if let Some(ref animations) = animations_to_expire {
|
if let Some(ref animations) = animations_to_expire {
|
||||||
|
@ -686,7 +686,7 @@ pub fn complete_expired_transitions(node: OpaqueNode, style: &mut Arc<ComputedVa
|
||||||
}
|
}
|
||||||
|
|
||||||
if had_animations_to_expire {
|
if had_animations_to_expire {
|
||||||
context.expired_animations.write().unwrap().remove(&node);
|
context.expired_animations.write().remove(&node);
|
||||||
}
|
}
|
||||||
|
|
||||||
had_animations_to_expire
|
had_animations_to_expire
|
||||||
|
|
|
@ -10,10 +10,11 @@ use dom::OpaqueNode;
|
||||||
use error_reporting::ParseErrorReporter;
|
use error_reporting::ParseErrorReporter;
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
use matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
|
use matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
|
||||||
|
use parking_lot::RwLock;
|
||||||
use selector_matching::Stylist;
|
use selector_matching::Stylist;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::{Arc, Mutex, RwLock};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use timer::Timer;
|
use timer::Timer;
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,12 @@ use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||||
use media_queries::{Device, MediaType};
|
use media_queries::{Device, MediaType};
|
||||||
use num_cpus;
|
use num_cpus;
|
||||||
use parallel::WorkQueueData;
|
use parallel::WorkQueueData;
|
||||||
|
use parking_lot::RwLock;
|
||||||
use selector_matching::Stylist;
|
use selector_matching::Stylist;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::Arc;
|
||||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||||
use style_traits::ViewportPx;
|
use style_traits::ViewportPx;
|
||||||
use stylesheets::Stylesheet;
|
use stylesheets::Stylesheet;
|
||||||
|
|
|
@ -605,11 +605,10 @@ trait PrivateMatchMethods: TElement {
|
||||||
// Merge any running transitions into the current style, and cancel them.
|
// Merge any running transitions into the current style, and cancel them.
|
||||||
let had_running_animations = context.running_animations
|
let had_running_animations = context.running_animations
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
|
||||||
.get(&this_opaque)
|
.get(&this_opaque)
|
||||||
.is_some();
|
.is_some();
|
||||||
if had_running_animations {
|
if had_running_animations {
|
||||||
let mut all_running_animations = context.running_animations.write().unwrap();
|
let mut all_running_animations = context.running_animations.write();
|
||||||
for mut running_animation in all_running_animations.get_mut(&this_opaque).unwrap() {
|
for mut running_animation in all_running_animations.get_mut(&this_opaque).unwrap() {
|
||||||
// This shouldn't happen frequently, but under some
|
// This shouldn't happen frequently, but under some
|
||||||
// circumstances mainly huge load or debug builds, the
|
// circumstances mainly huge load or debug builds, the
|
||||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -1056,6 +1056,7 @@ dependencies = [
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
"ordered-float 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ordered-float 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"range 0.0.1",
|
"range 0.0.1",
|
||||||
|
@ -1094,6 +1095,7 @@ dependencies = [
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
|
"parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"script 0.0.1",
|
"script 0.0.1",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue