mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Move all PropertyDeclarationBlock from RwLock<_> to Locked<_>
This commit is contained in:
parent
aeffca2a59
commit
1bacd0eb15
28 changed files with 321 additions and 208 deletions
|
@ -2,7 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use style::keyframes::{Keyframe, KeyframesAnimation, KeyframePercentage, KeyframeSelector};
|
||||
use style::keyframes::{KeyframesStep, KeyframesStepValue};
|
||||
|
@ -30,7 +29,7 @@ fn test_no_property_in_keyframe() {
|
|||
let keyframes = vec![
|
||||
Arc::new(shared_lock.wrap(Keyframe {
|
||||
selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(1.)]),
|
||||
block: Arc::new(RwLock::new(PropertyDeclarationBlock::new()))
|
||||
block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::new()))
|
||||
})),
|
||||
];
|
||||
let animation = KeyframesAnimation::from_keyframes(&keyframes, &shared_lock.read());
|
||||
|
@ -46,14 +45,14 @@ fn test_no_property_in_keyframe() {
|
|||
fn test_missing_property_in_initial_keyframe() {
|
||||
let shared_lock = SharedRwLock::new();
|
||||
let declarations_on_initial_keyframe =
|
||||
Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
|
||||
Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
|
||||
PropertyDeclaration::Width(
|
||||
LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
|
||||
Importance::Normal
|
||||
)));
|
||||
|
||||
let declarations_on_final_keyframe =
|
||||
Arc::new(RwLock::new({
|
||||
Arc::new(shared_lock.wrap({
|
||||
let mut block = PropertyDeclarationBlock::new();
|
||||
block.push(
|
||||
PropertyDeclaration::Width(
|
||||
|
@ -103,7 +102,7 @@ fn test_missing_property_in_initial_keyframe() {
|
|||
fn test_missing_property_in_final_keyframe() {
|
||||
let shared_lock = SharedRwLock::new();
|
||||
let declarations_on_initial_keyframe =
|
||||
Arc::new(RwLock::new({
|
||||
Arc::new(shared_lock.wrap({
|
||||
let mut block = PropertyDeclarationBlock::new();
|
||||
block.push(
|
||||
PropertyDeclaration::Width(
|
||||
|
@ -119,7 +118,7 @@ fn test_missing_property_in_final_keyframe() {
|
|||
}));
|
||||
|
||||
let declarations_on_final_keyframe =
|
||||
Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
|
||||
Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
|
||||
PropertyDeclaration::Height(
|
||||
LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
|
||||
Importance::Normal,
|
||||
|
@ -160,7 +159,7 @@ fn test_missing_property_in_final_keyframe() {
|
|||
fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() {
|
||||
let shared_lock = SharedRwLock::new();
|
||||
let declarations =
|
||||
Arc::new(RwLock::new({
|
||||
Arc::new(shared_lock.wrap({
|
||||
let mut block = PropertyDeclarationBlock::new();
|
||||
block.push(
|
||||
PropertyDeclaration::Width(
|
||||
|
@ -178,7 +177,7 @@ fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() {
|
|||
let keyframes = vec![
|
||||
Arc::new(shared_lock.wrap(Keyframe {
|
||||
selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.)]),
|
||||
block: Arc::new(RwLock::new(PropertyDeclarationBlock::new()))
|
||||
block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::new()))
|
||||
})),
|
||||
Arc::new(shared_lock.wrap(Keyframe {
|
||||
selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.5)]),
|
||||
|
@ -191,7 +190,7 @@ fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() {
|
|||
KeyframesStep {
|
||||
start_percentage: KeyframePercentage(0.),
|
||||
value: KeyframesStepValue::Declarations {
|
||||
block: Arc::new(RwLock::new(
|
||||
block: Arc::new(shared_lock.wrap(
|
||||
// XXX: Should we use ComputedValues in this case?
|
||||
PropertyDeclarationBlock::new()
|
||||
))
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::{Parser, SourcePosition};
|
||||
use parking_lot::RwLock;
|
||||
use rayon;
|
||||
use servo_url::ServoUrl;
|
||||
use std::sync::Arc;
|
||||
|
@ -65,9 +64,11 @@ fn test_insertion(rule_tree: &RuleTree, rules: Vec<(StyleSource, CascadeLevel)>)
|
|||
rule_tree.insert_ordered_rules(rules.into_iter())
|
||||
}
|
||||
|
||||
fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, CascadeLevel)]) -> StrongRuleNode {
|
||||
fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, CascadeLevel)],
|
||||
shared_lock: &SharedRwLock)
|
||||
-> StrongRuleNode {
|
||||
let mut rules = rules.to_vec();
|
||||
rules.push((StyleSource::Declarations(Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
|
||||
rules.push((StyleSource::Declarations(Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
|
||||
PropertyDeclaration::Display(
|
||||
longhands::display::SpecifiedValue::block),
|
||||
Importance::Normal
|
||||
|
@ -121,11 +122,12 @@ fn bench_expensive_insertion(b: &mut Bencher) {
|
|||
.bar { height: 500px; } \
|
||||
.baz { display: block; }");
|
||||
|
||||
let shared_lock = SharedRwLock::new();
|
||||
b.iter(|| {
|
||||
let _gc = AutoGCRuleTree::new(&r);
|
||||
|
||||
for _ in 0..(4000 + 400) {
|
||||
test::black_box(test_insertion_style_attribute(&r, &rules_matched));
|
||||
test::black_box(test_insertion_style_attribute(&r, &rules_matched, &shared_lock));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -170,6 +172,7 @@ fn bench_expensive_insersion_parallel(b: &mut Bencher) {
|
|||
.bar { height: 500px; } \
|
||||
.baz { display: block; }");
|
||||
|
||||
let shared_lock = SharedRwLock::new();
|
||||
b.iter(|| {
|
||||
let _gc = AutoGCRuleTree::new(&r);
|
||||
|
||||
|
@ -178,12 +181,14 @@ fn bench_expensive_insersion_parallel(b: &mut Bencher) {
|
|||
s.spawn(|s| {
|
||||
for _ in 0..1000 {
|
||||
test::black_box(test_insertion_style_attribute(&r,
|
||||
&rules_matched));
|
||||
&rules_matched,
|
||||
&shared_lock));
|
||||
}
|
||||
s.spawn(|_| {
|
||||
for _ in 0..100 {
|
||||
test::black_box(test_insertion_style_attribute(&r,
|
||||
&rules_matched));
|
||||
&rules_matched,
|
||||
&shared_lock));
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -109,7 +109,7 @@ fn test_parse_stylesheet() {
|
|||
specificity: (0 << 20) + (1 << 10) + (1 << 0),
|
||||
},
|
||||
]),
|
||||
block: Arc::new(RwLock::new(block_from(vec![
|
||||
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![
|
||||
(PropertyDeclaration::Display(longhands::display::SpecifiedValue::none),
|
||||
Importance::Important),
|
||||
(PropertyDeclaration::Custom(Atom::from("a"),
|
||||
|
@ -154,7 +154,7 @@ fn test_parse_stylesheet() {
|
|||
specificity: (0 << 20) + (0 << 10) + (1 << 0),
|
||||
},
|
||||
]),
|
||||
block: Arc::new(RwLock::new(block_from(vec![
|
||||
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![
|
||||
(PropertyDeclaration::Display(longhands::display::SpecifiedValue::block),
|
||||
Importance::Normal),
|
||||
]))),
|
||||
|
@ -185,7 +185,7 @@ fn test_parse_stylesheet() {
|
|||
specificity: (1 << 20) + (1 << 10) + (0 << 0),
|
||||
},
|
||||
]),
|
||||
block: Arc::new(RwLock::new(block_from(vec![
|
||||
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![
|
||||
(PropertyDeclaration::BackgroundColor(
|
||||
longhands::background_color::SpecifiedValue {
|
||||
authored: Some("blue".to_owned().into_boxed_str()),
|
||||
|
@ -241,7 +241,7 @@ fn test_parse_stylesheet() {
|
|||
Arc::new(stylesheet.shared_lock.wrap(Keyframe {
|
||||
selector: KeyframeSelector::new_for_unit_testing(
|
||||
vec![KeyframePercentage::new(0.)]),
|
||||
block: Arc::new(RwLock::new(block_from(vec![
|
||||
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![
|
||||
(PropertyDeclaration::Width(
|
||||
LengthOrPercentageOrAuto::Percentage(Percentage(0.))),
|
||||
Importance::Normal),
|
||||
|
@ -250,7 +250,7 @@ fn test_parse_stylesheet() {
|
|||
Arc::new(stylesheet.shared_lock.wrap(Keyframe {
|
||||
selector: KeyframeSelector::new_for_unit_testing(
|
||||
vec![KeyframePercentage::new(1.)]),
|
||||
block: Arc::new(RwLock::new(block_from(vec![
|
||||
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![
|
||||
(PropertyDeclaration::Width(
|
||||
LengthOrPercentageOrAuto::Percentage(Percentage(1.))),
|
||||
Importance::Normal),
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use html5ever_atoms::LocalName;
|
||||
use parking_lot::RwLock;
|
||||
use selectors::parser::LocalName as LocalNameSelector;
|
||||
use servo_atoms::Atom;
|
||||
use std::sync::Arc;
|
||||
|
@ -25,7 +24,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
|
|||
|
||||
let locked = Arc::new(shared_lock.wrap(StyleRule {
|
||||
selectors: selectors,
|
||||
block: Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
|
||||
block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
|
||||
PropertyDeclaration::Display(
|
||||
longhands::display::SpecifiedValue::block),
|
||||
Importance::Normal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue