mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
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.
This commit is contained in:
parent
1b2daae453
commit
648ce1e44e
18 changed files with 329 additions and 323 deletions
|
@ -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 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue