From 120ca506c1de0d45884354b425762e90c660f52e Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 2 Feb 2008 00:13:19 +0000 Subject: Make text input boxes with height:auto; and no initial value get a sensible height. Make all form elements have their dimensions based on the configured minimum font size, if the current text size is smaller. Remove redundant code for setting radio icon and checkbox sizes. All em/ex based sizes now respect the min font size, when it's in effect. Updated default styles for form elements. svn path=/trunk/netsurf/; revision=3813 --- css/css.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'css') diff --git a/css/css.c b/css/css.c index cb007978a..f863d4cfb 100644 --- a/css/css.c +++ b/css/css.c @@ -99,6 +99,7 @@ #include "css/parser.h" #ifdef riscos #include "desktop/gui.h" +#include "desktop/options.h" #endif #include "utils/log.h" #include "utils/messages.h" @@ -3010,12 +3011,34 @@ unsigned int css_hash(const char *s, int length) float css_len2px(const struct css_length *length, const struct css_style *style) { - assert(!((length->unit == CSS_UNIT_EM || length->unit == CSS_UNIT_EX) && style == 0)); + struct css_length font; + font.unit = CSS_UNIT_PT; + + assert(!((length->unit == CSS_UNIT_EM || length->unit == CSS_UNIT_EX) && + style == 0)); switch (length->unit) { - case CSS_UNIT_EM: return length->value * css_len2px(&style->font_size.value.length, 0); - case CSS_UNIT_EX: return length->value * css_len2px(&style->font_size.value.length, 0) * 0.6; + case CSS_UNIT_EM: + if ((font.value = css_len2pt(&style-> + font_size.value.length, style)) < + option_font_min_size / 10) { + font.value = option_font_min_size / 10; + return length->value * css_len2px(&font, + style); + } else + return length->value * css_len2px(&style-> + font_size.value.length, 0); + case CSS_UNIT_EX: + if ((font.value = css_len2pt(&style-> + font_size.value.length, style)) < + option_font_min_size / 10) { + font.value = option_font_min_size / 10; + return length->value * css_len2px(&font, + style) * 0.6; + } else + return length->value * css_len2px(&style-> + font_size.value.length, 0) * 0.6; case CSS_UNIT_PX: return length->value; - /* We assume the screen and any other output has the same dpi */ + /* We assume the screen and any other output has the same dpi */ case CSS_UNIT_IN: return length->value * css_screen_dpi; case CSS_UNIT_CM: return length->value * css_screen_dpi / 2.54; case CSS_UNIT_MM: return length->value * css_screen_dpi / 25.4; -- cgit v1.2.3