mirror of
https://github.com/servo/servo.git
synced 2025-08-18 11:55:39 +01:00
Use parking_lot::RwLock instead of DOMRefCell for PropertyDeclarationBlock
This commit is contained in:
parent
d986fd2d2f
commit
89a29a7f12
24 changed files with 121 additions and 106 deletions
|
@ -13,6 +13,7 @@ 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 = "0.13"
|
||||
string_cache = {version = "0.2.26", features = ["heap_size"]}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* 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::domrefcell::DOMRefCell;
|
||||
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, DeclaredValue};
|
||||
use style::properties::{longhands, Importance};
|
||||
use style::selector_matching::{Rule, SelectorMap};
|
||||
|
@ -21,7 +21,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec<Vec<Rule>> {
|
|||
.unwrap().into_iter().map(|s| {
|
||||
Rule {
|
||||
selector: s.complex_selector.clone(),
|
||||
declarations: Arc::new(DOMRefCell::new(PropertyDeclarationBlock {
|
||||
declarations: Arc::new(RwLock::new(PropertyDeclarationBlock {
|
||||
declarations: vec![
|
||||
(PropertyDeclaration::Display(DeclaredValue::Value(
|
||||
longhands::display::SpecifiedValue::block)),
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
use cssparser::{self, Parser, SourcePosition};
|
||||
use media_queries::CSSErrorReporterTest;
|
||||
use parking_lot::RwLock;
|
||||
use selectors::parser::*;
|
||||
use std::borrow::ToOwned;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use string_cache::{Atom, Namespace as NsAtom};
|
||||
use style::domrefcell::DOMRefCell;
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage};
|
||||
use style::parser::ParserContextExtraData;
|
||||
|
@ -51,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,
|
||||
|
@ -98,7 +88,7 @@ fn test_parse_stylesheet() {
|
|||
specificity: (0 << 20) + (1 << 10) + (1 << 0),
|
||||
},
|
||||
],
|
||||
block: Arc::new(DOMRefCell::new(PropertyDeclarationBlock {
|
||||
block: Arc::new(RwLock::new(PropertyDeclarationBlock {
|
||||
declarations: vec![
|
||||
(PropertyDeclaration::Display(DeclaredValue::Value(
|
||||
longhands::display::SpecifiedValue::none)),
|
||||
|
@ -146,7 +136,7 @@ fn test_parse_stylesheet() {
|
|||
specificity: (0 << 20) + (0 << 10) + (1 << 0),
|
||||
},
|
||||
],
|
||||
block: Arc::new(DOMRefCell::new(PropertyDeclarationBlock {
|
||||
block: Arc::new(RwLock::new(PropertyDeclarationBlock {
|
||||
declarations: vec![
|
||||
(PropertyDeclaration::Display(DeclaredValue::Value(
|
||||
longhands::display::SpecifiedValue::block)),
|
||||
|
@ -181,7 +171,7 @@ fn test_parse_stylesheet() {
|
|||
specificity: (1 << 20) + (1 << 10) + (0 << 0),
|
||||
},
|
||||
],
|
||||
block: Arc::new(DOMRefCell::new(PropertyDeclarationBlock {
|
||||
block: Arc::new(RwLock::new(PropertyDeclarationBlock {
|
||||
declarations: vec![
|
||||
(PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
|
||||
longhands::background_color::SpecifiedValue {
|
||||
|
@ -237,7 +227,7 @@ fn test_parse_stylesheet() {
|
|||
Arc::new(Keyframe {
|
||||
selector: KeyframeSelector::new_for_unit_testing(
|
||||
vec![KeyframePercentage::new(0.)]),
|
||||
block: Arc::new(DOMRefCell::new(PropertyDeclarationBlock {
|
||||
block: Arc::new(RwLock::new(PropertyDeclarationBlock {
|
||||
declarations: vec![
|
||||
(PropertyDeclaration::Width(DeclaredValue::Value(
|
||||
LengthOrPercentageOrAuto::Percentage(Percentage(0.)))),
|
||||
|
@ -249,7 +239,7 @@ fn test_parse_stylesheet() {
|
|||
Arc::new(Keyframe {
|
||||
selector: KeyframeSelector::new_for_unit_testing(
|
||||
vec![KeyframePercentage::new(1.)]),
|
||||
block: Arc::new(DOMRefCell::new(PropertyDeclarationBlock {
|
||||
block: Arc::new(RwLock::new(PropertyDeclarationBlock {
|
||||
declarations: vec![
|
||||
(PropertyDeclaration::Width(DeclaredValue::Value(
|
||||
LengthOrPercentageOrAuto::Percentage(Percentage(1.)))),
|
||||
|
@ -266,7 +256,9 @@ fn test_parse_stylesheet() {
|
|||
}))
|
||||
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
assert_eq!(format!("{:#?}", stylesheet), format!("{:#?}", expected));
|
||||
}
|
||||
|
||||
struct CSSError {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue