From 648ce1e44e65b194184b713e8b47695d5ff17921 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Thu, 15 Dec 2016 16:00:40 -0800 Subject: Make the DomTraversalContext own the SharedStyleContext and share it immutably across the traversal. This allows us to get rid of a bunch of lifetimes and simplify a lot of code. It also lets us get rid of that nasty lifetime transmute, which is awesome. The situation with thread-local contexts is still suboptimal, but we fix that in subsequent patches. --- components/layout/sequential.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'components/layout/sequential.rs') diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index b4d31269629..e5f62fe1cea 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -5,7 +5,7 @@ //! Implements sequential traversals over the DOM and flow trees. use app_units::Au; -use context::{LayoutContext, SharedLayoutContext}; +use context::{LayoutContext, SharedLayoutContext, ThreadLocalLayoutContext}; use display_list_builder::DisplayListBuildState; use euclid::point::Point2D; use floats::SpeculatedFloatPlacement; @@ -16,13 +16,12 @@ use fragment::FragmentBorderBoxIterator; use generated_content::ResolveGeneratedContent; use gfx_traits::ScrollRootId; use servo_config::opts; -use style::context::StyleContext; use style::servo::restyle_damage::{REFLOW, STORE_OVERFLOW}; use traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList}; pub use style::sequential::traverse_dom; -pub fn resolve_generated_content(root: &mut Flow, shared_layout_context: &SharedLayoutContext) { +pub fn resolve_generated_content(root: &mut Flow, shared: &SharedLayoutContext) { fn doit(flow: &mut Flow, level: u32, traversal: &mut ResolveGeneratedContent) { if !traversal.should_process(flow) { return @@ -35,13 +34,14 @@ pub fn resolve_generated_content(root: &mut Flow, shared_layout_context: &Shared } } - let layout_context = LayoutContext::new(shared_layout_context); + let tlc = ThreadLocalLayoutContext::new(shared); + let layout_context = LayoutContext::new(shared, &*tlc); let mut traversal = ResolveGeneratedContent::new(&layout_context); doit(root, 0, &mut traversal) } pub fn traverse_flow_tree_preorder(root: &mut Flow, - shared_layout_context: &SharedLayoutContext) { + shared: &SharedLayoutContext) { fn doit(flow: &mut Flow, assign_inline_sizes: AssignISizes, assign_block_sizes: AssignBSizes) { @@ -58,7 +58,8 @@ pub fn traverse_flow_tree_preorder(root: &mut Flow, } } - let layout_context = LayoutContext::new(shared_layout_context); + let tlc = ThreadLocalLayoutContext::new(shared); + let layout_context = LayoutContext::new(shared, &*tlc); if opts::get().bubble_inline_sizes_separately { let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context }; -- cgit v1.2.3