Skip to content

Commit

Permalink
style: Add internal overflow-clip-box-block/-inline properties and ma…
Browse files Browse the repository at this point in the history
…ke overflow-clip-box a shorthand.

Bug: 1422839
Reviewed-by: emilio
  • Loading branch information
Mats Palmgren authored and emilio committed Dec 5, 2017
1 parent b56d7b8 commit cdf7ae5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/style/properties/longhand/box.mako.rs
Expand Up @@ -373,9 +373,18 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box",
spec="Internal, not web-exposed, \
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")}

${helpers.single_keyword("overflow-clip-box", "padding-box content-box",
${helpers.single_keyword("overflow-clip-box-block", "padding-box content-box",
products="gecko", animation_value_type="discrete", enabled_in="ua",
gecko_pref="layout.css.overflow-clip-box.enabled",
gecko_constant_prefix="NS_STYLE_OVERFLOW_CLIP_BOX",
flags="APPLIES_TO_PLACEHOLDER",
spec="Internal, not web-exposed, \
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")}

${helpers.single_keyword("overflow-clip-box-inline", "padding-box content-box",
products="gecko", animation_value_type="discrete", enabled_in="ua",
gecko_pref="layout.css.overflow-clip-box.enabled",
gecko_constant_prefix="NS_STYLE_OVERFLOW_CLIP_BOX",
flags="APPLIES_TO_PLACEHOLDER",
spec="Internal, not web-exposed, \
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")}
Expand Down
42 changes: 42 additions & 0 deletions components/style/properties/shorthand/box.mako.rs
Expand Up @@ -58,6 +58,48 @@
}
</%helpers:shorthand>

<%helpers:shorthand name="overflow-clip-box" sub_properties="overflow-clip-box-block overflow-clip-box-inline"
enabled_in="ua" gecko_pref="layout.css.overflow-clip-box.enabled"
spec="Internal, not web-exposed, may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)"
products="gecko">
use properties::longhands::{overflow_clip_box_block, overflow_clip_box_inline};

pub fn to_inline_value(block_value: overflow_clip_box_block::SpecifiedValue)
-> overflow_clip_box_inline::SpecifiedValue {
match block_value {
overflow_clip_box_block::SpecifiedValue::padding_box =>
overflow_clip_box_inline::SpecifiedValue::padding_box,
overflow_clip_box_block::SpecifiedValue::content_box =>
overflow_clip_box_inline::SpecifiedValue::content_box
}
}

pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<Longhands, ParseError<'i>> {
let block_value = overflow_clip_box_block::parse(context, input)?;
let inline_value = input.try(|input| overflow_clip_box_inline::parse(context, input)).unwrap_or(
to_inline_value(block_value));

Ok(expanded! {
overflow_clip_box_block: block_value,
overflow_clip_box_inline: inline_value,
})
}

impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
if to_inline_value(*self.overflow_clip_box_block) == *self.overflow_clip_box_inline {
self.overflow_clip_box_block.to_css(dest)
} else {
self.overflow_clip_box_block.to_css(dest)?;
dest.write_str(" ")?;
self.overflow_clip_box_inline.to_css(dest)
}
}
}

</%helpers:shorthand>

macro_rules! try_parse_one {
($input: expr, $var: ident, $prop_module: ident) => {
if $var.is_none() {
Expand Down

0 comments on commit cdf7ae5

Please sign in to comment.