diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs index a11a19561c4..e612d3b9977 100644 --- a/components/style/style_adjuster.rs +++ b/components/style/style_adjuster.rs @@ -469,48 +469,22 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { } } - /// CSS3 overflow-x and overflow-y require some fixup as well in some - /// cases. - /// - /// overflow: clip and overflow: visible are meaningful only when used in - /// both dimensions. + /// CSS overflow-x and overflow-y require some fixup as well in some cases. + /// https://drafts.csswg.org/css-overflow-3/#overflow-properties + /// "Computed value: as specified, except with `visible`/`clip` computing to + /// `auto`/`hidden` (respectively) if one of `overflow-x` or `overflow-y` is + /// neither `visible` nor `clip`." fn adjust_for_overflow(&mut self) { - let original_overflow_x = self.style.get_box().clone_overflow_x(); - let original_overflow_y = self.style.get_box().clone_overflow_y(); - - let mut overflow_x = original_overflow_x; - let mut overflow_y = original_overflow_y; - + let overflow_x = self.style.get_box().clone_overflow_x(); + let overflow_y = self.style.get_box().clone_overflow_y(); if overflow_x == overflow_y { - return; + return; // optimization for the common case } - // If 'visible' is specified but doesn't match the other dimension, - // it turns into 'auto'. - if overflow_x == Overflow::Visible { - overflow_x = Overflow::Auto; - } - - if overflow_y == Overflow::Visible { - overflow_y = Overflow::Auto; - } - - #[cfg(feature = "gecko")] - { - // overflow: clip is deprecated, so convert to hidden if it's - // specified in only one dimension. - if overflow_x == Overflow::Clip { - overflow_x = Overflow::Hidden; - } - if overflow_y == Overflow::Clip { - overflow_y = Overflow::Hidden; - } - } - - if overflow_x != original_overflow_x || overflow_y != original_overflow_y { + if overflow_x.is_scrollable() != overflow_y.is_scrollable() { let box_style = self.style.mutate_box(); - box_style.set_overflow_x(overflow_x); - box_style.set_overflow_y(overflow_y); + box_style.set_overflow_x(overflow_x.to_scrollable()); + box_style.set_overflow_y(overflow_y.to_scrollable()); } }