mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
style: Implement overflow:clip/visible combinations.
Differential Revision: https://phabricator.services.mozilla.com/D73717
This commit is contained in:
parent
9bfcb3d741
commit
b29824bf75
1 changed files with 11 additions and 37 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue