From e96f02718ae59754b1f9e3a1f9bb629475f38ea9 Mon Sep 17 00:00:00 2001 From: Junyoung Cho Date: Thu, 5 Jun 2014 16:36:42 -0600 Subject: [PATCH] Fix the vertical alignment error for img tag. --- src/components/main/layout/inline.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index 5efc5002952..1df0e898401 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -985,7 +985,11 @@ impl InlineFlow { vertical_align::middle => { // TODO: x-height value should be used from font info. let xheight = Au(0); - (-(xheight + fragment.content_height()).scale_by(0.5), false) + let fragment_height = fragment.content_height(); + let offset_top = -(xheight + fragment_height).scale_by(0.5); + *height_above_baseline = offset_top.scale_by(-1.0); + *depth_below_baseline = fragment_height - *height_above_baseline; + (offset_top, false) }, vertical_align::sub => { // TODO: The proper position for subscripts should be used. Lower the baseline to