gfx: Avoid copying stacking contexts around so much during stacking

context creation.
This commit is contained in:
Patrick Walton 2016-03-02 11:48:49 -08:00
parent 4233e0f163
commit 983576ebaa

View file

@ -1643,18 +1643,24 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
StackingContextCreationMode::PseudoFloat StackingContextCreationMode::PseudoFloat
}; };
let mut stacking_context = let stacking_context_index = contexts.len();
self.fragment.create_stacking_context(stacking_context_id, contexts.push(self.fragment.create_stacking_context(stacking_context_id,
&self.base, &self.base,
ScrollPolicy::Scrollable, ScrollPolicy::Scrollable,
creation_mode); creation_mode));
let (mut floating, mut positioned) = child_contexts.into_iter().partition(|context| {
context.context_type == StackingContextType::PseudoFloat
});
stacking_context.children.append(&mut floating); let mut floating = vec![];
contexts.push(stacking_context); for child_context in child_contexts.into_iter() {
contexts.append(&mut positioned); if child_context.context_type == StackingContextType::PseudoFloat {
// Floating.
floating.push(child_context)
} else {
// Positioned.
contexts.push(child_context)
}
}
contexts[stacking_context_index].children = floating;
return stacking_context_id; return stacking_context_id;
} }
@ -1670,7 +1676,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
&self.base, &self.base,
scroll_policy, scroll_policy,
StackingContextCreationMode::InnerScrollWrapper); StackingContextCreationMode::InnerScrollWrapper);
inner_stacking_context.children.append(&mut child_contexts); inner_stacking_context.children = child_contexts;
let mut outer_stacking_context = self.fragment.create_stacking_context( let mut outer_stacking_context = self.fragment.create_stacking_context(
stacking_context_id, stacking_context_id,
@ -1685,7 +1691,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
&self.base, &self.base,
scroll_policy, scroll_policy,
StackingContextCreationMode::Normal); StackingContextCreationMode::Normal);
stacking_context.children.append(&mut child_contexts); stacking_context.children = child_contexts;
stacking_context stacking_context
}; };