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

Avoid creating a LayoutContext in parallel::assign_inline_sizes. #11822

Merged
merged 14 commits into from Jun 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
109 changes: 55 additions & 54 deletions components/layout/block.rs

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions components/layout/flex.rs
Expand Up @@ -27,6 +27,7 @@ use std::sync::Arc;
use style::computed_values::flex_direction;
use style::logical_geometry::LogicalSize;
use style::properties::{ComputedValues, ServoComputedValues};
use style::servo::SharedStyleContext;
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};

/// The size of an axis. May be a specified size, a min/max
Expand Down Expand Up @@ -184,7 +185,7 @@ impl FlexFlow {
// Currently, this is the core of BlockFlow::propagate_assigned_inline_size_to_children() with
// all float and table logic stripped out.
fn block_mode_assign_inline_sizes(&mut self,
_layout_context: &LayoutContext,
_shared_context: &SharedStyleContext,
inline_start_content_edge: Au,
inline_end_content_edge: Au,
content_inline_size: Au) {
Expand Down Expand Up @@ -229,7 +230,7 @@ impl FlexFlow {
// Currently, this is the core of InlineFlow::propagate_assigned_inline_size_to_children() with
// fragment logic stripped out.
fn inline_mode_assign_inline_sizes(&mut self,
_layout_context: &LayoutContext,
_shared_context: &SharedStyleContext,
inline_start_content_edge: Au,
_inline_end_content_edge: Au,
content_inline_size: Au) {
Expand Down Expand Up @@ -402,7 +403,7 @@ impl Flow for FlexFlow {
}
}

fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) {
fn assign_inline_sizes(&mut self, shared_context: &SharedStyleContext) {
let _scope = layout_debug_scope!("flex::assign_inline_sizes {:x}", self.block_flow.base.debug_id());
debug!("assign_inline_sizes");

Expand All @@ -413,7 +414,7 @@ impl Flow for FlexFlow {
// Our inline-size was set to the inline-size of the containing block by the flow's parent.
// Now compute the real value.
let containing_block_inline_size = self.block_flow.base.block_container_inline_size;
self.block_flow.compute_used_inline_size(layout_context, containing_block_inline_size);
self.block_flow.compute_used_inline_size(shared_context, containing_block_inline_size);
if self.block_flow.base.flags.is_float() {
self.block_flow.float.as_mut().unwrap().containing_inline_size = containing_block_inline_size
}
Expand Down Expand Up @@ -460,15 +461,15 @@ impl Flow for FlexFlow {
Mode::Inline => {
self.available_main_size = available_inline_size;
self.available_cross_size = available_block_size;
self.inline_mode_assign_inline_sizes(layout_context,
self.inline_mode_assign_inline_sizes(shared_context,
inline_start_content_edge,
inline_end_content_edge,
content_inline_size)
},
Mode::Block => {
self.available_main_size = available_block_size;
self.available_cross_size = available_inline_size;
self.block_mode_assign_inline_sizes(layout_context,
self.block_mode_assign_inline_sizes(shared_context,
inline_start_content_edge,
inline_end_content_edge,
content_inline_size)
Expand Down
7 changes: 4 additions & 3 deletions components/layout/flow.rs
Expand Up @@ -52,6 +52,7 @@ use style::computed_values::{clear, display, empty_cells, float, position, overf
use style::dom::TRestyleDamage;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::properties::{self, ComputedValues, ServoComputedValues};
use style::servo::SharedStyleContext;
use style::values::computed::LengthOrPercentageOrAuto;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, TableFlow};
use table_caption::TableCaptionFlow;
Expand Down Expand Up @@ -193,7 +194,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
}

/// Pass 2 of reflow: computes inline-size.
fn assign_inline_sizes(&mut self, _ctx: &LayoutContext) {
fn assign_inline_sizes(&mut self, _shared_context: &SharedStyleContext) {
panic!("assign_inline_sizes not yet implemented")
}

Expand Down Expand Up @@ -1560,7 +1561,7 @@ impl ContainingBlockLink {
}

#[inline]
pub fn explicit_block_containing_size(&self, layout_context: &LayoutContext) -> Option<Au> {
pub fn explicit_block_containing_size(&self, shared_context: &SharedStyleContext) -> Option<Au> {
match self.link {
None => {
panic!("Link to containing block not established; perhaps you forgot to call \
Expand All @@ -1569,7 +1570,7 @@ impl ContainingBlockLink {
Some(ref link) => {
let flow = link.upgrade().unwrap();
if flow.is_block_like() {
flow.as_block().explicit_block_containing_size(layout_context)
flow.as_block().explicit_block_containing_size(shared_context)
} else if flow.is_inline_flow() {
Some(flow.as_inline().minimum_block_size_above_baseline)
} else {
Expand Down
6 changes: 4 additions & 2 deletions components/layout/inline.rs
Expand Up @@ -33,8 +33,10 @@ use std::sync::Arc;
use std::{fmt, i32, isize, mem};
use style::computed_values::{display, overflow_x, position, text_align, text_justify};
use style::computed_values::{text_overflow, vertical_align, white_space};
use style::context::StyleContext;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::properties::{ComputedValues, ServoComputedValues};
use style::servo::SharedStyleContext;
use style::values::computed::LengthOrPercentage;
use text;
use unicode_bidi;
Expand Down Expand Up @@ -1348,7 +1350,7 @@ impl Flow for InlineFlow {

/// Recursively (top-down) determines the actual inline-size of child contexts and fragments.
/// When called on this context, the context has had its inline-size set by the parent context.
fn assign_inline_sizes(&mut self, _: &LayoutContext) {
fn assign_inline_sizes(&mut self, _: &SharedStyleContext) {
let _scope = layout_debug_scope!("inline::assign_inline_sizes {:x}", self.base.debug_id());

// Initialize content fragment inline-sizes if they haven't been initialized already.
Expand Down Expand Up @@ -1466,7 +1468,7 @@ impl Flow for InlineFlow {
// This is preorder because the block-size of an absolute flow may depend on
// the block-size of its containing block, which may also be an absolute flow.
(&mut *self as &mut Flow).traverse_preorder_absolute_flows(
&mut AbsoluteAssignBSizesTraversal(layout_context));
&mut AbsoluteAssignBSizesTraversal(layout_context.shared_context()));
}

self.base.position.size.block = match self.lines.last() {
Expand Down
7 changes: 4 additions & 3 deletions components/layout/list_item.rs
Expand Up @@ -25,6 +25,7 @@ use std::sync::Arc;
use style::computed_values::{list_style_type, position};
use style::logical_geometry::LogicalSize;
use style::properties::{ComputedValues, ServoComputedValues};
use style::servo::SharedStyleContext;
use text;

/// A block with the CSS `display` property equal to `list-item`.
Expand Down Expand Up @@ -81,14 +82,14 @@ impl Flow for ListItemFlow {
self.block_flow.bubble_inline_sizes()
}

fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) {
self.block_flow.assign_inline_sizes(layout_context);
fn assign_inline_sizes(&mut self, shared_context: &SharedStyleContext) {
self.block_flow.assign_inline_sizes(shared_context);

let mut marker_inline_start = self.block_flow.fragment.border_box.start.i;

for marker in self.marker_fragments.iter_mut().rev() {
let containing_block_inline_size = self.block_flow.base.block_container_inline_size;
let container_block_size = self.block_flow.explicit_block_containing_size(layout_context);
let container_block_size = self.block_flow.explicit_block_containing_size(shared_context);
marker.assign_replaced_inline_size_if_necessary(containing_block_inline_size, container_block_size);

// Do this now. There's no need to do this in bubble-widths, since markers do not
Expand Down
13 changes: 7 additions & 6 deletions components/layout/multicol.rs
Expand Up @@ -23,6 +23,7 @@ use std::sync::Arc;
use style::context::StyleContext;
use style::logical_geometry::LogicalSize;
use style::properties::{ComputedValues, ServoComputedValues};
use style::servo::SharedStyleContext;
use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
use util::print_tree::PrintTree;

Expand Down Expand Up @@ -77,9 +78,9 @@ impl Flow for MulticolFlow {
self.block_flow.bubble_inline_sizes();
}

fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) {
fn assign_inline_sizes(&mut self, shared_context: &SharedStyleContext) {
debug!("assign_inline_sizes({}): assigning inline_size for flow", "multicol");
self.block_flow.compute_inline_sizes(layout_context);
self.block_flow.compute_inline_sizes(shared_context);

// Move in from the inline-start border edge.
let inline_start_content_edge = self.block_flow.fragment.border_box.start.i +
Expand All @@ -90,7 +91,7 @@ impl Flow for MulticolFlow {
self.block_flow.fragment.margin.inline_end +
self.block_flow.fragment.border_padding.inline_end;

self.block_flow.assign_inline_sizes(layout_context);
self.block_flow.assign_inline_sizes(shared_context);
let padding_and_borders = self.block_flow.fragment.border_padding.inline_start_end();
let content_inline_size =
self.block_flow.fragment.border_box.size.inline - padding_and_borders;
Expand Down Expand Up @@ -119,7 +120,7 @@ impl Flow for MulticolFlow {
self.block_flow.fragment.border_box.size.inline = content_inline_size + padding_and_borders;

self.block_flow.propagate_assigned_inline_size_to_children(
layout_context, inline_start_content_edge, inline_end_content_edge, column_width,
shared_context, inline_start_content_edge, inline_end_content_edge, column_width,
|_, _, _, _, _, _| {});
}

Expand Down Expand Up @@ -237,9 +238,9 @@ impl Flow for MulticolColumnFlow {
self.block_flow.bubble_inline_sizes();
}

fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) {
fn assign_inline_sizes(&mut self, shared_context: &SharedStyleContext) {
debug!("assign_inline_sizes({}): assigning inline_size for flow", "multicol column");
self.block_flow.assign_inline_sizes(layout_context);
self.block_flow.assign_inline_sizes(shared_context);
}

fn assign_block_size<'a>(&mut self, ctx: &'a LayoutContext<'a>) {
Expand Down
3 changes: 1 addition & 2 deletions components/layout/parallel.rs
Expand Up @@ -203,9 +203,8 @@ impl<'a> ParallelPostorderFlowTraversal for AssignBSizes<'a> {}
fn assign_inline_sizes(unsafe_flows: UnsafeFlowList,
proxy: &mut WorkerProxy<SharedLayoutContext, UnsafeFlowList>) {
let shared_layout_context = proxy.user_data();
let layout_context = LayoutContext::new(shared_layout_context);
let assign_inline_sizes_traversal = AssignISizes {
layout_context: &layout_context,
shared_context: &shared_layout_context.style_context,
};
assign_inline_sizes_traversal.run_parallel(unsafe_flows, proxy)
}
Expand Down
3 changes: 2 additions & 1 deletion components/layout/sequential.rs
Expand Up @@ -17,6 +17,7 @@ use fragment::FragmentBorderBoxIterator;
use generated_content::ResolveGeneratedContent;
use gfx::display_list::{DisplayItem, StackingContext};
use script_layout_interface::restyle_damage::{REFLOW, STORE_OVERFLOW};
use style::context::StyleContext;
use traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList, ComputeAbsolutePositions};
use util::opts;

Expand Down Expand Up @@ -70,7 +71,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
}
}

let assign_inline_sizes = AssignISizes { layout_context: &layout_context };
let assign_inline_sizes = AssignISizes { shared_context: layout_context.shared_context() };
let assign_block_sizes = AssignBSizes { layout_context: &layout_context };

doit(root, assign_inline_sizes, assign_block_sizes);
Expand Down
11 changes: 6 additions & 5 deletions components/layout/table.rs
Expand Up @@ -27,6 +27,7 @@ use std::sync::Arc;
use style::computed_values::{border_collapse, border_spacing, table_layout};
use style::logical_geometry::LogicalSize;
use style::properties::{ComputedValues, ServoComputedValues};
use style::servo::SharedStyleContext;
use style::values::CSSFloat;
use style::values::computed::LengthOrPercentageOrAuto;
use table_row::TableRowFlow;
Expand Down Expand Up @@ -324,7 +325,7 @@ impl Flow for TableFlow {

/// Recursively (top-down) determines the actual inline-size of child contexts and fragments.
/// When called on this context, the context has had its inline-size set by the parent context.
fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) {
fn assign_inline_sizes(&mut self, shared_context: &SharedStyleContext) {
let _scope = layout_debug_scope!("table::assign_inline_sizes {:x}",
self.block_flow.base.debug_id());
debug!("assign_inline_sizes({}): assigning inline_size for flow", "table");
Expand All @@ -347,7 +348,7 @@ impl Flow for TableFlow {
border_collapse: self.block_flow.fragment.style.get_inheritedtable().border_collapse,
};
inline_size_computer.compute_used_inline_size(&mut self.block_flow,
layout_context,
shared_context,
containing_block_inline_size);

let inline_start_content_edge = self.block_flow.fragment.border_padding.inline_start;
Expand Down Expand Up @@ -398,7 +399,7 @@ impl Flow for TableFlow {
&self.collapsed_inline_direction_border_widths_for_table;
let mut collapsed_block_direction_border_widths_for_table =
self.collapsed_block_direction_border_widths_for_table.iter().peekable();
self.block_flow.propagate_assigned_inline_size_to_children(layout_context,
self.block_flow.propagate_assigned_inline_size_to_children(shared_context,
inline_start_content_edge,
inline_end_content_edge,
content_inline_size,
Expand Down Expand Up @@ -517,11 +518,11 @@ impl ISizeAndMarginsComputer for InternalTable {
/// CSS Section 10.4: Minimum and Maximum inline-sizes
fn compute_used_inline_size(&self,
block: &mut BlockFlow,
layout_context: &LayoutContext,
shared_context: &SharedStyleContext,
parent_flow_inline_size: Au) {
let mut input = self.compute_inline_size_constraint_inputs(block,
parent_flow_inline_size,
layout_context);
shared_context);

// Tables are always at least as wide as their minimum inline size.
let minimum_inline_size =
Expand Down
5 changes: 3 additions & 2 deletions components/layout/table_caption.rs
Expand Up @@ -19,6 +19,7 @@ use std::fmt;
use std::sync::Arc;
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
use style::servo::SharedStyleContext;
use util::print_tree::PrintTree;

/// A table formatting context.
Expand Down Expand Up @@ -55,9 +56,9 @@ impl Flow for TableCaptionFlow {
self.block_flow.bubble_inline_sizes();
}

fn assign_inline_sizes(&mut self, ctx: &LayoutContext) {
fn assign_inline_sizes(&mut self, shared_context: &SharedStyleContext) {
debug!("assign_inline_sizes({}): assigning inline_size for flow", "table_caption");
self.block_flow.assign_inline_sizes(ctx);
self.block_flow.assign_inline_sizes(shared_context);
}

fn assign_block_size<'a>(&mut self, layout_context: &'a LayoutContext<'a>) {
Expand Down
7 changes: 4 additions & 3 deletions components/layout/table_cell.rs
Expand Up @@ -25,6 +25,7 @@ use std::sync::Arc;
use style::computed_values::{border_collapse, border_top_style, vertical_align};
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::{ComputedValues, ServoComputedValues};
use style::servo::SharedStyleContext;
use table::InternalTable;
use table_row::{CollapsedBorder, CollapsedBorderProvenance};
use util::print_tree::PrintTree;
Expand Down Expand Up @@ -162,7 +163,7 @@ impl Flow for TableCellFlow {
/// Recursively (top-down) determines the actual inline-size of child contexts and fragments.
/// When called on this context, the context has had its inline-size set by the parent table
/// row.
fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) {
fn assign_inline_sizes(&mut self, shared_context: &SharedStyleContext) {
let _scope = layout_debug_scope!("table_cell::assign_inline_sizes {:x}",
self.block_flow.base.debug_id());
debug!("assign_inline_sizes({}): assigning inline_size for flow", "table_cell");
Expand All @@ -174,7 +175,7 @@ impl Flow for TableCellFlow {
border_collapse: self.block_flow.fragment.style.get_inheritedtable().border_collapse,
};
inline_size_computer.compute_used_inline_size(&mut self.block_flow,
layout_context,
shared_context,
containing_block_inline_size);

let inline_start_content_edge =
Expand All @@ -188,7 +189,7 @@ impl Flow for TableCellFlow {
let content_inline_size =
self.block_flow.fragment.border_box.size.inline - padding_and_borders;

self.block_flow.propagate_assigned_inline_size_to_children(layout_context,
self.block_flow.propagate_assigned_inline_size_to_children(shared_context,
inline_start_content_edge,
inline_end_content_edge,
content_inline_size,
Expand Down
3 changes: 2 additions & 1 deletion components/layout/table_colgroup.rs
Expand Up @@ -20,6 +20,7 @@ use std::fmt;
use std::sync::Arc;
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
use style::servo::SharedStyleContext;
use style::values::computed::LengthOrPercentageOrAuto;

/// A table formatting context.
Expand Down Expand Up @@ -81,7 +82,7 @@ impl Flow for TableColGroupFlow {

/// Table column inline-sizes are assigned in the table flow and propagated to table row flows
/// and/or rowgroup flows. Therefore, table colgroup flows do not need to assign inline-sizes.
fn assign_inline_sizes(&mut self, _: &LayoutContext) {
fn assign_inline_sizes(&mut self, _: &SharedStyleContext) {
}

/// Table columns do not have block-size.
Expand Down