diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 378274b7edf..81ba77a946f 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3098,6 +3098,7 @@ fn static_assert() { scroll-snap-type-x scroll-snap-type-y scroll-snap-coordinate perspective-origin -moz-binding will-change overscroll-behavior-x overscroll-behavior-y + overflow-clip-box-inline overflow-clip-box-block perspective-origin -moz-binding will-change shape-outside contain touch-action""" %> <%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}"> @@ -3491,6 +3492,10 @@ fn static_assert() { ${impl_keyword('overscroll_behavior_x', 'mOverscrollBehaviorX', overscroll_behavior_keyword)} ${impl_keyword('overscroll_behavior_y', 'mOverscrollBehaviorY', overscroll_behavior_keyword)} + <% overflow_clip_box_keyword = Keyword("overflow-clip-box", "padding-box content-box") %> + ${impl_keyword('overflow_clip_box_inline', 'mOverflowClipBoxInline', overflow_clip_box_keyword)} + ${impl_keyword('overflow_clip_box_block', 'mOverflowClipBoxBlock', overflow_clip_box_keyword)} + pub fn set_perspective_origin(&mut self, v: longhands::perspective_origin::computed_value::T) { self.gecko.mPerspectiveOrigin[0].set(v.horizontal); self.gecko.mPerspectiveOrigin[1].set(v.vertical); diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 4da02c832b5..abdbba0ea6b 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -373,21 +373,21 @@ ${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-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)")} +% for direction in ["inline", "block"]: + ${helpers.predefined_type( + "overflow-clip-box-" + direction, + "OverflowClipBox", + "computed::OverflowClipBox::padding_box", + products="gecko", + enabled_in="ua", + needs_context=False, + flags="APPLIES_TO_PLACEHOLDER", + gecko_pref="layout.css.overscroll-behavior.enabled", + animation_value_type="discrete", + spec="Internal, may be standardized in the future: \ + https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box", + )} +% endfor <% overflow_custom_consts = { "-moz-hidden-unscrollable": "CLIP" } diff --git a/components/style/properties/shorthand/box.mako.rs b/components/style/properties/shorthand/box.mako.rs index 43fa29849fa..3720657142e 100644 --- a/components/style/properties/shorthand/box.mako.rs +++ b/components/style/properties/shorthand/box.mako.rs @@ -58,46 +58,42 @@ } -<%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}; +<%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, may be standardized in the future " + "(https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)" + products="gecko" +> + use values::specified::OverflowClipBox; + pub fn parse_value<'i, 't>( + _: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + let block_value = OverflowClipBox::parse(input)?; + let inline_value = + input.try(|input| OverflowClipBox::parse(input)).unwrap_or(block_value); - 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 - } - } + Ok(expanded! { + overflow_clip_box_block: block_value, + overflow_clip_box_inline: inline_value, + }) + } - pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) - -> Result> { - 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(&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 { + impl<'a> ToCss for LonghandsToSerialize<'a> { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { self.overflow_clip_box_block.to_css(dest)?; - dest.write_str(" ")?; - self.overflow_clip_box_inline.to_css(dest) - } - } - } + if self.overflow_clip_box_block != self.overflow_clip_box_inline { + dest.write_str(" ")?; + self.overflow_clip_box_inline.to_css(dest)?; + } + + Ok(()) + } + } macro_rules! try_parse_one { diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index fe83543e108..e43fbd61569 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -9,7 +9,7 @@ use values::computed::length::LengthOrPercentage; use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount; use values::generics::box_::VerticalAlign as GenericVerticalAlign; -pub use values::specified::box_::{AnimationName, OverscrollBehavior, ScrollSnapType}; +pub use values::specified::box_::{AnimationName, OverflowClipBox, OverscrollBehavior, ScrollSnapType}; /// A computed value for the `vertical-align` property. pub type VerticalAlign = GenericVerticalAlign; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index b898884489f..a79f9990cd8 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -40,7 +40,8 @@ pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVa pub use self::font::{FontFamily, FontLanguageOverride, FontVariantSettings, FontVariantEastAsian}; pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XTextZoom, XLang}; -pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior, ScrollSnapType, VerticalAlign}; +pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior}; +pub use self::box_::{OverflowClipBox, ScrollSnapType, VerticalAlign}; pub use self::color::{Color, ColorPropertyValue, RGBAColor}; pub use self::effects::{BoxShadow, Filter, SimpleShadow}; pub use self::flex::FlexBasis; diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index ca7c6d9a0a6..a27d80440ee 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -124,3 +124,10 @@ define_css_keyword_enum! { OverscrollBehavior: "none" => None, } add_impls_for_keyword_enum!(OverscrollBehavior); + +// FIXME(emilio): Make all keywords CamelCase. +define_css_keyword_enum! { OverflowClipBox: + "padding-box" => padding_box, + "content-box" => content_box, +} +add_impls_for_keyword_enum!(OverflowClipBox); diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 65796120392..f9e8b7976ae 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -34,7 +34,8 @@ pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVa pub use self::font::{FontFamily, FontLanguageOverride, FontVariantSettings, FontVariantEastAsian}; pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XTextZoom, XLang}; -pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior, ScrollSnapType, VerticalAlign}; +pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior}; +pub use self::box_::{OverflowClipBox, ScrollSnapType, VerticalAlign}; pub use self::color::{Color, ColorPropertyValue, RGBAColor}; pub use self::effects::{BoxShadow, Filter, SimpleShadow}; pub use self::flex::FlexBasis;