mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Rework the way scroll roots are collected
Collect scroll roots during the collect_stacking_context phase instead of during display list construction. This will be useful in order to collect containing block scroll roots as well as to give scroll roots sequential ids in the future. This change also pulls stacking context children out of the StackingContext struct itself, which should reduce very slightly the memory used by the finished display list. This also simplifies the DisplayListBuilder because it no longer has to maintain a stack of ScrollRootIds and StackingContextIds and can instead just rely on the program stack.
This commit is contained in:
parent
124301cf48
commit
29876d2703
17 changed files with 227 additions and 275 deletions
|
@ -232,17 +232,11 @@ pub struct BuildDisplayList<'a> {
|
|||
impl<'a> BuildDisplayList<'a> {
|
||||
#[inline]
|
||||
pub fn traverse(&mut self, flow: &mut Flow) {
|
||||
let new_stacking_context =
|
||||
flow::base(flow).stacking_context_id != self.state.stacking_context_id();
|
||||
if new_stacking_context {
|
||||
self.state.push_stacking_context_id(flow::base(flow).stacking_context_id);
|
||||
}
|
||||
let parent_stacking_context_id = self.state.current_stacking_context_id;
|
||||
self.state.current_stacking_context_id = flow::base(flow).stacking_context_id;
|
||||
|
||||
let new_scroll_root =
|
||||
flow::base(flow).scroll_root_id != self.state.scroll_root_id();
|
||||
if new_scroll_root {
|
||||
self.state.push_scroll_root_id(flow::base(flow).scroll_root_id);
|
||||
}
|
||||
let parent_scroll_root_id = self.state.current_scroll_root_id;
|
||||
self.state.current_scroll_root_id = flow::base(flow).scroll_root_id;
|
||||
|
||||
if self.should_process() {
|
||||
flow.build_display_list(&mut self.state);
|
||||
|
@ -253,13 +247,8 @@ impl<'a> BuildDisplayList<'a> {
|
|||
self.traverse(kid);
|
||||
}
|
||||
|
||||
if new_stacking_context {
|
||||
self.state.pop_stacking_context_id();
|
||||
}
|
||||
|
||||
if new_scroll_root {
|
||||
self.state.pop_scroll_root_id();
|
||||
}
|
||||
self.state.current_stacking_context_id = parent_stacking_context_id;
|
||||
self.state.current_scroll_root_id = parent_scroll_root_id;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue