Make move mutation out of compute_minimum_ascent_and_descent

This commit is contained in:
Brendan Zabarauskas 2014-06-20 10:02:37 -07:00
parent 61216c301d
commit 520675b237
2 changed files with 6 additions and 5 deletions

View file

@ -293,7 +293,9 @@ impl<'a> FlowConstructor<'a> {
}
let mut inline_flow = box InlineFlow::from_fragments((*node).clone(), fragments);
inline_flow.compute_minimum_ascent_and_descent(self.font_context(), &**node.style());
let (ascent, descent) = inline_flow.compute_minimum_ascent_and_descent(self.font_context(), &**node.style());
inline_flow.minimum_height_above_baseline = ascent;
inline_flow.minimum_depth_below_baseline = descent;
let mut inline_flow = inline_flow as Box<Flow>;
TextRunScanner::new().scan_for_runs(self.font_context(), inline_flow);
let mut inline_flow = FlowRef::new(inline_flow);

View file

@ -1057,15 +1057,14 @@ impl InlineFlow {
/// construction.
///
/// `style` is the style of the block.
pub fn compute_minimum_ascent_and_descent(&mut self,
pub fn compute_minimum_ascent_and_descent(&self,
font_context: &mut FontContext,
style: &ComputedValues) {
style: &ComputedValues) -> (Au, Au) {
let font_style = text::computed_style_to_font_style(style);
let font_metrics = text::font_metrics_for_style(font_context, &font_style);
let line_height = text::line_height_from_style(style, style.get_font().font_size);
let inline_metrics = InlineMetrics::from_font_metrics(&font_metrics, line_height);
self.minimum_height_above_baseline = inline_metrics.height_above_baseline;
self.minimum_depth_below_baseline = inline_metrics.depth_below_baseline;
(inline_metrics.height_above_baseline, inline_metrics.depth_below_baseline)
}
}