contain: paint should update overflow and display properties

This commit is contained in:
Nazım Can Altınova 2017-04-19 02:30:04 +03:00
parent aa077ed40a
commit fe47726b7c
No known key found for this signature in database
GPG key ID: AF9BCD7CE6449954
2 changed files with 34 additions and 3 deletions

View file

@ -2076,7 +2076,7 @@ ${helpers.single_keyword("transform-style",
} }
</%helpers:longhand> </%helpers:longhand>
<%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"> spec="https://drafts.csswg.org/css-contain/#contain-property">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;

View file

@ -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_x::T as overflow;
use computed_values::overflow_y; 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, true) => {}
(true, _) => { (true, _) => {
style.mutate_box().set_overflow_x(overflow::auto); 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: // CSS 2.1 section 9.7:
// //
// If 'position' has the value 'absolute' or 'fixed', [...] the computed // If 'position' has the value 'absolute' or 'fixed', [...] the computed