mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Avoid splitting boxes if possible
This commit is contained in:
parent
d6d36997c6
commit
9efaf831fc
1 changed files with 20 additions and 18 deletions
|
@ -1203,27 +1203,29 @@ impl Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let left_box = if left_range.length() > CharIndex(0) {
|
let left_is_some = left_range.length() > CharIndex(0);
|
||||||
let new_text_box_info = ScannedTextBoxInfo::new(text_box_info.run.clone(), left_range);
|
|
||||||
let width = new_text_box_info.run.advance_for_range(&left_range);
|
|
||||||
let height = self.border_box.size.height;
|
|
||||||
let size = Size2D(width, height);
|
|
||||||
Some(self.transform(size, ScannedTextBox(new_text_box_info)))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let right_box = right_range.map_or(None, |right_range: Range<CharIndex>| {
|
if (pieces_processed_count == 1 || !left_is_some) && !starts_line {
|
||||||
let new_text_box_info = ScannedTextBoxInfo::new(text_box_info.run.clone(), right_range);
|
|
||||||
let width = new_text_box_info.run.advance_for_range(&right_range);
|
|
||||||
let height = self.border_box.size.height;
|
|
||||||
let size = Size2D(width, height);
|
|
||||||
Some(self.transform(size, ScannedTextBox(new_text_box_info)))
|
|
||||||
});
|
|
||||||
|
|
||||||
if (pieces_processed_count == 1 || left_box.is_none()) && !starts_line {
|
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
let left_box = if left_is_some {
|
||||||
|
let new_text_box_info = ScannedTextBoxInfo::new(text_box_info.run.clone(), left_range);
|
||||||
|
let width = new_text_box_info.run.advance_for_range(&left_range);
|
||||||
|
let height = self.border_box.size.height;
|
||||||
|
let size = Size2D(width, height);
|
||||||
|
Some(self.transform(size, ScannedTextBox(new_text_box_info)))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
let right_box = right_range.map(|right_range| {
|
||||||
|
let new_text_box_info = ScannedTextBoxInfo::new(text_box_info.run.clone(), right_range);
|
||||||
|
let width = new_text_box_info.run.advance_for_range(&right_range);
|
||||||
|
let height = self.border_box.size.height;
|
||||||
|
let size = Size2D(width, height);
|
||||||
|
(self.transform(size, ScannedTextBox(new_text_box_info)))
|
||||||
|
});
|
||||||
|
|
||||||
Some((left_box, right_box))
|
Some((left_box, right_box))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue