aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/sequential.rs
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2016-12-15 16:00:40 -0800
committerBobby Holley <bobbyholley@gmail.com>2016-12-16 10:57:27 -0800
commit648ce1e44e65b194184b713e8b47695d5ff17921 (patch)
tree94a20912b289dd1799cc017720f6daf83ed6d121 /components/layout/sequential.rs
parent1b2daae453e9276977059fd51c9b733e6400f35c (diff)
downloadservo-648ce1e44e65b194184b713e8b47695d5ff17921.tar.gz
servo-648ce1e44e65b194184b713e8b47695d5ff17921.zip
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.
Diffstat (limited to 'components/layout/sequential.rs')
-rw-r--r--components/layout/sequential.rs13
1 files changed, 7 insertions, 6 deletions
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 };