mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
auto merge of #5062 : Adenilson/servo/printDisplayList01, r=pcwalton
This patch will iterate through the DisplayList after the reflow is done and print its elements (as also any sub-lists associated to a child node stacking context).
This commit is contained in:
commit
67b78983db
3 changed files with 59 additions and 0 deletions
|
@ -148,6 +148,53 @@ impl DisplayList {
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print the display list. Only makes sense to call it after performing reflow.
|
||||||
|
pub fn print_items(&self, mut indentation: String) {
|
||||||
|
let min_length = 4;
|
||||||
|
// We cover the case of an empty string.
|
||||||
|
if indentation.len() == 0 {
|
||||||
|
indentation = String::from_str("####");
|
||||||
|
}
|
||||||
|
|
||||||
|
// We grow the indentation by 4 characters if needed.
|
||||||
|
// I wish to push it all as a slice, but it won't work if the string is a single char.
|
||||||
|
while indentation.len() < min_length {
|
||||||
|
let c = indentation.char_at(0);
|
||||||
|
indentation.push(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closures are so nice!
|
||||||
|
let doit = |items: &Vec<DisplayItem>| {
|
||||||
|
for item in items.iter() {
|
||||||
|
match *item {
|
||||||
|
// TODO(savago): would be nice to have other information associated with
|
||||||
|
// each display item (e.g. coordinates?).
|
||||||
|
DisplayItem::SolidColorClass(ref solid_color) => println!("{} SolidColor.", indentation),
|
||||||
|
DisplayItem::TextClass(ref text) => println!("{} TextClass.", indentation),
|
||||||
|
DisplayItem::ImageClass(ref image_item) => println!("{} ImageClass.", indentation),
|
||||||
|
DisplayItem::BorderClass(ref image_item) => println!("{} BorderClass.", indentation),
|
||||||
|
DisplayItem::GradientClass(ref image_item) => println!("{} GradientClass.", indentation),
|
||||||
|
DisplayItem::LineClass(ref line_item) => println!("{} LineClass.", indentation),
|
||||||
|
DisplayItem::BoxShadowClass(ref box_shadow_item) => println!("{} BoxShadowClass.", indentation),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
doit(&(self.all_display_items()));
|
||||||
|
if self.children.len() != 0 {
|
||||||
|
println!("{} Children stacking contexts list length: {}", indentation, self.children.len());
|
||||||
|
for subitem in self.children.iter() {
|
||||||
|
doit(&subitem.display_list.all_display_items());
|
||||||
|
if subitem.display_list.children.len() != 0 {
|
||||||
|
// Rant: String doesn't have a substr() method that won't overflow if the
|
||||||
|
// selected range is bigger than the string length.
|
||||||
|
subitem.display_list.print_items(indentation.clone()+indentation.slice(0, min_length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents one CSS stacking context, which may or may not have a hardware layer.
|
/// Represents one CSS stacking context, which may or may not have a hardware layer.
|
||||||
|
|
|
@ -709,6 +709,12 @@ impl LayoutTask {
|
||||||
color,
|
color,
|
||||||
ScrollPolicy::Scrollable));
|
ScrollPolicy::Scrollable));
|
||||||
let origin = Rect(Point2D(Au(0), Au(0)), root_size);
|
let origin = Rect(Point2D(Au(0), Au(0)), root_size);
|
||||||
|
|
||||||
|
if opts::get().dump_display_list {
|
||||||
|
println!("#### start printing display list.");
|
||||||
|
display_list.print_items(String::from_str("#"));
|
||||||
|
}
|
||||||
|
|
||||||
let stacking_context = Arc::new(StackingContext::new(display_list,
|
let stacking_context = Arc::new(StackingContext::new(display_list,
|
||||||
&origin,
|
&origin,
|
||||||
&origin,
|
&origin,
|
||||||
|
|
|
@ -110,6 +110,9 @@ pub struct Opts {
|
||||||
/// Dumps the flow tree after a layout.
|
/// Dumps the flow tree after a layout.
|
||||||
pub dump_flow_tree: bool,
|
pub dump_flow_tree: bool,
|
||||||
|
|
||||||
|
/// Dumps the flow tree after a layout.
|
||||||
|
pub dump_display_list: bool,
|
||||||
|
|
||||||
/// Whether to show an error when display list geometry escapes flow overflow regions.
|
/// Whether to show an error when display list geometry escapes flow overflow regions.
|
||||||
pub validate_display_list_geometry: bool,
|
pub validate_display_list_geometry: bool,
|
||||||
|
|
||||||
|
@ -132,6 +135,7 @@ pub fn print_debug_usage(app: &str) {
|
||||||
print_option("bubble-widths", "Bubble intrinsic widths separately like other engines.");
|
print_option("bubble-widths", "Bubble intrinsic widths separately like other engines.");
|
||||||
print_option("disable-text-aa", "Disable antialiasing of rendered text.");
|
print_option("disable-text-aa", "Disable antialiasing of rendered text.");
|
||||||
print_option("dump-flow-tree", "Print the flow tree after each layout.");
|
print_option("dump-flow-tree", "Print the flow tree after each layout.");
|
||||||
|
print_option("dump-display-list", "Print the display list after each layout.");
|
||||||
print_option("profile-tasks", "Instrument each task, writing the output to a file.");
|
print_option("profile-tasks", "Instrument each task, writing the output to a file.");
|
||||||
print_option("show-compositor-borders", "Paint borders along layer and tile boundaries.");
|
print_option("show-compositor-borders", "Paint borders along layer and tile boundaries.");
|
||||||
print_option("show-fragment-borders", "Paint borders along fragment boundaries.");
|
print_option("show-fragment-borders", "Paint borders along fragment boundaries.");
|
||||||
|
@ -183,6 +187,7 @@ pub fn default_opts() -> Opts {
|
||||||
initial_window_size: TypedSize2D(800, 600),
|
initial_window_size: TypedSize2D(800, 600),
|
||||||
user_agent: None,
|
user_agent: None,
|
||||||
dump_flow_tree: false,
|
dump_flow_tree: false,
|
||||||
|
dump_display_list: false,
|
||||||
validate_display_list_geometry: false,
|
validate_display_list_geometry: false,
|
||||||
profile_tasks: false,
|
profile_tasks: false,
|
||||||
resources_path: None,
|
resources_path: None,
|
||||||
|
@ -330,6 +335,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
||||||
show_debug_parallel_layout: debug_options.contains(&"show-parallel-layout"),
|
show_debug_parallel_layout: debug_options.contains(&"show-parallel-layout"),
|
||||||
enable_text_antialiasing: !debug_options.contains(&"disable-text-aa"),
|
enable_text_antialiasing: !debug_options.contains(&"disable-text-aa"),
|
||||||
dump_flow_tree: debug_options.contains(&"dump-flow-tree"),
|
dump_flow_tree: debug_options.contains(&"dump-flow-tree"),
|
||||||
|
dump_display_list: debug_options.contains(&"dump-display-list"),
|
||||||
validate_display_list_geometry: debug_options.contains(&"validate-display-list-geometry"),
|
validate_display_list_geometry: debug_options.contains(&"validate-display-list-geometry"),
|
||||||
resources_path: opt_match.opt_str("resources-path"),
|
resources_path: opt_match.opt_str("resources-path"),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue