aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-02-25 20:15:56 -0700
committerbors-servo <metajack+bors@gmail.com>2015-02-25 20:15:56 -0700
commit67b78983db31128604339e2fd7f391e878cf9f9b (patch)
tree11b73307dcab8b0a6874af41f46e1363d20b57a1
parent259792e4818c6356a87d8375503feff9f837cf21 (diff)
parentb9e9d7471d12079c3c2d7970b21bd56a1460ee78 (diff)
downloadservo-67b78983db31128604339e2fd7f391e878cf9f9b.tar.gz
servo-67b78983db31128604339e2fd7f391e878cf9f9b.zip
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).
-rw-r--r--components/gfx/display_list/mod.rs47
-rw-r--r--components/layout/layout_task.rs6
-rw-r--r--components/util/opts.rs6
3 files changed, 59 insertions, 0 deletions
diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs
index 50aa8b0867b..e9e230bd968 100644
--- a/components/gfx/display_list/mod.rs
+++ b/components/gfx/display_list/mod.rs
@@ -148,6 +148,53 @@ impl DisplayList {
}
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.
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs
index 3d2bc463cdc..1b043c3d26b 100644
--- a/components/layout/layout_task.rs
+++ b/components/layout/layout_task.rs
@@ -709,6 +709,12 @@ impl LayoutTask {
color,
ScrollPolicy::Scrollable));
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,
&origin,
&origin,
diff --git a/components/util/opts.rs b/components/util/opts.rs
index baad6654b8b..b64fe4e8f46 100644
--- a/components/util/opts.rs
+++ b/components/util/opts.rs
@@ -110,6 +110,9 @@ pub struct Opts {
/// Dumps the flow tree after a layout.
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.
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("disable-text-aa", "Disable antialiasing of rendered text.");
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("show-compositor-borders", "Paint borders along layer and tile 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),
user_agent: None,
dump_flow_tree: false,
+ dump_display_list: false,
validate_display_list_geometry: false,
profile_tasks: false,
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"),
enable_text_antialiasing: !debug_options.contains(&"disable-text-aa"),
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"),
resources_path: opt_match.opt_str("resources-path"),
};