mirror of
https://github.com/servo/servo.git
synced 2025-09-15 01:18:22 +01:00
Auto merge of #14104 - iamrohit7:scroll-snap-type, r=Manishearth,waffles
Adds scroll-snap-type shorthand property <!-- Please describe your changes on the following line: --> Follow up to #14017 --- r=Manishearth <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes `scroll_snap_type::should_serialize_to_single_value_if_sub_types_are_equal`, `scroll_snap_type::should_serialize_to_empty_string_if_sub_types_not_equal` <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/14104) <!-- Reviewable:end -->
This commit is contained in:
commit
3959817424
5 changed files with 103 additions and 16 deletions
|
@ -1006,4 +1006,53 @@ mod shorthand_serialization {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
mod scroll_snap_type {
|
||||
pub use super::*;
|
||||
use style::properties::longhands::scroll_snap_type_x::computed_value::T as ScrollSnapTypeXValue;
|
||||
|
||||
#[test]
|
||||
fn should_serialize_to_empty_string_if_sub_types_not_equal() {
|
||||
let declarations = vec![
|
||||
(PropertyDeclaration::ScrollSnapTypeX(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)),
|
||||
Importance::Normal),
|
||||
(PropertyDeclaration::ScrollSnapTypeY(DeclaredValue::Value(ScrollSnapTypeXValue::none)),
|
||||
Importance::Normal)
|
||||
];
|
||||
|
||||
let block = PropertyDeclarationBlock {
|
||||
declarations: declarations,
|
||||
important_count: 0
|
||||
};
|
||||
|
||||
let mut s = String::new();
|
||||
|
||||
let x = block.single_value_to_css("scroll-snap-type", &mut s);
|
||||
|
||||
assert_eq!(x.is_ok(), true);
|
||||
assert_eq!(s, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_serialize_to_single_value_if_sub_types_are_equal() {
|
||||
let declarations = vec![
|
||||
(PropertyDeclaration::ScrollSnapTypeX(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)),
|
||||
Importance::Normal),
|
||||
(PropertyDeclaration::ScrollSnapTypeY(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)),
|
||||
Importance::Normal)
|
||||
];
|
||||
|
||||
let block = PropertyDeclarationBlock {
|
||||
declarations: declarations,
|
||||
important_count: 0
|
||||
};
|
||||
|
||||
let mut s = String::new();
|
||||
|
||||
let x = block.single_value_to_css("scroll-snap-type", &mut s);
|
||||
|
||||
assert_eq!(x.is_ok(), true);
|
||||
assert_eq!(s, "mandatory");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue