From 277cbf407e86a73ca8a6f6382af4fe4771b33199 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 19 Aug 2015 16:30:00 -0700 Subject: [PATCH] gfx: Sort layers according to their Z-index value before handing them off to the compositor. Closes #7166. --- components/gfx/paint_task.rs | 8 ++++++++ tests/ref/basic.list | 1 + tests/ref/layerization_z_order_a.html | 26 +++++++++++++++++++++++++ tests/ref/layerization_z_order_ref.html | 22 +++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 tests/ref/layerization_z_order_a.html create mode 100644 tests/ref/layerization_z_order_ref.html diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 175a7b040f1..26c5308ae3e 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -27,6 +27,7 @@ use msg::constellation_msg::PipelineExitType; use profile_traits::mem::{self, ReportsChan}; use profile_traits::time::{self, profile}; use rand::{self, Rng}; +use smallvec::SmallVec; use skia::gl_context::GLContext; use std::borrow::ToOwned; use std::mem as std_mem; @@ -393,7 +394,14 @@ impl PaintTask where C: PaintListener + Send + 'static { } }; + // Sort positioned children according to z-index. + let mut positioned_children: SmallVec<[Arc; 8]> = SmallVec::new(); for kid in &stacking_context.display_list.children { + positioned_children.push((*kid).clone()); + } + positioned_children.sort_by(|this, other| this.z_index.cmp(&other.z_index)); + + for kid in positioned_children.iter() { build(properties, &**kid, &page_position, &transform, &perspective, next_parent_id) } } diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 72f98ee3402..14d9ae7ab9d 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -191,6 +191,7 @@ experimental == iframe/size_attributes_vertical_writing_mode.html iframe/size_at == jumpiness_a.html jumpiness_ref.html == last_child_pseudo_a.html last_child_pseudo_b.html == last_of_type_pseudo_a.html last_of_type_pseudo_b.html +== layerization_z_order_a.html layerization_z_order_ref.html == legacy_cellspacing_attribute_a.html border_spacing_ref.html == legacy_input_size_attribute_override_a.html legacy_input_size_attribute_override_ref.html == legacy_table_border_attribute_a.html legacy_table_border_attribute_ref.html diff --git a/tests/ref/layerization_z_order_a.html b/tests/ref/layerization_z_order_a.html new file mode 100644 index 00000000000..8056764dfb1 --- /dev/null +++ b/tests/ref/layerization_z_order_a.html @@ -0,0 +1,26 @@ + +
+
+
+ diff --git a/tests/ref/layerization_z_order_ref.html b/tests/ref/layerization_z_order_ref.html new file mode 100644 index 00000000000..3fedaf228d2 --- /dev/null +++ b/tests/ref/layerization_z_order_ref.html @@ -0,0 +1,22 @@ + +
+
+