From 6b8d46dc857caac5f19a645184de1741eba80664 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Thu, 22 May 2014 10:51:08 -0700 Subject: [PATCH 1/8] Move some of the box splitting logic into inline.rs --- src/components/main/layout/box_.rs | 38 +++++++++++++++------------- src/components/main/layout/inline.rs | 17 +++++++++++-- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs index 125817264f1..fbf805bb1c0 100644 --- a/src/components/main/layout/box_.rs +++ b/src/components/main/layout/box_.rs @@ -1131,12 +1131,22 @@ impl Box { } } - /// Attempts to split this box so that its width is no more than `max_width`. + /// Attempts to find the split positions of a text box so that its width is + /// no more than `max_width`. /// /// A return value of `None` indicates that the box could not be split. - /// Otherwise the split boxes are returned. The left and right boxes are - /// optional due to the possibility of them being whitespace. - pub fn split_to_width(&self, max_width: Au, starts_line: bool) -> Option<(Option, Option)> { + /// Otherwise tuples of the width of the splits, the index into the text + /// boxes to the left and right side of the split, and the respective text + /// box info are returned. The left and right boxes are optional due to the + /// possibility of them being whitespace. + /// + // TODO: The returned box info values should be removed along with the box + // splitting logic in inline.rs + pub fn find_split_positions(&self, start: CharIndex, max_width: Au, starts_line: bool) -> Option<( + Option<(Range, Au)>, + Option<(Range, Au)>, + Arc<~TextRun>, // TODO: remove + )> { match self.specific { GenericBox | IframeBox(_) | ImageBox(_) | TableBox | TableCellBox | TableRowBox | TableWrapperBox => None, @@ -1145,7 +1155,7 @@ impl Box { ScannedTextBox(ref text_box_info) => { let mut pieces_processed_count: uint = 0; let mut remaining_width: Au = max_width; - let mut left_range = Range::new(text_box_info.range.begin(), CharIndex(0)); + let mut left_range = Range::new(text_box_info.range.begin() + start, CharIndex(0)); let mut right_range: Option> = None; debug!("split_to_width: splitting text box (strlen={:u}, range={}, \ @@ -1217,25 +1227,17 @@ impl Box { if (pieces_processed_count == 1 || !left_is_some) && !starts_line { None } 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))) + let left = if left_is_some { + Some((left_range, text_box_info.run.advance_for_range(&left_range))) } 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))) + let right = right_range.map(|right_range| { + (right_range, text_box_info.run.advance_for_range(&right_range)) }); - Some((left_box, right_box)) + Some((left, right, text_box_info.run.clone())) } } } diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index 58e21329f95..42a3210a56c 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use css::node_style::StyledNode; -use layout::box_::Box; +use layout::box_::{Box, ScannedTextBox, ScannedTextBoxInfo}; use layout::context::LayoutContext; use layout::floats::{FloatLeft, Floats, PlacementInfo}; use layout::flow::{BaseFlow, FlowClass, Flow, InlineFlowClass}; @@ -492,7 +492,20 @@ impl LineboxScanner { } let available_width = green_zone.width - self.pending_line.bounds.size.width; - match in_box.split_to_width(available_width, line_is_empty) { + match in_box.find_split_positions(CharIndex(0), available_width, line_is_empty).map( + |(left, right, run)| { + let make_box = |(range, width): (Range, Au)| { + let info = ScannedTextBoxInfo::new(run.clone(), range); + let specific = ScannedTextBox(info); + let size = Size2D(width, in_box.border_box.size.height); + // TODO: Remove box splitting + in_box.transform(size, specific) + }; + + (left.map(|x| { debug!("LineboxScanner: Left split {}", x); make_box(x) }), + right.map(|x| { debug!("LineboxScanner: Right split {}", x); make_box(x) })) + } + ) { None => { debug!("LineboxScanner: Tried to split unsplittable render box! Deferring to next \ line. {}", in_box); From 7c14d9f2108928a7e9ad1ed38ca8b19a97e74067 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Fri, 23 May 2014 12:53:17 -0700 Subject: [PATCH 2/8] Use a SplitInfo struct instead of a tuple to make the code more self-documenting --- src/components/main/layout/box_.rs | 35 ++++++++++++++++------------ src/components/main/layout/inline.rs | 14 +++++------ 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs index fbf805bb1c0..070a461baf6 100644 --- a/src/components/main/layout/box_.rs +++ b/src/components/main/layout/box_.rs @@ -241,6 +241,12 @@ impl ScannedTextBoxInfo { } } +#[deriving(Show)] +pub struct SplitInfo { + pub range: Range, + pub width: Au, +} + /// Data for an unscanned text box. Unscanned text boxes are the results of flow construction that /// have not yet had their width determined. #[deriving(Clone)] @@ -1090,7 +1096,7 @@ impl Box { /// Split box which includes new-line character. /// /// A return value of `None` indicates that the box could not be split. - /// Otherwise the split boxes are returned. The right boxe is optional due + /// Otherwise the split boxes are returned. The right box is optional due /// to the possibility of it being whitespace. pub fn split_by_new_line(&self) -> Option<(Box, Option)> { match self.specific { @@ -1135,18 +1141,11 @@ impl Box { /// no more than `max_width`. /// /// A return value of `None` indicates that the box could not be split. - /// Otherwise tuples of the width of the splits, the index into the text - /// boxes to the left and right side of the split, and the respective text - /// box info are returned. The left and right boxes are optional due to the - /// possibility of them being whitespace. - /// - // TODO: The returned box info values should be removed along with the box - // splitting logic in inline.rs - pub fn find_split_positions(&self, start: CharIndex, max_width: Au, starts_line: bool) -> Option<( - Option<(Range, Au)>, - Option<(Range, Au)>, - Arc<~TextRun>, // TODO: remove - )> { + /// Otherwise the information pertaining to the split is returned. The left + /// and right split information are both optional due to the possibility of + /// them being whitespace. + pub fn find_split_positions(&self, start: CharIndex, max_width: Au, starts_line: bool) + -> Option<(Option, Option, Arc<~TextRun> /* TODO: remove */)> { match self.specific { GenericBox | IframeBox(_) | ImageBox(_) | TableBox | TableCellBox | TableRowBox | TableWrapperBox => None, @@ -1228,13 +1227,19 @@ impl Box { None } else { let left = if left_is_some { - Some((left_range, text_box_info.run.advance_for_range(&left_range))) + Some(SplitInfo { + range: left_range, + width: text_box_info.run.advance_for_range(&left_range), + }) } else { None }; let right = right_range.map(|right_range| { - (right_range, text_box_info.run.advance_for_range(&right_range)) + SplitInfo { + range: right_range, + width: text_box_info.run.advance_for_range(&right_range), + } }); Some((left, right, text_box_info.run.clone())) diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index 42a3210a56c..cc2c0df5ade 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use css::node_style::StyledNode; -use layout::box_::{Box, ScannedTextBox, ScannedTextBoxInfo}; +use layout::box_::{Box, ScannedTextBox, ScannedTextBoxInfo, SplitInfo}; use layout::context::LayoutContext; use layout::floats::{FloatLeft, Floats, PlacementInfo}; use layout::flow::{BaseFlow, FlowClass, Flow, InlineFlowClass}; @@ -494,16 +494,16 @@ impl LineboxScanner { let available_width = green_zone.width - self.pending_line.bounds.size.width; match in_box.find_split_positions(CharIndex(0), available_width, line_is_empty).map( |(left, right, run)| { - let make_box = |(range, width): (Range, Au)| { - let info = ScannedTextBoxInfo::new(run.clone(), range); + // TODO: Remove box splitting + let split_box = |split: SplitInfo| { + let info = ScannedTextBoxInfo::new(run.clone(), split.range); let specific = ScannedTextBox(info); - let size = Size2D(width, in_box.border_box.size.height); - // TODO: Remove box splitting + let size = Size2D(split.width, in_box.border_box.size.height); in_box.transform(size, specific) }; - (left.map(|x| { debug!("LineboxScanner: Left split {}", x); make_box(x) }), - right.map(|x| { debug!("LineboxScanner: Right split {}", x); make_box(x) })) + (left.map(|x| { debug!("LineboxScanner: Left split {}", x); split_box(x) }), + right.map(|x| { debug!("LineboxScanner: Right split {}", x); split_box(x) })) } ) { None => { From d6dba5158a37c0a25fda531bc8ac78c3539dbbfe Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Fri, 23 May 2014 14:42:17 -0700 Subject: [PATCH 3/8] Move box splitting by new-line to inline.rs --- src/components/main/layout/box_.rs | 31 ++++++++++++-------------- src/components/main/layout/inline.rs | 33 +++++++++++++++++++++------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs index 070a461baf6..d1ab9ea2481 100644 --- a/src/components/main/layout/box_.rs +++ b/src/components/main/layout/box_.rs @@ -1093,12 +1093,13 @@ impl Box { } } - /// Split box which includes new-line character. + /// Find the split of a box that includes a new-line character. /// - /// A return value of `None` indicates that the box could not be split. - /// Otherwise the split boxes are returned. The right box is optional due - /// to the possibility of it being whitespace. - pub fn split_by_new_line(&self) -> Option<(Box, Option)> { + /// A return value of `None` indicates that the box is not splittable. + /// Otherwise the split information is returned. The right information is + /// optional due to the possibility of it being whitespace. + pub fn find_split_positions_by_new_line(&self) + -> Option<(SplitInfo, Option, Arc<~TextRun> /* TODO: remove */)> { match self.specific { GenericBox | IframeBox(_) | ImageBox(_) | TableBox | TableCellBox | TableRowBox | TableWrapperBox => None, @@ -1113,26 +1114,22 @@ impl Box { text_box_info.range.length() - (cur_new_line_pos + CharIndex(1))); // Left box is for left text of first founded new-line character. - let left_box = { - let new_text_box_info = ScannedTextBoxInfo::new(text_box_info.run.clone(), left_range); - let new_metrics = new_text_box_info.run.metrics_for_range(&left_range); - let mut new_box = self.transform(new_metrics.bounding_box.size, ScannedTextBox(new_text_box_info)); - new_box.new_line_pos = vec!(); - new_box + let left_box = SplitInfo { + range: left_range, + width: text_box_info.run.advance_for_range(&left_range), }; // Right box is for right text of first founded new-line character. let right_box = if right_range.length() > CharIndex(0) { - let new_text_box_info = ScannedTextBoxInfo::new(text_box_info.run.clone(), right_range); - let new_metrics = new_text_box_info.run.metrics_for_range(&right_range); - let mut new_box = self.transform(new_metrics.bounding_box.size, ScannedTextBox(new_text_box_info)); - new_box.new_line_pos = new_line_pos; - Some(new_box) + Some(SplitInfo { + range: right_range, + width: text_box_info.run.advance_for_range(&right_range), + }) } else { None }; - Some((left_box, right_box)) + Some((left_box, right_box, text_box_info.run.clone())) } } } 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!") From 32862b4aa98a0ede595d31a8dd0f2077fe23931b Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Fri, 23 May 2014 15:39:11 -0700 Subject: [PATCH 4/8] Improve function naming --- src/components/main/layout/box_.rs | 4 ++-- src/components/main/layout/inline.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs index d1ab9ea2481..6abcf9ff035 100644 --- a/src/components/main/layout/box_.rs +++ b/src/components/main/layout/box_.rs @@ -1098,7 +1098,7 @@ impl Box { /// A return value of `None` indicates that the box is not splittable. /// Otherwise the split information is returned. The right information is /// optional due to the possibility of it being whitespace. - pub fn find_split_positions_by_new_line(&self) + pub fn find_split_info_by_new_line(&self) -> Option<(SplitInfo, Option, Arc<~TextRun> /* TODO: remove */)> { match self.specific { GenericBox | IframeBox(_) | ImageBox(_) | TableBox | TableCellBox | @@ -1141,7 +1141,7 @@ impl Box { /// Otherwise the information pertaining to the split is returned. The left /// and right split information are both optional due to the possibility of /// them being whitespace. - pub fn find_split_positions(&self, start: CharIndex, max_width: Au, starts_line: bool) + pub fn find_split_info_for_width(&self, start: CharIndex, max_width: Au, starts_line: bool) -> Option<(Option, Option, Arc<~TextRun> /* TODO: remove */)> { match self.specific { GenericBox | IframeBox(_) | ImageBox(_) | TableBox | TableCellBox | diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index 527dcc3e651..cd250c0553a 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -425,7 +425,7 @@ impl LineboxScanner { true } else { debug!("LineboxScanner: Found a new-line character, so splitting theline."); - match in_box.split_by_new_line() { + match in_box.find_split_info_by_new_line() { Some((left, right, run)) => { // TODO: Remove box splitting let split_box = |split: SplitInfo| { @@ -509,7 +509,7 @@ impl LineboxScanner { } let available_width = green_zone.width - self.pending_line.bounds.size.width; - match in_box.find_split_positions(CharIndex(0), available_width, line_is_empty).map( + match in_box.find_split_info_for_width(CharIndex(0), available_width, line_is_empty).map( |(left, right, run)| { // TODO: Remove box splitting let split_box = |split: SplitInfo| { From de3b193e929717e4c3341f21d9b20911383df160 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Fri, 23 May 2014 18:15:12 -0700 Subject: [PATCH 5/8] Update to owned::Box --- src/components/main/layout/box_.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs index 6abcf9ff035..aa61f75f7c1 100644 --- a/src/components/main/layout/box_.rs +++ b/src/components/main/layout/box_.rs @@ -1099,7 +1099,7 @@ impl Box { /// Otherwise the split information is returned. The right information is /// optional due to the possibility of it being whitespace. pub fn find_split_info_by_new_line(&self) - -> Option<(SplitInfo, Option, Arc<~TextRun> /* TODO: remove */)> { + -> Option<(SplitInfo, Option, Arc> /* TODO: remove */)> { match self.specific { GenericBox | IframeBox(_) | ImageBox(_) | TableBox | TableCellBox | TableRowBox | TableWrapperBox => None, @@ -1142,7 +1142,7 @@ impl Box { /// and right split information are both optional due to the possibility of /// them being whitespace. pub fn find_split_info_for_width(&self, start: CharIndex, max_width: Au, starts_line: bool) - -> Option<(Option, Option, Arc<~TextRun> /* TODO: remove */)> { + -> Option<(Option, Option, Arc> /* TODO: remove */)> { match self.specific { GenericBox | IframeBox(_) | ImageBox(_) | TableBox | TableCellBox | TableRowBox | TableWrapperBox => None, From a94805d64a6b326deb8456817b1b4b57fe3168bd Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 27 May 2014 11:25:18 -0700 Subject: [PATCH 6/8] Use constructor for SplitInfo to reduce code repetition --- src/components/main/layout/box_.rs | 34 ++++++++++++------------------ 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs index aa61f75f7c1..25c6ab67ba8 100644 --- a/src/components/main/layout/box_.rs +++ b/src/components/main/layout/box_.rs @@ -247,6 +247,15 @@ pub struct SplitInfo { pub width: Au, } +impl SplitInfo { + fn new(range: Range, info: &ScannedTextBoxInfo) -> SplitInfo { + SplitInfo { + range: range, + width: info.run.advance_for_range(&range), + } + } +} + /// Data for an unscanned text box. Unscanned text boxes are the results of flow construction that /// have not yet had their width determined. #[deriving(Clone)] @@ -1114,17 +1123,11 @@ impl Box { text_box_info.range.length() - (cur_new_line_pos + CharIndex(1))); // Left box is for left text of first founded new-line character. - let left_box = SplitInfo { - range: left_range, - width: text_box_info.run.advance_for_range(&left_range), - }; + let left_box = SplitInfo::new(left_range, text_box_info); // Right box is for right text of first founded new-line character. let right_box = if right_range.length() > CharIndex(0) { - Some(SplitInfo { - range: right_range, - width: text_box_info.run.advance_for_range(&right_range), - }) + Some(SplitInfo::new(right_range, text_box_info)) } else { None }; @@ -1224,20 +1227,11 @@ impl Box { None } else { let left = if left_is_some { - Some(SplitInfo { - range: left_range, - width: text_box_info.run.advance_for_range(&left_range), - }) + Some(SplitInfo::new(left_range, text_box_info)) } else { - None + None }; - - let right = right_range.map(|right_range| { - SplitInfo { - range: right_range, - width: text_box_info.run.advance_for_range(&right_range), - } - }); + let right = right_range.map(|right_range| SplitInfo::new(right_range, text_box_info)); Some((left, right, text_box_info.run.clone())) } From 28aed0d511713a9d4cd6ea397a406954702b3021 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 27 May 2014 11:33:59 -0700 Subject: [PATCH 7/8] Update TODOs --- src/components/main/layout/box_.rs | 12 ++++++++++-- src/components/main/layout/inline.rs | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs index 25c6ab67ba8..a82699f0537 100644 --- a/src/components/main/layout/box_.rs +++ b/src/components/main/layout/box_.rs @@ -243,6 +243,8 @@ impl ScannedTextBoxInfo { #[deriving(Show)] pub struct SplitInfo { + // TODO(bjz): this should only need to be a single character index, but both values are + // currently needed for splitting in the `inline::try_append_*` functions. pub range: Range, pub width: Au, } @@ -1107,8 +1109,11 @@ impl Box { /// A return value of `None` indicates that the box is not splittable. /// Otherwise the split information is returned. The right information is /// optional due to the possibility of it being whitespace. + // + // TODO(bjz): The text run should be removed in the future, but it is currently needed for + // the current method of box splitting in the `inline::try_append_*` functions. pub fn find_split_info_by_new_line(&self) - -> Option<(SplitInfo, Option, Arc> /* TODO: remove */)> { + -> Option<(SplitInfo, Option, Arc> /* TODO(bjz): remove */)> { match self.specific { GenericBox | IframeBox(_) | ImageBox(_) | TableBox | TableCellBox | TableRowBox | TableWrapperBox => None, @@ -1144,8 +1149,11 @@ impl Box { /// Otherwise the information pertaining to the split is returned. The left /// and right split information are both optional due to the possibility of /// them being whitespace. + // + // TODO(bjz): The text run should be removed in the future, but it is currently needed for + // the current method of box splitting in the `inline::try_append_*` functions. pub fn find_split_info_for_width(&self, start: CharIndex, max_width: Au, starts_line: bool) - -> Option<(Option, Option, Arc> /* TODO: remove */)> { + -> Option<(Option, Option, Arc> /* TODO(bjz): remove */)> { match self.specific { GenericBox | IframeBox(_) | ImageBox(_) | TableBox | TableCellBox | TableRowBox | TableWrapperBox => None, diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index cd250c0553a..8a2e6821c8c 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -427,7 +427,7 @@ impl LineboxScanner { debug!("LineboxScanner: Found a new-line character, so splitting theline."); match in_box.find_split_info_by_new_line() { Some((left, right, run)) => { - // TODO: Remove box splitting + // TODO(bjz): Remove box splitting let split_box = |split: SplitInfo| { let info = ScannedTextBoxInfo::new(run.clone(), split.range); let specific = ScannedTextBox(info); @@ -511,7 +511,7 @@ impl LineboxScanner { let available_width = green_zone.width - self.pending_line.bounds.size.width; match in_box.find_split_info_for_width(CharIndex(0), available_width, line_is_empty).map( |(left, right, run)| { - // TODO: Remove box splitting + // TODO(bjz): Remove box splitting let split_box = |split: SplitInfo| { let info = ScannedTextBoxInfo::new(run.clone(), split.range); let specific = ScannedTextBox(info); From a944e378eb33d05528971e19234761ed2aadbfdb Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 27 May 2014 11:58:30 -0700 Subject: [PATCH 8/8] Formatting fixes --- src/components/main/layout/inline.rs | 29 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index 8a2e6821c8c..4879bd8a5e7 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -441,13 +441,13 @@ impl LineboxScanner { left.new_line_pos = vec!(); self.push_box_to_line(left); - right.map(|right| { + for right in right.move_iter() { 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!") @@ -509,20 +509,19 @@ impl LineboxScanner { } let available_width = green_zone.width - self.pending_line.bounds.size.width; - match in_box.find_split_info_for_width(CharIndex(0), available_width, line_is_empty).map( - |(left, right, run)| { - // TODO(bjz): 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) - }; + let split = in_box.find_split_info_for_width(CharIndex(0), available_width, line_is_empty); + match split.map(|(left, right, run)| { + // TODO(bjz): 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) + }; - (left.map(|x| { debug!("LineboxScanner: Left split {}", x); split_box(x) }), - right.map(|x| { debug!("LineboxScanner: Right split {}", x); split_box(x) })) - } - ) { + (left.map(|x| { debug!("LineboxScanner: Left split {}", x); split_box(x) }), + right.map(|x| { debug!("LineboxScanner: Right split {}", x); split_box(x) })) + }) { None => { debug!("LineboxScanner: Tried to split unsplittable render box! Deferring to next \ line. {}", in_box);