mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Use Option::expect instead of pattern matching in try_append_to_line_by_new_line
This commit is contained in:
parent
344af248e7
commit
762669b5c6
1 changed files with 22 additions and 25 deletions
|
@ -477,33 +477,30 @@ impl LineBreaker {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
debug!("LineBreaker: Found a new-line character, so splitting theline.");
|
debug!("LineBreaker: Found a new-line character, so splitting theline.");
|
||||||
match in_fragment.find_split_info_by_new_line() {
|
|
||||||
Some((left, right, run)) => {
|
|
||||||
// TODO(bjz): Remove fragment splitting
|
|
||||||
let split_fragment = |split: SplitInfo| {
|
|
||||||
let info = ScannedTextFragmentInfo::new(run.clone(), split.range);
|
|
||||||
let specific = ScannedTextFragment(info);
|
|
||||||
let size = Size2D(split.width, in_fragment.border_box.size.height);
|
|
||||||
in_fragment.transform(size, specific)
|
|
||||||
};
|
|
||||||
|
|
||||||
debug!("LineBreaker: Pushing the fragment to the left of the new-line character \
|
let (left, right, run) = in_fragment.find_split_info_by_new_line()
|
||||||
to the line.");
|
.expect("LineBreaker: This split case makes no sense!");
|
||||||
let mut left = split_fragment(left);
|
|
||||||
left.new_line_pos = vec!();
|
|
||||||
self.push_fragment_to_line(left);
|
|
||||||
|
|
||||||
for right in right.move_iter() {
|
// TODO(bjz): Remove fragment splitting
|
||||||
debug!("LineBreaker: Deferring the fragment to the right of the new-line \
|
let split_fragment = |split: SplitInfo| {
|
||||||
character to the line.");
|
let info = ScannedTextFragmentInfo::new(run.clone(), split.range);
|
||||||
let mut right = split_fragment(right);
|
let specific = ScannedTextFragment(info);
|
||||||
right.new_line_pos = in_fragment.new_line_pos.clone();
|
let size = Size2D(split.width, in_fragment.border_box.size.height);
|
||||||
self.work_list.push_front(right);
|
in_fragment.transform(size, specific)
|
||||||
}
|
};
|
||||||
},
|
|
||||||
None => {
|
debug!("LineBreaker: Pushing the fragment to the left of the new-line character \
|
||||||
error!("LineBreaker: This split case makes no sense!")
|
to the line.");
|
||||||
},
|
let mut left = split_fragment(left);
|
||||||
|
left.new_line_pos = vec![];
|
||||||
|
self.push_fragment_to_line(left);
|
||||||
|
|
||||||
|
for right in right.move_iter() {
|
||||||
|
debug!("LineBreaker: Deferring the fragment to the right of the new-line \
|
||||||
|
character to the line.");
|
||||||
|
let mut right = split_fragment(right);
|
||||||
|
right.new_line_pos = in_fragment.new_line_pos.clone();
|
||||||
|
self.work_list.push_front(right);
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue