servo: Merge #2890 - Change calculate_line_height to use font-size from style (from glennw:font-size)

Source-Repo: https://github.com/servo/servo
Source-Revision: 3d796b1ccf8afa2044367d7c27411cd0bb6ec967
This commit is contained in:
Glenn Watson 2014-07-21 19:11:28 -07:00
Родитель 45f340deaf
Коммит 71b902deff
3 изменённых файлов: 9 добавлений и 18 удалений

Просмотреть файл

@ -455,8 +455,8 @@ impl Fragment {
}
}
pub fn calculate_line_height(&self, font_size: Au) -> Au {
text::line_height_from_style(self.style(), font_size)
pub fn calculate_line_height(&self) -> Au {
text::line_height_from_style(self.style())
}
/// Returns the sum of the inline-sizes of all the borders of this fragment. This is private because
@ -1089,15 +1089,9 @@ impl Fragment {
ImageFragment(ref image_fragment_info) => {
image_fragment_info.computed_block_size()
}
ScannedTextFragment(ref text_fragment_info) => {
ScannedTextFragment(_) => {
// Compute the block-size based on the line-block-size and font size.
//
// FIXME(pcwalton): Shouldn't we use the value of the `font-size` property below
// instead of the bounding box of the text run?
let (range, run) = (&text_fragment_info.range, &text_fragment_info.run);
let text_bounds = run.metrics_for_range(range).bounding_box;
let em_size = text_bounds.size.height;
self.calculate_line_height(em_size)
self.calculate_line_height()
}
TableColumnFragment(_) => fail!("Table column fragments do not have block_size"),
UnscannedTextFragment(_) => fail!("Unscanned text fragments should have been scanned by now!"),
@ -1388,8 +1382,7 @@ impl Fragment {
}
ScannedTextFragment(ref text_fragment) => {
// See CSS 2.1 § 10.8.1.
let font_size = self.style().get_font().font_size;
let line_height = self.calculate_line_height(font_size);
let line_height = self.calculate_line_height();
InlineMetrics::from_font_metrics(&text_fragment.run.font_metrics, line_height)
}
_ => {

Просмотреть файл

@ -1027,8 +1027,7 @@ impl InlineFlow {
},
vertical_align::Length(length) => (-(length + ascent), false),
vertical_align::Percentage(p) => {
let pt_size = fragment.font_style().pt_size;
let line_height = fragment.calculate_line_height(Au::from_pt(pt_size));
let line_height = fragment.calculate_line_height();
let percent_offset = line_height.scale_by(p);
(-(percent_offset + ascent), false)
}
@ -1073,7 +1072,7 @@ impl InlineFlow {
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 line_height = text::line_height_from_style(style);
let inline_metrics = InlineMetrics::from_font_metrics(&font_metrics, line_height);
(inline_metrics.block_size_above_baseline, inline_metrics.depth_below_baseline)
}

Просмотреть файл

@ -293,9 +293,8 @@ pub fn computed_style_to_font_style(style: &ComputedValues) -> FontStyle {
}
/// Returns the line block-size needed by the given computed style and font size.
///
/// FIXME(pcwalton): I believe this should not take a separate `font-size` parameter.
pub fn line_height_from_style(style: &ComputedValues, font_size: Au) -> Au {
pub fn line_height_from_style(style: &ComputedValues) -> Au {
let font_size = style.get_font().font_size;
let from_inline = match style.get_inheritedbox().line_height {
line_height::Normal => font_size.scale_by(1.14),
line_height::Number(l) => font_size.scale_by(l),