diff options
author | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2020-02-11 18:50:54 +0100 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2020-02-21 11:11:00 +0100 |
commit | 5cbe05366bf11de3bb38e89a3d2ae2aacfadf2b6 (patch) | |
tree | b57e0fb695be560d35fdc347387f1d07c323c212 /components/layout_thread_2020/lib.rs | |
parent | 9c3feb746b5039339cb4e20aff9a3f72f2963170 (diff) | |
download | servo-5cbe05366bf11de3bb38e89a3d2ae2aacfadf2b6.tar.gz servo-5cbe05366bf11de3bb38e89a3d2ae2aacfadf2b6.zip |
Add layout debugger support to layout_2020
Diffstat (limited to 'components/layout_thread_2020/lib.rs')
-rw-r--r-- | components/layout_thread_2020/lib.rs | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index be24d768595..6a2ba3b706b 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -36,6 +36,7 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use layout::context::LayoutContext; use layout::display_list::{DisplayListBuilder, WebRenderImageInfo}; +use layout::layout_debug; use layout::query::{ process_content_box_request, process_content_boxes_request, LayoutRPCImpl, LayoutThreadData, }; @@ -175,7 +176,7 @@ pub struct LayoutThread { box_tree_root: RefCell<Option<BoxTreeRoot>>, /// The root of the fragment tree. - fragment_tree_root: RefCell<Option<FragmentTreeRoot>>, + fragment_tree_root: RefCell<Option<Arc<FragmentTreeRoot>>>, /// The document-specific shared lock used for author-origin stylesheets document_shared_lock: Option<SharedRwLock>, @@ -234,6 +235,10 @@ pub struct LayoutThread { /// Emits notifications when there is a relayout. relayout_event: bool, + + /// True if each step of layout is traced to an external JSON file + /// for debugging purposes. + trace_layout: bool, } impl LayoutThreadFactory for LayoutThread { @@ -266,7 +271,7 @@ impl LayoutThreadFactory for LayoutThread { dump_rule_tree: bool, relayout_event: bool, _nonincremental_layout: bool, - _trace_layout: bool, + trace_layout: bool, dump_flow_tree: bool, ) { thread::Builder::new() @@ -314,6 +319,7 @@ impl LayoutThreadFactory for LayoutThread { dump_style_tree, dump_rule_tree, dump_flow_tree, + trace_layout, ); let reporter_name = format!("layout-reporter-{}", id); @@ -482,6 +488,7 @@ impl LayoutThread { dump_style_tree: bool, dump_rule_tree: bool, dump_flow_tree: bool, + trace_layout: bool, ) -> LayoutThread { // Let webrender know about this pipeline by sending an empty display list. webrender_api_sender.send_initial_transaction(webrender_document, id.to_webrender()); @@ -567,6 +574,7 @@ impl LayoutThread { dump_style_tree, dump_rule_tree, dump_flow_tree, + trace_layout, } } @@ -866,9 +874,9 @@ impl LayoutThread { self.dump_style_tree, self.dump_rule_tree, self.relayout_event, - true, // nonincremental_layout - false, // trace_layout - self.dump_flow_tree, + true, // nonincremental_layout + self.trace_layout, // trace_layout + self.dump_flow_tree, // dump_flow_tree ); } @@ -1165,7 +1173,7 @@ impl LayoutThread { run_layout() }; *self.box_tree_root.borrow_mut() = Some(box_tree); - *self.fragment_tree_root.borrow_mut() = Some(fragment_tree); + *self.fragment_tree_root.borrow_mut() = Some(Arc::new(fragment_tree)); } for element in elements_with_snapshot { @@ -1195,7 +1203,7 @@ impl LayoutThread { // Perform post-style recalculation layout passes. if let Some(root) = &*self.fragment_tree_root.borrow() { self.perform_post_style_recalc_layout_passes( - root, + root.clone(), &data.reflow_goal, Some(&document), &mut layout_context, @@ -1358,7 +1366,7 @@ impl LayoutThread { let mut layout_context = self.build_layout_context(guards, false, &snapshots, origin); self.perform_post_style_recalc_layout_passes( - root, + root.clone(), &ReflowGoal::TickAnimations, None, &mut layout_context, @@ -1369,7 +1377,7 @@ impl LayoutThread { fn perform_post_style_recalc_layout_passes( &self, - fragment_tree: &FragmentTreeRoot, + fragment_tree: Arc<FragmentTreeRoot>, reflow_goal: &ReflowGoal, document: Option<&ServoLayoutDocument>, context: &mut LayoutContext, @@ -1384,6 +1392,11 @@ impl LayoutThread { .needs_paint_from_layout(); return; } + + if self.trace_layout { + layout_debug::begin_trace(fragment_tree.clone()); + } + if let Some(document) = document { document.will_paint(); } @@ -1426,6 +1439,10 @@ impl LayoutThread { display_list.wr.finalize(), ); + if self.trace_layout { + layout_debug::end_trace(self.generation.get()); + } + self.generation.set(self.generation.get() + 1); } |