From 67d8aa84d2e63503a9d5c250f0eb1eb659f84619 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 2 Jun 2020 18:16:35 +0200 Subject: Anonymous flex item for text directly in a flex container --- components/layout_2020/flow/construct.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'components/layout_2020/flow/construct.rs') diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs index 186a4b4d4ff..a0f6af39357 100644 --- a/components/layout_2020/flow/construct.rs +++ b/components/layout_2020/flow/construct.rs @@ -47,6 +47,30 @@ impl BlockFormattingContext { }; (bfc, inline_content_sizes) } + + pub fn construct_for_text_runs<'dom>( + context: &LayoutContext, + runs: impl Iterator, + content_sizes: ContentSizesRequest, + text_decoration_line: TextDecorationLine, + ) -> (Self, BoxContentSizes) { + // FIXME: do white space collapsing + let inline_level_boxes = runs + .map(|run| ArcRefCell::new(InlineLevelBox::TextRun(run))) + .collect(); + + let ifc = InlineFormattingContext { + inline_level_boxes, + text_decoration_line, + }; + let content_sizes = content_sizes.compute(|| ifc.inline_content_sizes(context)); + let contents = BlockContainer::InlineFormattingContext(ifc); + let bfc = Self { + contents, + contains_floats: false, + }; + (bfc, content_sizes) + } } struct BlockLevelJob<'dom, Node> { -- cgit v1.2.3