From 9bfcb3d74164f1b0a65c5d3c3c36810f54574c4b Mon Sep 17 00:00:00 2001 From: Jeremy Ir Date: Sat, 1 Aug 2020 01:56:58 +0000 Subject: [PATCH] style: Rename overflow:-moz-hidden-unscrollable to overflow:clip. Differential Revision: https://phabricator.services.mozilla.com/D73716 --- components/style/style_adjuster.rs | 6 +++--- components/style/values/specified/box.rs | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs index fb5fae96bd0..a11a19561c4 100644 --- a/components/style/style_adjuster.rs +++ b/components/style/style_adjuster.rs @@ -499,10 +499,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { { // overflow: clip is deprecated, so convert to hidden if it's // specified in only one dimension. - if overflow_x == Overflow::MozHiddenUnscrollable { + if overflow_x == Overflow::Clip { overflow_x = Overflow::Hidden; } - if overflow_y == Overflow::MozHiddenUnscrollable { + if overflow_y == Overflow::Clip { overflow_y = Overflow::Hidden; } } @@ -560,7 +560,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { let overflow_y = box_style.clone_overflow_y(); fn scrollable(v: Overflow) -> bool { - v != Overflow::MozHiddenUnscrollable && v != Overflow::Visible + v != Overflow::Clip && v != Overflow::Visible } // If at least one is scrollable we'll adjust the other one in diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index 4274905310d..82bb0ab9df0 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -1991,5 +1991,25 @@ pub enum Overflow { Scroll, Auto, #[cfg(feature = "gecko")] - MozHiddenUnscrollable, + #[parse(aliases = "-moz-hidden-unscrollable")] + Clip, +} + +impl Overflow { + /// Return true if the value will create a scrollable box. + #[inline] + pub fn is_scrollable(&self) -> bool { + matches!(*self, Self::Hidden | Self::Scroll | Self::Auto) + } + /// Convert the value to a scrollable value if it's not already scrollable. + /// This maps `visible` to `auto` and `clip` to `hidden`. + #[inline] + pub fn to_scrollable(&self) -> Self { + match *self { + Self::Hidden | Self::Scroll | Self::Auto => *self, + Self::Visible => Self::Auto, + #[cfg(feature = "gecko")] + Self::Clip => Self::Hidden, + } + } }