From 1695d14a9e248edb3f51856d25a35a96861e251e Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 15 Apr 2016 16:00:07 -0700 Subject: [PATCH] Don't strip out all empty fragments Empty fragments may need to be layed out to draw borders, padding/background, and insertion points. (Fragments that consist of discardable whitespace and control characters, on the other hand, can still be discarded.) This ends up preserving some useless empty fragments. It's possible we could avoid this by storing some sort of flag on "important" empty fragments, so we can discard the rest. --- components/layout/construct.rs | 1 + components/layout/text.rs | 15 +++++++-------- .../metadata-css/css21_dev/html4/bidi-011.htm.ini | 3 --- 3 files changed, 8 insertions(+), 11 deletions(-) delete mode 100644 tests/wpt/metadata-css/css21_dev/html4/bidi-011.htm.ini diff --git a/components/layout/construct.rs b/components/layout/construct.rs index dd8b7ec0756..ee961942300 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -1861,6 +1861,7 @@ fn control_chars_to_fragment(node: &InlineFragmentNodeInfo, let info = SpecificFragmentInfo::UnscannedText( box UnscannedTextFragmentInfo::new(String::from(text), None)); let mut style = node.style.clone(); + properties::modify_style_for_replaced_content(&mut style); properties::modify_style_for_text(&mut style); Fragment::from_opaque_node_and_style(node.address, node.pseudo, diff --git a/components/layout/text.rs b/components/layout/text.rs index da89ae495b8..22fbeb9ad1a 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -173,6 +173,7 @@ impl TextRunScanner { let mut insertion_point = None; for (fragment_index, in_fragment) in self.clump.iter().enumerate() { + debug!(" flushing {:?}", in_fragment); let mut mapping = RunMapping::new(&run_info_list[..], &run_info, fragment_index); let text; let selection; @@ -239,7 +240,6 @@ impl TextRunScanner { mapping.flush(&mut mappings, &mut run_info, &**text, - insertion_point, compression, text_transform, &mut last_whitespace, @@ -269,7 +269,6 @@ impl TextRunScanner { mapping.flush(&mut mappings, &mut run_info, &**text, - insertion_point, compression, text_transform, &mut last_whitespace, @@ -606,15 +605,12 @@ impl RunMapping { mappings: &mut Vec, run_info: &mut RunInfo, text: &str, - insertion_point: Option, compression: CompressionMode, text_transform: text_transform::T, last_whitespace: &mut bool, start_position: &mut usize, end_position: usize) { - if *start_position == end_position && insertion_point.is_none() { - return; - } + let was_empty = *start_position == end_position; let old_byte_length = run_info.text.len(); *last_whitespace = util::transform_text(&text[(*start_position)..end_position], compression, @@ -633,8 +629,11 @@ impl RunMapping { run_info.character_length = run_info.character_length + character_count; *start_position = end_position; - // Don't flush mappings that contain no characters and no insertion_point. - if character_count == 0 && !self.contains_insertion_point(insertion_point) { + // Don't save mappings that contain only discarded characters. + // (But keep ones that contained no characters to begin with, since they might have been + // generated by an empty flow to draw its borders/padding/insertion point.) + let is_empty = character_count == 0; + if is_empty && !was_empty { return; } diff --git a/tests/wpt/metadata-css/css21_dev/html4/bidi-011.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/bidi-011.htm.ini deleted file mode 100644 index 01a83ba5f16..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/bidi-011.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[bidi-011.htm] - type: reftest - expected: FAIL