aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flexbox.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2020-06-02 18:49:55 +0200
committerSimon Sapin <simon.sapin@exyr.org>2020-06-04 13:19:53 +0200
commit29005e1626a11cf1fc840998327896297e82d2cc (patch)
treeccdbb638e20a03135003d3ef85f8c79751eef8b6 /components/layout_2020/flexbox.rs
parent67d8aa84d2e63503a9d5c250f0eb1eb659f84619 (diff)
downloadservo-29005e1626a11cf1fc840998327896297e82d2cc.tar.gz
servo-29005e1626a11cf1fc840998327896297e82d2cc.zip
Keep flex items in `order`-modified document order in the box tree
Diffstat (limited to 'components/layout_2020/flexbox.rs')
-rw-r--r--components/layout_2020/flexbox.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/components/layout_2020/flexbox.rs b/components/layout_2020/flexbox.rs
index 154c9ab3071..7a7b7414f5d 100644
--- a/components/layout_2020/flexbox.rs
+++ b/components/layout_2020/flexbox.rs
@@ -185,6 +185,17 @@ where
fn finish(mut self) -> FlexContainer {
self.wrap_any_text_in_anonymous_block_container();
+
+ // https://drafts.csswg.org/css-flexbox/#order-modified-document-order
+ self.children.sort_by_key(|child| match &*child.borrow() {
+ FlexLevelBox::FlexItem(item) => item.style.clone_order(),
+
+ // “Absolutely-positioned children of a flex container are treated
+ // as having order: 0 for the purpose of determining their painting order
+ // relative to flex items.”
+ FlexLevelBox::OutOfFlowAbsolutelyPositionedBox(_) => 0,
+ });
+
FlexContainer {
children: self.children,
}