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 { fn finish(mut self) -> FlexContainer {
self.wrap_any_text_in_anonymous_block_container(); 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 { FlexContainer {
children: self.children, children: self.children,
} }

View file

@ -266,7 +266,8 @@ ${helpers.predefined_type(
"order", "order",
"Integer", "Integer",
"0", "0",
engines="gecko servo-2013", engines="gecko servo-2013 servo-2020",
servo_2020_pref="layout.flexbox.enabled",
extra_prefixes="webkit", extra_prefixes="webkit",
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
spec="https://drafts.csswg.org/css-flexbox/#order-property", spec="https://drafts.csswg.org/css-flexbox/#order-property",