mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
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.
This commit is contained in:
parent
1807fd3cc5
commit
1695d14a9e
3 changed files with 8 additions and 11 deletions
|
@ -1861,6 +1861,7 @@ fn control_chars_to_fragment(node: &InlineFragmentNodeInfo,
|
||||||
let info = SpecificFragmentInfo::UnscannedText(
|
let info = SpecificFragmentInfo::UnscannedText(
|
||||||
box UnscannedTextFragmentInfo::new(String::from(text), None));
|
box UnscannedTextFragmentInfo::new(String::from(text), None));
|
||||||
let mut style = node.style.clone();
|
let mut style = node.style.clone();
|
||||||
|
properties::modify_style_for_replaced_content(&mut style);
|
||||||
properties::modify_style_for_text(&mut style);
|
properties::modify_style_for_text(&mut style);
|
||||||
Fragment::from_opaque_node_and_style(node.address,
|
Fragment::from_opaque_node_and_style(node.address,
|
||||||
node.pseudo,
|
node.pseudo,
|
||||||
|
|
|
@ -173,6 +173,7 @@ impl TextRunScanner {
|
||||||
let mut insertion_point = None;
|
let mut insertion_point = None;
|
||||||
|
|
||||||
for (fragment_index, in_fragment) in self.clump.iter().enumerate() {
|
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 mut mapping = RunMapping::new(&run_info_list[..], &run_info, fragment_index);
|
||||||
let text;
|
let text;
|
||||||
let selection;
|
let selection;
|
||||||
|
@ -239,7 +240,6 @@ impl TextRunScanner {
|
||||||
mapping.flush(&mut mappings,
|
mapping.flush(&mut mappings,
|
||||||
&mut run_info,
|
&mut run_info,
|
||||||
&**text,
|
&**text,
|
||||||
insertion_point,
|
|
||||||
compression,
|
compression,
|
||||||
text_transform,
|
text_transform,
|
||||||
&mut last_whitespace,
|
&mut last_whitespace,
|
||||||
|
@ -269,7 +269,6 @@ impl TextRunScanner {
|
||||||
mapping.flush(&mut mappings,
|
mapping.flush(&mut mappings,
|
||||||
&mut run_info,
|
&mut run_info,
|
||||||
&**text,
|
&**text,
|
||||||
insertion_point,
|
|
||||||
compression,
|
compression,
|
||||||
text_transform,
|
text_transform,
|
||||||
&mut last_whitespace,
|
&mut last_whitespace,
|
||||||
|
@ -606,15 +605,12 @@ impl RunMapping {
|
||||||
mappings: &mut Vec<RunMapping>,
|
mappings: &mut Vec<RunMapping>,
|
||||||
run_info: &mut RunInfo,
|
run_info: &mut RunInfo,
|
||||||
text: &str,
|
text: &str,
|
||||||
insertion_point: Option<CharIndex>,
|
|
||||||
compression: CompressionMode,
|
compression: CompressionMode,
|
||||||
text_transform: text_transform::T,
|
text_transform: text_transform::T,
|
||||||
last_whitespace: &mut bool,
|
last_whitespace: &mut bool,
|
||||||
start_position: &mut usize,
|
start_position: &mut usize,
|
||||||
end_position: usize) {
|
end_position: usize) {
|
||||||
if *start_position == end_position && insertion_point.is_none() {
|
let was_empty = *start_position == end_position;
|
||||||
return;
|
|
||||||
}
|
|
||||||
let old_byte_length = run_info.text.len();
|
let old_byte_length = run_info.text.len();
|
||||||
*last_whitespace = util::transform_text(&text[(*start_position)..end_position],
|
*last_whitespace = util::transform_text(&text[(*start_position)..end_position],
|
||||||
compression,
|
compression,
|
||||||
|
@ -633,8 +629,11 @@ impl RunMapping {
|
||||||
run_info.character_length = run_info.character_length + character_count;
|
run_info.character_length = run_info.character_length + character_count;
|
||||||
*start_position = end_position;
|
*start_position = end_position;
|
||||||
|
|
||||||
// Don't flush mappings that contain no characters and no insertion_point.
|
// Don't save mappings that contain only discarded characters.
|
||||||
if character_count == 0 && !self.contains_insertion_point(insertion_point) {
|
// (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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bidi-011.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue