Skip to content

Commit

Permalink
Paint position:absolute nodes above position:static by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Dec 16, 2024
1 parent adb59c1 commit fc0b97c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/blitz-dom/src/stylo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use style::{
},
dom::{LayoutIterator, NodeInfo, OpaqueNode, TDocument, TElement, TNode, TShadowRoot},
global_style_data::GLOBAL_STYLE_DATA,
properties::generated::longhands::position::computed_value::T as Position,
properties::PropertyDeclarationBlock,
selector_parser::{NonTSPseudoClass, SelectorImpl},
servo_arc::{Arc, ArcBorrow},
Expand Down Expand Up @@ -149,7 +150,27 @@ impl crate::document::Document {
.sort_by(|left, right| {
let left_node = self.nodes.get(*left).unwrap();
let right_node = self.nodes.get(*right).unwrap();
left_node.z_index().cmp(&right_node.z_index())
left_node
.z_index()
.cmp(&right_node.z_index())
.then_with(|| {
fn position_to_order(pos: Position) -> u8 {
match pos {
Position::Static | Position::Relative | Position::Sticky => 0,
Position::Absolute | Position::Fixed => 1,
}
}
let left_position = left_node
.primary_styles()
.map(|s| position_to_order(s.clone_position()))
.unwrap_or(0);
let right_position = right_node
.primary_styles()
.map(|s| position_to_order(s.clone_position()))
.unwrap_or(0);

left_position.cmp(&right_position)
})
})
}
}
Expand Down

0 comments on commit fc0b97c

Please sign in to comment.