mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #14410 - canaltinova:stylo-things, r=Manishearth
Implement 3 more properties for stylo <!-- Please describe your changes on the following line: --> Implemented these new properties: 1. Implemented parsing/serialization and stylo glue for `background-blend-mode`. 2. Made `align-items` work for stylo. 3. Implemented parsing/serialization for `-moz-column-rule`. --- <!-- 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] These changes do not require tests because it's stylo changes. <!-- 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/14410) <!-- Reviewable:end -->
This commit is contained in:
commit
b3cdcfaa39
6 changed files with 118 additions and 7 deletions
|
@ -1571,7 +1571,8 @@ fn static_assert() {
|
||||||
<% skip_background_longhands = """background-repeat
|
<% skip_background_longhands = """background-repeat
|
||||||
background-image background-clip
|
background-image background-clip
|
||||||
background-origin background-attachment
|
background-origin background-attachment
|
||||||
background-size background-position""" %>
|
background-size background-position
|
||||||
|
background-blend-mode""" %>
|
||||||
<%self:impl_trait style_struct_name="Background"
|
<%self:impl_trait style_struct_name="Background"
|
||||||
skip_longhands="${skip_background_longhands}"
|
skip_longhands="${skip_background_longhands}"
|
||||||
skip_additionals="*">
|
skip_additionals="*">
|
||||||
|
@ -1586,6 +1587,29 @@ fn static_assert() {
|
||||||
T::local => structs::NS_STYLE_IMAGELAYER_ATTACHMENT_LOCAL as u8,
|
T::local => structs::NS_STYLE_IMAGELAYER_ATTACHMENT_LOCAL as u8,
|
||||||
}
|
}
|
||||||
</%self:simple_image_array_property>
|
</%self:simple_image_array_property>
|
||||||
|
|
||||||
|
<%self:simple_image_array_property name="blend_mode" shorthand="background" field_name="mBlendMode">
|
||||||
|
use properties::longhands::background_blend_mode::single_value::computed_value::T;
|
||||||
|
|
||||||
|
match servo {
|
||||||
|
T::normal => structs::NS_STYLE_BLEND_NORMAL as u8,
|
||||||
|
T::multiply => structs::NS_STYLE_BLEND_MULTIPLY as u8,
|
||||||
|
T::screen => structs::NS_STYLE_BLEND_SCREEN as u8,
|
||||||
|
T::overlay => structs::NS_STYLE_BLEND_OVERLAY as u8,
|
||||||
|
T::darken => structs::NS_STYLE_BLEND_DARKEN as u8,
|
||||||
|
T::lighten => structs::NS_STYLE_BLEND_LIGHTEN as u8,
|
||||||
|
T::color_dodge => structs::NS_STYLE_BLEND_COLOR_DODGE as u8,
|
||||||
|
T::color_burn => structs::NS_STYLE_BLEND_COLOR_BURN as u8,
|
||||||
|
T::hard_light => structs::NS_STYLE_BLEND_HARD_LIGHT as u8,
|
||||||
|
T::soft_light => structs::NS_STYLE_BLEND_SOFT_LIGHT as u8,
|
||||||
|
T::difference => structs::NS_STYLE_BLEND_DIFFERENCE as u8,
|
||||||
|
T::exclusion => structs::NS_STYLE_BLEND_EXCLUSION as u8,
|
||||||
|
T::hue => structs::NS_STYLE_BLEND_HUE as u8,
|
||||||
|
T::saturation => structs::NS_STYLE_BLEND_SATURATION as u8,
|
||||||
|
T::color => structs::NS_STYLE_BLEND_COLOR as u8,
|
||||||
|
T::luminosity => structs::NS_STYLE_BLEND_LUMINOSITY as u8,
|
||||||
|
}
|
||||||
|
</%self:simple_image_array_property>
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<%self:impl_trait style_struct_name="List"
|
<%self:impl_trait style_struct_name="List"
|
||||||
|
|
|
@ -339,3 +339,10 @@ ${helpers.single_keyword("background-origin",
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
</%helpers:vector_longhand>
|
</%helpers:vector_longhand>
|
||||||
|
|
||||||
|
// https://drafts.fxtf.org/compositing/#background-blend-mode
|
||||||
|
${helpers.single_keyword("background-blend-mode",
|
||||||
|
"""normal multiply screen overlay darken lighten color-dodge
|
||||||
|
color-burn hard-light soft-light difference exclusion hue
|
||||||
|
saturation color luminosity""",
|
||||||
|
vector="true", products="gecko", animatable=False)}
|
||||||
|
|
|
@ -273,6 +273,11 @@ ${helpers.single_keyword("column-fill", "auto balance",
|
||||||
Au::from_px(3) // medium
|
Au::from_px(3) // medium
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||||
|
BorderWidth::Medium
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||||
BorderWidth::parse(context, input)
|
BorderWidth::parse(context, input)
|
||||||
}
|
}
|
||||||
|
@ -289,8 +294,9 @@ ${helpers.predefined_type("-moz-column-rule-color", "CSSColor",
|
||||||
${helpers.single_keyword("column-span", "none all",
|
${helpers.single_keyword("column-span", "none all",
|
||||||
products="none", animatable=False)}
|
products="none", animatable=False)}
|
||||||
|
|
||||||
${helpers.single_keyword("column-rule-style",
|
${helpers.single_keyword("-moz-column-rule-style",
|
||||||
"none hidden dotted dashed solid double groove ridge inset outset",
|
"none hidden dotted dashed solid double groove ridge inset outset",
|
||||||
products="gecko",
|
products="gecko",
|
||||||
|
gecko_ffi_name="mColumnRuleStyle",
|
||||||
gecko_constant_prefix="NS_STYLE_BORDER_STYLE",
|
gecko_constant_prefix="NS_STYLE_BORDER_STYLE",
|
||||||
animatable=False)}
|
animatable=False)}
|
||||||
|
|
|
@ -86,13 +86,13 @@ ${helpers.single_keyword("justify-content", "flex-start flex-end center space-be
|
||||||
products="servo",
|
products="servo",
|
||||||
animatable=False)}
|
animatable=False)}
|
||||||
|
|
||||||
// FIXME(heycam): Disable align-items in geckolib since we don't support the Gecko initial value
|
// https://drafts.csswg.org/css-flexbox/#propdef-align-items
|
||||||
// 'normal' yet.
|
// FIXME: This is a workaround for 'normal' value. We don't support the Gecko initial value 'normal' yet.
|
||||||
${helpers.single_keyword("align-items", "stretch flex-start flex-end center baseline",
|
${helpers.single_keyword("align-items", "stretch flex-start flex-end center baseline" if product == "servo"
|
||||||
|
else "normal stretch flex-start flex-end center baseline",
|
||||||
need_clone=True,
|
need_clone=True,
|
||||||
gecko_constant_prefix="NS_STYLE_ALIGN",
|
gecko_constant_prefix="NS_STYLE_ALIGN",
|
||||||
animatable=False,
|
animatable=False)}
|
||||||
products="servo")}
|
|
||||||
|
|
||||||
${helpers.single_keyword("align-content", "stretch flex-start flex-end center space-between space-around",
|
${helpers.single_keyword("align-content", "stretch flex-start flex-end center space-between space-around",
|
||||||
gecko_constant_prefix="NS_STYLE_ALIGN",
|
gecko_constant_prefix="NS_STYLE_ALIGN",
|
||||||
|
@ -110,8 +110,11 @@ ${helpers.predefined_type("flex-shrink", "Number",
|
||||||
needs_context=False,
|
needs_context=False,
|
||||||
animatable=True)}
|
animatable=True)}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-align/#align-self-property
|
||||||
|
// FIXME: We don't support the Gecko value 'normal' yet.
|
||||||
${helpers.single_keyword("align-self", "auto stretch flex-start flex-end center baseline",
|
${helpers.single_keyword("align-self", "auto stretch flex-start flex-end center baseline",
|
||||||
need_clone=True,
|
need_clone=True,
|
||||||
|
extra_gecko_values="normal",
|
||||||
gecko_constant_prefix="NS_STYLE_ALIGN",
|
gecko_constant_prefix="NS_STYLE_ALIGN",
|
||||||
animatable=False)}
|
animatable=False)}
|
||||||
|
|
||||||
|
|
|
@ -1687,6 +1687,9 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
||||||
align_items::flex_start => align_self::flex_start,
|
align_items::flex_start => align_self::flex_start,
|
||||||
align_items::flex_end => align_self::flex_end,
|
align_items::flex_end => align_self::flex_end,
|
||||||
align_items::center => align_self::center,
|
align_items::center => align_self::center,
|
||||||
|
% if product == "gecko":
|
||||||
|
align_items::normal => align_self::normal,
|
||||||
|
% endif
|
||||||
};
|
};
|
||||||
style.mutate_position().set_align_self(self_align);
|
style.mutate_position().set_align_self(self_align);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,3 +57,71 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</%helpers:shorthand>
|
</%helpers:shorthand>
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-multicol/#column-rule
|
||||||
|
<%helpers:shorthand name="-moz-column-rule" products="gecko"
|
||||||
|
sub_properties="-moz-column-rule-width -moz-column-rule-style -moz-column-rule-color">
|
||||||
|
use properties::longhands::{_moz_column_rule_width, _moz_column_rule_style};
|
||||||
|
use properties::longhands::_moz_column_rule_color;
|
||||||
|
|
||||||
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
|
% for name in "width style color".split():
|
||||||
|
let mut column_rule_${name} = None;
|
||||||
|
% endfor
|
||||||
|
let mut any = false;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
% for name in "width style color".split():
|
||||||
|
if column_rule_${name}.is_none() {
|
||||||
|
if let Ok(value) = input.try(|input|
|
||||||
|
_moz_column_rule_${name}::parse(context, input)) {
|
||||||
|
column_rule_${name} = Some(value);
|
||||||
|
any = true;
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
% endfor
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if any {
|
||||||
|
Ok(Longhands {
|
||||||
|
% for name in "width style".split():
|
||||||
|
_moz_column_rule_${name}: column_rule_${name}
|
||||||
|
.or(Some(_moz_column_rule_${name}::get_initial_specified_value())),
|
||||||
|
% endfor
|
||||||
|
_moz_column_rule_color: column_rule_color,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> LonghandsToSerialize<'a> {
|
||||||
|
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
let mut need_space = false;
|
||||||
|
try!(self._moz_column_rule_width.to_css(dest));
|
||||||
|
|
||||||
|
if let DeclaredValue::Value(ref width) = *self._moz_column_rule_width {
|
||||||
|
try!(width.to_css(dest));
|
||||||
|
need_space = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let DeclaredValue::Value(ref style) = *self._moz_column_rule_style {
|
||||||
|
if need_space {
|
||||||
|
try!(write!(dest, " "));
|
||||||
|
}
|
||||||
|
try!(style.to_css(dest));
|
||||||
|
need_space = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let DeclaredValue::Value(ref color) = *self._moz_column_rule_color {
|
||||||
|
if need_space {
|
||||||
|
try!(write!(dest, " "));
|
||||||
|
}
|
||||||
|
try!(color.to_css(dest));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%helpers:shorthand>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue