mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Have shorthand parsing functions return values
Shorthands are responsible to set all its longhands to a proper value, rather than returning None. Fixes #15380.
This commit is contained in:
parent
2e07ce7e84
commit
f33b0b4ea3
18 changed files with 240 additions and 259 deletions
|
@ -492,8 +492,7 @@
|
||||||
|
|
||||||
pub struct Longhands {
|
pub struct Longhands {
|
||||||
% for sub_property in shorthand.sub_properties:
|
% for sub_property in shorthand.sub_properties:
|
||||||
pub ${sub_property.ident}:
|
pub ${sub_property.ident}: longhands::${sub_property.ident}::SpecifiedValue,
|
||||||
Option<longhands::${sub_property.ident}::SpecifiedValue>,
|
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,14 +605,11 @@
|
||||||
if let Ok(value) = value {
|
if let Ok(value) = value {
|
||||||
% for sub_property in shorthand.sub_properties:
|
% for sub_property in shorthand.sub_properties:
|
||||||
declarations.push((PropertyDeclaration::${sub_property.camel_case}(
|
declarations.push((PropertyDeclaration::${sub_property.camel_case}(
|
||||||
match value.${sub_property.ident} {
|
% if sub_property.boxed:
|
||||||
% if sub_property.boxed:
|
DeclaredValue::Value(Box::new(value.${sub_property.ident}))
|
||||||
Some(value) => DeclaredValue::Value(Box::new(value)),
|
% else:
|
||||||
% else:
|
DeclaredValue::Value(value.${sub_property.ident})
|
||||||
Some(value) => DeclaredValue::Value(value),
|
% endif
|
||||||
% endif
|
|
||||||
None => DeclaredValue::Initial,
|
|
||||||
}
|
|
||||||
), Importance::Normal));
|
), Importance::Normal));
|
||||||
% endfor
|
% endfor
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -660,7 +656,7 @@
|
||||||
% endif
|
% endif
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
% for side in ["top", "right", "bottom", "left"]:
|
% for side in ["top", "right", "bottom", "left"]:
|
||||||
${to_rust_ident(sub_property_pattern % side)}: Some(${side}),
|
${to_rust_ident(sub_property_pattern % side)}: ${side},
|
||||||
% endfor
|
% endfor
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,12 @@ pub mod longhands {
|
||||||
<%include file="/longhand/xul.mako.rs" />
|
<%include file="/longhand/xul.mako.rs" />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! unwrap_or_initial {
|
||||||
|
($prop: ident) => (unwrap_or_initial!($prop, $prop));
|
||||||
|
($prop: ident, $expr: expr) =>
|
||||||
|
($expr.unwrap_or_else(|| $prop::get_initial_specified_value()));
|
||||||
|
}
|
||||||
|
|
||||||
/// A module with code for all the shorthand css properties, and a few
|
/// A module with code for all the shorthand css properties, and a few
|
||||||
/// serialization helpers.
|
/// serialization helpers.
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
@ -343,13 +349,12 @@ impl PropertyDeclarationIdSet {
|
||||||
% if property in shorthand.sub_properties:
|
% if property in shorthand.sub_properties:
|
||||||
Some(ShorthandId::${shorthand.camel_case}) => {
|
Some(ShorthandId::${shorthand.camel_case}) => {
|
||||||
shorthands::${shorthand.ident}::parse_value(&context, input)
|
shorthands::${shorthand.ident}::parse_value(&context, input)
|
||||||
.map(|result| match result.${property.ident} {
|
.map(|result| {
|
||||||
% if property.boxed:
|
% if property.boxed:
|
||||||
Some(value) => DeclaredValue::Value(Box::new(value)),
|
DeclaredValue::Value(Box::new(result.${property.ident}))
|
||||||
% else:
|
% else:
|
||||||
Some(value) => DeclaredValue::Value(value),
|
DeclaredValue::Value(result.${property.ident})
|
||||||
% endif
|
% endif
|
||||||
None => DeclaredValue::Initial,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -115,15 +115,15 @@
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
background_color: background_color,
|
background_color: unwrap_or_initial!(background_color),
|
||||||
background_image: Some(background_image),
|
background_image: background_image,
|
||||||
background_position_x: Some(background_position_x),
|
background_position_x: background_position_x,
|
||||||
background_position_y: Some(background_position_y),
|
background_position_y: background_position_y,
|
||||||
background_repeat: Some(background_repeat),
|
background_repeat: background_repeat,
|
||||||
background_attachment: Some(background_attachment),
|
background_attachment: background_attachment,
|
||||||
background_size: Some(background_size),
|
background_size: background_size,
|
||||||
background_origin: Some(background_origin),
|
background_origin: background_origin,
|
||||||
background_clip: Some(background_clip),
|
background_clip: background_clip,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,8 +246,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
background_position_x: Some(position_x),
|
background_position_x: position_x,
|
||||||
background_position_y: Some(position_y),
|
background_position_y: position_y,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ ${helpers.four_sides_shorthand("border-style", "border-%s-style",
|
||||||
let (top, right, bottom, left) = try!(parse_four_sides(input, |i| specified::BorderWidth::parse(context, i)));
|
let (top, right, bottom, left) = try!(parse_four_sides(input, |i| specified::BorderWidth::parse(context, i)));
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
% for side in ["top", "right", "bottom", "left"]:
|
% for side in ["top", "right", "bottom", "left"]:
|
||||||
${to_rust_ident('border-%s-width' % side)}: Some(${side}),
|
${to_rust_ident('border-%s-width' % side)}: ${side},
|
||||||
% endfor
|
% endfor
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -42,10 +42,10 @@ ${helpers.four_sides_shorthand("border-style", "border-%s-style",
|
||||||
|
|
||||||
|
|
||||||
pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
||||||
-> Result<(Option<specified::CSSColor>,
|
-> Result<(specified::CSSColor,
|
||||||
Option<specified::BorderStyle>,
|
specified::BorderStyle,
|
||||||
Option<specified::BorderWidth>), ()> {
|
specified::BorderWidth), ()> {
|
||||||
use values::specified;
|
use values::specified::{CSSColor, BorderStyle, BorderWidth};
|
||||||
let _unused = context;
|
let _unused = context;
|
||||||
let mut color = None;
|
let mut color = None;
|
||||||
let mut style = None;
|
let mut style = None;
|
||||||
|
@ -53,21 +53,21 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
||||||
let mut any = false;
|
let mut any = false;
|
||||||
loop {
|
loop {
|
||||||
if color.is_none() {
|
if color.is_none() {
|
||||||
if let Ok(value) = input.try(|i| specified::CSSColor::parse(context, i)) {
|
if let Ok(value) = input.try(|i| CSSColor::parse(context, i)) {
|
||||||
color = Some(value);
|
color = Some(value);
|
||||||
any = true;
|
any = true;
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if style.is_none() {
|
if style.is_none() {
|
||||||
if let Ok(value) = input.try(|i| specified::BorderStyle::parse(context, i)) {
|
if let Ok(value) = input.try(|i| BorderStyle::parse(context, i)) {
|
||||||
style = Some(value);
|
style = Some(value);
|
||||||
any = true;
|
any = true;
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if width.is_none() {
|
if width.is_none() {
|
||||||
if let Ok(value) = input.try(|i| specified::BorderWidth::parse(context, i)) {
|
if let Ok(value) = input.try(|i| BorderWidth::parse(context, i)) {
|
||||||
width = Some(value);
|
width = Some(value);
|
||||||
any = true;
|
any = true;
|
||||||
continue
|
continue
|
||||||
|
@ -75,7 +75,13 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if any { Ok((color, style, width)) } else { Err(()) }
|
if any {
|
||||||
|
Ok((color.unwrap_or_else(|| CSSColor::currentcolor()),
|
||||||
|
style.unwrap_or(BorderStyle::none),
|
||||||
|
width.unwrap_or(BorderWidth::Medium)))
|
||||||
|
} else {
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
% for side, logical in ALL_SIDES:
|
% for side, logical in ALL_SIDES:
|
||||||
|
@ -158,10 +164,10 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
||||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
let radii = try!(BorderRadius::parse(context, input));
|
let radii = try!(BorderRadius::parse(context, input));
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
border_top_left_radius: Some(radii.top_left),
|
border_top_left_radius: radii.top_left,
|
||||||
border_top_right_radius: Some(radii.top_right),
|
border_top_right_radius: radii.top_right,
|
||||||
border_bottom_right_radius: Some(radii.bottom_right),
|
border_bottom_right_radius: radii.bottom_right,
|
||||||
border_bottom_left_radius: Some(radii.bottom_left),
|
border_bottom_left_radius: radii.bottom_left,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +260,7 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
% for name in "outset repeat slice source width".split():
|
% for name in "outset repeat slice source width".split():
|
||||||
border_image_${name}: Some(border_image_${name}),
|
border_image_${name}: border_image_${name},
|
||||||
% endfor
|
% endfor
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
let overflow = try!(overflow_x::parse(context, input));
|
let overflow = try!(overflow_x::parse(context, input));
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
overflow_x: Some(overflow),
|
overflow_x: overflow,
|
||||||
overflow_y: Some(overflow_y::SpecifiedValue(overflow)),
|
overflow_y: overflow_y::SpecifiedValue(overflow),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,31 +103,25 @@ macro_rules! try_parse_one {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
|
||||||
return Ok(Longhands {
|
|
||||||
transition_property: None,
|
|
||||||
transition_duration: None,
|
|
||||||
transition_timing_function: None,
|
|
||||||
transition_delay: None,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
let results = try!(input.parse_comma_separated(|i| parse_one_transition(context, i)));
|
|
||||||
let (mut properties, mut durations) = (Vec::new(), Vec::new());
|
let (mut properties, mut durations) = (Vec::new(), Vec::new());
|
||||||
let (mut timing_functions, mut delays) = (Vec::new(), Vec::new());
|
let (mut timing_functions, mut delays) = (Vec::new(), Vec::new());
|
||||||
for result in results {
|
|
||||||
properties.push(result.transition_property);
|
if input.try(|input| input.expect_ident_matching("none")).is_err() {
|
||||||
durations.push(result.transition_duration);
|
let results = try!(input.parse_comma_separated(|i| parse_one_transition(context, i)));
|
||||||
timing_functions.push(result.transition_timing_function);
|
for result in results {
|
||||||
delays.push(result.transition_delay);
|
properties.push(result.transition_property);
|
||||||
|
durations.push(result.transition_duration);
|
||||||
|
timing_functions.push(result.transition_timing_function);
|
||||||
|
delays.push(result.transition_delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
transition_property: Some(transition_property::SpecifiedValue(properties)),
|
transition_property: transition_property::SpecifiedValue(properties),
|
||||||
transition_duration: Some(transition_duration::SpecifiedValue(durations)),
|
transition_duration: transition_duration::SpecifiedValue(durations),
|
||||||
transition_timing_function:
|
transition_timing_function:
|
||||||
Some(transition_timing_function::SpecifiedValue(timing_functions)),
|
transition_timing_function::SpecifiedValue(timing_functions),
|
||||||
transition_delay: Some(transition_delay::SpecifiedValue(delays)),
|
transition_delay: transition_delay::SpecifiedValue(delays),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,21 +252,6 @@ macro_rules! try_parse_one {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
|
||||||
return Ok(Longhands {
|
|
||||||
animation_name: None,
|
|
||||||
animation_duration: None,
|
|
||||||
animation_timing_function: None,
|
|
||||||
animation_delay: None,
|
|
||||||
animation_iteration_count: None,
|
|
||||||
animation_direction: None,
|
|
||||||
animation_fill_mode: None,
|
|
||||||
animation_play_state: None,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
let results = try!(input.parse_comma_separated(|i| parse_one_animation(context, i)));
|
|
||||||
|
|
||||||
let mut names = vec![];
|
let mut names = vec![];
|
||||||
let mut durations = vec![];
|
let mut durations = vec![];
|
||||||
let mut timing_functions = vec![];
|
let mut timing_functions = vec![];
|
||||||
|
@ -282,26 +261,29 @@ macro_rules! try_parse_one {
|
||||||
let mut fill_modes = vec![];
|
let mut fill_modes = vec![];
|
||||||
let mut play_states = vec![];
|
let mut play_states = vec![];
|
||||||
|
|
||||||
for result in results.into_iter() {
|
if input.try(|input| input.expect_ident_matching("none")).is_err() {
|
||||||
names.push(result.animation_name);
|
let results = try!(input.parse_comma_separated(|i| parse_one_animation(context, i)));
|
||||||
durations.push(result.animation_duration);
|
for result in results.into_iter() {
|
||||||
timing_functions.push(result.animation_timing_function);
|
names.push(result.animation_name);
|
||||||
delays.push(result.animation_delay);
|
durations.push(result.animation_duration);
|
||||||
iteration_counts.push(result.animation_iteration_count);
|
timing_functions.push(result.animation_timing_function);
|
||||||
directions.push(result.animation_direction);
|
delays.push(result.animation_delay);
|
||||||
fill_modes.push(result.animation_fill_mode);
|
iteration_counts.push(result.animation_iteration_count);
|
||||||
play_states.push(result.animation_play_state);
|
directions.push(result.animation_direction);
|
||||||
|
fill_modes.push(result.animation_fill_mode);
|
||||||
|
play_states.push(result.animation_play_state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
animation_name: Some(animation_name::SpecifiedValue(names)),
|
animation_name: animation_name::SpecifiedValue(names),
|
||||||
animation_duration: Some(animation_duration::SpecifiedValue(durations)),
|
animation_duration: animation_duration::SpecifiedValue(durations),
|
||||||
animation_timing_function: Some(animation_timing_function::SpecifiedValue(timing_functions)),
|
animation_timing_function: animation_timing_function::SpecifiedValue(timing_functions),
|
||||||
animation_delay: Some(animation_delay::SpecifiedValue(delays)),
|
animation_delay: animation_delay::SpecifiedValue(delays),
|
||||||
animation_iteration_count: Some(animation_iteration_count::SpecifiedValue(iteration_counts)),
|
animation_iteration_count: animation_iteration_count::SpecifiedValue(iteration_counts),
|
||||||
animation_direction: Some(animation_direction::SpecifiedValue(directions)),
|
animation_direction: animation_direction::SpecifiedValue(directions),
|
||||||
animation_fill_mode: Some(animation_fill_mode::SpecifiedValue(fill_modes)),
|
animation_fill_mode: animation_fill_mode::SpecifiedValue(fill_modes),
|
||||||
animation_play_state: Some(animation_play_state::SpecifiedValue(play_states)),
|
animation_play_state: animation_play_state::SpecifiedValue(play_states),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,8 +346,8 @@ macro_rules! try_parse_one {
|
||||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
let result = try!(scroll_snap_type_x::parse(context, input));
|
let result = try!(scroll_snap_type_x::parse(context, input));
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
scroll_snap_type_x: Some(result),
|
scroll_snap_type_x: result,
|
||||||
scroll_snap_type_y: Some(result),
|
scroll_snap_type_y: result,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
Err(())
|
Err(())
|
||||||
} else {
|
} else {
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
column_count: column_count,
|
column_count: unwrap_or_initial!(column_count),
|
||||||
column_width: column_width,
|
column_width: unwrap_or_initial!(column_width),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,11 +87,9 @@
|
||||||
}
|
}
|
||||||
if any {
|
if any {
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
% for name in "width style".split():
|
column_rule_width: unwrap_or_initial!(column_rule_width),
|
||||||
column_rule_${name}: column_rule_${name}
|
column_rule_style: unwrap_or_initial!(column_rule_style),
|
||||||
.or(Some(column_rule_${name}::get_initial_specified_value())),
|
column_rule_color: unwrap_or_initial!(column_rule_color),
|
||||||
% endfor
|
|
||||||
column_rule_color: column_rule_color,
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(())
|
||||||
|
|
|
@ -14,6 +14,12 @@
|
||||||
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font">
|
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font">
|
||||||
use properties::longhands::{font_style, font_variant, font_weight, font_stretch};
|
use properties::longhands::{font_style, font_variant, font_weight, font_stretch};
|
||||||
use properties::longhands::{font_size, line_height};
|
use properties::longhands::{font_size, line_height};
|
||||||
|
% if product == "gecko":
|
||||||
|
use properties::longhands::{font_size_adjust, font_kerning, font_variant_caps, font_variant_position};
|
||||||
|
% endif
|
||||||
|
% if product == "none":
|
||||||
|
use properties::longhands::font_language_override;
|
||||||
|
% endif
|
||||||
use properties::longhands::font_family::SpecifiedValue as FontFamily;
|
use properties::longhands::font_family::SpecifiedValue as FontFamily;
|
||||||
|
|
||||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
|
@ -72,22 +78,19 @@
|
||||||
};
|
};
|
||||||
let family = FontFamily::parse(input)?;
|
let family = FontFamily::parse(input)?;
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
font_style: style,
|
% for name in "style variant weight stretch size".split():
|
||||||
font_variant: variant,
|
font_${name}: unwrap_or_initial!(font_${name}, ${name}),
|
||||||
font_weight: weight,
|
% endfor
|
||||||
font_stretch: stretch,
|
line_height: unwrap_or_initial!(line_height),
|
||||||
font_size: size,
|
font_family: family,
|
||||||
line_height: line_height,
|
% if product == "gecko":
|
||||||
font_family: Some(family),
|
% for name in "size_adjust kerning variant_caps variant_position".split():
|
||||||
% if product == "gecko":
|
font_${name}: font_${name}::get_initial_specified_value(),
|
||||||
font_size_adjust: None,
|
% endfor
|
||||||
font_kerning: None,
|
% endif
|
||||||
font_variant_caps: None,
|
% if product == "none":
|
||||||
font_variant_position: None,
|
font_language_override: font_language_override::get_initial_specified_value(),
|
||||||
% endif
|
% endif
|
||||||
% if product == "none":
|
|
||||||
font_language_override: None,
|
|
||||||
% endif
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
let url = UrlOrNone::parse(context, input)?;
|
let url = UrlOrNone::parse(context, input)?;
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
marker_start: Some(url.clone()),
|
marker_start: url.clone(),
|
||||||
marker_mid: Some(url.clone()),
|
marker_mid: url.clone(),
|
||||||
marker_end: Some(url),
|
marker_end: url,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,9 @@
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if color.is_some() || style.is_some() {
|
if color.is_some() || style.is_some() {
|
||||||
if style.is_none() {
|
|
||||||
style = Some(text_emphasis_style::get_initial_specified_value());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
text_emphasis_color: color,
|
text_emphasis_color: unwrap_or_initial!(text_emphasis_color, color),
|
||||||
text_emphasis_style: style,
|
text_emphasis_style: unwrap_or_initial!(text_emphasis_style, style),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(())
|
||||||
|
@ -68,13 +64,9 @@
|
||||||
-webkit-text-stroke-width"
|
-webkit-text-stroke-width"
|
||||||
products="gecko"
|
products="gecko"
|
||||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke">
|
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke">
|
||||||
use cssparser::Color as CSSParserColor;
|
|
||||||
use properties::longhands::{_webkit_text_stroke_color, _webkit_text_stroke_width};
|
use properties::longhands::{_webkit_text_stroke_color, _webkit_text_stroke_width};
|
||||||
use values::specified::CSSColor;
|
|
||||||
|
|
||||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
use values::specified::{BorderWidth, Length};
|
|
||||||
|
|
||||||
let mut color = None;
|
let mut color = None;
|
||||||
let mut width = None;
|
let mut width = None;
|
||||||
loop {
|
loop {
|
||||||
|
@ -96,9 +88,8 @@
|
||||||
|
|
||||||
if color.is_some() || width.is_some() {
|
if color.is_some() || width.is_some() {
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
_webkit_text_stroke_color: color.or(Some(CSSColor { parsed: CSSParserColor::CurrentColor,
|
_webkit_text_stroke_color: unwrap_or_initial!(_webkit_text_stroke_color, color),
|
||||||
authored: None })),
|
_webkit_text_stroke_width: unwrap_or_initial!(_webkit_text_stroke_width, width),
|
||||||
_webkit_text_stroke_width: width.or(Some(BorderWidth::from_length(Length::zero()))),
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(())
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let position = unwrap_or_initial!(list_style_position, position);
|
||||||
|
|
||||||
// If there are two `none`s, then we can't have a type or image; if there is one `none`,
|
// If there are two `none`s, then we can't have a type or image; if there is one `none`,
|
||||||
// then we can't have both a type *and* an image; if there is no `none` then we're fine as
|
// then we can't have both a type *and* an image; if there is no `none` then we're fine as
|
||||||
// long as we parsed something.
|
// long as we parsed something.
|
||||||
|
@ -58,36 +60,36 @@
|
||||||
(true, 2, None, None) => {
|
(true, 2, None, None) => {
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
list_style_position: position,
|
list_style_position: position,
|
||||||
list_style_image: Some(Either::Second(None_)),
|
list_style_image: Either::Second(None_),
|
||||||
list_style_type: Some(list_style_type::SpecifiedValue::none),
|
list_style_type: list_style_type::SpecifiedValue::none,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(true, 1, None, Some(image)) => {
|
(true, 1, None, Some(image)) => {
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
list_style_position: position,
|
list_style_position: position,
|
||||||
list_style_image: Some(image),
|
list_style_image: image,
|
||||||
list_style_type: Some(list_style_type::SpecifiedValue::none),
|
list_style_type: list_style_type::SpecifiedValue::none,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(true, 1, Some(list_style_type), None) => {
|
(true, 1, Some(list_style_type), None) => {
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
list_style_position: position,
|
list_style_position: position,
|
||||||
list_style_image: Some(Either::Second(None_)),
|
list_style_image: Either::Second(None_),
|
||||||
list_style_type: Some(list_style_type),
|
list_style_type: list_style_type,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(true, 1, None, None) => {
|
(true, 1, None, None) => {
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
list_style_position: position,
|
list_style_position: position,
|
||||||
list_style_image: Some(Either::Second(None_)),
|
list_style_image: Either::Second(None_),
|
||||||
list_style_type: Some(list_style_type::SpecifiedValue::none),
|
list_style_type: list_style_type::SpecifiedValue::none,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(true, 0, list_style_type, image) => {
|
(true, 0, list_style_type, image) => {
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
list_style_position: position,
|
list_style_position: position,
|
||||||
list_style_image: image,
|
list_style_image: unwrap_or_initial!(list_style_image, image),
|
||||||
list_style_type: list_style_type,
|
list_style_type: unwrap_or_initial!(list_style_type),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
% 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():
|
||||||
mask_${name}: Some(mask_${name}),
|
mask_${name}: mask_${name},
|
||||||
% endfor
|
% endfor
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -263,8 +263,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
mask_position_x: Some(position_x),
|
mask_position_x: position_x,
|
||||||
mask_position_y: Some(position_y),
|
mask_position_y: position_y,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<%helpers:shorthand name="outline" sub_properties="outline-color outline-style outline-width"
|
<%helpers:shorthand name="outline" sub_properties="outline-color outline-style outline-width"
|
||||||
spec="https://drafts.csswg.org/css-ui/#propdef-outline">
|
spec="https://drafts.csswg.org/css-ui/#propdef-outline">
|
||||||
use properties::longhands::{outline_width, outline_style};
|
use properties::longhands::{outline_color, outline_width, outline_style};
|
||||||
use values::specified;
|
use values::specified;
|
||||||
use parser::Parse;
|
use parser::Parse;
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@
|
||||||
}
|
}
|
||||||
if any {
|
if any {
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
outline_color: color,
|
outline_color: unwrap_or_initial!(outline_color, color),
|
||||||
outline_style: style,
|
outline_style: unwrap_or_initial!(outline_style, style),
|
||||||
outline_width: width,
|
outline_width: unwrap_or_initial!(outline_width, width),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(())
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
flex_direction: direction,
|
flex_direction: unwrap_or_initial!(flex_direction, direction),
|
||||||
flex_wrap: wrap,
|
flex_wrap: unwrap_or_initial!(flex_wrap, wrap),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@
|
||||||
|
|
||||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||||
return Ok(Longhands {
|
return Ok(Longhands {
|
||||||
flex_grow: Some(Number(0.0)),
|
flex_grow: Number(0.0),
|
||||||
flex_shrink: Some(Number(0.0)),
|
flex_shrink: Number(0.0),
|
||||||
flex_basis: Some(LengthOrPercentageOrAutoOrContent::Auto)
|
flex_basis: LengthOrPercentageOrAutoOrContent::Auto
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
loop {
|
loop {
|
||||||
|
@ -99,9 +99,9 @@
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
flex_grow: grow.or(Some(Number(1.0))),
|
flex_grow: grow.unwrap_or(Number(1.0)),
|
||||||
flex_shrink: shrink.or(Some(Number(1.0))),
|
flex_shrink: shrink.unwrap_or(Number(1.0)),
|
||||||
flex_basis: basis.or(Some(LengthOrPercentageOrAutoOrContent::Length(NoCalcLength::zero())))
|
flex_basis: basis.unwrap_or(LengthOrPercentageOrAutoOrContent::Length(NoCalcLength::zero()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration">
|
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration">
|
||||||
use cssparser::Color as CSSParserColor;
|
use cssparser::Color as CSSParserColor;
|
||||||
use properties::longhands::{text_decoration_color, text_decoration_line, text_decoration_style};
|
use properties::longhands::{text_decoration_color, text_decoration_line, text_decoration_style};
|
||||||
use values::specified::CSSColor;
|
|
||||||
|
|
||||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
let (mut color, mut line, mut style, mut any) = (None, None, None, false);
|
let (mut color, mut line, mut style, mut any) = (None, None, None, false);
|
||||||
|
@ -41,10 +40,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Longhands {
|
Ok(Longhands {
|
||||||
text_decoration_color: color.or(Some(CSSColor { parsed: CSSParserColor::CurrentColor,
|
text_decoration_color: unwrap_or_initial!(text_decoration_color, color),
|
||||||
authored: None })),
|
text_decoration_line: unwrap_or_initial!(text_decoration_line, line),
|
||||||
text_decoration_line: line.or(Some(text_decoration_line::computed_value::none)),
|
text_decoration_style: unwrap_or_initial!(text_decoration_style, style),
|
||||||
text_decoration_style: style.or(Some(text_decoration_style::computed_value::T::solid)),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,15 @@ fn background_shorthand_should_parse_all_available_properties_when_specified() {
|
||||||
content-box red");
|
content-box red");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
assert_eq!(result.background_image, parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
||||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "center"));
|
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "center"));
|
||||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "top"));
|
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "top"));
|
||||||
assert_eq!(result.background_size.unwrap(), parse_longhand!(background_size, "200px 200px"));
|
assert_eq!(result.background_size, parse_longhand!(background_size, "200px 200px"));
|
||||||
assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "repeat-x"));
|
assert_eq!(result.background_repeat, parse_longhand!(background_repeat, "repeat-x"));
|
||||||
assert_eq!(result.background_attachment.unwrap(), parse_longhand!(background_attachment, "fixed"));
|
assert_eq!(result.background_attachment, parse_longhand!(background_attachment, "fixed"));
|
||||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "content-box"));
|
assert_eq!(result.background_clip, parse_longhand!(background_clip, "content-box"));
|
||||||
assert_eq!(result.background_color.unwrap(), parse_longhand!(background_color, "red"));
|
assert_eq!(result.background_color, parse_longhand!(background_color, "red"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -38,27 +38,27 @@ fn background_shorthand_should_parse_when_some_fields_set() {
|
||||||
let mut parser = Parser::new("14px 40px repeat-y");
|
let mut parser = Parser::new("14px 40px repeat-y");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "14px"));
|
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "14px"));
|
||||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "40px"));
|
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "40px"));
|
||||||
assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "repeat-y"));
|
assert_eq!(result.background_repeat, parse_longhand!(background_repeat, "repeat-y"));
|
||||||
|
|
||||||
let mut parser = Parser::new("url(\"http://servo/test.png\") repeat blue");
|
let mut parser = Parser::new("url(\"http://servo/test.png\") repeat blue");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
assert_eq!(result.background_image, parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
||||||
assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "repeat"));
|
assert_eq!(result.background_repeat, parse_longhand!(background_repeat, "repeat"));
|
||||||
assert_eq!(result.background_color.unwrap(), parse_longhand!(background_color, "blue"));
|
assert_eq!(result.background_color, parse_longhand!(background_color, "blue"));
|
||||||
|
|
||||||
let mut parser = Parser::new("padding-box");
|
let mut parser = Parser::new("padding-box");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "padding-box"));
|
assert_eq!(result.background_clip, parse_longhand!(background_clip, "padding-box"));
|
||||||
|
|
||||||
let mut parser = Parser::new("url(\"http://servo/test.png\")");
|
let mut parser = Parser::new("url(\"http://servo/test.png\")");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
assert_eq!(result.background_image, parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -69,17 +69,17 @@ fn background_shorthand_should_parse_comma_separated_declarations() {
|
||||||
center / 100% 100% no-repeat, white");
|
center / 100% 100% no-repeat, white");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\"), \
|
assert_eq!(result.background_image, parse_longhand!(background_image, "url(\"http://servo/test.png\"), \
|
||||||
url(\"http://servo/test.png\"), none"));
|
url(\"http://servo/test.png\"), none"));
|
||||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "left, center, 0%"));
|
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "left, center, 0%"));
|
||||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "top, center, 0%"));
|
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "top, center, 0%"));
|
||||||
assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "no-repeat, no-repeat, repeat"));
|
assert_eq!(result.background_repeat, parse_longhand!(background_repeat, "no-repeat, no-repeat, repeat"));
|
||||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "border-box, border-box, border-box"));
|
assert_eq!(result.background_clip, parse_longhand!(background_clip, "border-box, border-box, border-box"));
|
||||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box, padding-box, \
|
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box, padding-box, \
|
||||||
padding-box"));
|
padding-box"));
|
||||||
assert_eq!(result.background_size.unwrap(), parse_longhand!(background_size, "auto auto, 100% 100%, auto auto"));
|
assert_eq!(result.background_size, parse_longhand!(background_size, "auto auto, 100% 100%, auto auto"));
|
||||||
assert_eq!(result.background_attachment.unwrap(), parse_longhand!(background_attachment, "scroll, scroll, scroll"));
|
assert_eq!(result.background_attachment, parse_longhand!(background_attachment, "scroll, scroll, scroll"));
|
||||||
assert_eq!(result.background_color.unwrap(), parse_longhand!(background_color, "white"));
|
assert_eq!(result.background_color, parse_longhand!(background_color, "white"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -89,15 +89,15 @@ fn background_shorthand_should_parse_position_and_size_correctly() {
|
||||||
let mut parser = Parser::new("7px 4px");
|
let mut parser = Parser::new("7px 4px");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "7px"));
|
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "7px"));
|
||||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "4px"));
|
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "4px"));
|
||||||
|
|
||||||
let mut parser = Parser::new("7px 4px / 30px 20px");
|
let mut parser = Parser::new("7px 4px / 30px 20px");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "7px"));
|
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "7px"));
|
||||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "4px"));
|
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "4px"));
|
||||||
assert_eq!(result.background_size.unwrap(), parse_longhand!(background_size, "30px 20px"));
|
assert_eq!(result.background_size, parse_longhand!(background_size, "30px 20px"));
|
||||||
|
|
||||||
let mut parser = Parser::new("/ 30px 20px");
|
let mut parser = Parser::new("/ 30px 20px");
|
||||||
assert!(background::parse_value(&context, &mut parser).is_err());
|
assert!(background::parse_value(&context, &mut parser).is_err());
|
||||||
|
@ -113,18 +113,18 @@ fn background_shorthand_should_parse_origin_and_clip_correctly() {
|
||||||
let mut parser = Parser::new("padding-box content-box");
|
let mut parser = Parser::new("padding-box content-box");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "content-box"));
|
assert_eq!(result.background_clip, parse_longhand!(background_clip, "content-box"));
|
||||||
|
|
||||||
let mut parser = Parser::new("padding-box padding-box");
|
let mut parser = Parser::new("padding-box padding-box");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "padding-box"));
|
assert_eq!(result.background_clip, parse_longhand!(background_clip, "padding-box"));
|
||||||
|
|
||||||
let mut parser = Parser::new("padding-box");
|
let mut parser = Parser::new("padding-box");
|
||||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "padding-box"));
|
assert_eq!(result.background_clip, parse_longhand!(background_clip, "padding-box"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ fn border_image_shorthand_should_parse_when_all_properties_specified() {
|
||||||
round stretch");
|
round stretch");
|
||||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.border_image_source.unwrap(),
|
assert_eq!(result.border_image_source,
|
||||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||||
assert_eq!(result.border_image_slice.unwrap(), parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
assert_eq!(result.border_image_slice, parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||||
assert_eq!(result.border_image_width.unwrap(), parse_longhand!(border_image_width, "20px 40px"));
|
assert_eq!(result.border_image_width, parse_longhand!(border_image_width, "20px 40px"));
|
||||||
assert_eq!(result.border_image_outset.unwrap(), parse_longhand!(border_image_outset, "10px"));
|
assert_eq!(result.border_image_outset, parse_longhand!(border_image_outset, "10px"));
|
||||||
assert_eq!(result.border_image_repeat.unwrap(), parse_longhand!(border_image_repeat, "round stretch"));
|
assert_eq!(result.border_image_repeat, parse_longhand!(border_image_repeat, "round stretch"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -35,12 +35,12 @@ fn border_image_shorthand_should_parse_without_width() {
|
||||||
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / / 10px round stretch");
|
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / / 10px round stretch");
|
||||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.border_image_source.unwrap(),
|
assert_eq!(result.border_image_source,
|
||||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||||
assert_eq!(result.border_image_slice.unwrap(), parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
assert_eq!(result.border_image_slice, parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||||
assert_eq!(result.border_image_outset.unwrap(), parse_longhand!(border_image_outset, "10px"));
|
assert_eq!(result.border_image_outset, parse_longhand!(border_image_outset, "10px"));
|
||||||
assert_eq!(result.border_image_repeat.unwrap(), parse_longhand!(border_image_repeat, "round stretch"));
|
assert_eq!(result.border_image_repeat, parse_longhand!(border_image_repeat, "round stretch"));
|
||||||
assert_eq!(result.border_image_width.unwrap(), border_image_width::get_initial_specified_value());
|
assert_eq!(result.border_image_width, border_image_width::get_initial_specified_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -50,12 +50,12 @@ fn border_image_shorthand_should_parse_without_outset() {
|
||||||
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / 20px 40px round");
|
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / 20px 40px round");
|
||||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.border_image_source.unwrap(),
|
assert_eq!(result.border_image_source,
|
||||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||||
assert_eq!(result.border_image_slice.unwrap(), parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
assert_eq!(result.border_image_slice, parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||||
assert_eq!(result.border_image_width.unwrap(), parse_longhand!(border_image_width, "20px 40px"));
|
assert_eq!(result.border_image_width, parse_longhand!(border_image_width, "20px 40px"));
|
||||||
assert_eq!(result.border_image_repeat.unwrap(), parse_longhand!(border_image_repeat, "round"));
|
assert_eq!(result.border_image_repeat, parse_longhand!(border_image_repeat, "round"));
|
||||||
assert_eq!(result.border_image_outset.unwrap(), border_image_outset::get_initial_specified_value());
|
assert_eq!(result.border_image_outset, border_image_outset::get_initial_specified_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -65,12 +65,12 @@ fn border_image_shorthand_should_parse_without_width_or_outset() {
|
||||||
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill round");
|
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill round");
|
||||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.border_image_source.unwrap(),
|
assert_eq!(result.border_image_source,
|
||||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||||
assert_eq!(result.border_image_slice.unwrap(), parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
assert_eq!(result.border_image_slice, parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||||
assert_eq!(result.border_image_repeat.unwrap(), parse_longhand!(border_image_repeat, "round"));
|
assert_eq!(result.border_image_repeat, parse_longhand!(border_image_repeat, "round"));
|
||||||
assert_eq!(result.border_image_width.unwrap(), border_image_width::get_initial_specified_value());
|
assert_eq!(result.border_image_width, border_image_width::get_initial_specified_value());
|
||||||
assert_eq!(result.border_image_outset.unwrap(), border_image_outset::get_initial_specified_value());
|
assert_eq!(result.border_image_outset, border_image_outset::get_initial_specified_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -80,12 +80,12 @@ fn border_image_shorthand_should_parse_with_just_source() {
|
||||||
let mut parser = Parser::new("linear-gradient(red, blue)");
|
let mut parser = Parser::new("linear-gradient(red, blue)");
|
||||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.border_image_source.unwrap(),
|
assert_eq!(result.border_image_source,
|
||||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||||
assert_eq!(result.border_image_slice.unwrap(), border_image_slice::get_initial_specified_value());
|
assert_eq!(result.border_image_slice, border_image_slice::get_initial_specified_value());
|
||||||
assert_eq!(result.border_image_width.unwrap(), border_image_width::get_initial_specified_value());
|
assert_eq!(result.border_image_width, border_image_width::get_initial_specified_value());
|
||||||
assert_eq!(result.border_image_outset.unwrap(), border_image_outset::get_initial_specified_value());
|
assert_eq!(result.border_image_outset, border_image_outset::get_initial_specified_value());
|
||||||
assert_eq!(result.border_image_repeat.unwrap(), border_image_repeat::get_initial_specified_value());
|
assert_eq!(result.border_image_repeat, border_image_repeat::get_initial_specified_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -115,14 +115,14 @@ fn webkit_text_stroke_shorthand_should_parse_properly() {
|
||||||
|
|
||||||
let mut parser = Parser::new("thin red");
|
let mut parser = Parser::new("thin red");
|
||||||
let result = _webkit_text_stroke::parse_value(&context, &mut parser).unwrap();
|
let result = _webkit_text_stroke::parse_value(&context, &mut parser).unwrap();
|
||||||
assert_eq!(result._webkit_text_stroke_color.unwrap(), parse_longhand!(_webkit_text_stroke_color, "red"));
|
assert_eq!(result._webkit_text_stroke_color, parse_longhand!(_webkit_text_stroke_color, "red"));
|
||||||
assert_eq!(result._webkit_text_stroke_width.unwrap(), parse_longhand!(_webkit_text_stroke_width, "thin"));
|
assert_eq!(result._webkit_text_stroke_width, parse_longhand!(_webkit_text_stroke_width, "thin"));
|
||||||
|
|
||||||
// ensure its no longer sensitive to order
|
// ensure its no longer sensitive to order
|
||||||
let mut parser = Parser::new("red thin");
|
let mut parser = Parser::new("red thin");
|
||||||
let result = _webkit_text_stroke::parse_value(&context, &mut parser).unwrap();
|
let result = _webkit_text_stroke::parse_value(&context, &mut parser).unwrap();
|
||||||
assert_eq!(result._webkit_text_stroke_color.unwrap(), parse_longhand!(_webkit_text_stroke_color, "red"));
|
assert_eq!(result._webkit_text_stroke_color, parse_longhand!(_webkit_text_stroke_color, "red"));
|
||||||
assert_eq!(result._webkit_text_stroke_width.unwrap(), parse_longhand!(_webkit_text_stroke_width, "thin"));
|
assert_eq!(result._webkit_text_stroke_width, parse_longhand!(_webkit_text_stroke_width, "thin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -19,15 +19,15 @@ fn mask_shorthand_should_parse_all_available_properties_when_specified() {
|
||||||
repeat-x padding-box border-box subtract");
|
repeat-x padding-box border-box subtract");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_image.unwrap(), parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
assert_eq!(result.mask_image, parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
||||||
assert_eq!(result.mask_mode.unwrap(), parse_longhand!(mask_mode, "luminance"));
|
assert_eq!(result.mask_mode, parse_longhand!(mask_mode, "luminance"));
|
||||||
assert_eq!(result.mask_position_x.unwrap(), parse_longhand!(mask_position_x, "7px"));
|
assert_eq!(result.mask_position_x, parse_longhand!(mask_position_x, "7px"));
|
||||||
assert_eq!(result.mask_position_y.unwrap(), parse_longhand!(mask_position_y, "4px"));
|
assert_eq!(result.mask_position_y, parse_longhand!(mask_position_y, "4px"));
|
||||||
assert_eq!(result.mask_size.unwrap(), parse_longhand!(mask_size, "70px 50px"));
|
assert_eq!(result.mask_size, parse_longhand!(mask_size, "70px 50px"));
|
||||||
assert_eq!(result.mask_repeat.unwrap(), parse_longhand!(mask_repeat, "repeat-x"));
|
assert_eq!(result.mask_repeat, parse_longhand!(mask_repeat, "repeat-x"));
|
||||||
assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box"));
|
assert_eq!(result.mask_origin, parse_longhand!(mask_origin, "padding-box"));
|
||||||
assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "border-box"));
|
assert_eq!(result.mask_clip, parse_longhand!(mask_clip, "border-box"));
|
||||||
assert_eq!(result.mask_composite.unwrap(), parse_longhand!(mask_composite, "subtract"));
|
assert_eq!(result.mask_composite, parse_longhand!(mask_composite, "subtract"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -37,26 +37,26 @@ fn mask_shorthand_should_parse_when_some_fields_set() {
|
||||||
let mut parser = Parser::new("14px 40px repeat-y");
|
let mut parser = Parser::new("14px 40px repeat-y");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_position_x.unwrap(), parse_longhand!(mask_position_x, "14px"));
|
assert_eq!(result.mask_position_x, parse_longhand!(mask_position_x, "14px"));
|
||||||
assert_eq!(result.mask_position_y.unwrap(), parse_longhand!(mask_position_y, "40px"));
|
assert_eq!(result.mask_position_y, parse_longhand!(mask_position_y, "40px"));
|
||||||
assert_eq!(result.mask_repeat.unwrap(), parse_longhand!(mask_repeat, "repeat-y"));
|
assert_eq!(result.mask_repeat, parse_longhand!(mask_repeat, "repeat-y"));
|
||||||
|
|
||||||
let mut parser = Parser::new("url(\"http://servo/test.png\") repeat add");
|
let mut parser = Parser::new("url(\"http://servo/test.png\") repeat add");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_image.unwrap(), parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
assert_eq!(result.mask_image, parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
||||||
assert_eq!(result.mask_repeat.unwrap(), parse_longhand!(mask_repeat, "repeat"));
|
assert_eq!(result.mask_repeat, parse_longhand!(mask_repeat, "repeat"));
|
||||||
assert_eq!(result.mask_composite.unwrap(), parse_longhand!(mask_composite, "add"));
|
assert_eq!(result.mask_composite, parse_longhand!(mask_composite, "add"));
|
||||||
|
|
||||||
let mut parser = Parser::new("intersect");
|
let mut parser = Parser::new("intersect");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_composite.unwrap(), parse_longhand!(mask_composite, "intersect"));
|
assert_eq!(result.mask_composite, parse_longhand!(mask_composite, "intersect"));
|
||||||
|
|
||||||
let mut parser = Parser::new("url(\"http://servo/test.png\")");
|
let mut parser = Parser::new("url(\"http://servo/test.png\")");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_image.unwrap(), parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
assert_eq!(result.mask_image, parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -66,15 +66,15 @@ fn mask_shorthand_should_parse_position_and_size_correctly() {
|
||||||
let mut parser = Parser::new("7px 4px");
|
let mut parser = Parser::new("7px 4px");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_position_x.unwrap(), parse_longhand!(mask_position_x, "7px"));
|
assert_eq!(result.mask_position_x, parse_longhand!(mask_position_x, "7px"));
|
||||||
assert_eq!(result.mask_position_y.unwrap(), parse_longhand!(mask_position_y, "4px"));
|
assert_eq!(result.mask_position_y, parse_longhand!(mask_position_y, "4px"));
|
||||||
|
|
||||||
let mut parser = Parser::new("7px 4px / 30px 20px");
|
let mut parser = Parser::new("7px 4px / 30px 20px");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_position_x.unwrap(), parse_longhand!(mask_position_x, "7px"));
|
assert_eq!(result.mask_position_x, parse_longhand!(mask_position_x, "7px"));
|
||||||
assert_eq!(result.mask_position_y.unwrap(), parse_longhand!(mask_position_y, "4px"));
|
assert_eq!(result.mask_position_y, parse_longhand!(mask_position_y, "4px"));
|
||||||
assert_eq!(result.mask_size.unwrap(), parse_longhand!(mask_size, "30px 20px"));
|
assert_eq!(result.mask_size, parse_longhand!(mask_size, "30px 20px"));
|
||||||
|
|
||||||
let mut parser = Parser::new("/ 30px 20px");
|
let mut parser = Parser::new("/ 30px 20px");
|
||||||
assert!(mask::parse_value(&context, &mut parser).is_err());
|
assert!(mask::parse_value(&context, &mut parser).is_err());
|
||||||
|
@ -90,20 +90,20 @@ fn mask_shorthand_should_parse_origin_and_clip_correctly() {
|
||||||
let mut parser = Parser::new("padding-box content-box");
|
let mut parser = Parser::new("padding-box content-box");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box"));
|
assert_eq!(result.mask_origin, parse_longhand!(mask_origin, "padding-box"));
|
||||||
assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "content-box"));
|
assert_eq!(result.mask_clip, parse_longhand!(mask_clip, "content-box"));
|
||||||
|
|
||||||
let mut parser = Parser::new("padding-box padding-box");
|
let mut parser = Parser::new("padding-box padding-box");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box"));
|
assert_eq!(result.mask_origin, parse_longhand!(mask_origin, "padding-box"));
|
||||||
assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "padding-box"));
|
assert_eq!(result.mask_clip, parse_longhand!(mask_clip, "padding-box"));
|
||||||
|
|
||||||
let mut parser = Parser::new("padding-box");
|
let mut parser = Parser::new("padding-box");
|
||||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||||
|
|
||||||
assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box"));
|
assert_eq!(result.mask_origin, parse_longhand!(mask_origin, "padding-box"));
|
||||||
assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "padding-box"));
|
assert_eq!(result.mask_clip, parse_longhand!(mask_clip, "padding-box"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue