Skip to content

Commit

Permalink
Make move mutation out of compute_minimum_ascent_and_descent
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanzab committed Jun 20, 2014
1 parent 61216c3 commit 520675b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/components/main/layout/construct.rs
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions src/components/main/layout/inline.rs
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 520675b

Please sign in to comment.