Bug 1422839 part 2 - Add internal overflow-clip-box-block/-inline properties and make overflow-clip-box a shorthand (Stylo changes). r=emilio
☠☠ backed out by 3942ce38b1f6 ☠ ☠
authorMats Palmgren <mats@mozilla.com>
Tue, 05 Dec 2017 05:36:00 +0200
changeset 394991 83101ef21e45eeecc9410b754699949c57540be9
parent 394990 436d102343668d07c92e4be00e90d2d31f89c599
child 394992 fc039432e4a62acd234c115025f1955d3d3d3ab2
push id97988
push usernerli@mozilla.com
push dateTue, 05 Dec 2017 14:08:41 +0000
treeherdermozilla-inbound@ff9d1a10cb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1422839
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1422839 part 2 - Add internal overflow-clip-box-block/-inline properties and make overflow-clip-box a shorthand (Stylo changes). r=emilio
servo/components/style/properties/longhand/box.mako.rs
servo/components/style/properties/shorthand/box.mako.rs
--- a/servo/components/style/properties/longhand/box.mako.rs
+++ b/servo/components/style/properties/longhand/box.mako.rs
@@ -368,19 +368,28 @@
 
 // CSS 2.1, Section 11 - Visual effects
 
 ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box",
     products="servo", animation_value_type="none", enabled_in="ua",
     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)")}
 
 <%
     overflow_custom_consts = { "-moz-hidden-unscrollable": "CLIP" }
 %>
 
--- a/servo/components/style/properties/shorthand/box.mako.rs
+++ b/servo/components/style/properties/shorthand/box.mako.rs
@@ -53,16 +53,58 @@
                 self.overflow_x.to_css(dest)
             } else {
                 Ok(())
             }
         }
     }
 </%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() {
             if let Ok(value) = $input.try($prop_module::SingleSpecifiedValue::parse) {
                 $var = Some(value);
                 continue;
             }
         }