Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start implementing text in layout 2020 #24822

Merged
merged 6 commits into from Nov 25, 2019

Properly use STYLE_THREAD_POOL in layout 2020

  • Loading branch information
nox committed Nov 25, 2019
commit 6f49dc23565b2041930f9ddf18779511bfc70de1
@@ -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);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.