Introduce and use Scoped TLS.

It turns out that it's problematic to embed ThreadLocalStyleContext within
LayoutContext, because parameterizing the former on TElement (which we do
in the next patch) infects all the traversal stuff with the trait parameters,
which we don't really want.

In general, it probably makes sense to use separate scoped TLS types for
the separate DOM and Flow tree passes, so we can add a different ScopedTLS
type for the Flow pass if we ever need it.

We also reorder the |scope| and |shared| parameters in parallel.rs, because
it aligns more with the order in style/parallel.rs. I did this when I was
adding a TLS parameter to all these functions, which I realized we don't need
for now.
This commit is contained in:
Bobby Holley 2016-12-16 11:50:11 -08:00
parent 8f7f62f810
commit c5f01fe3b8
16 changed files with 212 additions and 205 deletions

View file

@ -5,7 +5,7 @@
//! Implements sequential traversals over the DOM and flow trees.
use app_units::Au;
use context::{LayoutContext, SharedLayoutContext, ThreadLocalLayoutContext};
use context::{LayoutContext, SharedLayoutContext};
use display_list_builder::DisplayListBuildState;
use euclid::point::Point2D;
use floats::SpeculatedFloatPlacement;
@ -34,8 +34,7 @@ pub fn resolve_generated_content(root: &mut Flow, shared: &SharedLayoutContext)
}
}
let tlc = ThreadLocalLayoutContext::new(shared);
let layout_context = LayoutContext::new(shared, &*tlc);
let layout_context = LayoutContext::new(shared);
let mut traversal = ResolveGeneratedContent::new(&layout_context);
doit(root, 0, &mut traversal)
}
@ -58,8 +57,7 @@ pub fn traverse_flow_tree_preorder(root: &mut Flow,
}
}
let tlc = ThreadLocalLayoutContext::new(shared);
let layout_context = LayoutContext::new(shared, &*tlc);
let layout_context = LayoutContext::new(shared);
if opts::get().bubble_inline_sizes_separately {
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };