diff options
46 files changed, 313 insertions, 265 deletions
diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index 68289ce2203..b7007219e7d 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -33,7 +33,7 @@ range = {path = "../range"} rustc-serialize = "0.3" script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} -selectors = {version = "0.13", features = ["heap_size"]} +selectors = "0.13" serde_macros = "0.8" smallvec = "0.1" string_cache = {version = "0.2.26", features = ["heap_size"]} diff --git a/components/plugins/lints/unrooted_must_root.rs b/components/plugins/lints/unrooted_must_root.rs index 5dc94df69f7..351817f2310 100644 --- a/components/plugins/lints/unrooted_must_root.rs +++ b/components/plugins/lints/unrooted_must_root.rs @@ -51,8 +51,6 @@ fn is_unrooted_ty(cx: &LateContext, ty: &ty::TyS, in_new_function: bool) -> bool false } else if match_def_path(cx, did.did, &["core", "cell", "Ref"]) || match_def_path(cx, did.did, &["core", "cell", "RefMut"]) - || match_def_path(cx, did.did, &["style", "refcell", "Ref"]) - || match_def_path(cx, did.did, &["style", "refcell", "RefMut"]) || match_def_path(cx, did.did, &["core", "slice", "Iter"]) || match_def_path(cx, did.did, &["std", "collections", "hash", "map", "OccupiedEntry"]) || match_def_path(cx, did.did, &["std", "collections", "hash", "map", "VacantEntry"]) { diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 626eb4e2288..14ea398964a 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -51,6 +51,7 @@ net_traits = {path = "../net_traits"} num-traits = "0.1.32" offscreen_gl_context = "0.4" open = "1.1.1" +parking_lot = "0.3" phf = "0.7.16" phf_macros = "0.7.16" plugins = {path = "../plugins"} @@ -62,7 +63,7 @@ regex = "0.1.43" rustc-serialize = "0.3" script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} -selectors = {version = "0.13", features = ["heap_size"]} +selectors = "0.13" serde = "0.8" smallvec = "0.1" string_cache = {version = "0.2.26", features = ["heap_size", "unstable"]} diff --git a/components/script/body.rs b/components/script/body.rs index 7777ef62a4e..814a62c30eb 100644 --- a/components/script/body.rs +++ b/components/script/body.rs @@ -19,9 +19,9 @@ use js::jsapi::JS_ParseJSON; use js::jsapi::Value as JSValue; use js::jsval::UndefinedValue; use mime::{Mime, TopLevel, SubLevel}; +use std::cell::Ref; use std::rc::Rc; use std::str; -use style::refcell::Ref; use url::form_urlencoded; pub enum BodyType { diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 36de48a1f9b..d5a00e6c1fa 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -15,10 +15,10 @@ use dom::element::{AttributeMutation, Element}; use dom::virtualmethods::vtable_for; use dom::window::Window; use std::borrow::ToOwned; +use std::cell::Ref; use std::mem; use string_cache::{Atom, Namespace}; use style::attr::{AttrIdentifier, AttrValue}; -use style::refcell::Ref; // https://dom.spec.whatwg.org/#interface-attr #[dom_struct] diff --git a/components/style/domrefcell.rs b/components/script/dom/bindings/cell.rs index a61a2a0d7fe..eef98076c0b 100644 --- a/components/style/domrefcell.rs +++ b/components/script/dom/bindings/cell.rs @@ -4,15 +4,14 @@ //! A shareable mutable container for the DOM. -use refcell::{BorrowError, BorrowMutError, Ref, RefCell, RefMut}; -use thread_state; +use std::cell::{BorrowError, BorrowMutError, Ref, RefCell, RefMut}; +use style::thread_state; /// A mutable field in the DOM. /// /// This extends the API of `core::cell::RefCell` to allow unsafe access in /// certain situations, with dynamic checking in debug builds. -#[derive(Clone)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, PartialEq, Debug, HeapSizeOf)] pub struct DOMRefCell<T> { value: RefCell<T>, } diff --git a/components/script/dom/bindings/mod.rs b/components/script/dom/bindings/mod.rs index 4cb10add852..013484a47b9 100644 --- a/components/script/dom/bindings/mod.rs +++ b/components/script/dom/bindings/mod.rs @@ -128,9 +128,8 @@ //! return `Err()` from the method with the appropriate [error value] //! (error/enum.Error.html). -pub use style::domrefcell as cell; - pub mod callback; +pub mod cell; pub mod constant; pub mod conversions; pub mod error; diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 53d141d114c..f71c2b83ef1 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -35,6 +35,7 @@ use cssparser::RGBA; use devtools_traits::CSSError; use devtools_traits::WorkerId; use dom::abstractworker::SharedRt; +use dom::bindings::cell::DOMRefCell; use dom::bindings::js::{JS, Root}; use dom::bindings::refcounted::{Trusted, TrustedPromise}; use dom::bindings::reflector::{Reflectable, Reflector}; @@ -89,7 +90,6 @@ use std::sync::mpsc::{Receiver, Sender}; use std::time::{SystemTime, Instant}; use string_cache::{Atom, Namespace, QualName}; use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto}; -use style::domrefcell::DOMRefCell; use style::element_state::*; use style::properties::PropertyDeclarationBlock; use style::selector_impl::{ElementSnapshot, PseudoElement}; diff --git a/components/script/dom/characterdata.rs b/components/script/dom/characterdata.rs index 979e9a70434..01f11e3ac50 100644 --- a/components/script/dom/characterdata.rs +++ b/components/script/dom/characterdata.rs @@ -19,7 +19,7 @@ use dom::element::Element; use dom::node::{Node, NodeDamage}; use dom::processinginstruction::ProcessingInstruction; use dom::text::Text; -use style::refcell::Ref; +use std::cell::Ref; use util::opts; // https://dom.spec.whatwg.org/#characterdata diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index c048446d813..0b8c9d8a062 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -13,14 +13,13 @@ use dom::bindings::str::DOMString; use dom::element::Element; use dom::node::{Node, NodeDamage, window_from_node}; use dom::window::Window; +use parking_lot::RwLock; use std::ascii::AsciiExt; -use std::slice; use std::sync::Arc; use string_cache::Atom; use style::parser::ParserContextExtraData; -use style::properties::{PropertyDeclaration, Shorthand, Importance}; +use style::properties::{Shorthand, Importance}; use style::properties::{is_supported_property, parse_one_declaration, parse_style_attribute}; -use style::refcell::Ref; use style::selector_impl::PseudoElement; // http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface @@ -93,7 +92,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { fn Length(&self) -> u32 { let elem = self.owner.upcast::<Element>(); let len = match *elem.style_attribute().borrow() { - Some(ref declarations) => declarations.declarations.len(), + Some(ref declarations) => declarations.read().declarations.len(), None => 0, }; len as u32 @@ -119,43 +118,42 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { // Step 2 if let Some(shorthand) = Shorthand::from_name(&property) { + let style_attribute = owner.style_attribute().borrow(); + let style_attribute = if let Some(ref style_attribute) = *style_attribute { + style_attribute.read() + } else { + // shorthand.longhands() is never empty, so with no style attribute + // step 2.2.2 would do this: + return DOMString::new() + }; + // Step 2.1 let mut list = vec![]; // Step 2.2 for longhand in shorthand.longhands() { // Step 2.2.1 - let declaration = owner.get_inline_style_declaration(&Atom::from(*longhand)); + let declaration = style_attribute.get(longhand); // Step 2.2.2 & 2.2.3 match declaration { - Some(declaration) => list.push(declaration), + Some(&(ref declaration, _importance)) => list.push(declaration), None => return DOMString::new(), } } // Step 2.3 - // Work around closures not being Clone - #[derive(Clone)] - struct Map<'a, 'b: 'a>(slice::Iter<'a, Ref<'b, (PropertyDeclaration, Importance)>>); - impl<'a, 'b> Iterator for Map<'a, 'b> { - type Item = &'a PropertyDeclaration; - fn next(&mut self) -> Option<Self::Item> { - self.0.next().map(|r| &r.0) - } - } - // TODO: important is hardcoded to false because method does not implement it yet let serialized_value = shorthand.serialize_shorthand_value_to_string( - Map(list.iter()), Importance::Normal); + list, Importance::Normal); return DOMString::from(serialized_value); } // Step 3 & 4 - match owner.get_inline_style_declaration(&property) { + owner.get_inline_style_declaration(&property, |d| match d { Some(declaration) => DOMString::from(declaration.0.value()), None => DOMString::new(), - } + }) } // https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority @@ -172,13 +170,18 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { .all(|priority| priority == "important") { return DOMString::from("important"); } - // Step 3 } else { - if let Some(decl) = self.owner.get_inline_style_declaration(&property) { - if decl.1.important() { - return DOMString::from("important"); + // Step 3 + return self.owner.get_inline_style_declaration(&property, |d| { + if let Some(decl) = d { + if decl.1.important() { + return DOMString::from("important"); + } } - } + + // Step 4 + DOMString::new() + }) } // Step 4 @@ -328,13 +331,14 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { let elem = self.owner.upcast::<Element>(); let style_attribute = elem.style_attribute().borrow(); style_attribute.as_ref().and_then(|declarations| { - declarations.declarations.get(index) - }).map(|&(ref declaration, importance)| { - let mut css = declaration.to_css_string(); - if importance.important() { - css += " !important"; - } - DOMString::from(css) + declarations.read().declarations.get(index).map(|entry| { + let (ref declaration, importance) = *entry; + let mut css = declaration.to_css_string(); + if importance.important() { + css += " !important"; + } + DOMString::from(css) + }) }) } @@ -344,7 +348,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { let style_attribute = elem.style_attribute().borrow(); if let Some(declarations) = style_attribute.as_ref() { - DOMString::from(declarations.to_css_string()) + DOMString::from(declarations.read().to_css_string()) } else { DOMString::new() } @@ -366,7 +370,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { *element.style_attribute().borrow_mut() = if decl_block.declarations.is_empty() { None // Step 2 } else { - Some(Arc::new(decl_block)) + Some(Arc::new(RwLock::new(decl_block))) }; element.sync_property_with_attrs_style(); let node = element.upcast::<Node>(); diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index f8238d645e1..5e834ef52cd 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -113,7 +113,7 @@ use script_traits::UntrustedNodeAddress; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::boxed::FnBox; -use std::cell::Cell; +use std::cell::{Cell, Ref, RefMut}; use std::collections::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::default::Default; @@ -125,7 +125,6 @@ use std::time::{Duration, Instant}; use string_cache::{Atom, QualName}; use style::attr::AttrValue; use style::context::ReflowGoal; -use style::refcell::{Ref, RefMut}; use style::selector_impl::ElementSnapshot; use style::str::{split_html_space_chars, str_join}; use style::stylesheets::Stylesheet; @@ -146,6 +145,14 @@ enum ParserBlockedByScript { Unblocked, } +#[derive(JSTraceable, HeapSizeOf)] +#[must_root] +struct StylesheetInDocument { + node: JS<Node>, + #[ignore_heap_size_of = "Arc"] + stylesheet: Arc<Stylesheet>, +} + // https://dom.spec.whatwg.org/#document #[dom_struct] pub struct Document { @@ -174,7 +181,7 @@ pub struct Document { anchors: MutNullableHeap<JS<HTMLCollection>>, applets: MutNullableHeap<JS<HTMLCollection>>, /// List of stylesheets associated with nodes in this document. |None| if the list needs to be refreshed. - stylesheets: DOMRefCell<Option<Vec<(JS<Node>, Arc<Stylesheet>)>>>, + stylesheets: DOMRefCell<Option<Vec<StylesheetInDocument>>>, /// Whether the list of stylesheets has changed since the last reflow was triggered. stylesheets_changed_since_reflow: Cell<bool>, ready_state: Cell<DocumentReadyState>, @@ -1879,13 +1886,16 @@ impl Document { node.get_stylesheet() } else { None - }.map(|stylesheet| (JS::from_ref(&*node), stylesheet)) + }.map(|stylesheet| StylesheetInDocument { + node: JS::from_ref(&*node), + stylesheet: stylesheet + }) }) .collect()); }; } self.stylesheets.borrow().as_ref().unwrap().iter() - .map(|&(_, ref stylesheet)| stylesheet.clone()) + .map(|s| s.stylesheet.clone()) .collect() } diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index 7b7e4b1e606..5c6d66c9a1a 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -14,9 +14,8 @@ use dom::bindings::reflector::{reflect_dom_object, Reflectable, Reflector}; use dom::dommatrix::DOMMatrix; use dom::dompoint::DOMPoint; use euclid::{Matrix4D, Point4D, Radians}; -use std::cell::Cell; +use std::cell::{Cell, Ref}; use std::f64; -use style::refcell::Ref; #[dom_struct] pub struct DOMMatrixReadOnly { diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 838da981524..5e00cb71c75 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -70,12 +70,13 @@ use html5ever::serialize::SerializeOpts; use html5ever::serialize::TraversalScope; use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode}; use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks}; +use parking_lot::RwLock; use selectors::matching::{ElementFlags, MatchingReason, matches}; use selectors::matching::{HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS}; use selectors::parser::{AttrSelector, NamespaceConstraint, parse_author_origin_selector_list_from_str}; use std::ascii::AsciiExt; use std::borrow::Cow; -use std::cell::Cell; +use std::cell::{Cell, Ref}; use std::convert::TryFrom; use std::default::Default; use std::fmt; @@ -89,7 +90,6 @@ use style::parser::ParserContextExtraData; use style::properties::{DeclaredValue, Importance}; use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute}; use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size, overflow_x}; -use style::refcell::Ref; use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl}; use style::selector_matching::ApplicableDeclarationBlock; use style::sink::Push; @@ -109,7 +109,8 @@ pub struct Element { prefix: Option<DOMString>, attrs: DOMRefCell<Vec<JS<Attr>>>, id_attribute: DOMRefCell<Option<Atom>>, - style_attribute: DOMRefCell<Option<Arc<PropertyDeclarationBlock>>>, + #[ignore_heap_size_of = "Arc"] + style_attribute: DOMRefCell<Option<Arc<RwLock<PropertyDeclarationBlock>>>>, attr_list: MutNullableHeap<JS<NamedNodeMap>>, class_list: MutNullableHeap<JS<DOMTokenList>>, state: Cell<ElementState>, @@ -297,7 +298,7 @@ pub trait LayoutElementHelpers { #[allow(unsafe_code)] unsafe fn html_element_in_html_document_for_layout(&self) -> bool; fn id_attribute(&self) -> *const Option<Atom>; - fn style_attribute(&self) -> *const Option<Arc<PropertyDeclarationBlock>>; + fn style_attribute(&self) -> *const Option<Arc<RwLock<PropertyDeclarationBlock>>>; fn local_name(&self) -> &Atom; fn namespace(&self) -> &Namespace; fn get_checked_state_for_layout(&self) -> bool; @@ -329,10 +330,10 @@ impl LayoutElementHelpers for LayoutJS<Element> { #[inline] fn from_declaration(rule: PropertyDeclaration) -> ApplicableDeclarationBlock { ApplicableDeclarationBlock::from_declarations( - Arc::new(PropertyDeclarationBlock { + Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: vec![(rule, Importance::Normal)], important_count: 0, - }), + })), Importance::Normal) } @@ -618,7 +619,7 @@ impl LayoutElementHelpers for LayoutJS<Element> { } #[allow(unsafe_code)] - fn style_attribute(&self) -> *const Option<Arc<PropertyDeclarationBlock>> { + fn style_attribute(&self) -> *const Option<Arc<RwLock<PropertyDeclarationBlock>>> { unsafe { (*self.unsafe_get()).style_attribute.borrow_for_layout() } @@ -707,7 +708,7 @@ impl Element { self.attrs.borrow() } - pub fn style_attribute(&self) -> &DOMRefCell<Option<Arc<PropertyDeclarationBlock>>> { + pub fn style_attribute(&self) -> &DOMRefCell<Option<Arc<RwLock<PropertyDeclarationBlock>>>> { &self.style_attribute } @@ -737,7 +738,7 @@ impl Element { // therefore, it should not trigger subsequent mutation events pub fn sync_property_with_attrs_style(&self) { let style_str = if let &Some(ref declarations) = &*self.style_attribute().borrow() { - declarations.to_css_string() + declarations.read().to_css_string() } else { String::new() }; @@ -769,7 +770,7 @@ impl Element { let mut inline_declarations = element.style_attribute.borrow_mut(); if let &mut Some(ref mut declarations) = &mut *inline_declarations { let mut importance = None; - let index = declarations.declarations.iter().position(|&(ref decl, i)| { + let index = declarations.read().declarations.iter().position(|&(ref decl, i)| { let matching = decl.matches(property); if matching { importance = Some(i) @@ -777,7 +778,7 @@ impl Element { matching }); if let Some(index) = index { - let declarations = Arc::make_mut(declarations); + let mut declarations = declarations.write(); declarations.declarations.remove(index); if importance.unwrap().important() { declarations.important_count -= 1; @@ -798,9 +799,8 @@ impl Element { let mut inline_declarations = element.style_attribute().borrow_mut(); if let &mut Some(ref mut declaration_block) = &mut *inline_declarations { { - // Usually, the reference count will be 1 here. But transitions could make it greater - // than that. - let declaration_block = Arc::make_mut(declaration_block); + let mut declaration_block = declaration_block.write(); + let declaration_block = &mut *declaration_block; let existing_declarations = &mut declaration_block.declarations; 'outer: for incoming_declaration in declarations { @@ -834,10 +834,10 @@ impl Element { 0 }; - *inline_declarations = Some(Arc::new(PropertyDeclarationBlock { + *inline_declarations = Some(Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: declarations.into_iter().map(|d| (d, importance)).collect(), important_count: important_count, - })); + }))); } update(self, declarations, importance); @@ -850,9 +850,8 @@ impl Element { { let mut inline_declarations = self.style_attribute().borrow_mut(); if let &mut Some(ref mut block) = &mut *inline_declarations { - // Usually, the reference counts of `from` and `to` will be 1 here. But transitions - // could make them greater than that. - let block = Arc::make_mut(block); + let mut block = block.write(); + let block = &mut *block; let declarations = &mut block.declarations; for &mut (ref declaration, ref mut importance) in declarations { if properties.iter().any(|p| declaration.name() == **p) { @@ -874,16 +873,15 @@ impl Element { self.sync_property_with_attrs_style(); } - pub fn get_inline_style_declaration(&self, - property: &Atom) - -> Option<Ref<(PropertyDeclaration, Importance)>> { - Ref::filter_map(self.style_attribute.borrow(), |inline_declarations| { - inline_declarations.as_ref().and_then(|declarations| { - declarations.declarations - .iter() - .find(|&&(ref decl, _)| decl.matches(&property)) - }) - }) + pub fn get_inline_style_declaration<F, R>(&self, property: &str, f: F) -> R + where F: FnOnce(Option<&(PropertyDeclaration, Importance)>) -> R { + let style_attr = self.style_attribute.borrow(); + if let Some(ref block) = *style_attr { + let block = block.read(); + f(block.get(property)) + } else { + f(None) + } } pub fn serialize(&self, traversal_scope: TraversalScope) -> Fallible<DOMString> { @@ -2129,11 +2127,11 @@ impl VirtualMethods for Element { *self.style_attribute.borrow_mut() = mutation.new_value(attr).map(|value| { let win = window_from_node(self); - Arc::new(parse_style_attribute( + Arc::new(RwLock::new(parse_style_attribute( &value, &doc.base_url(), win.css_error_reporter(), - ParserContextExtraData::default())) + ParserContextExtraData::default()))) }); if node.is_in_doc() { node.dirty(NodeDamage::NodeStyleDamaged); diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 9236c75c699..24e28e7639b 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -47,6 +47,7 @@ struct ImageRequest { state: State, parsed_url: Option<Url>, source_url: Option<DOMString>, + #[ignore_heap_size_of = "Arc"] image: Option<Arc<Image>>, metadata: Option<ImageMetadata>, } diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 7c6cabd345e..74e21ac9668 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -52,6 +52,7 @@ no_jsmanaged_fields!(Stylesheet); pub struct HTMLLinkElement { htmlelement: HTMLElement, rel_list: MutNullableHeap<JS<DOMTokenList>>, + #[ignore_heap_size_of = "Arc"] stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>, /// https://html.spec.whatwg.org/multipage/#a-style-sheet-that-is-blocking-scripts diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 34e4dbdfefe..1b057783908 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -27,6 +27,7 @@ use style::viewport::ViewportRule; #[dom_struct] pub struct HTMLMetaElement { htmlelement: HTMLElement, + #[ignore_heap_size_of = "Arc"] stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>, } diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index a54cd5c1eb9..697abfe6e67 100644 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -24,6 +24,7 @@ use string_cache::Atom; #[dom_struct] pub struct HTMLObjectElement { htmlelement: HTMLElement, + #[ignore_heap_size_of = "Arc"] image: DOMRefCell<Option<Arc<Image>>>, } diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 5e0706e5d65..4db70eb1c8f 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -24,6 +24,7 @@ use style::stylesheets::{Stylesheet, Origin}; #[dom_struct] pub struct HTMLStyleElement { htmlelement: HTMLElement, + #[ignore_heap_size_of = "Arc"] stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>, } diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs index ba15f565c27..ebfe0abf49e 100644 --- a/components/script/dom/request.rs +++ b/components/script/dom/request.rs @@ -35,10 +35,9 @@ use net_traits::request::Referrer as NetTraitsRequestReferrer; use net_traits::request::Request as NetTraitsRequest; use net_traits::request::RequestMode as NetTraitsRequestMode; use net_traits::request::Type as NetTraitsRequestType; -use std::cell::Cell; +use std::cell::{Cell, Ref}; use std::mem; use std::rc::Rc; -use style::refcell::Ref; use url::Url; #[dom_struct] diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index b8eeb81fb66..66a7e84f112 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -22,10 +22,10 @@ use hyper::header::Headers as HyperHeaders; use hyper::status::StatusCode; use hyper_serde::Serde; use net_traits::response::{ResponseBody as NetTraitsResponseBody}; +use std::cell::Ref; use std::mem; use std::rc::Rc; use std::str::FromStr; -use style::refcell::Ref; use url::Position; use url::Url; diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 9c7768ce5e7..9b976c5a31d 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -83,6 +83,7 @@ pub struct WorkerGlobalScope { worker_id: WorkerId, pipeline_id: PipelineId, worker_url: Url, + #[ignore_heap_size_of = "Arc"] closing: Option<Arc<AtomicBool>>, #[ignore_heap_size_of = "Defined in js"] runtime: Runtime, diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index b609a545277..19b00c422e5 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -41,6 +41,7 @@ use dom::node::{LayoutNodeHelpers, Node}; use dom::text::Text; use gfx_traits::ByteIndex; use msg::constellation_msg::PipelineId; +use parking_lot::RwLock; use range::Range; use script_layout_interface::{HTMLCanvasData, LayoutNodeType, TrustedNodeAddress}; use script_layout_interface::{OpaqueStyleAndLayoutData, PartialPersistentLayoutData}; @@ -461,7 +462,7 @@ impl<'le> TElement for ServoLayoutElement<'le> { ServoLayoutNode::from_layout_js(self.element.upcast()) } - fn style_attribute(&self) -> Option<&Arc<PropertyDeclarationBlock>> { + fn style_attribute(&self) -> Option<&Arc<RwLock<PropertyDeclarationBlock>>> { unsafe { (*self.element.style_attribute()).as_ref() } diff --git a/components/script/lib.rs b/components/script/lib.rs index 234f6c0f224..a7c73205d2f 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -17,6 +17,7 @@ #![feature(slice_patterns)] #![feature(stmt_expr_attributes)] #![feature(question_mark)] +#![feature(try_borrow)] #![feature(try_from)] #![deny(unsafe_code)] @@ -64,6 +65,7 @@ extern crate net_traits; extern crate num_traits; extern crate offscreen_gl_context; extern crate open; +extern crate parking_lot; extern crate phf; #[macro_use] extern crate profile_traits; diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml index 18c90e2cf59..970c74aa515 100644 --- a/components/script_layout_interface/Cargo.toml +++ b/components/script_layout_interface/Cargo.toml @@ -27,7 +27,7 @@ plugins = {path = "../plugins"} profile_traits = {path = "../profile_traits"} range = {path = "../range"} script_traits = {path = "../script_traits"} -selectors = {version = "0.13", features = ["heap_size"]} +selectors = "0.13" string_cache = {version = "0.2.26", features = ["heap_size"]} style = {path = "../style"} url = {version = "1.2", features = ["heap_size"]} diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index c88c090559e..de7c74f5af4 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -82,7 +82,7 @@ name = "app_units" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -123,7 +123,7 @@ dependencies = [ "core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.1.0 (git+https://github.com/servo/rust-freetype)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -249,7 +249,7 @@ dependencies = [ "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", @@ -451,7 +451,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -531,7 +531,7 @@ name = "devtools_traits" version = "0.0.1" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -685,7 +685,7 @@ name = "euclid" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -798,7 +798,7 @@ dependencies = [ "freetype 0.1.0 (git+https://github.com/servo/rust-freetype)", "gfx_traits 0.0.1", "harfbuzz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "layers 0.5.3 (git+https://github.com/servo/rust-layers)", @@ -845,7 +845,7 @@ version = "0.0.1" dependencies = [ "azure 0.8.0 (git+https://github.com/servo/rust-azure)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "layers 0.5.3 (git+https://github.com/servo/rust-layers)", "msg 0.0.1", @@ -937,7 +937,7 @@ dependencies = [ [[package]] name = "heapsize" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -980,7 +980,7 @@ name = "html5ever" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1117,7 +1117,7 @@ version = "0.1.3" source = "git+https://github.com/servo/rust-mozjs#fc380e0e7700f3179a86e8261eafe0828532bbfe" dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1154,7 +1154,7 @@ dependencies = [ "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "glx 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "io-surface 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1177,7 +1177,7 @@ dependencies = [ "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1221,7 +1221,7 @@ dependencies = [ "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "layout 0.0.1", @@ -1419,7 +1419,7 @@ version = "0.0.1" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1509,7 +1509,7 @@ name = "net_traits" version = "0.0.1" dependencies = [ "cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1919,7 +1919,7 @@ dependencies = [ name = "range" version = "0.0.1" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2000,7 +2000,7 @@ dependencies = [ "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2017,6 +2017,7 @@ dependencies = [ "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)", "phf_macros 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", @@ -2053,7 +2054,7 @@ dependencies = [ "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2091,7 +2092,7 @@ dependencies = [ "devtools_traits 0.0.1", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2119,8 +2120,6 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2308,7 +2307,7 @@ version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "phf_generator 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)", "phf_shared 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2327,7 +2326,7 @@ dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2362,6 +2361,7 @@ dependencies = [ "app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2378,7 +2378,7 @@ dependencies = [ "app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2526,7 +2526,7 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2563,7 +2563,7 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2727,7 +2727,7 @@ dependencies = [ "core-graphics 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2898,7 +2898,7 @@ dependencies = [ "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glx 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b280007fa9c7442cfd1e0b1addb8d1a59240267110e8705f8f7e2c7bfb7e2f72" "checksum harfbuzz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6b76113246f5c089dcf272cf89c3f61168a4d77b50ec5b2c1fab8c628c9ea762" -"checksum heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "abb306abb8d398e053cfb1b3e7b72c2f580be048b85745c52652954f8ad1439c" +"checksum heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8c80e194758495a9109566134dc06e42ea0423987d6ceca016edaa90381b3549" "checksum heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c9a70a1ef0122b54e0553f1d960b686c40d33a7953bc63029509a7649c8ee2c4" "checksum heartbeats-simple 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "78c0810722eacd0bdd3f1f691524bd9900bf8fed1947f6b883c10ddecd2560b1" "checksum heartbeats-simple-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d975666b80fe43ca3af2294ba5995a0f3a2a00fe8a229ac4788bdfd5f01a45d" diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 358df77ff8c..2a208f7ff3d 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -16,8 +16,8 @@ gecko = [] servo = ["serde/unstable", "serde", "serde_macros", "heapsize_plugin", "style_traits/servo", "app_units/plugins", "cssparser/heap_size", "cssparser/serde-serialization", - "selectors/heap_size", "selectors/unstable", "string_cache", - "url/heap_size", "plugins"] + "selectors/unstable", "string_cache", + "url/heap_size", "plugins", "parking_lot/nightly"] testing = [] [dependencies] diff --git a/components/style/animation.rs b/components/style/animation.rs index c65553a78f4..9e55ca2e52a 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -383,7 +383,7 @@ fn compute_style_for_animation_step(context: &SharedStyleContext, // TODO: avoiding this spurious clone might involve having to create // an Arc in the below (more common case). KeyframesStepValue::ComputedValues => style_from_cascade.clone(), - KeyframesStepValue::Declarations(ref declarations) => { + KeyframesStepValue::Declarations { block: ref declarations } => { let declaration_block = ApplicableDeclarationBlock { mixed_declarations: declarations.clone(), importance: Importance::Normal, diff --git a/components/style/dom.rs b/components/style/dom.rs index a8da0d72fc3..1dce89886ba 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -9,6 +9,7 @@ use atomic_refcell::{AtomicRef, AtomicRefMut}; use data::PersistentStyleData; use element_state::ElementState; +use parking_lot::RwLock; use properties::{ComputedValues, PropertyDeclarationBlock}; use restyle_hints::{RESTYLE_DESCENDANTS, RESTYLE_LATER_SIBLINGS, RESTYLE_SELF, RestyleHint}; use selector_impl::{ElementExt, PseudoElement}; @@ -202,7 +203,7 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre fn as_node(&self) -> Self::ConcreteNode; - fn style_attribute(&self) -> Option<&Arc<PropertyDeclarationBlock>>; + fn style_attribute(&self) -> Option<&Arc<RwLock<PropertyDeclarationBlock>>>; fn get_state(&self) -> ElementState; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 6212e0da05f..9be91c87178 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -32,6 +32,7 @@ use gecko_bindings::structs::{nsChangeHint, nsIAtom, nsIContent, nsStyleContext} use gecko_bindings::structs::OpaqueStyleData; use gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasFFI}; use libc::uintptr_t; +use parking_lot::RwLock; use parser::ParserContextExtraData; use properties::{ComputedValues, parse_style_attribute}; use properties::PropertyDeclarationBlock; @@ -58,7 +59,7 @@ impl NonOpaqueStyleData { pub struct GeckoDeclarationBlock { - pub declarations: Option<Arc<PropertyDeclarationBlock>>, + pub declarations: Option<Arc<RwLock<PropertyDeclarationBlock>>>, // XXX The following two fields are made atomic to work around the // ownership system so that they can be changed inside a shared // instance. It wouldn't provide safety as Rust usually promises, @@ -468,7 +469,7 @@ impl<'le> TElement for GeckoElement<'le> { unsafe { GeckoNode(&*(self.0 as *const _ as *const RawGeckoNode)) } } - fn style_attribute(&self) -> Option<&Arc<PropertyDeclarationBlock>> { + fn style_attribute(&self) -> Option<&Arc<RwLock<PropertyDeclarationBlock>>> { let declarations = unsafe { Gecko_GetServoDeclarationBlock(self.0) }; if declarations.is_null() { None diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index 01043b0fc5e..3283e535fc8 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -4,6 +4,7 @@ use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, RuleListParser}; use cssparser::{DeclarationListParser, DeclarationParser}; +use parking_lot::RwLock; use parser::{ParserContext, log_css_error}; use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock}; use properties::PropertyDeclarationParseResult; @@ -68,7 +69,7 @@ impl KeyframeSelector { } /// A keyframe. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Keyframe { pub selector: KeyframeSelector, @@ -77,23 +78,27 @@ pub struct Keyframe { /// so the second value of these tuples is always `Importance::Normal`. /// But including them enables `compute_style_for_animation_step` to create a `ApplicableDeclarationBlock` /// by cloning an `Arc<_>` (incrementing a reference count) rather than re-creating a `Vec<_>`. - pub block: Arc<PropertyDeclarationBlock>, + #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + pub block: Arc<RwLock<PropertyDeclarationBlock>>, } /// A keyframes step value. This can be a synthetised keyframes animation, that /// is, one autogenerated from the current computed values, or a list of /// declarations to apply. // TODO: Find a better name for this? -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum KeyframesStepValue { /// See `Keyframe::declarations`’s docs about the presence of `Importance`. - Declarations(Arc<PropertyDeclarationBlock>), + Declarations { + #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + block: Arc<RwLock<PropertyDeclarationBlock>> + }, ComputedValues, } /// A single step from a keyframe animation. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct KeyframesStep { /// The percentage of the animation duration when this step starts. @@ -109,12 +114,13 @@ pub struct KeyframesStep { } impl KeyframesStep { + #[allow(unsafe_code)] #[inline] fn new(percentage: KeyframePercentage, value: KeyframesStepValue) -> Self { let declared_timing_function = match value { - KeyframesStepValue::Declarations(ref block) => { - block.declarations.iter().any(|&(ref prop_decl, _)| { + KeyframesStepValue::Declarations { ref block } => { + block.read().declarations.iter().any(|&(ref prop_decl, _)| { match *prop_decl { PropertyDeclaration::AnimationTimingFunction(..) => true, _ => false, @@ -136,7 +142,7 @@ impl KeyframesStep { /// of keyframes, in order. /// /// It only takes into account animable properties. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct KeyframesAnimation { pub steps: Vec<KeyframesStep>, @@ -150,11 +156,12 @@ pub struct KeyframesAnimation { /// /// In practice, browsers seem to try to do their best job at it, so we might /// want to go through all the actual keyframes and deduplicate properties. +#[allow(unsafe_code)] fn get_animated_properties(keyframe: &Keyframe) -> Vec<TransitionProperty> { let mut ret = vec![]; // NB: declarations are already deduplicated, so we don't have to check for // it here. - for &(ref declaration, _) in keyframe.block.declarations.iter() { + for &(ref declaration, _) in keyframe.block.read().declarations.iter() { if let Some(property) = TransitionProperty::from_declaration(declaration) { ret.push(property); } @@ -178,8 +185,9 @@ impl KeyframesAnimation { for keyframe in keyframes { for percentage in keyframe.selector.0.iter() { - steps.push(KeyframesStep::new(*percentage, - KeyframesStepValue::Declarations(keyframe.block.clone()))); + steps.push(KeyframesStep::new(*percentage, KeyframesStepValue::Declarations { + block: keyframe.block.clone(), + })); } } @@ -265,10 +273,10 @@ impl<'a> QualifiedRuleParser for KeyframeListParser<'a> { } Ok(Arc::new(Keyframe { selector: prelude, - block: Arc::new(PropertyDeclarationBlock { + block: Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: declarations, important_count: 0, - }), + })), })) } } diff --git a/components/style/lib.rs b/components/style/lib.rs index 51ee0e122e5..c1b8dd874f0 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -90,7 +90,6 @@ pub mod context; pub mod custom_properties; pub mod data; pub mod dom; -pub mod domrefcell; pub mod element_state; pub mod error_reporting; pub mod font_face; diff --git a/components/style/matching.rs b/components/style/matching.rs index 24e67352fbe..24334512cf0 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -13,7 +13,7 @@ use cascade_info::CascadeInfo; use context::{SharedStyleContext, StyleContext}; use data::PersistentStyleData; use dom::{NodeInfo, TElement, TNode, TRestyleDamage, UnsafeNode}; -use properties::{ComputedValues, PropertyDeclarationBlock, cascade}; +use properties::{ComputedValues, cascade}; use properties::longhands::display::computed_value as display; use selector_impl::{PseudoElement, TheSelectorImpl}; use selector_matching::{ApplicableDeclarationBlock, Stylist}; @@ -24,6 +24,7 @@ use sink::ForgetfulSink; use smallvec::SmallVec; use std::collections::HashMap; use std::hash::{BuildHasherDefault, Hash, Hasher}; +use std::ops::Deref; use std::slice::IterMut; use std::sync::Arc; use string_cache::Atom; @@ -139,7 +140,7 @@ impl<'a> Hash for ApplicableDeclarationsCacheQuery<'a> { for declaration in self.declarations { // Each declaration contians an Arc, which is a stable // pointer; we use that for hashing and equality. - let ptr: *const PropertyDeclarationBlock = &*declaration.mixed_declarations; + let ptr: *const _ = Arc::deref(&declaration.mixed_declarations); ptr.hash(state); declaration.importance.hash(state); } @@ -502,7 +503,13 @@ trait PrivateMatchMethods: TNode { -> Arc<ComputedValues> where Ctx: StyleContext<'a> { - let mut cacheable = true; + // Don’t cache applicable declarations for elements with a style attribute. + // Since the style attribute contributes to that set, no other element would have the same set + // and the cache would not be effective anyway. + // This also works around the test failures at + // https://github.com/servo/servo/pull/13459#issuecomment-250717584 + let has_style_attribute = self.as_element().map_or(false, |e| e.style_attribute().is_some()); + let mut cacheable = !has_style_attribute; let shared_context = context.shared_context(); if animate_properties { cacheable = !self.update_animations_for_cascade(shared_context, diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index e55d3d1c06d..86234b17f20 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -29,7 +29,7 @@ use computed_values; #[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide}; use logical_geometry::WritingMode; use parser::{ParserContext, ParserContextExtraData, log_css_error}; -use selector_matching::ApplicableDeclarationBlock; +use selector_matching::{ApplicableDeclarationBlock, ApplicableDeclarationBlockReadGuard}; use stylesheets::Origin; use values::LocalToCss; use values::HasViewportPercentage; @@ -311,6 +311,10 @@ impl PropertyDeclarationBlock { pub fn any_normal(&self) -> bool { self.declarations.len() > self.important_count as usize } + + pub fn get(&self, property_name: &str) -> Option< &(PropertyDeclaration, Importance)> { + self.declarations.iter().find(|&&(ref decl, _)| decl.matches(property_name)) + } } impl ToCss for PropertyDeclarationBlock { @@ -741,7 +745,7 @@ impl Shorthand { /// Serializes possible shorthand value to String. pub fn serialize_shorthand_value_to_string<'a, I>(self, declarations: I, importance: Importance) -> String - where I: Iterator<Item=&'a PropertyDeclaration> + Clone { + where I: IntoIterator<Item=&'a PropertyDeclaration>, I::IntoIter: Clone { let appendable_value = self.get_shorthand_appendable_value(declarations).unwrap(); let mut result = String::new(); append_declaration_value(&mut result, appendable_value, importance).unwrap(); @@ -755,7 +759,7 @@ impl Shorthand { declarations: I, is_first_serialization: &mut bool) -> Result<bool, fmt::Error> - where W: Write, I: Iterator<Item=&'a PropertyDeclaration> + Clone { + where W: Write, I: IntoIterator<Item=&'a PropertyDeclaration>, I::IntoIter: Clone { match self.get_shorthand_appendable_value(declarations) { None => Ok(false), Some(appendable_value) => { @@ -772,8 +776,10 @@ impl Shorthand { } } - fn get_shorthand_appendable_value<'a, I>(self, declarations: I) -> Option<AppendableValue<'a, I>> - where I: Iterator<Item=&'a PropertyDeclaration> + Clone { + fn get_shorthand_appendable_value<'a, I>(self, declarations: I) + -> Option<AppendableValue<'a, I::IntoIter>> + where I: IntoIterator<Item=&'a PropertyDeclaration>, I::IntoIter: Clone { + let declarations = declarations.into_iter(); // Only cloning iterators (a few pointers each) not declarations. let mut declarations2 = declarations.clone(); @@ -1378,7 +1384,7 @@ pub use gecko_properties::ComputedValues; pub type ServoComputedValues = ComputedValues; #[cfg(feature = "servo")] -#[cfg_attr(feature = "servo", derive(Clone, Debug, HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(Clone, Debug))] pub struct ComputedValues { % for style_struct in data.active_style_structs(): ${style_struct.ident}: Arc<style_structs::${style_struct.name}>, @@ -1719,7 +1725,7 @@ mod lazy_static_module { #[allow(unused_mut, unused_imports)] fn cascade_with_cached_declarations( viewport_size: Size2D<Au>, - applicable_declarations: &[ApplicableDeclarationBlock], + applicable_declarations: &[ApplicableDeclarationBlockReadGuard], shareable: bool, parent_style: &ComputedValues, cached_style: &ComputedValues, @@ -1749,8 +1755,8 @@ fn cascade_with_cached_declarations( let mut seen = PropertyBitField::new(); // Declaration blocks are stored in increasing precedence order, // we want them in decreasing order here. - for sub_list in applicable_declarations.iter().rev() { - for declaration in sub_list.iter().rev() { + for block in applicable_declarations.iter().rev() { + for declaration in block.iter().rev() { match *declaration { % for style_struct in data.active_style_structs(): % for property in style_struct.longhands: @@ -1877,15 +1883,20 @@ pub fn cascade(viewport_size: Size2D<Au>, None => (true, initial_values), }; + // Aquire locks for at least the lifetime of `specified_custom_properties`. + let applicable_declarations = applicable_declarations.iter() + .map(|block| block.read()) + .collect::<Vec<_>>(); + let inherited_custom_properties = inherited_style.custom_properties(); - let mut custom_properties = None; + let mut specified_custom_properties = None; let mut seen_custom = HashSet::new(); - for sub_list in applicable_declarations.iter().rev() { - for declaration in sub_list.iter().rev() { + for block in applicable_declarations.iter().rev() { + for declaration in block.iter().rev() { match *declaration { PropertyDeclaration::Custom(ref name, ref value) => { ::custom_properties::cascade( - &mut custom_properties, &inherited_custom_properties, + &mut specified_custom_properties, &inherited_custom_properties, &mut seen_custom, name, value) } _ => {} @@ -1893,11 +1904,11 @@ pub fn cascade(viewport_size: Size2D<Au>, } } let custom_properties = ::custom_properties::finish_cascade( - custom_properties, &inherited_custom_properties); + specified_custom_properties, &inherited_custom_properties); if let (Some(cached_style), Some(parent_style)) = (cached_style, parent_style) { let style = cascade_with_cached_declarations(viewport_size, - applicable_declarations, + &applicable_declarations, shareable, parent_style, cached_style, @@ -1938,8 +1949,8 @@ pub fn cascade(viewport_size: Size2D<Au>, // virtual dispatch instead. ComputedValues::do_cascade_property(|cascade_property| { % for category_to_cascade_now in ["early", "other"]: - for sub_list in applicable_declarations.iter().rev() { - for declaration in sub_list.iter().rev() { + for block in applicable_declarations.iter().rev() { + for declaration in block.iter().rev() { if let PropertyDeclaration::Custom(..) = *declaration { continue } diff --git a/components/style/refcell.rs b/components/style/refcell.rs index f9a2b4a0672..a41fa2b63b1 100644 --- a/components/style/refcell.rs +++ b/components/style/refcell.rs @@ -15,7 +15,6 @@ #![allow(unsafe_code)] -#[cfg(feature = "servo")] use heapsize::HeapSizeOf; use std::cell::{UnsafeCell, Cell}; use std::cmp::Ordering; use std::fmt::{self, Debug, Display}; @@ -32,13 +31,6 @@ pub struct RefCell<T: ?Sized> { value: UnsafeCell<T>, } -#[cfg(feature = "servo")] -impl<T: HeapSizeOf> HeapSizeOf for RefCell<T> { - fn heap_size_of_children(&self) -> usize { - self.borrow().heap_size_of_children() - } -} - /// An enumeration of values returned from the `state` method on a `RefCell<T>`. #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum BorrowState { @@ -535,18 +527,6 @@ impl<'b, T: ?Sized> Ref<'b, T> { borrow: orig.borrow, } } - - #[inline] - pub fn filter_map<U: ?Sized, F>(orig: Ref<'b, T>, f: F) -> Option<Ref<'b, U>> - where F: FnOnce(&T) -> Option<&U> - { - f(orig.value).map(move |new_value| { - Ref { - value: new_value, - borrow: orig.borrow, - } - }) - } } impl<'b, T: ?Sized> RefMut<'b, T> { diff --git a/components/style/restyle_hints.rs b/components/style/restyle_hints.rs index 1471f451843..b47180b60a9 100644 --- a/components/style/restyle_hints.rs +++ b/components/style/restyle_hints.rs @@ -340,6 +340,7 @@ impl Sensitivities { #[derive(Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] struct Dependency { + #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] selector: Arc<ComplexSelector<TheSelectorImpl>>, hint: RestyleHint, sensitivities: Sensitivities, diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index 292b6cc7d9c..e7a4c47f6a5 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -9,6 +9,7 @@ use element_state::*; use error_reporting::StdoutErrorReporter; use keyframes::KeyframesAnimation; use media_queries::{Device, MediaType}; +use parking_lot::{RwLock, RwLockReadGuard}; use properties::{self, PropertyDeclaration, PropertyDeclarationBlock, ComputedValues, Importance}; use quickersort::sort_by; use restyle_hints::{RestyleHint, DependencySet}; @@ -78,10 +79,12 @@ pub struct Stylist { state_deps: DependencySet, /// Selectors in the page affecting siblings + #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] sibling_affecting_selectors: Vec<Selector<TheSelectorImpl>>, /// Selectors in the page matching elements with non-common style-affecting /// attributes. + #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] non_common_style_affecting_attributes_selectors: Vec<Selector<TheSelectorImpl>>, } @@ -176,7 +179,7 @@ impl Stylist { map.insert(Rule { selector: selector.complex_selector.clone(), - declarations: style_rule.declarations.clone(), + declarations: style_rule.block.clone(), specificity: selector.specificity, source_order: rules_source_order, }); @@ -325,11 +328,12 @@ impl Stylist { /// that is, whether the matched selectors are simple enough to allow the /// matching logic to be reduced to the logic in /// `css::matching::PrivateMatchMethods::candidate_element_allows_for_style_sharing`. + #[allow(unsafe_code)] pub fn push_applicable_declarations<E, V>( &self, element: &E, parent_bf: Option<&BloomFilter>, - style_attribute: Option<&Arc<PropertyDeclarationBlock>>, + style_attribute: Option<&Arc<RwLock<PropertyDeclarationBlock>>>, pseudo_element: Option<&PseudoElement>, applicable_declarations: &mut V, reason: MatchingReason) -> StyleRelations @@ -388,8 +392,8 @@ impl Stylist { debug!("author normal: {:?}", relations); // Step 4: Normal style attributes. - if let Some(sa) = style_attribute { - if sa.any_normal() { + if let Some(sa) = style_attribute { + if sa.read().any_normal() { relations |= AFFECTED_BY_STYLE_ATTRIBUTE; Push::push( applicable_declarations, @@ -411,7 +415,7 @@ impl Stylist { // Step 6: `!important` style attributes. if let Some(sa) = style_attribute { - if sa.any_important() { + if sa.read().any_important() { relations |= AFFECTED_BY_STYLE_ATTRIBUTE; Push::push( applicable_declarations, @@ -689,6 +693,7 @@ impl SelectorMap { /// Append to `rule_list` all universal Rules (rules with selector `*|*`) in /// `self` sorted by specifity and source order. + #[allow(unsafe_code)] pub fn get_universal_rules<V>(&self, matching_rules_list: &mut V) where V: VecLike<ApplicableDeclarationBlock> @@ -702,11 +707,12 @@ impl SelectorMap { for rule in self.other_rules.iter() { if rule.selector.compound_selector.is_empty() && rule.selector.next.is_none() { - if rule.declarations.any_normal() { + let block = rule.declarations.read(); + if block.any_normal() { matching_rules_list.push( rule.to_applicable_declaration_block(Importance::Normal)); } - if rule.declarations.any_important() { + if block.any_important() { matching_rules_list.push( rule.to_applicable_declaration_block(Importance::Important)); } @@ -743,6 +749,7 @@ impl SelectorMap { } /// Adds rules in `rules` that match `element` to the `matching_rules` list. + #[allow(unsafe_code)] fn get_matching_rules<E, V>(element: &E, parent_bf: Option<&BloomFilter>, rules: &[Rule], @@ -754,7 +761,7 @@ impl SelectorMap { V: VecLike<ApplicableDeclarationBlock> { for rule in rules.iter() { - let block = &rule.declarations; + let block = rule.declarations.read(); let any_declaration_for_importance = if importance.important() { block.any_important() } else { @@ -839,8 +846,10 @@ pub struct Rule { // This is an Arc because Rule will essentially be cloned for every element // that it matches. Selector contains an owned vector (through // ComplexSelector) and we want to avoid the allocation. + #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] pub selector: Arc<ComplexSelector<TheSelectorImpl>>, - pub declarations: Arc<PropertyDeclarationBlock>, + #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + pub declarations: Arc<RwLock<PropertyDeclarationBlock>>, pub source_order: usize, pub specificity: u32, } @@ -864,7 +873,8 @@ impl Rule { pub struct ApplicableDeclarationBlock { /// Contains declarations of either importance, but only those of self.importance are relevant. /// Use ApplicableDeclarationBlock::iter - pub mixed_declarations: Arc<PropertyDeclarationBlock>, + #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + pub mixed_declarations: Arc<RwLock<PropertyDeclarationBlock>>, pub importance: Importance, pub source_order: usize, pub specificity: u32, @@ -872,7 +882,7 @@ pub struct ApplicableDeclarationBlock { impl ApplicableDeclarationBlock { #[inline] - pub fn from_declarations(declarations: Arc<PropertyDeclarationBlock>, + pub fn from_declarations(declarations: Arc<RwLock<PropertyDeclarationBlock>>, importance: Importance) -> Self { ApplicableDeclarationBlock { @@ -883,9 +893,24 @@ impl ApplicableDeclarationBlock { } } + pub fn read(&self) -> ApplicableDeclarationBlockReadGuard { + ApplicableDeclarationBlockReadGuard { + guard: self.mixed_declarations.read(), + importance: self.importance, + } + } + +} + +pub struct ApplicableDeclarationBlockReadGuard<'a> { + guard: RwLockReadGuard<'a, PropertyDeclarationBlock>, + importance: Importance, +} + +impl<'a> ApplicableDeclarationBlockReadGuard<'a> { pub fn iter(&self) -> ApplicableDeclarationBlockIter { ApplicableDeclarationBlockIter { - iter: self.mixed_declarations.declarations.iter(), + iter: self.guard.declarations.iter(), importance: self.importance, } } diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index 56bd8e88944..556d6bbc49d 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -11,6 +11,7 @@ use error_reporting::ParseErrorReporter; use font_face::{FontFaceRule, parse_font_face_block}; use keyframes::{Keyframe, parse_keyframe_list}; use media_queries::{Device, MediaQueryList, parse_media_query_list}; +use parking_lot::RwLock; use parser::{ParserContext, ParserContextExtraData, log_css_error}; use properties::{PropertyDeclarationBlock, parse_property_declaration_list}; use selector_impl::TheSelectorImpl; @@ -42,8 +43,7 @@ pub enum Origin { } -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug)] pub struct Stylesheet { /// List of rules in the order they were found (important for /// cascading order) @@ -62,8 +62,7 @@ pub struct UserAgentStylesheets { } -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug)] pub enum CSSRule { // No Charset here, CSSCharsetRule has been removed from CSSOM // https://drafts.csswg.org/cssom/#changes-from-5-december-2013 @@ -85,15 +84,13 @@ pub struct NamespaceRule { pub url: Namespace, } -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug)] pub struct KeyframesRule { pub name: Atom, pub keyframes: Vec<Arc<Keyframe>>, } -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug)] pub struct MediaRule { pub media_queries: Arc<MediaQueryList>, pub rules: Vec<CSSRule>, @@ -107,11 +104,10 @@ impl MediaRule { } } -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug)] pub struct StyleRule { pub selectors: Vec<Selector<TheSelectorImpl>>, - pub declarations: Arc<PropertyDeclarationBlock>, + pub block: Arc<RwLock<PropertyDeclarationBlock>>, } @@ -563,7 +559,7 @@ impl<'a, 'b> QualifiedRuleParser for NestedRuleParser<'a, 'b> { -> Result<CSSRule, ()> { Ok(CSSRule::Style(Arc::new(StyleRule { selectors: prelude, - declarations: Arc::new(parse_property_declaration_list(self.context, input)) + block: Arc::new(RwLock::new(parse_property_declaration_list(self.context, input))) }))) } } diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index f2ecc4c327b..a081b0328a5 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -55,7 +55,7 @@ name = "app_units" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -96,7 +96,7 @@ dependencies = [ "core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.1.0 (git+https://github.com/servo/rust-freetype)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -222,7 +222,7 @@ dependencies = [ "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", @@ -408,7 +408,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -488,7 +488,7 @@ name = "devtools_traits" version = "0.0.1" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -601,7 +601,7 @@ name = "euclid" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -714,7 +714,7 @@ dependencies = [ "freetype 0.1.0 (git+https://github.com/servo/rust-freetype)", "gfx_traits 0.0.1", "harfbuzz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "layers 0.5.3 (git+https://github.com/servo/rust-layers)", @@ -752,7 +752,7 @@ version = "0.0.1" dependencies = [ "azure 0.8.0 (git+https://github.com/servo/rust-azure)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "layers 0.5.3 (git+https://github.com/servo/rust-layers)", "msg 0.0.1", @@ -844,7 +844,7 @@ dependencies = [ [[package]] name = "heapsize" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -887,7 +887,7 @@ name = "html5ever" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1024,7 +1024,7 @@ version = "0.1.3" source = "git+https://github.com/servo/rust-mozjs#fc380e0e7700f3179a86e8261eafe0828532bbfe" dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1061,7 +1061,7 @@ dependencies = [ "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "glx 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "io-surface 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1084,7 +1084,7 @@ dependencies = [ "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1121,7 +1121,7 @@ dependencies = [ "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "layout 0.0.1", @@ -1319,7 +1319,7 @@ version = "0.0.1" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1387,7 +1387,7 @@ name = "net_traits" version = "0.0.1" dependencies = [ "cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1770,7 +1770,7 @@ dependencies = [ name = "range" version = "0.0.1" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1851,7 +1851,7 @@ dependencies = [ "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1868,6 +1868,7 @@ dependencies = [ "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)", "phf_macros 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", @@ -1904,7 +1905,7 @@ dependencies = [ "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1932,7 +1933,7 @@ dependencies = [ "devtools_traits 0.0.1", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1960,8 +1961,6 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2191,7 +2190,7 @@ version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "phf_generator 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)", "phf_shared 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2210,7 +2209,7 @@ dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2245,7 +2244,7 @@ dependencies = [ "app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2393,7 +2392,7 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2430,7 +2429,7 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2587,7 +2586,7 @@ dependencies = [ "core-graphics 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2752,7 +2751,7 @@ dependencies = [ "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glx 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b280007fa9c7442cfd1e0b1addb8d1a59240267110e8705f8f7e2c7bfb7e2f72" "checksum harfbuzz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6b76113246f5c089dcf272cf89c3f61168a4d77b50ec5b2c1fab8c628c9ea762" -"checksum heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "abb306abb8d398e053cfb1b3e7b72c2f580be048b85745c52652954f8ad1439c" +"checksum heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8c80e194758495a9109566134dc06e42ea0423987d6ceca016edaa90381b3549" "checksum heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c9a70a1ef0122b54e0553f1d960b686c40d33a7953bc63029509a7649c8ee2c4" "checksum heartbeats-simple 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "78c0810722eacd0bdd3f1f691524bd9900bf8fed1947f6b883c10ddecd2560b1" "checksum heartbeats-simple-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d975666b80fe43ca3af2294ba5995a0f3a2a00fe8a229ac4788bdfd5f01a45d" diff --git a/ports/geckolib/Cargo.lock b/ports/geckolib/Cargo.lock index 22cd756a8f3..ad9fb96bc92 100644 --- a/ports/geckolib/Cargo.lock +++ b/ports/geckolib/Cargo.lock @@ -9,6 +9,7 @@ dependencies = [ "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "style_traits 0.0.1", @@ -29,7 +30,7 @@ name = "app_units" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -51,7 +52,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -142,7 +143,7 @@ name = "euclid" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -161,7 +162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "heapsize" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -369,7 +370,7 @@ dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -482,7 +483,7 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -539,7 +540,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "44ef2a3e4a621518e488db36820a12b49a9d5004764b8daf1458bbe5d7c9b626" "checksum fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8e8af7b5408ab0c4910cad114c8f9eb454bf75df7afe8964307eeafb68a13a5e" "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" -"checksum heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "abb306abb8d398e053cfb1b3e7b72c2f580be048b85745c52652954f8ad1439c" +"checksum heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8c80e194758495a9109566134dc06e42ea0423987d6ceca016edaa90381b3549" "checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49247ec2a285bb3dcb23cbd9c35193c025e7251bfce77c1d5da97e6362dffe7f" diff --git a/ports/geckolib/Cargo.toml b/ports/geckolib/Cargo.toml index 63f980f3bb9..50260374172 100644 --- a/ports/geckolib/Cargo.toml +++ b/ports/geckolib/Cargo.toml @@ -17,6 +17,7 @@ lazy_static = "0.2" libc = "0.2" log = {version = "0.3.5", features = ["release_max_level_info"]} num_cpus = "0.2.2" +parking_lot = "0.3" selectors = "0.13" style = {path = "../../components/style", features = ["gecko"]} style_traits = {path = "../../components/style_traits"} diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index b6768b6a256..a2110da4a3f 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -7,6 +7,7 @@ use app_units::Au; use env_logger; use euclid::Size2D; +use parking_lot::RwLock; use std::mem::transmute; use std::ptr; use std::slice; @@ -344,7 +345,9 @@ pub extern "C" fn Servo_ParseStyleAttribute(bytes: *const u8, length: u32, -> ServoDeclarationBlockStrong { let value = unsafe { from_utf8_unchecked(slice::from_raw_parts(bytes, length as usize)) }; Arc::new(GeckoDeclarationBlock { - declarations: GeckoElement::parse_style_attribute(value).map(Arc::new), + declarations: GeckoElement::parse_style_attribute(value).map(|block| { + Arc::new(RwLock::new(block)) + }), cache: AtomicPtr::new(cache), immutable: AtomicBool::new(false), }).into_strong() diff --git a/ports/geckolib/lib.rs b/ports/geckolib/lib.rs index f3925e2fa02..0b6493db278 100644 --- a/ports/geckolib/lib.rs +++ b/ports/geckolib/lib.rs @@ -9,6 +9,7 @@ extern crate env_logger; extern crate euclid; extern crate libc; #[macro_use] extern crate log; +extern crate parking_lot; extern crate url; #[allow(non_snake_case)] diff --git a/tests/unit/style/Cargo.toml b/tests/unit/style/Cargo.toml index a7923a49a69..4dd3dd0e574 100644 --- a/tests/unit/style/Cargo.toml +++ b/tests/unit/style/Cargo.toml @@ -13,8 +13,9 @@ doctest = false app_units = "0.3" cssparser = {version = "0.7", features = ["heap_size"]} euclid = "0.10.1" +parking_lot = "0.3" rustc-serialize = "0.3" -selectors = {version = "0.13", features = ["heap_size"]} +selectors = "0.13" string_cache = {version = "0.2.26", features = ["heap_size"]} style = {path = "../../../components/style"} style_traits = {path = "../../../components/style_traits"} diff --git a/tests/unit/style/lib.rs b/tests/unit/style/lib.rs index d394e69e8c6..ebbd6afa05a 100644 --- a/tests/unit/style/lib.rs +++ b/tests/unit/style/lib.rs @@ -9,6 +9,7 @@ extern crate app_units; extern crate cssparser; extern crate euclid; +extern crate parking_lot; extern crate rustc_serialize; extern crate selectors; #[macro_use(atom, ns)] extern crate string_cache; diff --git a/tests/unit/style/selector_matching.rs b/tests/unit/style/selector_matching.rs index b6422a75c09..1d5f4f8777f 100644 --- a/tests/unit/style/selector_matching.rs +++ b/tests/unit/style/selector_matching.rs @@ -3,12 +3,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::Parser; +use parking_lot::RwLock; use selectors::parser::{LocalName, ParserContext, parse_selector_list}; use std::sync::Arc; use string_cache::Atom; use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, DeclaredValue}; use style::properties::{longhands, Importance}; use style::selector_matching::{Rule, SelectorMap}; +use style::thread_state; /// Helper method to get some Rules from selector strings. /// Each sublist of the result contains the Rules for one StyleRule. @@ -19,14 +21,14 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec<Vec<Rule>> { .unwrap().into_iter().map(|s| { Rule { selector: s.complex_selector.clone(), - declarations: Arc::new(PropertyDeclarationBlock { + declarations: Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: vec![ (PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::block)), Importance::Normal), ], important_count: 0, - }), + })), specificity: s.specificity, source_order: i, } @@ -99,6 +101,7 @@ fn test_insert() { #[test] fn test_get_universal_rules() { + thread_state::initialize(thread_state::LAYOUT); let map = get_mock_map(&["*|*", "#foo > *|*", ".klass", "#id"]); let mut decls = vec![]; diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index 802ffb52f84..dd1b8eba094 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -4,6 +4,7 @@ use cssparser::{self, Parser, SourcePosition}; use media_queries::CSSErrorReporterTest; +use parking_lot::RwLock; use selectors::parser::*; use std::borrow::ToOwned; use std::sync::Arc; @@ -50,17 +51,7 @@ fn test_parse_stylesheet() { let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent, Box::new(CSSErrorReporterTest), ParserContextExtraData::default()); - macro_rules! assert_eq { - ($left: expr, $right: expr) => { - let left = $left; - let right = $right; - if left != right { - panic!("{:#?} != {:#?}", left, right) - } - } - } - - assert_eq!(stylesheet, Stylesheet { + let expected = Stylesheet { origin: Origin::UserAgent, media: None, dirty_on_viewport_size_change: false, @@ -97,7 +88,7 @@ fn test_parse_stylesheet() { specificity: (0 << 20) + (1 << 10) + (1 << 0), }, ], - declarations: Arc::new(PropertyDeclarationBlock { + block: Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: vec![ (PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::none)), @@ -106,7 +97,7 @@ fn test_parse_stylesheet() { Importance::Important), ], important_count: 2, - }), + })), })), CSSRule::Style(Arc::new(StyleRule { selectors: vec![ @@ -145,14 +136,14 @@ fn test_parse_stylesheet() { specificity: (0 << 20) + (0 << 10) + (1 << 0), }, ], - declarations: Arc::new(PropertyDeclarationBlock { + block: Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: vec![ (PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::block)), Importance::Normal), ], important_count: 0, - }), + })), })), CSSRule::Style(Arc::new(StyleRule { selectors: vec![ @@ -180,7 +171,7 @@ fn test_parse_stylesheet() { specificity: (1 << 20) + (1 << 10) + (0 << 0), }, ], - declarations: Arc::new(PropertyDeclarationBlock { + block: Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: vec![ (PropertyDeclaration::BackgroundColor(DeclaredValue::Value( longhands::background_color::SpecifiedValue { @@ -228,7 +219,7 @@ fn test_parse_stylesheet() { Importance::Normal), ], important_count: 0, - }), + })), })), CSSRule::Keyframes(Arc::new(KeyframesRule { name: "foo".into(), @@ -236,19 +227,19 @@ fn test_parse_stylesheet() { Arc::new(Keyframe { selector: KeyframeSelector::new_for_unit_testing( vec![KeyframePercentage::new(0.)]), - block: Arc::new(PropertyDeclarationBlock { + block: Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: vec![ (PropertyDeclaration::Width(DeclaredValue::Value( LengthOrPercentageOrAuto::Percentage(Percentage(0.)))), Importance::Normal), ], important_count: 0, - }) + })) }), Arc::new(Keyframe { selector: KeyframeSelector::new_for_unit_testing( vec![KeyframePercentage::new(1.)]), - block: Arc::new(PropertyDeclarationBlock { + block: Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: vec![ (PropertyDeclaration::Width(DeclaredValue::Value( LengthOrPercentageOrAuto::Percentage(Percentage(1.)))), @@ -259,13 +250,15 @@ fn test_parse_stylesheet() { Importance::Normal), ], important_count: 0, - }), + })), }), ] })) ], - }); + }; + + assert_eq!(format!("{:#?}", stylesheet), format!("{:#?}", expected)); } struct CSSError { |