Skip to content
Permalink
Browse files

Properly use STYLE_THREAD_POOL in layout 2020

  • Loading branch information
nox committed Nov 20, 2019
1 parent 1446756 commit 6f49dc23565b2041930f9ddf18779511bfc70de1
Showing with 12 additions and 11 deletions.
  1. +12 −11 components/layout_thread_2020/lib.rs
@@ -88,7 +88,7 @@ use style::context::{SharedStyleContext, ThreadLocalStyleContextCreationInfo};
use style::dom::{TDocument, TElement, TNode};
use style::driver;
use style::error_reporting::RustLogReporter;
use style::global_style_data::GLOBAL_STYLE_DATA;
use style::global_style_data::{GLOBAL_STYLE_DATA, STYLE_THREAD_POOL};
use style::invalidation::element::restyle_hints::RestyleHint;
use style::media_queries::{Device, MediaList, MediaType};
use style::properties::PropertyId;
@@ -1087,28 +1087,29 @@ impl LayoutThread {
RecalcStyle::pre_traverse(element, shared)
};

let rayon_pool = STYLE_THREAD_POOL.pool();
let rayon_pool = rayon_pool.as_ref().unwrap();

let box_tree = if token.should_traverse() {
driver::traverse_dom(&traversal, token, None);

let shared = DomTraversal::<ServoLayoutElement>::shared_context(&traversal);
Some(BoxTreeRoot::construct(
shared,
document.root_element().unwrap().as_node(),
))
let root_node = document.root_element().unwrap().as_node();
let box_tree = rayon_pool.install(|| BoxTreeRoot::construct(shared, root_node));
Some(box_tree)
} else {
None
};

layout_context = traversal.destroy();

if let Some(box_tree) = box_tree {
let fragment_tree = box_tree.layout(
&layout_context,
Size2D::new(
self.viewport_size.width.to_f32_px(),
self.viewport_size.height.to_f32_px(),
),
let viewport_size = Size2D::new(
self.viewport_size.width.to_f32_px(),
self.viewport_size.height.to_f32_px(),
);
let fragment_tree =
rayon_pool.install(|| box_tree.layout(&layout_context, viewport_size));
*self.box_tree_root.borrow_mut() = Some(box_tree);
*self.fragment_tree_root.borrow_mut() = Some(fragment_tree);
}

0 comments on commit 6f49dc2

Please sign in to comment.
You can’t perform that action at this time.