mirror of
https://github.com/servo/servo.git
synced 2025-06-13 02:44:29 +00:00
Simplify table logic in effective_overflow() (#33431)
On tables, we need to treat an overflow value of `scroll` or `auto` as `visible`. Both `scroll` or `auto` are scrollable, which implies that the other axis must also have a scrollable value. Therefore, when we make the value behave as the non-scrollable `visible`, we need to adjust the other axis too. The previous logic was checking `is_scrollable()` but that wasn't necessary, since computed values must have the same scrollability. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
497df024b1
commit
6e80a34d09
1 changed files with 22 additions and 33 deletions
|
@ -622,49 +622,38 @@ impl ComputedValuesExt for ComputedValues {
|
||||||
/// <https://www.w3.org/TR/css-overflow-3/#overflow-control>
|
/// <https://www.w3.org/TR/css-overflow-3/#overflow-control>
|
||||||
fn effective_overflow(&self) -> PhysicalVec<Overflow> {
|
fn effective_overflow(&self) -> PhysicalVec<Overflow> {
|
||||||
let style_box = self.get_box();
|
let style_box = self.get_box();
|
||||||
let mut overflow_x = style_box.overflow_x;
|
let overflow_x = style_box.overflow_x;
|
||||||
let mut overflow_y = style_box.overflow_y;
|
let overflow_y = style_box.overflow_y;
|
||||||
// According to <https://drafts.csswg.org/css-tables/#global-style-overrides>,
|
let ignores_overflow = match style_box.display.inside() {
|
||||||
// overflow applies to table-wrapper boxes and not to table grid boxes.
|
stylo::DisplayInside::Table => {
|
||||||
// That's what Blink and WebKit do, however Firefox matches a CSSWG resolution that says
|
// According to <https://drafts.csswg.org/css-tables/#global-style-overrides>,
|
||||||
// the opposite: <https://lists.w3.org/Archives/Public/www-style/2012Aug/0298.html>
|
// - overflow applies to table-wrapper boxes and not to table grid boxes.
|
||||||
// Due to the way that we implement table-wrapper boxes, it's easier to align with Firefox.
|
// That's what Blink and WebKit do, however Firefox matches a CSSWG resolution that says
|
||||||
match style_box.display.inside() {
|
// the opposite: <https://lists.w3.org/Archives/Public/www-style/2012Aug/0298.html>
|
||||||
stylo::DisplayInside::Table
|
// Due to the way that we implement table-wrapper boxes, it's easier to align with Firefox.
|
||||||
if matches!(self.pseudo(), Some(PseudoElement::ServoTableGrid)) =>
|
// - Tables ignore overflow values different than visible, clip and hidden.
|
||||||
{
|
// This affects both axes, to ensure they have the same scrollability.
|
||||||
// <https://drafts.csswg.org/css-tables/#global-style-overrides>
|
!matches!(self.pseudo(), Some(PseudoElement::ServoTableGrid)) ||
|
||||||
// Tables ignore overflow values different than visible, clip and hidden.
|
matches!(overflow_x, Overflow::Auto | Overflow::Scroll) ||
|
||||||
// We also need to make sure that both axes have the same scrollability.
|
matches!(overflow_y, Overflow::Auto | Overflow::Scroll)
|
||||||
if matches!(overflow_x, Overflow::Auto | Overflow::Scroll) {
|
|
||||||
overflow_x = Overflow::Visible;
|
|
||||||
if overflow_y.is_scrollable() {
|
|
||||||
overflow_y = Overflow::Visible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if matches!(overflow_y, Overflow::Auto | Overflow::Scroll) {
|
|
||||||
overflow_y = Overflow::Visible;
|
|
||||||
if overflow_x.is_scrollable() {
|
|
||||||
overflow_x = Overflow::Visible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
stylo::DisplayInside::TableColumn |
|
stylo::DisplayInside::TableColumn |
|
||||||
stylo::DisplayInside::TableColumnGroup |
|
stylo::DisplayInside::TableColumnGroup |
|
||||||
stylo::DisplayInside::TableRow |
|
stylo::DisplayInside::TableRow |
|
||||||
stylo::DisplayInside::TableRowGroup |
|
stylo::DisplayInside::TableRowGroup |
|
||||||
stylo::DisplayInside::TableHeaderGroup |
|
stylo::DisplayInside::TableHeaderGroup |
|
||||||
stylo::DisplayInside::TableFooterGroup |
|
stylo::DisplayInside::TableFooterGroup => {
|
||||||
stylo::DisplayInside::Table => {
|
|
||||||
// <https://drafts.csswg.org/css-tables/#global-style-overrides>
|
// <https://drafts.csswg.org/css-tables/#global-style-overrides>
|
||||||
// Table-track and table-track-group boxes ignore overflow.
|
// Table-track and table-track-group boxes ignore overflow.
|
||||||
// We also ignore it on table-wrapper boxes (see above).
|
true
|
||||||
overflow_x = Overflow::Visible;
|
|
||||||
overflow_y = Overflow::Visible;
|
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => false,
|
||||||
|
};
|
||||||
|
if ignores_overflow {
|
||||||
|
PhysicalVec::new(Overflow::Visible, Overflow::Visible)
|
||||||
|
} else {
|
||||||
|
PhysicalVec::new(overflow_x, overflow_y)
|
||||||
}
|
}
|
||||||
PhysicalVec::new(overflow_x, overflow_y)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this style is a normal block and establishes
|
/// Return true if this style is a normal block and establishes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue