diff options
author | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-05-23 14:42:17 -0700 |
---|---|---|
committer | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-05-27 09:15:14 -0700 |
commit | d6dba5158a37c0a25fda531bc8ac78c3539dbbfe (patch) | |
tree | a7faf266ffcd62cc4b5b28dc3e78fd5068a5ab9f /src/components/main/layout/inline.rs | |
parent | 7c14d9f2108928a7e9ad1ed38ca8b19a97e74067 (diff) | |
download | servo-d6dba5158a37c0a25fda531bc8ac78c3539dbbfe.tar.gz servo-d6dba5158a37c0a25fda531bc8ac78c3539dbbfe.zip |
Move box splitting by new-line to inline.rs
Diffstat (limited to 'src/components/main/layout/inline.rs')
-rw-r--r-- | src/components/main/layout/inline.rs | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index cc2c0df5ade..527dcc3e651 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -419,18 +419,35 @@ impl LineboxScanner { fn try_append_to_line_by_new_line(&mut self, in_box: Box) -> bool { if in_box.new_line_pos.len() == 0 { - // In case of box does not include new-line character + debug!("LineboxScanner: Did not find a new-line character, so pushing the box to \ + the line without splitting."); self.push_box_to_line(in_box); true } else { - // In case of box includes new-line character + debug!("LineboxScanner: Found a new-line character, so splitting theline."); match in_box.split_by_new_line() { - Some((left_box, Some(right_box))) => { - self.push_box_to_line(left_box); - self.work_list.push_front(right_box); - }, - Some((left_box, None)) => { - self.push_box_to_line(left_box); + Some((left, right, run)) => { + // TODO: Remove box splitting + let split_box = |split: SplitInfo| { + let info = ScannedTextBoxInfo::new(run.clone(), split.range); + let specific = ScannedTextBox(info); + let size = Size2D(split.width, in_box.border_box.size.height); + in_box.transform(size, specific) + }; + + debug!("LineboxScanner: Pushing the box to the left of the new-line character \ + to the line."); + let mut left = split_box(left); + left.new_line_pos = vec!(); + self.push_box_to_line(left); + + right.map(|right| { + debug!("LineboxScanner: Deferring the box to the right of the new-line \ + character to the line."); + let mut right = split_box(right); + right.new_line_pos = in_box.new_line_pos.clone(); + self.work_list.push_front(right); + }); }, None => { error!("LineboxScanner: This split case makes no sense!") |