mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #15225 - DexterHaslem:fix-transform-none, r=emilio
fix transform: none serialization <!-- Please describe your changes on the following line: --> As mentioned I struggled a bit figuring out the unit tests, please let me know if I missed anything or if there is a better way as usual! I will likely give the related implementing the rest of serialization for transform a shot next --- <!-- 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 - [X] These changes fix #15195 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/15225) <!-- Reviewable:end -->
This commit is contained in:
commit
1395b72884
2 changed files with 28 additions and 0 deletions
|
@ -1251,6 +1251,11 @@ ${helpers.single_keyword("animation-fill-mode",
|
||||||
|
|
||||||
impl ToCss for SpecifiedValue {
|
impl ToCss for SpecifiedValue {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
|
||||||
|
if self.0.is_empty() {
|
||||||
|
return dest.write_str("none")
|
||||||
|
}
|
||||||
|
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for operation in &self.0 {
|
for operation in &self.0 {
|
||||||
if !first {
|
if !first {
|
||||||
|
|
|
@ -1067,4 +1067,27 @@ mod shorthand_serialization {
|
||||||
assert_eq!(s, "mandatory");
|
assert_eq!(s, "mandatory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod transform {
|
||||||
|
pub use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_serialize_none_correctly() {
|
||||||
|
use cssparser::Parser;
|
||||||
|
use media_queries::CSSErrorReporterTest;
|
||||||
|
use style::parser::ParserContext;
|
||||||
|
use style::properties::longhands::transform;
|
||||||
|
use style::stylesheets::Origin;
|
||||||
|
|
||||||
|
let mut s = String::new();
|
||||||
|
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||||
|
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
|
||||||
|
|
||||||
|
let parsed = transform::parse(&context, &mut Parser::new("none")).unwrap();
|
||||||
|
let try_serialize = parsed.to_css(&mut s);
|
||||||
|
|
||||||
|
assert_eq!(try_serialize.is_ok(), true);
|
||||||
|
assert_eq!(s, "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue