diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-07-08 14:58:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-08 12:58:38 +0000 |
commit | 89944bd330c1e46a6f406c9aa36e5118ddd06902 (patch) | |
tree | 234e9c7d0ff1c70fc1cdffad6e7b29024716835b /components/layout_2020/table/construct.rs | |
parent | 2888193cfe3d1b3317984324add07a5e4e4228dc (diff) | |
download | servo-89944bd330c1e46a6f406c9aa36e5118ddd06902.tar.gz servo-89944bd330c1e46a6f406c9aa36e5118ddd06902.zip |
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>
Diffstat (limited to 'components/layout_2020/table/construct.rs')
-rw-r--r-- | components/layout_2020/table/construct.rs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/components/layout_2020/table/construct.rs b/components/layout_2020/table/construct.rs index 9be0331aba1..8e90cab0e4a 100644 --- a/components/layout_2020/table/construct.rs +++ b/components/layout_2020/table/construct.rs @@ -18,6 +18,7 @@ use super::{ Table, TableCaption, TableSlot, TableSlotCell, TableSlotCoordinates, TableSlotOffset, TableTrack, TableTrackGroup, TableTrackGroupType, }; +use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::dom::{BoxSlot, NodeExt}; use crate::dom_traversal::{Contents, NodeAndStyleInfo, NonReplacedContents, TraversalHandler}; @@ -842,23 +843,31 @@ where DisplayLayoutInternal::TableCaption => { let contents = match contents.try_into() { Ok(non_replaced_contents) => { - BlockFormattingContext::construct( - self.context, - info, - non_replaced_contents, - self.current_text_decoration_line, - false, /* is_list_item */ + NonReplacedFormattingContextContents::Flow( + BlockFormattingContext::construct( + self.context, + info, + non_replaced_contents, + self.current_text_decoration_line, + false, /* is_list_item */ + ), ) }, Err(_replaced) => { unreachable!("Replaced should not have a LayoutInternal display type."); }, }; - self.builder.table.captions.push(TableCaption { - contents, - style: info.style.clone(), - base_fragment_info: info.into(), - }); + + let caption = TableCaption { + context: ArcRefCell::new(NonReplacedFormattingContext { + style: info.style.clone(), + base_fragment_info: info.into(), + content_sizes: None, + contents, + }), + }; + + self.builder.table.captions.push(caption); // We are doing this until we have actually set a Box for this `BoxSlot`. ::std::mem::forget(box_slot) |