layout: Take percentage columns into account when sizing table grid min and max (#35167)

The specification doesn't say how to deal with percentages when
determining the minimum and maximum size of a table grid, so follow the
approach that Chromium uses.

Essentially, figure out the "missing" percentage from the non-percentage
columns and then use that to work backwards to fine the size of the
percentage ones.

This change is larger than one might expect, because this percentage
approach shouldn't happen for tables that are descendants of a flex,
grid or table container (except when there is an interceding absolute).
We have to pass this information down when building the box tree. This
will also make it easier to improve propagated text decorations in the
future.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Martin Robinson 2025-01-27 16:04:37 +01:00 committed by GitHub
parent d5fcc5a5d5
commit 6b04bc6263
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 228 additions and 226 deletions

View file

@ -30,7 +30,7 @@ use crate::positioned::{AbsolutelyPositionedBox, PositioningContext};
use crate::replaced::ReplacedContents;
use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, DisplayInside};
use crate::taffy::{TaffyItemBox, TaffyItemBoxInner};
use crate::DefiniteContainingBlock;
use crate::{DefiniteContainingBlock, PropagatedBoxTreeData};
pub struct BoxTree {
/// Contains typically exactly one block-level box, which was generated by the root element.
@ -289,6 +289,8 @@ fn construct_for_root_element<'dom>(
let contents = ReplacedContents::for_element(root_element, context)
.map_or_else(|| NonReplacedContents::OfElement.into(), Contents::Replaced);
let propagated_data = PropagatedBoxTreeData::default().union(&info.style);
let root_box = if box_style.position.is_absolutely_positioned() {
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(ArcRefCell::new(
AbsolutelyPositionedBox::construct(context, &info, display_inside, contents),
@ -299,15 +301,15 @@ fn construct_for_root_element<'dom>(
&info,
display_inside,
contents,
propagated_data,
))
} else {
let propagated_text_decoration_line = info.style.clone_text_decoration_line();
BlockLevelBox::Independent(IndependentFormattingContext::construct(
context,
&info,
display_inside,
contents,
propagated_text_decoration_line,
propagated_data,
))
};