diff --git a/components/layout/block.rs b/components/layout/block.rs index 94b7cc43b2c..ab810c59521 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -58,6 +58,7 @@ use style::computed_values::{position, text_align, transform, transform_style}; use style::context::StyleContext; use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; use style::properties::{ComputedValues, ServoComputedValues}; +use style::servo::SharedStyleContext; use style::values::computed::{LengthOrNone, LengthOrPercentageOrNone}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto}; use util::geometry::MAX_RECT; @@ -451,7 +452,7 @@ fn translate_including_floats(cur_b: &mut Au, delta: Au, floats: &mut Floats) { /// /// Note that flows with position 'fixed' just form a flat list as they all /// have the Root flow as their CB. -pub struct AbsoluteAssignBSizesTraversal<'a>(pub &'a LayoutContext<'a>); +pub struct AbsoluteAssignBSizesTraversal<'a>(pub &'a SharedStyleContext); impl<'a> PreorderFlowTraversal for AbsoluteAssignBSizesTraversal<'a> { #[inline] @@ -474,7 +475,7 @@ impl<'a> PreorderFlowTraversal for AbsoluteAssignBSizesTraversal<'a> { return } - block.calculate_absolute_block_size_and_margins(&self.0); + block.calculate_absolute_block_size_and_margins(self.0); } } @@ -589,56 +590,56 @@ impl BlockFlow { /// Compute the actual inline size and position for this block. pub fn compute_used_inline_size(&mut self, - layout_context: &LayoutContext, + shared_context: &SharedStyleContext, containing_block_inline_size: Au) { let block_type = self.block_type(); match block_type { BlockType::AbsoluteReplaced => { let inline_size_computer = AbsoluteReplaced; inline_size_computer.compute_used_inline_size(self, - layout_context, + shared_context, containing_block_inline_size); } BlockType::AbsoluteNonReplaced => { let inline_size_computer = AbsoluteNonReplaced; inline_size_computer.compute_used_inline_size(self, - layout_context, + shared_context, containing_block_inline_size); } BlockType::FloatReplaced => { let inline_size_computer = FloatReplaced; inline_size_computer.compute_used_inline_size(self, - layout_context, + shared_context, containing_block_inline_size); } BlockType::FloatNonReplaced => { let inline_size_computer = FloatNonReplaced; inline_size_computer.compute_used_inline_size(self, - layout_context, + shared_context, containing_block_inline_size); } BlockType::InlineBlockReplaced => { let inline_size_computer = InlineBlockReplaced; inline_size_computer.compute_used_inline_size(self, - layout_context, + shared_context, containing_block_inline_size); } BlockType::InlineBlockNonReplaced => { let inline_size_computer = InlineBlockNonReplaced; inline_size_computer.compute_used_inline_size(self, - layout_context, + shared_context, containing_block_inline_size); } BlockType::Replaced => { let inline_size_computer = BlockReplaced; inline_size_computer.compute_used_inline_size(self, - layout_context, + shared_context, containing_block_inline_size); } BlockType::NonReplaced => { let inline_size_computer = BlockNonReplaced; inline_size_computer.compute_used_inline_size(self, - layout_context, + shared_context, containing_block_inline_size); } } @@ -696,8 +697,8 @@ impl BlockFlow { /// /// TODO(#2017, pcwalton): This is somewhat inefficient (traverses kids twice); can we do /// better? - fn adjust_fragments_for_collapsed_margins_if_root<'a>(&mut self, - layout_context: &'a LayoutContext<'a>) { + fn adjust_fragments_for_collapsed_margins_if_root(&mut self, + shared_context: &SharedStyleContext) { if !self.is_root() { return } @@ -727,7 +728,7 @@ impl BlockFlow { // infrastructure to make it scrollable. let viewport_size = LogicalSize::from_physical(self.fragment.style.writing_mode, - layout_context.shared_context().viewport_size); + shared_context.viewport_size); let block_size = max(viewport_size.block, self.fragment.border_box.size.block + block_start_margin_value + block_end_margin_value); @@ -1030,7 +1031,7 @@ impl BlockFlow { self.fragment.inline_start_offset(), Au(0))); self.base.floats = floats.clone(); - self.adjust_fragments_for_collapsed_margins_if_root(layout_context); + self.adjust_fragments_for_collapsed_margins_if_root(layout_context.shared_context()); } else { // We don't need to reflow, but we still need to perform in-order traversals if // necessary. @@ -1045,7 +1046,7 @@ impl BlockFlow { // 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())); } // Don't remove the dirty bits yet if we're absolutely-positioned, since our final size @@ -1135,14 +1136,14 @@ impl BlockFlow { self.base.position.size); } - pub fn explicit_block_containing_size(&self, layout_context: &LayoutContext) -> Option { + pub fn explicit_block_containing_size(&self, shared_context: &SharedStyleContext) -> Option { if self.is_root() || self.is_fixed() { let viewport_size = LogicalSize::from_physical(self.fragment.style.writing_mode, - layout_context.shared_context().viewport_size); + shared_context.viewport_size); Some(viewport_size.block) } else if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) && self.base.block_container_explicit_block_size.is_none() { - self.base.absolute_cb.explicit_block_containing_size(layout_context) + self.base.absolute_cb.explicit_block_containing_size(shared_context) } else { self.base.block_container_explicit_block_size } @@ -1201,10 +1202,10 @@ impl BlockFlow { } } - fn calculate_absolute_block_size_and_margins(&mut self, layout_context: &LayoutContext) { + fn calculate_absolute_block_size_and_margins(&mut self, shared_context: &SharedStyleContext) { let opaque_self = OpaqueFlow::from_flow(self); let containing_block_block_size = - self.containing_block_size(&layout_context.shared_context().viewport_size, opaque_self).block; + self.containing_block_size(&shared_context.viewport_size, opaque_self).block; // This is the stored content block-size value from assign-block-size let content_block_size = self.fragment.border_box.size.block; @@ -1294,9 +1295,9 @@ impl BlockFlow { /// Compute inline size based using the `block_container_inline_size` set by the parent flow. /// /// This is run in the `AssignISizes` traversal. - fn propagate_and_compute_used_inline_size(&mut self, layout_context: &LayoutContext) { + fn propagate_and_compute_used_inline_size(&mut self, shared_context: &SharedStyleContext) { let containing_block_inline_size = self.base.block_container_inline_size; - self.compute_used_inline_size(layout_context, containing_block_inline_size); + self.compute_used_inline_size(shared_context, containing_block_inline_size); if self.base.flags.is_float() { self.float.as_mut().unwrap().containing_inline_size = containing_block_inline_size } @@ -1310,7 +1311,7 @@ impl BlockFlow { /// and the code for block layout is significantly simpler. #[inline(always)] pub fn propagate_assigned_inline_size_to_children(&mut self, - layout_context: &LayoutContext, + shared_context: &SharedStyleContext, inline_start_content_edge: Au, inline_end_content_edge: Au, content_inline_size: Au, @@ -1330,7 +1331,7 @@ impl BlockFlow { box_sizing::T::border_box => self.fragment.border_padding.block_start_end(), box_sizing::T::content_box => Au(0), }; - let parent_container_size = self.explicit_block_containing_size(layout_context); + let parent_container_size = self.explicit_block_containing_size(shared_context); // https://drafts.csswg.org/css-ui-3/#box-sizing let explicit_content_size = self .explicit_block_size(parent_container_size) @@ -1338,7 +1339,7 @@ impl BlockFlow { // Calculate containing block inline size. let containing_block_size = if flags.contains(IS_ABSOLUTELY_POSITIONED) { - self.containing_block_size(&layout_context.shared_context().viewport_size, opaque_self).inline + self.containing_block_size(&shared_context.viewport_size, opaque_self).inline } else { content_inline_size }; @@ -1615,7 +1616,7 @@ impl BlockFlow { } } - pub fn compute_inline_sizes(&mut self, layout_context: &LayoutContext) { + pub fn compute_inline_sizes(&mut self, shared_context: &SharedStyleContext) { if !self.base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) { return } @@ -1633,13 +1634,13 @@ impl BlockFlow { debug!("Setting root position"); self.base.position.start = LogicalPoint::zero(self.base.writing_mode); self.base.block_container_inline_size = LogicalSize::from_physical( - self.base.writing_mode, layout_context.shared_context().viewport_size).inline; + self.base.writing_mode, shared_context.viewport_size).inline; self.base.block_container_writing_mode = self.base.writing_mode; } // Our inline-size was set to the inline-size of the containing block by the flow's parent. // Now compute the real value. - self.propagate_and_compute_used_inline_size(layout_context); + self.propagate_and_compute_used_inline_size(shared_context); // Now for some speculation. match self.formatting_context_type() { @@ -1718,10 +1719,10 @@ impl Flow for BlockFlow { /// /// Dual fragments consume some inline-size first, and the remainder is assigned to all child /// (block) contexts. - fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { + fn assign_inline_sizes(&mut self, shared_context: &SharedStyleContext) { let _scope = layout_debug_scope!("block::assign_inline_sizes {:x}", self.base.debug_id()); - self.compute_inline_sizes(layout_context); + self.compute_inline_sizes(shared_context); // Move in from the inline-start border edge. let inline_start_content_edge = self.fragment.border_box.start.i + @@ -1736,7 +1737,7 @@ impl Flow for BlockFlow { let content_inline_size = self.fragment.border_box.size.inline - padding_and_borders; - self.propagate_assigned_inline_size_to_children(layout_context, + self.propagate_assigned_inline_size_to_children(shared_context, inline_start_content_edge, inline_end_content_edge, content_inline_size, @@ -2275,10 +2276,10 @@ pub trait ISizeAndMarginsComputer { fn compute_inline_size_constraint_inputs(&self, block: &mut BlockFlow, parent_flow_inline_size: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> ISizeConstraintInput { let containing_block_inline_size = - self.containing_block_inline_size(block, parent_flow_inline_size, layout_context); + self.containing_block_inline_size(block, parent_flow_inline_size, shared_context); block.fragment.compute_block_direction_margins(containing_block_inline_size); block.fragment.compute_inline_direction_margins(containing_block_inline_size); @@ -2286,7 +2287,7 @@ pub trait ISizeAndMarginsComputer { let mut computed_inline_size = self.initial_computed_inline_size(block, parent_flow_inline_size, - layout_context); + shared_context); let style = block.fragment.style(); match (computed_inline_size, style.get_position().box_sizing) { (MaybeAuto::Specified(size), box_sizing::T::border_box) => { @@ -2381,18 +2382,18 @@ pub trait ISizeAndMarginsComputer { fn initial_computed_inline_size(&self, block: &mut BlockFlow, parent_flow_inline_size: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> MaybeAuto { MaybeAuto::from_style(block.fragment().style().content_inline_size(), self.containing_block_inline_size(block, parent_flow_inline_size, - layout_context)) + shared_context)) } fn containing_block_inline_size(&self, _: &mut BlockFlow, parent_flow_inline_size: Au, - _: &LayoutContext) + _: &SharedStyleContext) -> Au { parent_flow_inline_size } @@ -2402,14 +2403,14 @@ pub trait ISizeAndMarginsComputer { /// 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); let containing_block_inline_size = - self.containing_block_inline_size(block, parent_flow_inline_size, layout_context); + self.containing_block_inline_size(block, parent_flow_inline_size, shared_context); let mut solution = self.solve_inline_size_constraints(block, &input); @@ -2727,10 +2728,10 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced { fn containing_block_inline_size(&self, block: &mut BlockFlow, _: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> Au { let opaque_block = OpaqueFlow::from_flow(block); - block.containing_block_size(&layout_context.shared_context().viewport_size, opaque_block).inline + block.containing_block_size(&shared_context.viewport_size, opaque_block).inline } fn set_inline_position_of_flow_if_necessary(&self, @@ -2838,12 +2839,12 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced { fn initial_computed_inline_size(&self, block: &mut BlockFlow, _: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> MaybeAuto { let opaque_block = OpaqueFlow::from_flow(block); let containing_block_inline_size = - block.containing_block_size(&layout_context.shared_context().viewport_size, opaque_block).inline; - let container_block_size = block.explicit_block_containing_size(layout_context); + block.containing_block_size(&shared_context.viewport_size, opaque_block).inline; + let container_block_size = block.explicit_block_containing_size(shared_context); let fragment = block.fragment(); fragment.assign_replaced_inline_size_if_necessary(containing_block_inline_size, container_block_size); // For replaced absolute flow, the rest of the constraint solving will @@ -2854,10 +2855,10 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced { fn containing_block_inline_size(&self, block: &mut BlockFlow, _: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> Au { let opaque_block = OpaqueFlow::from_flow(block); - block.containing_block_size(&layout_context.shared_context().viewport_size, opaque_block).inline + block.containing_block_size(&shared_context.viewport_size, opaque_block).inline } fn set_inline_position_of_flow_if_necessary(&self, @@ -2900,9 +2901,9 @@ impl ISizeAndMarginsComputer for BlockReplaced { fn initial_computed_inline_size(&self, block: &mut BlockFlow, parent_flow_inline_size: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> MaybeAuto { - let container_block_size = block.explicit_block_containing_size(layout_context); + let container_block_size = block.explicit_block_containing_size(shared_context); let fragment = block.fragment(); fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size, container_block_size); // For replaced block flow, the rest of the constraint solving will @@ -2958,9 +2959,9 @@ impl ISizeAndMarginsComputer for FloatReplaced { fn initial_computed_inline_size(&self, block: &mut BlockFlow, parent_flow_inline_size: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> MaybeAuto { - let container_block_size = block.explicit_block_containing_size(layout_context); + let container_block_size = block.explicit_block_containing_size(shared_context); let fragment = block.fragment(); fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size, container_block_size); // For replaced block flow, the rest of the constraint solving will @@ -3046,9 +3047,9 @@ impl ISizeAndMarginsComputer for InlineBlockReplaced { fn initial_computed_inline_size(&self, block: &mut BlockFlow, parent_flow_inline_size: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> MaybeAuto { - let container_block_size = block.explicit_block_containing_size(layout_context); + let container_block_size = block.explicit_block_containing_size(shared_context); let fragment = block.fragment(); fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size, container_block_size); // For replaced block flow, the rest of the constraint solving will diff --git a/components/layout/flex.rs b/components/layout/flex.rs index dd279bbdfdf..031ebb03e8b 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -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 @@ -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) { @@ -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) { @@ -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"); @@ -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 } @@ -460,7 +461,7 @@ 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) @@ -468,7 +469,7 @@ impl Flow for FlexFlow { 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) diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 3dc7fac29dc..73277288e3b 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -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; @@ -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") } @@ -1560,7 +1561,7 @@ impl ContainingBlockLink { } #[inline] - pub fn explicit_block_containing_size(&self, layout_context: &LayoutContext) -> Option { + pub fn explicit_block_containing_size(&self, shared_context: &SharedStyleContext) -> Option { match self.link { None => { panic!("Link to containing block not established; perhaps you forgot to call \ @@ -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 { diff --git a/components/layout/inline.rs b/components/layout/inline.rs index ab2054a00ac..af1f6c878cd 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -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; @@ -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. @@ -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() { diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index be0620b817d..f32c3ec873f 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -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`. @@ -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 diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 09f0efd1130..e8e974ec5a2 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -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; @@ -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 + @@ -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; @@ -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, |_, _, _, _, _, _| {}); } @@ -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>) { diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index b0afae2eeed..ba23c0d7061 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -203,9 +203,8 @@ impl<'a> ParallelPostorderFlowTraversal for AssignBSizes<'a> {} fn assign_inline_sizes(unsafe_flows: UnsafeFlowList, proxy: &mut WorkerProxy) { 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) } diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index a761251b77f..9d51df51a80 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -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; @@ -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); diff --git a/components/layout/table.rs b/components/layout/table.rs index 2f91ea6774d..0299d9b9b01 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -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; @@ -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"); @@ -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; @@ -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, @@ -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 = diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index 1c24491d06d..ad7c43d3f99 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -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. @@ -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>) { diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 4f043e351c4..8b6db89ff38 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -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; @@ -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"); @@ -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 = @@ -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, diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index 6dce7bd56d1..f1041e24107 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -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. @@ -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. diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index dbeafead32e..b8835d493ef 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -27,6 +27,7 @@ use std::sync::Arc; use style::computed_values::{border_collapse, border_spacing, border_top_style}; use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; use style::properties::{ComputedValues, ServoComputedValues}; +use style::servo::SharedStyleContext; use style::values::computed::LengthOrPercentageOrAuto; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt}; use table_cell::{CollapsedBordersForCell, TableCellFlow}; @@ -311,7 +312,7 @@ impl Flow for TableRowFlow { pref_inline_size); } - fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { + fn assign_inline_sizes(&mut self, shared_context: &SharedStyleContext) { let _scope = layout_debug_scope!("table_row::assign_inline_sizes {:x}", self.block_flow.base.debug_id()); debug!("assign_inline_sizes({}): assigning inline_size for flow", "table_row"); @@ -327,7 +328,7 @@ impl Flow for TableRowFlow { 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); // Spread out the completed inline sizes among columns with spans > 1. @@ -380,7 +381,7 @@ impl Flow for TableRowFlow { let spacing = self.spacing; let row_writing_mode = self.block_flow.base.writing_mode; let table_writing_mode = self.table_writing_mode; - 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, containing_block_inline_size, diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index e7e3e2fa938..91dcb0f00a2 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -23,6 +23,7 @@ use std::sync::Arc; use style::computed_values::{border_collapse, border_spacing}; use style::logical_geometry::{LogicalSize, WritingMode}; use style::properties::{ComputedValues, ServoComputedValues}; +use style::servo::SharedStyleContext; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow}; use table_row; use util::print_tree::PrintTree; @@ -139,7 +140,7 @@ impl Flow for TableRowGroupFlow { /// 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_rowgroup::assign_inline_sizes {:x}", self.block_flow.base.debug_id()); debug!("assign_inline_sizes({}): assigning inline_size for flow", "table_rowgroup"); @@ -154,7 +155,7 @@ impl Flow for TableRowGroupFlow { border_collapse: border_collapse, }; inline_size_computer.compute_used_inline_size(&mut self.block_flow, - layout_context, + shared_context, containing_block_inline_size); let column_computed_inline_sizes = &self.column_computed_inline_sizes; @@ -164,7 +165,7 @@ impl Flow for TableRowGroupFlow { &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, diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 8a7d47562f4..c331cd9ee2a 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -32,6 +32,7 @@ use std::sync::Arc; use style::computed_values::{border_collapse, 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::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize}; @@ -204,7 +205,7 @@ impl TableWrapperFlow { fn compute_used_inline_size( &mut self, - layout_context: &LayoutContext, + shared_context: &SharedStyleContext, parent_flow_inline_size: Au, intermediate_column_inline_sizes: &[IntermediateColumnInlineSize]) { let (border_padding, spacing) = self.border_padding_and_spacing(); @@ -233,7 +234,7 @@ impl TableWrapperFlow { let input = inline_size_computer.compute_inline_size_constraint_inputs(&mut self.block_flow, parent_flow_inline_size, - layout_context); + shared_context); let solution = inline_size_computer.solve_inline_size_constraints(&mut self.block_flow, &input); @@ -253,7 +254,7 @@ impl TableWrapperFlow { let input = inline_size_computer.compute_inline_size_constraint_inputs(&mut self.block_flow, parent_flow_inline_size, - layout_context); + shared_context); let solution = inline_size_computer.solve_inline_size_constraints(&mut self.block_flow, &input); @@ -272,7 +273,7 @@ impl TableWrapperFlow { let input = inline_size_computer.compute_inline_size_constraint_inputs(&mut self.block_flow, parent_flow_inline_size, - layout_context); + shared_context); let solution = inline_size_computer.solve_inline_size_constraints(&mut self.block_flow, &input); @@ -319,7 +320,7 @@ impl Flow for TableWrapperFlow { 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", if self.block_flow.base.flags.is_float() { "floated table_wrapper" @@ -344,7 +345,7 @@ impl Flow for TableWrapperFlow { containing_block_inline_size; } - self.compute_used_inline_size(layout_context, + self.compute_used_inline_size(shared_context, containing_block_inline_size, &intermediate_column_inline_sizes); @@ -374,7 +375,7 @@ impl Flow for TableWrapperFlow { match assigned_column_inline_sizes { None => { self.block_flow - .propagate_assigned_inline_size_to_children(layout_context, + .propagate_assigned_inline_size_to_children(shared_context, inline_start_content_edge, inline_end_content_edge, content_inline_size, @@ -382,7 +383,7 @@ impl Flow for TableWrapperFlow { } Some(ref assigned_column_inline_sizes) => { self.block_flow - .propagate_assigned_inline_size_to_children(layout_context, + .propagate_assigned_inline_size_to_children(shared_context, inline_start_content_edge, inline_end_content_edge, content_inline_size, @@ -767,12 +768,12 @@ impl ISizeAndMarginsComputer for Table { fn initial_computed_inline_size(&self, block: &mut BlockFlow, parent_flow_inline_size: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> MaybeAuto { let containing_block_inline_size = self.containing_block_inline_size(block, parent_flow_inline_size, - layout_context); + shared_context); initial_computed_inline_size(block, containing_block_inline_size, self.minimum_width_of_all_columns, @@ -802,12 +803,12 @@ impl ISizeAndMarginsComputer for FloatedTable { fn initial_computed_inline_size(&self, block: &mut BlockFlow, parent_flow_inline_size: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> MaybeAuto { let containing_block_inline_size = self.containing_block_inline_size(block, parent_flow_inline_size, - layout_context); + shared_context); initial_computed_inline_size(block, containing_block_inline_size, self.minimum_width_of_all_columns, @@ -837,12 +838,12 @@ impl ISizeAndMarginsComputer for AbsoluteTable { fn initial_computed_inline_size(&self, block: &mut BlockFlow, parent_flow_inline_size: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> MaybeAuto { let containing_block_inline_size = self.containing_block_inline_size(block, parent_flow_inline_size, - layout_context); + shared_context); initial_computed_inline_size(block, containing_block_inline_size, self.minimum_width_of_all_columns, @@ -852,9 +853,9 @@ impl ISizeAndMarginsComputer for AbsoluteTable { fn containing_block_inline_size(&self, block: &mut BlockFlow, parent_flow_inline_size: Au, - layout_context: &LayoutContext) + shared_context: &SharedStyleContext) -> Au { - AbsoluteNonReplaced.containing_block_inline_size(block, parent_flow_inline_size, layout_context) + AbsoluteNonReplaced.containing_block_inline_size(block, parent_flow_inline_size, shared_context) } fn solve_inline_size_constraints(&self, diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index 0571f903ea4..9888db994c0 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -18,6 +18,7 @@ use style::dom::TNode; use style::matching::MatchMethods; use style::properties::ServoComputedValues; use style::selector_impl::ServoSelectorImpl; +use style::servo::SharedStyleContext; use style::traversal::{DomTraversalContext, STYLE_BLOOM}; use style::traversal::{put_thread_local_bloom_filter, recalc_style_at}; use util::opts; @@ -168,13 +169,13 @@ impl<'a> PostorderFlowTraversal for BubbleISizes<'a> { /// The assign-inline-sizes traversal. In Gecko this corresponds to `Reflow`. #[derive(Copy, Clone)] pub struct AssignISizes<'a> { - pub layout_context: &'a LayoutContext<'a>, + pub shared_context: &'a SharedStyleContext, } impl<'a> PreorderFlowTraversal for AssignISizes<'a> { #[inline] fn process(&self, flow: &mut Flow) { - flow.assign_inline_sizes(self.layout_context); + flow.assign_inline_sizes(self.shared_context); } #[inline]