Use PropertyDeclarationBlock in a DOMRefCell everywhere.

This commit is contained in:
Simon Sapin 2016-08-31 01:56:10 +02:00
parent d4f704cad2
commit d986fd2d2f
14 changed files with 146 additions and 100 deletions

View file

@ -6,9 +6,11 @@ use cssparser::Parser;
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};
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(DOMRefCell::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![];

View file

@ -9,6 +9,7 @@ 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;
@ -97,7 +98,7 @@ fn test_parse_stylesheet() {
specificity: (0 << 20) + (1 << 10) + (1 << 0),
},
],
declarations: Arc::new(PropertyDeclarationBlock {
block: Arc::new(DOMRefCell::new(PropertyDeclarationBlock {
declarations: vec![
(PropertyDeclaration::Display(DeclaredValue::Value(
longhands::display::SpecifiedValue::none)),
@ -106,7 +107,7 @@ fn test_parse_stylesheet() {
Importance::Important),
],
important_count: 2,
}),
})),
})),
CSSRule::Style(Arc::new(StyleRule {
selectors: vec![
@ -145,14 +146,14 @@ fn test_parse_stylesheet() {
specificity: (0 << 20) + (0 << 10) + (1 << 0),
},
],
declarations: Arc::new(PropertyDeclarationBlock {
block: Arc::new(DOMRefCell::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 +181,7 @@ fn test_parse_stylesheet() {
specificity: (1 << 20) + (1 << 10) + (0 << 0),
},
],
declarations: Arc::new(PropertyDeclarationBlock {
block: Arc::new(DOMRefCell::new(PropertyDeclarationBlock {
declarations: vec![
(PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
longhands::background_color::SpecifiedValue {
@ -228,7 +229,7 @@ fn test_parse_stylesheet() {
Importance::Normal),
],
important_count: 0,
}),
})),
})),
CSSRule::Keyframes(Arc::new(KeyframesRule {
name: "foo".into(),
@ -236,19 +237,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(DOMRefCell::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(DOMRefCell::new(PropertyDeclarationBlock {
declarations: vec![
(PropertyDeclaration::Width(DeclaredValue::Value(
LengthOrPercentageOrAuto::Percentage(Percentage(1.)))),
@ -259,7 +260,7 @@ fn test_parse_stylesheet() {
Importance::Normal),
],
important_count: 0,
}),
})),
}),
]
}))