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 => {