mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Auto merge of #15298 - upsuper:mask-shorthand, r=nox
Fix two issues of parsing and serialization of mask shorthand <!-- 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/15298) <!-- Reviewable:end -->
This commit is contained in:
commit
5f0c294caf
2 changed files with 9 additions and 9 deletions
|
@ -49,10 +49,6 @@
|
||||||
if let Ok(value) = input.try(|input| mask_image::single_value
|
if let Ok(value) = input.try(|input| mask_image::single_value
|
||||||
::parse(context, input)) {
|
::parse(context, input)) {
|
||||||
image = Some(value);
|
image = Some(value);
|
||||||
|
|
||||||
// Parse mask mode, if applicable.
|
|
||||||
mode = input.try(|input| mask_mode::single_value::parse(context, input)).ok();
|
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +66,7 @@
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
% for name in "repeat origin clip composite".split():
|
% for name in "repeat origin clip composite mode".split():
|
||||||
if ${name}.is_none() {
|
if ${name}.is_none() {
|
||||||
if let Ok(value) = input.try(|input| mask_${name}::single_value
|
if let Ok(value) = input.try(|input| mask_${name}::single_value
|
||||||
::parse(context, input)) {
|
::parse(context, input)) {
|
||||||
|
@ -146,6 +142,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..len {
|
for i in 0..len {
|
||||||
|
if i > 0 {
|
||||||
|
try!(dest.write_str(", "));
|
||||||
|
}
|
||||||
|
|
||||||
% for name in "image mode position_x position_y size repeat origin clip composite".split():
|
% for name in "image mode position_x position_y size repeat origin clip composite".split():
|
||||||
let ${name} = if let DeclaredValue::Value(ref arr) = *self.mask_${name} {
|
let ${name} = if let DeclaredValue::Value(ref arr) = *self.mask_${name} {
|
||||||
arr.0.get(i % arr.0.len())
|
arr.0.get(i % arr.0.len())
|
||||||
|
|
|
@ -107,12 +107,12 @@ fn mask_shorthand_should_parse_origin_and_clip_correctly() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mask_shorthand_should_not_parse_when_mode_specified_but_image_not() {
|
fn mask_shorthand_should_parse_mode_everywhere() {
|
||||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||||
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
|
let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
|
||||||
let mut parser = Parser::new("luminance 7px 4px repeat-x padding");
|
let mut parser = Parser::new("luminance 7px 4px repeat-x padding-box");
|
||||||
assert!(mask::parse_value(&context, &mut parser).is_err());
|
assert!(mask::parse_value(&context, &mut parser).is_ok());
|
||||||
|
|
||||||
let mut parser = Parser::new("alpha");
|
let mut parser = Parser::new("alpha");
|
||||||
assert!(mask::parse_value(&context, &mut parser).is_err());
|
assert!(mask::parse_value(&context, &mut parser).is_ok());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue