layout: Improve layout of table captions (#32695)

- Instead of treating captions as a `BlockFormattingContext`, treat it as
  a `NonReplacedFormattingContext`, which allows reusing flow layout for
  captions -- fixing some issues with sizing.
- Pass in the proper size of the containing block when laying out,
  fixing margin calculation.
- Follow the unspecified rules about how various size properties on
  captions affect their size.
- Improve linebreaking around atomics, which is tested by
  caption-related tests. This fixes intrinsic size calculation regarding
  soft wrap opportunities around atomic and also makes the code making
  these actual soft wrap opportunities a bit better.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2024-07-08 14:58:38 +02:00 committed by GitHub
parent 2888193cfe
commit 89944bd330
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 225 additions and 454 deletions

View file

@ -926,7 +926,7 @@ impl NonReplacedFormattingContext {
///
/// - <https://drafts.csswg.org/css2/visudet.html#blockwidth>
/// - <https://drafts.csswg.org/css2/visudet.html#normal-block>
fn layout_in_flow_block_level(
pub(crate) fn layout_in_flow_block_level(
&self,
layout_context: &LayoutContext,
positioning_context: &mut PositioningContext,
@ -1367,7 +1367,7 @@ struct ContainingBlockPaddingAndBorder<'a> {
max_box_size: LogicalVec2<Option<Length>>,
}
pub(crate) struct ResolvedMargins {
struct ResolvedMargins {
/// Used value for the margin properties, as exposed in getComputedStyle().
pub margin: LogicalSides<Au>,
@ -1440,7 +1440,7 @@ fn solve_containing_block_padding_and_border_for_in_flow_box<'a>(
/// Note that in the presence of floats, this shouldn't be used for a block-level box
/// that establishes an independent formatting context (or is replaced), since the
/// margins could then be incorrect.
pub(crate) fn solve_margins(
fn solve_margins(
containing_block: &ContainingBlock<'_>,
pbm: &PaddingBorderMargin,
inline_size: Au,