Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the way scroll roots are collected #14603

Merged
merged 1 commit into from Jan 10, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -303,9 +303,6 @@ pub struct StackingContext {
/// The scroll policy of this layer.
pub scroll_policy: ScrollPolicy,

/// Children of this StackingContext.
pub children: Vec<StackingContext>,

/// The id of the parent scrolling area that contains this StackingContext.
pub parent_scroll_id: ScrollRootId,
}
@@ -338,7 +335,6 @@ impl StackingContext {
perspective: perspective,
establishes_3d_context: establishes_3d_context,
scroll_policy: scroll_policy,
children: Vec::new(),
parent_scroll_id: parent_scroll_id,
}
}
@@ -359,32 +355,7 @@ impl StackingContext {
ScrollRootId::root())
}

pub fn add_child(&mut self, mut child: StackingContext) {
child.update_overflow_for_all_children();
self.children.push(child);
}

pub fn child_at_mut(&mut self, index: usize) -> &mut StackingContext {
&mut self.children[index]
}

pub fn children(&self) -> &[StackingContext] {
&self.children
}

fn update_overflow_for_all_children(&mut self) {
for child in self.children.iter() {
if self.context_type == StackingContextType::Real &&
child.context_type == StackingContextType::Real {
// This child might be transformed, so we need to take into account
// its transformed overflow rect too, but at the correct position.
let overflow = child.overflow_rect_in_parent_space();
self.overflow = self.overflow.union(&overflow);
}
}
}

fn overflow_rect_in_parent_space(&self) -> Rect<Au> {
pub fn overflow_rect_in_parent_space(&self) -> Rect<Au> {
// Transform this stacking context to get it into the same space as
// the parent stacking context.
//
@@ -402,14 +373,6 @@ impl StackingContext {
f32_rect_to_au_rect(overflow)
}

pub fn print_with_tree(&self, print_tree: &mut PrintTree) {
print_tree.new_level(format!("{:?}", self));
for kid in self.children() {
kid.print_with_tree(print_tree);
}
print_tree.end_level();
}

pub fn to_display_list_items(self) -> (DisplayItem, DisplayItem) {
let mut base_item = BaseDisplayItem::empty();
base_item.stacking_context_id = self.id;
@@ -42,8 +42,7 @@ use flow::IS_ABSOLUTELY_POSITIONED;
use flow_list::FlowList;
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
use fragment::{IS_INLINE_FLEX_ITEM, IS_BLOCK_FLEX_ITEM};
use gfx::display_list::{ClippingRegion, StackingContext};
use gfx_traits::ScrollRootId;
use gfx::display_list::ClippingRegion;
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::{AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
@@ -2195,10 +2194,8 @@ impl Flow for BlockFlow {
}
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.collect_stacking_contexts_for_block(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.collect_stacking_contexts_for_block(state);
}

fn build_display_list(&mut self, state: &mut DisplayListBuildState) {

Large diffs are not rendered by default.

@@ -16,8 +16,6 @@ use flow;
use flow::{Flow, FlowClass, ImmutableFlowUtils, OpaqueFlow};
use flow::{INLINE_POSITION_IS_STATIC, IS_ABSOLUTELY_POSITIONED};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use layout_debug;
use model::{IntrinsicISizes, MaybeAuto, SizeConstraint};
use model::{specified, specified_or_none};
@@ -967,10 +965,8 @@ impl Flow for FlexFlow {
self.build_display_list_for_flex(state);
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
@@ -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);
}
}

@@ -16,10 +16,9 @@ use flow::OpaqueFlow;
use flow_ref::FlowRef;
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
use fragment::SpecificFragmentInfo;
use gfx::display_list::{OpaqueNode, StackingContext};
use gfx::display_list::OpaqueNode;
use gfx::font::FontMetrics;
use gfx::font_context::FontContext;
use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::IntrinsicISizesContribution;
@@ -1622,10 +1621,8 @@ impl Flow for InlineFlow {

fn update_late_computed_block_position_if_necessary(&mut self, _: Au) {}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.collect_stacking_contexts_for_inline(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.collect_stacking_contexts_for_inline(state);
}

fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
@@ -17,8 +17,6 @@ use flow::{Flow, FlowClass, OpaqueFlow};
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedContentInfo};
use fragment::Overflow;
use generated_content;
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use inline::InlineFlow;
use std::sync::Arc;
use style::computed_values::{list_style_type, position};
@@ -144,10 +142,8 @@ impl Flow for ListItemFlow {
self.build_display_list_for_list_item(state);
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
@@ -15,8 +15,6 @@ use euclid::Size2D;
use floats::FloatKind;
use flow::{Flow, FlowClass, OpaqueFlow, mut_base, FragmentationContext};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use std::cmp::{min, max};
use std::fmt;
@@ -188,10 +186,8 @@ impl Flow for MulticolFlow {
self.block_flow.build_display_list(state);
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
@@ -272,10 +268,8 @@ impl Flow for MulticolColumnFlow {
self.block_flow.build_display_list(state);
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
@@ -14,7 +14,6 @@ use flow::{PostorderFlowTraversal, PreorderFlowTraversal};
use flow::IS_ABSOLUTELY_POSITIONED;
use fragment::FragmentBorderBoxIterator;
use generated_content::ResolveGeneratedContent;
use gfx_traits::ScrollRootId;
use servo_config::opts;
use style::servo::restyle_damage::{REFLOW, STORE_OVERFLOW};
use traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};
@@ -76,9 +75,8 @@ pub fn traverse_flow_tree_preorder(root: &mut Flow,
pub fn build_display_list_for_subtree<'a>(flow_root: &mut Flow,
shared_layout_context: &'a SharedLayoutContext)
-> DisplayListBuildState<'a> {
let mut state = DisplayListBuildState::new(shared_layout_context,
flow::base(flow_root).stacking_context_id);
flow_root.collect_stacking_contexts(&mut state.root_stacking_context, ScrollRootId::root());
let mut state = DisplayListBuildState::new(shared_layout_context);
flow_root.collect_stacking_contexts(&mut state);

let mut build_display_list = BuildDisplayList { state: state };
build_display_list.traverse(flow_root);
@@ -16,8 +16,6 @@ use flow;
use flow::{BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ImmutableFlowUtils, OpaqueFlow};
use flow_list::MutFlowListIterator;
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
@@ -501,10 +499,8 @@ impl Flow for TableFlow {
self.block_flow.build_display_list_for_block(state, border_painting_mode);
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
@@ -13,8 +13,6 @@ use display_list_builder::DisplayListBuildState;
use euclid::Point2D;
use flow::{Flow, FlowClass, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use std::fmt;
use std::sync::Arc;
@@ -83,10 +81,8 @@ impl Flow for TableCaptionFlow {
self.block_flow.build_display_list(state);
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
@@ -14,8 +14,6 @@ use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode, Dis
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use flow::{self, Flow, FlowClass, IS_ABSOLUTELY_POSITIONED, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::MaybeAuto;
@@ -262,10 +260,8 @@ impl Flow for TableCellFlow {
self.block_flow.build_display_list_for_block(state, border_painting_mode)
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
@@ -12,8 +12,6 @@ use display_list_builder::DisplayListBuildState;
use euclid::Point2D;
use flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow, SpecificFragmentInfo};
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use layout_debug;
use std::cmp::max;
use std::fmt;
@@ -96,9 +94,7 @@ impl Flow for TableColGroupFlow {
// Table columns are invisible.
fn build_display_list(&mut self, _: &mut DisplayListBuildState) { }

fn collect_stacking_contexts(&mut self,
_parent: &mut StackingContext,
_parent_scroll_root_id: ScrollRootId) {}
fn collect_stacking_contexts(&mut self, _: &mut DisplayListBuildState) {}

fn repair_style(&mut self, _: &Arc<ServoComputedValues>) {}

@@ -15,8 +15,6 @@ use euclid::Point2D;
use flow::{self, EarlyAbsolutePositionInfo, Flow, FlowClass, ImmutableFlowUtils, OpaqueFlow};
use flow_list::MutFlowListIterator;
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::MaybeAuto;
@@ -481,10 +479,8 @@ impl Flow for TableRowFlow {
self.block_flow.build_display_list_for_block(state, border_painting_mode);
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
@@ -13,8 +13,6 @@ use display_list_builder::DisplayListBuildState;
use euclid::Point2D;
use flow::{Flow, FlowClass, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use serde::{Serialize, Serializer};
@@ -184,10 +182,8 @@ impl Flow for TableRowGroupFlow {
self.block_flow.build_display_list(state);
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
@@ -22,8 +22,6 @@ use euclid::Point2D;
use floats::FloatKind;
use flow::{Flow, FlowClass, ImmutableFlowUtils, INLINE_POSITION_IS_STATIC, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use model::MaybeAuto;
use std::cmp::{max, min};
@@ -462,10 +460,8 @@ impl Flow for TableWrapperFlow {
self.block_flow.build_display_list(state);
}

fn collect_stacking_contexts(&mut self,
parent: &mut StackingContext,
parent_scroll_root_id: ScrollRootId) {
self.block_flow.collect_stacking_contexts(parent, parent_scroll_root_id);
fn collect_stacking_contexts(&mut self, state: &mut DisplayListBuildState) {
self.block_flow.collect_stacking_contexts(state);
}

fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.