Keep flex items in order-modified document order in the box tree

This commit is contained in:
Simon Sapin 2020-06-02 18:49:55 +02:00
parent 67d8aa84d2
commit 29005e1626
2 changed files with 13 additions and 1 deletions

View file

@ -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,
}