aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Watson <gw@intuitionlibrary.com>2014-07-22 08:33:05 +1000
committerGlenn Watson <gw@intuitionlibrary.com>2014-07-22 08:33:05 +1000
commit383ce249dcf668a83099be5b82c5022b64dd0506 (patch)
treed930790f1a3bf14be391bf98542ddef1c48b47f5
parent3670ee6f1fc5066101cc5a357443494552ea37f2 (diff)
downloadservo-383ce249dcf668a83099be5b82c5022b64dd0506.tar.gz
servo-383ce249dcf668a83099be5b82c5022b64dd0506.zip
Change calculate_line_height to use font-size from style.
-rw-r--r--src/components/layout/fragment.rs17
-rw-r--r--src/components/layout/inline.rs5
-rw-r--r--src/components/layout/text.rs5
3 files changed, 9 insertions, 18 deletions
diff --git a/src/components/layout/fragment.rs b/src/components/layout/fragment.rs
index f495d5d1e0e..e933b9d87d6 100644
--- a/src/components/layout/fragment.rs
+++ b/src/components/layout/fragment.rs
@@ -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)
}
_ => {
diff --git a/src/components/layout/inline.rs b/src/components/layout/inline.rs
index be44969eb5a..c856cdf6dcb 100644
--- a/src/components/layout/inline.rs
+++ b/src/components/layout/inline.rs
@@ -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)
}
diff --git a/src/components/layout/text.rs b/src/components/layout/text.rs
index e283cf432d3..f0fc612ea32 100644
--- a/src/components/layout/text.rs
+++ b/src/components/layout/text.rs
@@ -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),