mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Add layout debugger support to layout_2020
This commit is contained in:
parent
9c3feb746b
commit
5cbe05366b
8 changed files with 186 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue