Author: jmb
Date: Tue Jun 30 13:58:06 2009
New Revision: 8206
URL:
http://source.netsurf-browser.org?rev=8206&view=rev
Log:
Make line-height calculation use css_used_font_size()
Modified:
branches/jmb/ns-libcss/render/layout.c
Modified: branches/jmb/ns-libcss/render/layout.c
URL:
http://source.netsurf-browser.org/branches/jmb/ns-libcss/render/layout.c?...
==============================================================================
--- branches/jmb/ns-libcss/render/layout.c (original)
+++ branches/jmb/ns-libcss/render/layout.c Tue Jun 30 13:58:06 2009
@@ -1728,10 +1728,11 @@
int line_height(const css_computed_style *style)
{
enum css_line_height lhtype;
- enum css_font_size fstype;
css_fixed lhvalue = 0, fsvalue = 0;
css_unit lhunit = CSS_UNIT_PX, fsunit = CSS_UNIT_PX;
- float font_len;
+ css_fixed font_len;
+ css_fixed min_font_size;
+ css_fixed line_height;
assert(style);
@@ -1746,29 +1747,27 @@
lhtype == CSS_LINE_HEIGHT_DIMENSION);
#endif
- fstype = css_computed_font_size(style, &fsvalue, &fsunit);
-
-#warning CSSport
- /** \todo Handle keyword font sizes correctly -- ideally make it so
- * layout.c never sees them. */
+ css_used_font_size(style, &fsvalue, &fsunit);
+
+ min_font_size = FDIV(FMULI(css_screen_dpi, option_font_min_size),
+ FLTTOFIX(720.0));
/* take account of minimum font size option */
- if ((font_len = FIXTOFLT(css_len2px(fsvalue, fsunit, 0))) <
- option_font_min_size * FIXTOFLT(css_screen_dpi) / 720.0)
- font_len = option_font_min_size *
- FIXTOFLT(css_screen_dpi) / 720.0;
+ if ((font_len = css_len2px(fsvalue, fsunit, 0)) < min_font_size)
+ font_len = min_font_size;
if (lhtype == CSS_LINE_HEIGHT_DIMENSION) {
if (lhunit == CSS_UNIT_PCT) {
- return FIXTOFLT(lhvalue) * font_len / 100.0;
+ line_height = FDIV(FMUL(lhvalue, font_len),
+ FLTTOFIX(100.0));
} else {
- return FIXTOINT(css_len2px(lhvalue, lhunit, style));
+ line_height = css_len2px(lhvalue, lhunit, style);
}
} else if (lhtype == CSS_LINE_HEIGHT_NUMBER) {
- return FIXTOFLT(lhvalue) * font_len;
- }
-
- return 0;
+ line_height = FMUL(lhvalue, font_len);
+ }
+
+ return FIXTOINT(line_height);
}