Auto merge of #16577 - emilio:adjust-overflow, r=Wafflespeanut

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

This is the missing piece to make the remaining contain tests not assert on
Gecko.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16577)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-04-23 06:33:08 -05:00 committed by GitHub
commit c65dea95d7

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":