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:
Martin Robinson 2016-12-06 14:07:08 -10:00
parent 124301cf48
commit 29876d2703
17 changed files with 227 additions and 275 deletions

View file

@ -35,7 +35,7 @@ use floats::{Floats, SpeculatedFloatPlacement};
use flow_list::{FlowList, MutFlowListIterator};
use flow_ref::{FlowRef, WeakFlowRef};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::{ClippingRegion, StackingContext};
use gfx::display_list::ClippingRegion;
use gfx_traits::{ScrollRootId, StackingContextId};
use gfx_traits::print_tree::PrintTree;
use inline::InlineFlow;
@ -221,9 +221,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
None
}
fn collect_stacking_contexts(&mut self,
_parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState);
/// If this is a float, places it. The default implementation does nothing.
fn place_float_if_applicable<'a>(&mut self) {}
@ -1115,11 +1113,9 @@ impl BaseFlow {
return self as *const BaseFlow as usize;
}
pub fn collect_stacking_contexts_for_children(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
pub fn collect_stacking_contexts_for_children(&mut self, state: &mut DisplayListBuildState) {
for kid in self.children.iter_mut() {
kid.collect_stacking_contexts(parent, parent_scroll_root_id);
kid.collect_stacking_contexts(state);
}
}