From fe47726b7c4c896b4a12b1efa5375e4425f20c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Wed, 19 Apr 2017 02:30:04 +0300 Subject: [PATCH] `contain: paint` should update overflow and display properties --- .../style/properties/longhand/box.mako.rs | 2 +- .../style/properties/properties.mako.rs | 35 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 698f715b96b..b7e516907a9 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -2076,7 +2076,7 @@ ${helpers.single_keyword("transform-style", } -<%helpers:longhand name="contain" animation_type="none" products="none" +<%helpers:longhand name="contain" animation_type="none" products="none" need_clone="True" spec="https://drafts.csswg.org/css-contain/#contain-property"> use std::fmt; use style_traits::ToCss; diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index d3d4d807659..3e729d4bf62 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -2407,8 +2407,11 @@ pub fn apply_declarations<'a, F, I>(device: &Device, { use computed_values::overflow_x::T as overflow; use computed_values::overflow_y; - match (style.get_box().clone_overflow_x() == longhands::overflow_x::computed_value::T::visible, - style.get_box().clone_overflow_y().0 == longhands::overflow_x::computed_value::T::visible) { + + let overflow_x = style.get_box().clone_overflow_x(); + let overflow_y = style.get_box().clone_overflow_y().0; + match (overflow_x == longhands::overflow_x::computed_value::T::visible, + overflow_y == longhands::overflow_x::computed_value::T::visible) { (true, true) => {} (true, _) => { style.mutate_box().set_overflow_x(overflow::auto); @@ -2418,8 +2421,36 @@ pub fn apply_declarations<'a, F, I>(device: &Device, } _ => {} } + + % if product == "gecko": + use properties::longhands::contain; + // When 'contain: paint', update overflow from 'visible' to 'clip'. + let contain = style.get_box().clone_contain(); + if contain.contains(contain::PAINT) { + if let longhands::overflow_x::computed_value::T::visible = overflow_x { + style.mutate_box().set_overflow_x(overflow::clip); + } + if let longhands::overflow_x::computed_value::T::visible = overflow_y { + style.mutate_box().set_overflow_y(overflow_y::T(overflow::clip)); + } + } + % endif } + % if product == "gecko": + { + use computed_values::display::T as display; + use properties::longhands::contain; + // An element with contain:paint or contain:layout needs to "be a + // formatting context" + let contain = style.get_box().clone_contain(); + if contain.contains(contain::PAINT) && + style.get_box().clone_display() == display::inline { + style.mutate_box().set_adjusted_display(display::inline_block); + } + } + % endif + // CSS 2.1 section 9.7: // // If 'position' has the value 'absolute' or 'fixed', [...] the computed