aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-07-16 19:34:22 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-07-16 19:44:19 +0200
commitfde93a60fe020f12908dc37b624b87f13d12244f (patch)
tree397a665b1dc3c9785068c56006c82899d4732aa6
parent96e812e732d2d874eeaddeab3d50cbd6bf7c2751 (diff)
downloadservo-fde93a60fe020f12908dc37b624b87f13d12244f.tar.gz
servo-fde93a60fe020f12908dc37b624b87f13d12244f.zip
style: Fix build and unit tests.
-rw-r--r--components/script/dom/cssstyledeclaration.rs4
-rw-r--r--tests/unit/style/keyframes.rs259
-rw-r--r--tests/unit/style/lib.rs1
-rw-r--r--tests/unit/style/stylesheets.rs4
4 files changed, 4 insertions, 264 deletions
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index 9f6c97dbc7d..3c6e489a797 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -17,7 +17,7 @@ use dom_struct::dom_struct;
use servo_arc::Arc;
use servo_url::ServoUrl;
use style::attr::AttrValue;
-use style::properties::{DeclarationSource, Importance, PropertyDeclarationBlock, PropertyId, LonghandId, ShorthandId};
+use style::properties::{DeclarationPushMode, Importance, PropertyDeclarationBlock, PropertyId, LonghandId, ShorthandId};
use style::properties::{parse_one_declaration_into, parse_style_attribute, SourcePropertyDeclaration};
use style::selector_parser::PseudoElement;
use style::shared_lock::Locked;
@@ -302,7 +302,7 @@ impl CSSStyleDeclaration {
*changed = pdb.extend(
declarations.drain(),
importance,
- DeclarationSource::CssOm,
+ DeclarationPushMode::Update,
);
Ok(())
diff --git a/tests/unit/style/keyframes.rs b/tests/unit/style/keyframes.rs
deleted file mode 100644
index 0f8f02d5d27..00000000000
--- a/tests/unit/style/keyframes.rs
+++ /dev/null
@@ -1,259 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 cssparser::SourceLocation;
-use servo_arc::Arc;
-use style::properties::{LonghandId, LonghandIdSet, PropertyDeclaration, PropertyDeclarationBlock, Importance};
-use style::properties::DeclarationSource;
-use style::shared_lock::SharedRwLock;
-use style::stylesheets::keyframes_rule::{Keyframe, KeyframesAnimation, KeyframePercentage, KeyframeSelector};
-use style::stylesheets::keyframes_rule::{KeyframesStep, KeyframesStepValue};
-use style::values::specified::{LengthOrPercentageOrAuto, NoCalcLength};
-
-macro_rules! longhand_set {
- ($($word:ident),+) => {{
- let mut set = LonghandIdSet::new();
- $(
- set.insert(LonghandId::$word);
- )+
- set
- }}
-}
-
-
-#[test]
-fn test_empty_keyframe() {
- let shared_lock = SharedRwLock::new();
- let keyframes = vec![];
- let animation = KeyframesAnimation::from_keyframes(&keyframes,
- /* vendor_prefix = */ None,
- &shared_lock.read());
- let expected = KeyframesAnimation {
- steps: vec![],
- properties_changed: LonghandIdSet::new(),
- vendor_prefix: None,
- };
-
- assert_eq!(format!("{:#?}", animation), format!("{:#?}", expected));
-}
-
-#[test]
-fn test_no_property_in_keyframe() {
- let shared_lock = SharedRwLock::new();
- let dummy_location = SourceLocation { line: 0, column: 0 };
- let keyframes = vec![
- Arc::new(shared_lock.wrap(Keyframe {
- selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(1.)]),
- block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::new())),
- source_location: dummy_location,
- })),
- ];
- let animation = KeyframesAnimation::from_keyframes(&keyframes,
- /* vendor_prefix = */ None,
- &shared_lock.read());
- let expected = KeyframesAnimation {
- steps: vec![],
- properties_changed: LonghandIdSet::new(),
- vendor_prefix: None,
- };
-
- assert_eq!(format!("{:#?}", animation), format!("{:#?}", expected));
-}
-
-#[test]
-fn test_missing_property_in_initial_keyframe() {
- let shared_lock = SharedRwLock::new();
- let declarations_on_initial_keyframe =
- 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(shared_lock.wrap({
- let mut block = PropertyDeclarationBlock::new();
- block.push(
- PropertyDeclaration::Width(
- LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
- Importance::Normal,
- DeclarationSource::Parsing,
- );
- block.push(
- PropertyDeclaration::Height(
- LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
- Importance::Normal,
- DeclarationSource::Parsing,
- );
- block
- }));
-
- let dummy_location = SourceLocation { line: 0, column: 0 };
- let keyframes = vec![
- Arc::new(shared_lock.wrap(Keyframe {
- selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.)]),
- block: declarations_on_initial_keyframe.clone(),
- source_location: dummy_location,
- })),
-
- Arc::new(shared_lock.wrap(Keyframe {
- selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(1.)]),
- block: declarations_on_final_keyframe.clone(),
- source_location: dummy_location,
- })),
- ];
- let animation = KeyframesAnimation::from_keyframes(&keyframes,
- /* vendor_prefix = */ None,
- &shared_lock.read());
- let expected = KeyframesAnimation {
- steps: vec![
- KeyframesStep {
- start_percentage: KeyframePercentage(0.),
- value: KeyframesStepValue::Declarations { block: declarations_on_initial_keyframe },
- declared_timing_function: false,
- },
- KeyframesStep {
- start_percentage: KeyframePercentage(1.),
- value: KeyframesStepValue::Declarations { block: declarations_on_final_keyframe },
- declared_timing_function: false,
- },
- ],
- properties_changed: longhand_set!(Width, Height),
- vendor_prefix: None,
- };
-
- assert_eq!(format!("{:#?}", animation), format!("{:#?}", expected));
-}
-
-#[test]
-fn test_missing_property_in_final_keyframe() {
- let shared_lock = SharedRwLock::new();
- let declarations_on_initial_keyframe =
- Arc::new(shared_lock.wrap({
- let mut block = PropertyDeclarationBlock::new();
- block.push(
- PropertyDeclaration::Width(
- LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
- Importance::Normal,
- DeclarationSource::Parsing,
- );
- block.push(
- PropertyDeclaration::Height(
- LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
- Importance::Normal,
- DeclarationSource::Parsing,
- );
- block
- }));
-
- let declarations_on_final_keyframe =
- Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
- PropertyDeclaration::Height(
- LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
- Importance::Normal,
- )));
-
- let dummy_location = SourceLocation { line: 0, column: 0 };
- let keyframes = vec![
- Arc::new(shared_lock.wrap(Keyframe {
- selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.)]),
- block: declarations_on_initial_keyframe.clone(),
- source_location: dummy_location,
- })),
-
- Arc::new(shared_lock.wrap(Keyframe {
- selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(1.)]),
- block: declarations_on_final_keyframe.clone(),
- source_location: dummy_location,
- })),
- ];
- let animation = KeyframesAnimation::from_keyframes(&keyframes,
- /* vendor_prefix = */ None,
- &shared_lock.read());
- let expected = KeyframesAnimation {
- steps: vec![
- KeyframesStep {
- start_percentage: KeyframePercentage(0.),
- value: KeyframesStepValue::Declarations { block: declarations_on_initial_keyframe },
- declared_timing_function: false,
- },
- KeyframesStep {
- start_percentage: KeyframePercentage(1.),
- value: KeyframesStepValue::Declarations { block: declarations_on_final_keyframe },
- declared_timing_function: false,
- },
- ],
- properties_changed: longhand_set!(Width, Height),
- vendor_prefix: None,
- };
-
- assert_eq!(format!("{:#?}", animation), format!("{:#?}", expected));
-}
-
-#[test]
-fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() {
- let shared_lock = SharedRwLock::new();
- let declarations =
- Arc::new(shared_lock.wrap({
- let mut block = PropertyDeclarationBlock::new();
- block.push(
- PropertyDeclaration::Width(
- LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
- Importance::Normal,
- DeclarationSource::Parsing,
- );
- block.push(
- PropertyDeclaration::Height(
- LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
- Importance::Normal,
- DeclarationSource::Parsing,
- );
- block
- }));
-
- let dummy_location = SourceLocation { line: 0, column: 0 };
- let keyframes = vec![
- Arc::new(shared_lock.wrap(Keyframe {
- selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.)]),
- block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::new())),
- source_location: dummy_location,
- })),
- Arc::new(shared_lock.wrap(Keyframe {
- selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.5)]),
- block: declarations.clone(),
- source_location: dummy_location,
- })),
- ];
- let animation = KeyframesAnimation::from_keyframes(&keyframes,
- /* vendor_prefix = */ None,
- &shared_lock.read());
- let expected = KeyframesAnimation {
- steps: vec![
- KeyframesStep {
- start_percentage: KeyframePercentage(0.),
- value: KeyframesStepValue::Declarations {
- block: Arc::new(shared_lock.wrap(
- // XXX: Should we use ComputedValues in this case?
- PropertyDeclarationBlock::new()
- ))
- },
- declared_timing_function: false,
- },
- KeyframesStep {
- start_percentage: KeyframePercentage(0.5),
- value: KeyframesStepValue::Declarations { block: declarations },
- declared_timing_function: false,
- },
- KeyframesStep {
- start_percentage: KeyframePercentage(1.),
- value: KeyframesStepValue::ComputedValues,
- declared_timing_function: false,
- }
- ],
- properties_changed: longhand_set!(Width, Height),
- vendor_prefix: None,
- };
-
- assert_eq!(format!("{:#?}", animation), format!("{:#?}", expected));
-}
diff --git a/tests/unit/style/lib.rs b/tests/unit/style/lib.rs
index faa15845195..f9fe10dbaae 100644
--- a/tests/unit/style/lib.rs
+++ b/tests/unit/style/lib.rs
@@ -25,7 +25,6 @@ extern crate test;
mod animated_properties;
mod attr;
mod custom_properties;
-mod keyframes;
mod logical_geometry;
mod parsing;
mod properties;
diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs
index 632d51074fe..0e75b5a8458 100644
--- a/tests/unit/style/stylesheets.rs
+++ b/tests/unit/style/stylesheets.rs
@@ -17,7 +17,7 @@ use std::sync::atomic::AtomicBool;
use style::context::QuirksMode;
use style::error_reporting::{ParseErrorReporter, ContextualParseError};
use style::media_queries::MediaList;
-use style::properties::{CSSWideKeyword, CustomDeclaration, DeclarationSource};
+use style::properties::{CSSWideKeyword, CustomDeclaration, DeclarationPushMode};
use style::properties::{DeclaredValueOwned, Importance};
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
use style::properties::longhands::{self, animation_timing_function};
@@ -34,7 +34,7 @@ pub fn block_from<I>(iterable: I) -> PropertyDeclarationBlock
where I: IntoIterator<Item=(PropertyDeclaration, Importance)> {
let mut block = PropertyDeclarationBlock::new();
for (d, i) in iterable {
- block.push(d, i, DeclarationSource::CssOm);
+ block.push(d, i, DeclarationPushMode::Append);
}
block
}