aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow/construct.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2020-06-02 18:16:35 +0200
committerSimon Sapin <simon.sapin@exyr.org>2020-06-04 13:19:53 +0200
commit67d8aa84d2e63503a9d5c250f0eb1eb659f84619 (patch)
tree386a132daae74fbb3a3a29e715bbd48d3932ddd0 /components/layout_2020/flow/construct.rs
parentec548e849ca328ccc18404313369dbffcf0a17b9 (diff)
downloadservo-67d8aa84d2e63503a9d5c250f0eb1eb659f84619.tar.gz
servo-67d8aa84d2e63503a9d5c250f0eb1eb659f84619.zip
Anonymous flex item for text directly in a flex container
Diffstat (limited to 'components/layout_2020/flow/construct.rs')
-rw-r--r--components/layout_2020/flow/construct.rs24
1 files changed, 24 insertions, 0 deletions
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<Item = TextRun>,
+ 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> {