mirror of
https://github.com/servo/servo.git
synced 2025-08-11 00:15:32 +01:00
Auto merge of #16527 - BorisChiou:stylo/transition/shorthands, r=emilio
stylo: Bug 1353628 - Support shorthand properties for CSS Transition. These patches add shorthand properties into TransitionProperty, so we can parse the shorthand properties properly and create transitions for them. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix Bug 1353628 - [X] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16527) <!-- Reviewable:end -->
This commit is contained in:
commit
355d5f89da
8 changed files with 150 additions and 25 deletions
|
@ -99,6 +99,7 @@ mod selectors;
|
|||
mod supports;
|
||||
mod text;
|
||||
mod text_overflow;
|
||||
mod transition_property;
|
||||
mod transition_timing_function;
|
||||
mod ui;
|
||||
mod value;
|
||||
|
|
67
tests/unit/style/parsing/transition_property.rs
Normal file
67
tests/unit/style/parsing/transition_property.rs
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* 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 parsing::parse;
|
||||
use style::properties::animated_properties::TransitionProperty;
|
||||
use style::properties::longhands::transition_property;
|
||||
use style::properties::shorthands::transition;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[test]
|
||||
fn test_longhand_properties() {
|
||||
assert_roundtrip_with_context!(transition_property::parse, "margin-left");
|
||||
assert_roundtrip_with_context!(transition_property::parse, "background-color");
|
||||
assert_roundtrip_with_context!(transition_property::parse, "width");
|
||||
|
||||
assert_eq!(parse_longhand!(transition_property, "margin-left, width"),
|
||||
transition_property::SpecifiedValue(
|
||||
vec![TransitionProperty::MarginLeft,
|
||||
TransitionProperty::Width]));
|
||||
|
||||
// TODO: If one of the identifiers listed is not a recognized property name or is not an
|
||||
// animatable property, the implementation must still start transitions on the animatable
|
||||
// properties. Therefore, the parser shouldn't return Err for non-animatable property.
|
||||
assert!(parse(transition_property::parse, "transition-duration").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shorthand_properties() {
|
||||
assert_roundtrip_with_context!(transition_property::parse, "margin");
|
||||
assert_roundtrip_with_context!(transition_property::parse, "background");
|
||||
assert_roundtrip_with_context!(transition_property::parse, "border-bottom");
|
||||
|
||||
assert_eq!(parse_longhand!(transition_property, "margin, background"),
|
||||
transition_property::SpecifiedValue(
|
||||
vec![TransitionProperty::Margin,
|
||||
TransitionProperty::Background]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keywords() {
|
||||
assert_roundtrip_with_context!(transition_property::parse, "all");
|
||||
assert_roundtrip_with_context!(transition_property::parse, "none");
|
||||
|
||||
assert_eq!(parse_longhand!(transition_property, "all"),
|
||||
transition_property::SpecifiedValue(vec![TransitionProperty::All]));
|
||||
assert_eq!(parse_longhand!(transition_property, "none"),
|
||||
transition_property::SpecifiedValue(vec![]));
|
||||
|
||||
assert!(parse(transition_property::parse, "inherit").is_err());
|
||||
assert!(parse(transition_property::parse, "initial").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transition_shorthand() {
|
||||
let result = parse(transition::parse_value, "2s margin-left, 4s background").unwrap();
|
||||
assert_eq!(result.transition_property,
|
||||
parse_longhand!(transition_property, "margin-left, background"));
|
||||
|
||||
let result = parse(transition::parse_value, "2s margin, 4s all").unwrap();
|
||||
assert_eq!(result.transition_property,
|
||||
parse_longhand!(transition_property, "margin, all"));
|
||||
|
||||
let result = parse(transition::parse_value, "none").unwrap();
|
||||
assert_eq!(result.transition_property,
|
||||
parse_longhand!(transition_property, "none"));
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
[events-001.htm]
|
||||
type: testharness
|
||||
[transition:padding, changing padding-left / events]
|
||||
expected: FAIL
|
||||
|
||||
[transition:padding, changing padding / events]
|
||||
expected: FAIL
|
||||
|
||||
[transition:padding, changing padding but not padding-bottom / events]
|
||||
expected: FAIL
|
||||
|
|
@ -15,9 +15,6 @@
|
|||
[parse 'foobar, all']
|
||||
expected: FAIL
|
||||
|
||||
[parse 'inherit']
|
||||
expected: FAIL
|
||||
|
||||
[parse 'initial']
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue