mirror of
https://github.com/servo/servo.git
synced 2025-06-23 08:34:42 +01:00
Fix origin/clip parsing behavior in mask and background shorthands
This commit is contained in:
parent
36222cf543
commit
1b35a3d9a8
4 changed files with 38 additions and 22 deletions
|
@ -11,6 +11,20 @@
|
|||
use properties::longhands::{background_color, background_position, background_repeat, background_attachment};
|
||||
use properties::longhands::{background_image, background_size, background_origin, background_clip};
|
||||
|
||||
impl From<background_origin::single_value::SpecifiedValue> for background_clip::single_value::SpecifiedValue {
|
||||
fn from(origin: background_origin::single_value::SpecifiedValue) ->
|
||||
background_clip::single_value::SpecifiedValue {
|
||||
match origin {
|
||||
background_origin::single_value::SpecifiedValue::content_box =>
|
||||
background_clip::single_value::SpecifiedValue::content_box,
|
||||
background_origin::single_value::SpecifiedValue::padding_box =>
|
||||
background_clip::single_value::SpecifiedValue::padding_box,
|
||||
background_origin::single_value::SpecifiedValue::border_box =>
|
||||
background_clip::single_value::SpecifiedValue::border_box,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||
let mut background_color = None;
|
||||
|
||||
|
@ -56,6 +70,11 @@
|
|||
% endfor
|
||||
break
|
||||
}
|
||||
if clip.is_none() {
|
||||
if let Some(origin) = origin {
|
||||
clip = Some(background_clip::single_value::SpecifiedValue::from(origin));
|
||||
}
|
||||
}
|
||||
let mut any = false;
|
||||
% for name in "image position repeat size attachment origin clip".split():
|
||||
any = any || ${name}.is_some();
|
||||
|
@ -199,14 +218,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
(Some(origin), _) => {
|
||||
try!(write!(dest, " "));
|
||||
try!(origin.to_css(dest));
|
||||
},
|
||||
(_, Some(clip)) => {
|
||||
try!(write!(dest, " "));
|
||||
try!(clip.to_css(dest));
|
||||
},
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,6 +10,19 @@
|
|||
use properties::longhands::{mask_mode, mask_repeat, mask_clip, mask_origin, mask_composite, mask_position};
|
||||
use properties::longhands::{mask_size, mask_image};
|
||||
|
||||
impl From<mask_origin::single_value::SpecifiedValue> for mask_clip::single_value::SpecifiedValue {
|
||||
fn from(origin: mask_origin::single_value::SpecifiedValue) -> mask_clip::single_value::SpecifiedValue {
|
||||
match origin {
|
||||
mask_origin::single_value::SpecifiedValue::content_box =>
|
||||
mask_clip::single_value::SpecifiedValue::content_box,
|
||||
mask_origin::single_value::SpecifiedValue::padding_box =>
|
||||
mask_clip::single_value::SpecifiedValue::padding_box,
|
||||
mask_origin::single_value::SpecifiedValue::border_box =>
|
||||
mask_clip::single_value::SpecifiedValue::border_box,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||
% for name in "image mode position size repeat origin clip composite".split():
|
||||
let mut mask_${name} = mask_${name}::SpecifiedValue(Vec::new());
|
||||
|
@ -56,6 +69,11 @@
|
|||
% endfor
|
||||
break
|
||||
}
|
||||
if clip.is_none() {
|
||||
if let Some(origin) = origin {
|
||||
clip = Some(mask_clip::single_value::SpecifiedValue::from(origin));
|
||||
}
|
||||
}
|
||||
let mut any = false;
|
||||
% for name in "image mode position size repeat origin clip composite".split():
|
||||
any = any || ${name}.is_some();
|
||||
|
@ -169,14 +187,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
(Some(origin), _) => {
|
||||
try!(write!(dest, " "));
|
||||
try!(origin.to_css(dest));
|
||||
},
|
||||
(_, Some(clip)) => {
|
||||
try!(write!(dest, " "));
|
||||
try!(clip.to_css(dest));
|
||||
},
|
||||
_ => {}
|
||||
};
|
||||
|
||||
|
|
|
@ -106,8 +106,8 @@ fn mask_shorthand_should_parse_origin_and_clip_correctly() {
|
|||
let mut parser = Parser::new("padding-box");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
// TODO(#13466): We should fix origin/clip parsing behavior.
|
||||
assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box"));
|
||||
assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "padding-box"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[background-335.htm]
|
||||
type: testharness
|
||||
[background_specified_box_one_clip]
|
||||
expected: FAIL
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue