style: Refactor overflow fixup to account for overflow: clip.

This is the missing piece to make the remaining contain tests not assert on
Gecko.
This commit is contained in:
Emilio Cobos Álvarez 2017-04-23 11:21:39 +02:00
parent 33c6abb1a8
commit 8b0e6ea46e
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -2436,33 +2436,55 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
use computed_values::overflow_x::T as overflow;
use computed_values::overflow_y;
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);
let original_overflow_x = style.get_box().clone_overflow_x();
let original_overflow_y = style.get_box().clone_overflow_y().0;
let mut overflow_x = original_overflow_x;
let mut overflow_y = original_overflow_y;
// 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.
if overflow_x != overflow_y {
// If 'visible' is specified but doesn't match the other dimension,
// it turns into 'auto'.
if overflow_x == overflow::visible {
overflow_x = overflow::auto;
}
(_, true) => {
style.mutate_box().set_overflow_y(overflow_y::T(overflow::auto));
if overflow_y == overflow::visible {
overflow_y = overflow::auto;
}
_ => {}
% if product == "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;
}
% endif
}
% 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 style.get_box().clone_contain().contains(contain::PAINT) {
if overflow_x == overflow::visible {
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));
if overflow_y == overflow::visible {
overflow_y = overflow::clip;
}
}
% endif
if overflow_x != original_overflow_x ||
overflow_y != original_overflow_y {
let mut box_style = style.mutate_box();
box_style.set_overflow_x(overflow_x);
box_style.set_overflow_y(overflow_y::T(overflow_y));
}
}
% if product == "gecko":