Apply min font size config option to radio icons and checkboxes.

svn path=/trunk/netsurf/; revision=3797
This commit is contained in:
Michael Drake 2008-01-29 00:42:15 +00:00
parent 416c81208b
commit 38dcd3f172
1 changed files with 47 additions and 13 deletions

View File

@ -46,6 +46,7 @@
#include "desktop/options.h" #include "desktop/options.h"
#include "render/box.h" #include "render/box.h"
#include "render/font.h" #include "render/font.h"
#include "render/form.h"
#include "render/layout.h" #include "render/layout.h"
#define NDEBUG #define NDEBUG
#include "utils/log.h" #include "utils/log.h"
@ -1027,6 +1028,7 @@ bool layout_line(struct box *first, int *width, int *y,
int space_before = 0, space_after = 0; int space_before = 0, space_after = 0;
unsigned int inline_count = 0; unsigned int inline_count = 0;
unsigned int i; unsigned int i;
int min_gadget_size = 0;
LOG(("first %p, first->text '%.*s', width %i, y %i, cx %i, cy %i", LOG(("first %p, first->text '%.*s', width %i, y %i, cx %i, cy %i",
first, (int) first->length, first->text, *width, first, (int) first->length, first->text, *width,
@ -1157,16 +1159,31 @@ bool layout_line(struct box *first, int *width, int *y,
/* inline replaced, 10.3.2 and 10.6.2 */ /* inline replaced, 10.3.2 and 10.6.2 */
assert(b->style); assert(b->style);
min_gadget_size = 0;
/* checkboxes and radiobuttons contain no text but need to
* follow configured min font size option */
if (b->gadget && (b->gadget->type == GADGET_RADIO ||
b->gadget->type == GADGET_CHECKBOX)) {
min_gadget_size = option_font_min_size * css_screen_dpi
/ 720.0;
min_gadget_size = min_gadget_size > css_len2px(&b->
style->font_size.value.length, b->style) ?
min_gadget_size : 0;
}
/* calculate box width */ /* calculate box width */
switch (b->style->width.width) { switch (b->style->width.width) {
case CSS_WIDTH_LENGTH: case CSS_WIDTH_LENGTH:
b->width = css_len2px(&b->style->width.value. b->width = min_gadget_size ? css_screen_dpi *
length, b->style); option_font_min_size / 720.0 :
css_len2px(&b->style->width.value.
length, b->style);
break; break;
case CSS_WIDTH_PERCENT: case CSS_WIDTH_PERCENT:
b->width = *width * b->width = min_gadget_size ? css_screen_dpi *
b->style->width.value.percent / option_font_min_size / 720.0 :
100; css_len2px(&b->style->width.value.
length, b->style);
break; break;
case CSS_WIDTH_AUTO: case CSS_WIDTH_AUTO:
default: default:
@ -1177,8 +1194,10 @@ bool layout_line(struct box *first, int *width, int *y,
/* height */ /* height */
switch (b->style->height.height) { switch (b->style->height.height) {
case CSS_HEIGHT_LENGTH: case CSS_HEIGHT_LENGTH:
b->height = css_len2px(&b->style->height.length, b->height = min_gadget_size ? css_screen_dpi *
b->style); option_font_min_size / 720.0 :
css_len2px(&b->style->height.length,
b->style);
break; break;
case CSS_HEIGHT_AUTO: case CSS_HEIGHT_AUTO:
default: default:
@ -1561,6 +1580,7 @@ struct box *layout_minmax_line(struct box *first,
float frac; float frac;
size_t i, j; size_t i, j;
struct box *b; struct box *b;
int min_gadget_size = 0;
/* corresponds to the pass 1 loop in layout_line() */ /* corresponds to the pass 1 loop in layout_line() */
for (b = first; b; b = b->next) { for (b = first; b; b = b->next) {
@ -1655,13 +1675,25 @@ struct box *layout_minmax_line(struct box *first,
/* inline replaced, 10.3.2 and 10.6.2 */ /* inline replaced, 10.3.2 and 10.6.2 */
assert(b->style); assert(b->style);
min_gadget_size = 0;
/* checkboxes and radiobuttons contain no text but need to
* follow configured min font size option */
if (b->gadget && (b->gadget->type == GADGET_RADIO ||
b->gadget->type == GADGET_CHECKBOX)) {
min_gadget_size = option_font_min_size * css_screen_dpi
/ 720.0;
min_gadget_size = min_gadget_size > css_len2px(&b->
style->font_size.value.length, b->style) ?
min_gadget_size : 0;
}
/* calculate box width */ /* calculate box width */
switch (b->style->width.width) { switch (b->style->width.width) {
case CSS_WIDTH_LENGTH: case CSS_WIDTH_LENGTH:
width = css_len2px(&b->style->width.value. width = min_gadget_size ? css_screen_dpi *
length, b->style); option_font_min_size / 720.0 :
if (width < 0) css_len2px(&b->style->width.value.
width = 0; length, b->style);
break; break;
case CSS_WIDTH_PERCENT: case CSS_WIDTH_PERCENT:
/*b->width = width * /*b->width = width *
@ -1677,8 +1709,10 @@ struct box *layout_minmax_line(struct box *first,
/* height */ /* height */
switch (b->style->height.height) { switch (b->style->height.height) {
case CSS_HEIGHT_LENGTH: case CSS_HEIGHT_LENGTH:
height = css_len2px(&b->style->height.length, height = min_gadget_size ? css_screen_dpi *
b->style); option_font_min_size / 720.0 :
css_len2px(&b->style->height.length,
b->style);
break; break;
case CSS_HEIGHT_AUTO: case CSS_HEIGHT_AUTO:
default: default: