From 74f108ee4dc5b915dfc8de0f88485245831ea7a9 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 12 Mar 2011 17:46:11 +0000 Subject: Saturated maths in css fixed point svn path=/trunk/netsurf/; revision=11975 --- render/font.c | 4 ++-- render/form.c | 5 +---- render/layout.c | 8 ++++---- render/textplain.c | 5 ++--- 4 files changed, 9 insertions(+), 13 deletions(-) (limited to 'render') diff --git a/render/font.c b/render/font.c index c731bc60c..87511b261 100644 --- a/render/font.c +++ b/render/font.c @@ -45,8 +45,8 @@ void font_plot_style_from_css(const css_computed_style *css, css_computed_font_family(css, &families)); css_computed_font_size(css, &length, &unit); - fstyle->size = FIXTOINT(FMULI(nscss_len2pt(length, unit), - FONT_SIZE_SCALE)); + fstyle->size = FIXTOINT(FMUL(nscss_len2pt(length, unit), + INTTOFIX(FONT_SIZE_SCALE))); /* Clamp font size to configured minimum */ if (fstyle->size < (option_font_min_size * FONT_SIZE_SCALE) / 10) diff --git a/render/form.c b/render/form.c index fd16b8bab..8a52a4fdb 100644 --- a/render/form.c +++ b/render/form.c @@ -900,10 +900,7 @@ bool form_open_select_menu(void *client_data, &fstyle); menu->f_size = fstyle.size; - menu->line_height = - FIXTOINT(FDIVI((FMUL(FLTTOFIX(1.2), - FMULI(nscss_screen_dpi, - (fstyle.size / FONT_SIZE_SCALE)))), 72)); + menu->line_height = FIXTOINT(FDIV((FMUL(FLTTOFIX(1.2), FMUL(nscss_screen_dpi, INTTOFIX((fstyle.size / FONT_SIZE_SCALE))))), F_72)); line_height_with_spacing = menu->line_height + menu->line_height * diff --git a/render/layout.c b/render/layout.c index a740e1a90..fa94729d2 100644 --- a/render/layout.c +++ b/render/layout.c @@ -59,7 +59,7 @@ #define AUTO INT_MIN /* Fixed point value percentage of an integer, to an integer */ -#define FPCT_OF_INT_TOINT(a, b) FIXTOINT(FMULI(FDIVI(a, 100), b)) +#define FPCT_OF_INT_TOINT(a, b) FIXTOINT(FMUL(FDIV(a, F_100), INTTOFIX(b))) static bool layout_block_context(struct box *block, int viewport_height, @@ -1889,7 +1889,7 @@ int line_height(const css_computed_style *style) line_height = nscss_len2px(lhvalue, CSS_UNIT_EM, style); if (lhtype != CSS_LINE_HEIGHT_NUMBER) - line_height = FDIVI(line_height, 100); + line_height = FDIV(line_height, F_100); } else { assert(lhunit != CSS_UNIT_PCT); @@ -3790,7 +3790,7 @@ void calculate_mbp_width(const css_computed_style *style, unsigned int side, type = margin_funcs[side](style, &value, &unit); if (type == CSS_MARGIN_SET) { if (unit == CSS_UNIT_PCT) { - *frac += FIXTOINT(FDIVI(value, 100)); + *frac += FIXTOINT(FDIV(value, F_100)); } else { *fixed += FIXTOINT(nscss_len2px(value, unit, style)); @@ -3812,7 +3812,7 @@ void calculate_mbp_width(const css_computed_style *style, unsigned int side, if (padding) { padding_funcs[side](style, &value, &unit); if (unit == CSS_UNIT_PCT) { - *frac += FIXTOINT(FDIVI(value, 100)); + *frac += FIXTOINT(FDIV(value, F_100)); } else { *fixed += FIXTOINT(nscss_len2px(value, unit, style)); } diff --git a/render/textplain.c b/render/textplain.c index 3a3ffd184..bc4505ce2 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -994,8 +994,7 @@ float textplain_line_height(void) /* Size is in points, so convert to pixels. * Then use a constant line height of 1.2 x font size. */ - return FIXTOFLT(FDIVI((FMUL(FLTTOFIX(1.2), - FMULI(nscss_screen_dpi, - (textplain_style.size / FONT_SIZE_SCALE)))), 72)); + return FIXTOFLT(FDIV((FMUL(FLTTOFIX(1.2), FMUL(nscss_screen_dpi, + INTTOFIX((textplain_style.size / FONT_SIZE_SCALE))))), F_72)); } -- cgit v1.2.3