From 0cb0c6bc4e1a641a3e25b6ac7363cfb1a4d7ca18 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 23 Aug 2016 16:13:23 +0200 Subject: [PATCH 1/7] Move image fetching methods to SharedLayoutContext. --- components/layout/context.rs | 19 ++++++++++--------- components/layout/display_list_builder.rs | 9 +++++---- components/layout/fragment.rs | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/components/layout/context.rs b/components/layout/context.rs index 02d4bdd8b8d..eb9024c2c5b 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -130,13 +130,15 @@ impl<'a> LayoutContext<'a> { pub fn font_context(&self) -> RefMut { self.cached_local_layout_context.font_context.borrow_mut() } +} +impl SharedLayoutContext { fn get_or_request_image_synchronously(&self, url: Url, use_placeholder: UsePlaceholder) -> Option> { debug_assert!(opts::get().output_file.is_some() || opts::get().exit_after_load); // See if the image is already available - let result = self.shared.image_cache_thread.find_image(url.clone(), use_placeholder); + let result = self.image_cache_thread.find_image(url.clone(), use_placeholder); match result { Ok(image) => return Some(image), @@ -150,7 +152,7 @@ impl<'a> LayoutContext<'a> { // If we are emitting an output file, then we need to block on // image load or we risk emitting an output file missing the image. let (sync_tx, sync_rx) = ipc::channel().unwrap(); - self.shared.image_cache_thread.request_image(url, ImageCacheChan(sync_tx), None); + self.image_cache_thread.request_image(url, ImageCacheChan(sync_tx), None); loop { match sync_rx.recv() { Err(_) => return None, @@ -174,16 +176,16 @@ impl<'a> LayoutContext<'a> { .map(|img| ImageOrMetadataAvailable::ImageAvailable(img)); } // See if the image is already available - let result = self.shared.image_cache_thread.find_image_or_metadata(url.clone(), - use_placeholder); + let result = self.image_cache_thread.find_image_or_metadata(url.clone(), + use_placeholder); match result { Ok(image_or_metadata) => Some(image_or_metadata), // Image failed to load, so just return nothing Err(ImageState::LoadError) => None, // Not yet requested, async mode - request image or metadata from the cache Err(ImageState::NotRequested) => { - let sender = self.shared.image_cache_sender.lock().unwrap().clone(); - self.shared.image_cache_thread.request_image_and_metadata(url, sender, None); + let sender = self.image_cache_sender.lock().unwrap().clone(); + self.image_cache_thread.request_image_and_metadata(url, sender, None); None } // Image has been requested, is still pending. Return no image for this paint loop. @@ -198,7 +200,7 @@ impl<'a> LayoutContext<'a> { fetch_image_data_as_well: bool) -> Option<(WebRenderImageInfo, Option)> { if !fetch_image_data_as_well { - let webrender_image_cache = self.shared.webrender_image_cache.read().unwrap(); + let webrender_image_cache = self.webrender_image_cache.read().unwrap(); if let Some(existing_webrender_image) = webrender_image_cache.get(&((*url).clone(), use_placeholder)) { return Some(((*existing_webrender_image).clone(), None)) @@ -216,8 +218,7 @@ impl<'a> LayoutContext<'a> { }; Some((image_info, bytes)) } else if !fetch_image_data_as_well { - let mut webrender_image_cache = self.shared - .webrender_image_cache + let mut webrender_image_cache = self.webrender_image_cache .write() .unwrap(); webrender_image_cache.insert(((*url).clone(), use_placeholder), diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index ce3df3f4c47..db8b67400fc 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -491,10 +491,11 @@ impl FragmentDisplayListBuilding for Fragment { index: usize) { let background = style.get_background(); let fetch_image_data_as_well = !opts::get().use_webrender; - let webrender_image = - state.layout_context.get_webrender_image_for_url(image_url, - UsePlaceholder::No, - fetch_image_data_as_well); + let webrender_image = state.layout_context + .shared + .get_webrender_image_for_url(image_url, + UsePlaceholder::No, + fetch_image_data_as_well); if let Some((webrender_image, image_data)) = webrender_image { debug!("(building display list) building background image"); diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index dbf6307bac1..aeff0639868 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -370,7 +370,7 @@ impl ImageFragmentInfo { pub fn new(node: &N, url: Option, layout_context: &LayoutContext) -> ImageFragmentInfo { let image_or_metadata = url.and_then(|url| { - layout_context.get_or_request_image_or_meta(url, UsePlaceholder::Yes) + layout_context.shared.get_or_request_image_or_meta(url, UsePlaceholder::Yes) }); let (image, metadata) = match image_or_metadata { From d00d9994e9285fddfb4f808bca03fb0e3dfec0d4 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 23 Aug 2016 16:54:24 +0200 Subject: [PATCH 2/7] Pass SharedStyleContext to ReplacedImageFragmentInfo::new. --- components/layout/fragment.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index aeff0639868..24703e46ae0 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -42,6 +42,7 @@ use style::computed_values::content::ContentItem; use style::computed_values::{border_collapse, box_sizing, clear, color, display, mix_blend_mode}; use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration}; use style::computed_values::{transform_style, vertical_align, white_space, word_break, z_index}; +use style::context::SharedStyleContext; use style::dom::TRestyleDamage; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::properties::ServoComputedValues; @@ -325,7 +326,7 @@ pub struct CanvasFragmentInfo { impl CanvasFragmentInfo { pub fn new(node: &N, data: HTMLCanvasData, ctx: &LayoutContext) -> CanvasFragmentInfo { CanvasFragmentInfo { - replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, ctx), + replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, ctx.style_context()), ipc_renderer: data.ipc_renderer .map(|renderer| Arc::new(Mutex::new(renderer))), dom_width: Au::from_px(data.width as i32), @@ -386,7 +387,7 @@ impl ImageFragmentInfo { }; ImageFragmentInfo { - replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, layout_context), + replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, layout_context.style_context()), image: image, metadata: metadata, } @@ -445,9 +446,9 @@ pub struct ReplacedImageFragmentInfo { } impl ReplacedImageFragmentInfo { - pub fn new(node: &N, ctx: &LayoutContext) -> ReplacedImageFragmentInfo + pub fn new(node: &N, ctx: &SharedStyleContext) -> ReplacedImageFragmentInfo where N: ThreadSafeLayoutNode { - let is_vertical = node.style(ctx.style_context()).writing_mode.is_vertical(); + let is_vertical = node.style(ctx).writing_mode.is_vertical(); ReplacedImageFragmentInfo { computed_inline_size: None, computed_block_size: None, From 7524e5549f8cda195d8453929770cf26218929c5 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 23 Aug 2016 16:58:45 +0200 Subject: [PATCH 3/7] Pass SharedStyleContext to CanvasFragmentInfo::new. --- components/layout/construct.rs | 2 +- components/layout/fragment.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/layout/construct.rs b/components/layout/construct.rs index bb7f0372189..cf8d69cbbf3 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -332,7 +332,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> } Some(LayoutNodeType::Element(LayoutElementType::HTMLCanvasElement)) => { let data = node.canvas_data().unwrap(); - SpecificFragmentInfo::Canvas(box CanvasFragmentInfo::new(node, data, self.layout_context)) + SpecificFragmentInfo::Canvas(box CanvasFragmentInfo::new(node, data, self.style_context())) } _ => { // This includes pseudo-elements. diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 24703e46ae0..0626ed76867 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -324,9 +324,12 @@ pub struct CanvasFragmentInfo { } impl CanvasFragmentInfo { - pub fn new(node: &N, data: HTMLCanvasData, ctx: &LayoutContext) -> CanvasFragmentInfo { + pub fn new(node: &N, + data: HTMLCanvasData, + ctx: &SharedStyleContext) + -> CanvasFragmentInfo { CanvasFragmentInfo { - replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, ctx.style_context()), + replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, ctx), ipc_renderer: data.ipc_renderer .map(|renderer| Arc::new(Mutex::new(renderer))), dom_width: Au::from_px(data.width as i32), From 938569e3c79d47781314a4af6b77b80076feec29 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 23 Aug 2016 17:32:06 +0200 Subject: [PATCH 4/7] Pass SharedLayoutContext to ImageFragmentInfo::new. --- components/layout/construct.rs | 6 +++--- components/layout/fragment.rs | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/layout/construct.rs b/components/layout/construct.rs index cf8d69cbbf3..9d4b28b42f4 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -308,13 +308,13 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> Some(LayoutNodeType::Element(LayoutElementType::HTMLImageElement)) => { let image_info = box ImageFragmentInfo::new(node, node.image_url(), - &self.layout_context); + &self.layout_context.shared); SpecificFragmentInfo::Image(image_info) } Some(LayoutNodeType::Element(LayoutElementType::HTMLObjectElement)) => { let image_info = box ImageFragmentInfo::new(node, node.object_data(), - &self.layout_context); + &self.layout_context.shared); SpecificFragmentInfo::Image(image_info) } Some(LayoutNodeType::Element(LayoutElementType::HTMLTableElement)) => { @@ -1267,7 +1267,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> Some(ref url) => { let image_info = box ImageFragmentInfo::new(node, Some((*url).clone()), - &self.layout_context); + &self.layout_context.shared); vec![Fragment::new(node, SpecificFragmentInfo::Image(image_info), self.layout_context)] } None => { diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 0626ed76867..40364a67905 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -8,7 +8,7 @@ use app_units::Au; use canvas_traits::CanvasMsg; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use euclid::{Point2D, Rect, Size2D}; use floats::ClearType; use flow::{self, ImmutableFlowUtils}; @@ -372,9 +372,10 @@ impl ImageFragmentInfo { /// FIXME(pcwalton): The fact that image fragments store the cache in the fragment makes little /// sense to me. pub fn new(node: &N, url: Option, - layout_context: &LayoutContext) -> ImageFragmentInfo { + shared_layout_context: &SharedLayoutContext) + -> ImageFragmentInfo { let image_or_metadata = url.and_then(|url| { - layout_context.shared.get_or_request_image_or_meta(url, UsePlaceholder::Yes) + shared_layout_context.get_or_request_image_or_meta(url, UsePlaceholder::Yes) }); let (image, metadata) = match image_or_metadata { @@ -390,7 +391,7 @@ impl ImageFragmentInfo { }; ImageFragmentInfo { - replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, layout_context.style_context()), + replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, &shared_layout_context.style_context), image: image, metadata: metadata, } From 05e9a9ac869b9aab8ba130aaa9cce6d725374d07 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 23 Aug 2016 18:04:33 +0200 Subject: [PATCH 5/7] Pass SharedLayoutContext to DisplayListBuildState::new. --- components/layout/display_list_builder.rs | 12 ++++++------ components/layout/sequential.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index db8b67400fc..de342475c7f 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -14,7 +14,7 @@ use app_units::{Au, AU_PER_PX}; use azure::azure_hl::Color; use block::{BlockFlow, BlockStackingContextType}; use canvas_traits::{CanvasMsg, CanvasData, FromLayoutMsg}; -use context::LayoutContext; +use context::SharedLayoutContext; use euclid::{Matrix4D, Point2D, Point3D, Radians, Rect, SideOffsets2D, Size2D}; use flex::FlexFlow; use flow::{BaseFlow, Flow, IS_ABSOLUTELY_POSITIONED}; @@ -65,16 +65,17 @@ fn get_cyclic(arr: &[T], index: usize) -> &T { } pub struct DisplayListBuildState<'a> { - pub layout_context: &'a LayoutContext<'a>, + pub shared_layout_context: &'a SharedLayoutContext, pub items: Vec, pub stacking_context_id_stack: Vec, } impl<'a> DisplayListBuildState<'a> { - pub fn new(layout_context: &'a LayoutContext, stacking_context_id: StackingContextId) + pub fn new(shared_layout_context: &'a SharedLayoutContext, + stacking_context_id: StackingContextId) -> DisplayListBuildState<'a> { DisplayListBuildState { - layout_context: layout_context, + shared_layout_context: shared_layout_context, items: Vec::new(), stacking_context_id_stack: vec!(stacking_context_id), } @@ -491,8 +492,7 @@ impl FragmentDisplayListBuilding for Fragment { index: usize) { let background = style.get_background(); let fetch_image_data_as_well = !opts::get().use_webrender; - let webrender_image = state.layout_context - .shared + let webrender_image = state.shared_layout_context .get_webrender_image_for_url(image_url, UsePlaceholder::No, fetch_image_data_as_well); diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index 1862086b163..cbd5954ebee 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -89,7 +89,7 @@ pub fn build_display_list_for_subtree(root: &mut FlowRef, &mut children); root_stacking_context.add_children(children); let mut build_display_list = BuildDisplayList { - state: DisplayListBuildState::new(&layout_context, + state: DisplayListBuildState::new(&layout_context.shared, flow::base(&*flow_root).stacking_context_id), }; build_display_list.traverse(&mut *flow_root); From 871c207c44ab00872dffd0eb16416a4e1acfe09c Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 24 Aug 2016 10:10:05 +0200 Subject: [PATCH 6/7] Pass SharedLayoutContext to Flow::compute_absolute_position. --- components/layout/block.rs | 10 +++++----- components/layout/flex.rs | 4 ++-- components/layout/flow.rs | 4 ++-- components/layout/inline.rs | 4 ++-- components/layout/list_item.rs | 4 ++-- components/layout/multicol.rs | 6 +++--- components/layout/table.rs | 4 ++-- components/layout/table_caption.rs | 4 ++-- components/layout/table_cell.rs | 4 ++-- components/layout/table_row.rs | 4 ++-- components/layout/table_rowgroup.rs | 4 ++-- components/layout/table_wrapper.rs | 4 ++-- components/layout/traversal.rs | 2 +- 13 files changed, 29 insertions(+), 29 deletions(-) diff --git a/components/layout/block.rs b/components/layout/block.rs index 178e0294eb0..17ced441c30 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -28,7 +28,7 @@ #![deny(unsafe_code)] use app_units::{Au, MAX_AU}; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::BlockFlowDisplayListBuilding; use display_list_builder::{BorderPaintingMode, DisplayListBuildState, FragmentDisplayListBuilding}; use euclid::{Point2D, Rect, Size2D}; @@ -1834,7 +1834,7 @@ impl Flow for BlockFlow { } } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { if self.base.flags.contains(NEEDS_LAYER) { self.fragment.flags.insert(HAS_LAYER) } @@ -1969,12 +1969,12 @@ impl Flow for BlockFlow { let stacking_relative_position_of_display_port_for_children = if is_stacking_context || self.is_root() { let visible_rect = - match layout_context.shared.visible_rects.get(&self.layer_id()) { + match layout_context.visible_rects.get(&self.layer_id()) { Some(visible_rect) => *visible_rect, - None => Rect::new(Point2D::zero(), layout_context.shared_context().viewport_size), + None => Rect::new(Point2D::zero(), layout_context.style_context.viewport_size), }; - let viewport_size = layout_context.shared_context().viewport_size; + let viewport_size = layout_context.style_context.viewport_size; visible_rect.inflate(viewport_size.width * DISPLAY_PORT_SIZE_FACTOR, viewport_size.height * DISPLAY_PORT_SIZE_FACTOR) } else if is_stacking_context { diff --git a/components/layout/flex.rs b/components/layout/flex.rs index 64cc24a0746..a255b5f1e7d 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -8,7 +8,7 @@ use app_units::{Au, MAX_AU}; use block::BlockFlow; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::{DisplayListBuildState, FlexFlowDisplayListBuilding}; use euclid::Point2D; use floats::FloatKind; @@ -920,7 +920,7 @@ impl Flow for FlexFlow { } } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context) } diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 2b42957826e..272b29d9d48 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -27,7 +27,7 @@ use app_units::Au; use block::{BlockFlow, FormattingContextType}; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::DisplayListBuildState; use euclid::{Point2D, Rect, Size2D}; use floats::{Floats, SpeculatedFloatPlacement}; @@ -318,7 +318,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static { } /// Phase 4 of reflow: computes absolute positions. - fn compute_absolute_position(&mut self, _: &LayoutContext) { + fn compute_absolute_position(&mut self, _: &SharedLayoutContext) { // The default implementation is a no-op. } diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 5d637b0f2da..ae3de177243 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -6,7 +6,7 @@ use app_units::Au; use block::AbsoluteAssignBSizesTraversal; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::DisplayListBuildState; use display_list_builder::{FragmentDisplayListBuilding, InlineFlowDisplayListBuilding}; use euclid::{Point2D, Size2D}; @@ -1532,7 +1532,7 @@ impl Flow for InlineFlow { } } - fn compute_absolute_position(&mut self, _: &LayoutContext) { + fn compute_absolute_position(&mut self, _: &SharedLayoutContext) { // First, gather up the positions of all the containing blocks (if any). // // FIXME(pcwalton): This will get the absolute containing blocks inside `...` wrong in the diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index 313510368e8..f51f56dea31 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -9,7 +9,7 @@ use app_units::Au; use block::BlockFlow; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::{DisplayListBuildState, ListItemFlowDisplayListBuilding}; use euclid::Point2D; use floats::FloatKind; @@ -124,7 +124,7 @@ impl Flow for ListItemFlow { } } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context) } diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 555e83e129d..e64479ffb11 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -8,7 +8,7 @@ use app_units::Au; use block::BlockFlow; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::DisplayListBuildState; use euclid::Point2D; use euclid::Size2D; @@ -163,7 +163,7 @@ impl Flow for MulticolFlow { } } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context); let pitch = LogicalSize::new(self.block_flow.base.writing_mode, self.column_pitch, Au(0)); let pitch = pitch.to_physical(self.block_flow.base.writing_mode); @@ -254,7 +254,7 @@ impl Flow for MulticolColumnFlow { Flow::fragment(&mut self.block_flow, layout_context, fragmentation_context) } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context) } diff --git a/components/layout/table.rs b/components/layout/table.rs index 62d506c7b4a..96475f4a9e2 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -9,7 +9,7 @@ use app_units::Au; use block::{BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer}; use block::{ISizeConstraintInput, ISizeConstraintSolution}; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode, DisplayListBuildState}; use euclid::Point2D; use flow; @@ -434,7 +434,7 @@ impl Flow for TableFlow { self.block_flow.assign_block_size_for_table_like_flow(vertical_spacing) } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context) } diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index 9c8aa2b0724..fc28b6c5833 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -8,7 +8,7 @@ use app_units::Au; use block::BlockFlow; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::DisplayListBuildState; use euclid::Point2D; use flow::{Flow, FlowClass, OpaqueFlow}; @@ -66,7 +66,7 @@ impl Flow for TableCaptionFlow { self.block_flow.assign_block_size(layout_context); } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context) } diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index a7778738d29..83c5fb522e3 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -8,7 +8,7 @@ use app_units::Au; use block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag}; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use cssparser::Color; use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode, DisplayListBuildState}; use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; @@ -208,7 +208,7 @@ impl Flow for TableCellFlow { self.assign_block_size_table_cell_base(layout_context); } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context) } diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index cb2f8f76c7c..a941905e5e9 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -8,7 +8,7 @@ use app_units::Au; use block::{BlockFlow, ISizeAndMarginsComputer}; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use cssparser::{Color, RGBA}; use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode, DisplayListBuildState}; use euclid::Point2D; @@ -413,7 +413,7 @@ impl Flow for TableRowFlow { self.assign_block_size_table_row_base(layout_context); } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context) } diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 3422401d20e..bc48a44838b 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -8,7 +8,7 @@ use app_units::Au; use block::{BlockFlow, ISizeAndMarginsComputer}; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::DisplayListBuildState; use euclid::Point2D; use flow::{Flow, FlowClass, OpaqueFlow}; @@ -195,7 +195,7 @@ impl Flow for TableRowGroupFlow { self.block_flow.assign_block_size_for_table_like_flow(self.spacing.vertical) } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context) } diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 8b554ea20b4..e07cee03084 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -16,7 +16,7 @@ use app_units::Au; use block::{AbsoluteNonReplaced, BlockFlow, FloatNonReplaced, ISizeAndMarginsComputer, ISizeConstraintInput}; use block::{ISizeConstraintSolution, MarginsMayCollapseFlag}; -use context::LayoutContext; +use context::{LayoutContext, SharedLayoutContext}; use display_list_builder::DisplayListBuildState; use euclid::Point2D; use floats::FloatKind; @@ -413,7 +413,7 @@ impl Flow for TableWrapperFlow { debug_assert!(remaining.is_none()); } - fn compute_absolute_position(&mut self, layout_context: &LayoutContext) { + fn compute_absolute_position(&mut self, layout_context: &SharedLayoutContext) { self.block_flow.compute_absolute_position(layout_context) } diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index 8e652dde8e9..37d9ed83091 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -204,7 +204,7 @@ pub struct ComputeAbsolutePositions<'a> { impl<'a> PreorderFlowTraversal for ComputeAbsolutePositions<'a> { #[inline] fn process(&self, flow: &mut Flow) { - flow.compute_absolute_position(self.layout_context); + flow.compute_absolute_position(self.layout_context.shared); } } From fd68208da6258a5ec993a6091d8b96dc0ecf3e23 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 23 Aug 2016 18:06:15 +0200 Subject: [PATCH 7/7] Stop creating a LayoutContext in build_display_list_for_subtree. --- components/layout/sequential.rs | 5 ++--- components/layout/traversal.rs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index cbd5954ebee..48a4c3b3889 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -82,14 +82,13 @@ pub fn build_display_list_for_subtree(root: &mut FlowRef, shared_layout_context: &SharedLayoutContext) -> Vec { let flow_root = flow_ref::deref_mut(root); - let layout_context = LayoutContext::new(shared_layout_context); - flow_root.traverse_preorder(&ComputeAbsolutePositions { layout_context: &layout_context }); + flow_root.traverse_preorder(&ComputeAbsolutePositions { layout_context: shared_layout_context }); let mut children = vec![]; flow_root.collect_stacking_contexts(root_stacking_context.id, &mut children); root_stacking_context.add_children(children); let mut build_display_list = BuildDisplayList { - state: DisplayListBuildState::new(&layout_context.shared, + state: DisplayListBuildState::new(shared_layout_context, flow::base(&*flow_root).stacking_context_id), }; build_display_list.traverse(&mut *flow_root); diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index 37d9ed83091..ca35419bc46 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -198,13 +198,13 @@ impl<'a> PostorderFlowTraversal for AssignBSizes<'a> { #[derive(Copy, Clone)] pub struct ComputeAbsolutePositions<'a> { - pub layout_context: &'a LayoutContext<'a>, + pub layout_context: &'a SharedLayoutContext, } impl<'a> PreorderFlowTraversal for ComputeAbsolutePositions<'a> { #[inline] fn process(&self, flow: &mut Flow) { - flow.compute_absolute_position(self.layout_context.shared); + flow.compute_absolute_position(self.layout_context); } }