From 040c09fbc51ac282b7224799851d62cd3a60ee7f Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 17 Sep 2015 08:36:27 -0700 Subject: [PATCH 1/2] Always reset HAS_NEWLY_CONSTRUCTED_FLOW during flow construction This extra reflows when the HAS_NEWLY_CONSTRUCTED_FLOW flag remained set during a later reflow. This masked other incremental layout bugs, including the one tested by the reftest in the commit following this one. --- components/layout/construct.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/layout/construct.rs b/components/layout/construct.rs index dd1d58a6acc..d7e1628dd38 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -1296,10 +1296,9 @@ impl<'a> FlowConstructor<'a> { pub fn repair_if_possible(&mut self, node: &ThreadSafeLayoutNode) -> bool { // We can skip reconstructing the flow if we don't have to reconstruct and none of our kids // did either. - if node.restyle_damage().contains(RECONSTRUCT_FLOW) { - return false - } - + // + // We visit the kids first and reset their HAS_NEWLY_CONSTRUCTED_FLOW flags after checking + // them. NOTE: Make sure not to bail out early before resetting all the flags! let mut need_to_reconstruct = false; for kid in node.children() { if kid.flags().contains(HAS_NEWLY_CONSTRUCTED_FLOW) { @@ -1311,6 +1310,11 @@ impl<'a> FlowConstructor<'a> { return false } + if node.restyle_damage().contains(RECONSTRUCT_FLOW) { + return false + } + + let mut style = node.style().clone(); let mut layout_data_ref = node.mutate_layout_data(); let layout_data = layout_data_ref.as_mut().expect("no layout data"); From 0c77705f522fe74c4d5df91474226fa5b3b1e5a2 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 17 Sep 2015 04:46:32 -0700 Subject: [PATCH 2/2] Reconstruct flows when text/font/list styles change Fixes #6501. --- components/layout/incremental.rs | 15 ++++++++++++--- tests/ref/basic.list | 1 + tests/ref/incremental_letter_spacing_a.html | 15 +++++++++++++++ tests/ref/incremental_letter_spacing_ref.html | 10 ++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 tests/ref/incremental_letter_spacing_a.html create mode 100644 tests/ref/incremental_letter_spacing_ref.html diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs index 14205b32cb5..adabc4bb471 100644 --- a/components/layout/incremental.rs +++ b/components/layout/incremental.rs @@ -175,13 +175,22 @@ pub fn compute_damage(old: &Option>, new: &ComputedValues) - get_padding.padding_top, get_padding.padding_right, get_padding.padding_bottom, get_padding.padding_left, get_box.width, get_box.height, - get_font.font_family, get_font.font_size, get_font.font_style, get_font.font_weight, get_inheritedtext.text_align, get_text.text_decoration, get_inheritedbox.line_height ]); add_if_not_equal!(old, new, damage, - [ REPAINT, BUBBLE_ISIZES, REFLOW_OUT_OF_FLOW, REFLOW, RECONSTRUCT_FLOW ], - [ get_box.float, get_box.display, get_box.position ]); + [ REPAINT, BUBBLE_ISIZES, REFLOW_OUT_OF_FLOW, REFLOW, RECONSTRUCT_FLOW ], [ + get_box.float, get_box.display, get_box.position, get_box.content, + get_counters.counter_reset, get_counters.counter_increment, + get_list.quotes, get_list.list_style_type, + + // If these text or font properties change, we need to reconstruct the flow so that + // text shaping is re-run. + get_inheritedtext.letter_spacing, get_inheritedtext.text_rendering, + get_inheritedtext.text_transform, get_inheritedtext.word_spacing, + get_font.font_family, get_font.font_style, get_font.font_variant, get_font.font_weight, + get_font.font_size, get_font.font_stretch + ]); // FIXME: test somehow that we checked every CSS property damage diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 65ae2cce853..311a02b86c9 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -160,6 +160,7 @@ prefs:"layout.writing-mode.enabled" == iframe/size_attributes_vertical_writing_m == img_width_style_intrinsic_width_a.html img_width_style_intrinsic_width_ref.html == incremental_float_a.html incremental_float_ref.html == incremental_inline_layout_a.html incremental_inline_layout_ref.html +== incremental_letter_spacing_a.html incremental_letter_spacing_ref.html == inline_absolute_hypothetical_clip_a.html inline_absolute_hypothetical_clip_ref.html == inline_absolute_out_of_flow_a.html inline_absolute_out_of_flow_ref.html != inline_background_a.html inline_background_ref.html diff --git a/tests/ref/incremental_letter_spacing_a.html b/tests/ref/incremental_letter_spacing_a.html new file mode 100644 index 00000000000..351cd100d05 --- /dev/null +++ b/tests/ref/incremental_letter_spacing_a.html @@ -0,0 +1,15 @@ + + + + + Incremental layout letter-spacing test + + +

Hello, world!

+ + + diff --git a/tests/ref/incremental_letter_spacing_ref.html b/tests/ref/incremental_letter_spacing_ref.html new file mode 100644 index 00000000000..0c1f3004bdd --- /dev/null +++ b/tests/ref/incremental_letter_spacing_ref.html @@ -0,0 +1,10 @@ + + + + + Incremental layout letter-spacing reference + + +

Hello, world!

+ +