r5386 tlsa - /trunk/netsurf/render/layout.c

netsurf at semichrome.net netsurf at semichrome.net
Sun Sep 21 00:25:37 BST 2008


Author: tlsa
Date: Sat Sep 20 18:25:37 2008
New Revision: 5386

URL: http://source.netsurf-browser.org?rev=5386&view=rev
Log:
Fix floated radio buttons and checkboxes.

Modified:
    trunk/netsurf/render/layout.c

Modified: trunk/netsurf/render/layout.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/layout.c?rev=5386&r1=5385&r2=5386&view=diff
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Sat Sep 20 18:25:37 2008
@@ -184,6 +184,7 @@
 	int max_neg_margin = 0;
 	int y = 0;
 	struct box *margin_box;
+	struct css_length gadget_size; /* Checkbox / radio buttons */
 
 	assert(block->type == BOX_BLOCK ||
 			block->type == BOX_INLINE_BLOCK ||
@@ -248,6 +249,17 @@
 		return true;
 	}
 
+	/* special case if the block contains an radio button or checkbox */
+	if (block->gadget && (block->gadget->type == GADGET_RADIO ||
+			block->gadget->type == GADGET_CHECKBOX)) {
+		/* form checkbox or radio button
+		 * if width or height is AUTO, set it to 1em */
+		gadget_size.unit = CSS_UNIT_EM;
+		gadget_size.value = 1;
+		if (block->height == AUTO)
+			block->height = css_len2px(&gadget_size, block->style);
+	}
+
 	box = margin_box = block->children;
 	/* set current coordinates to top-left of the block */
 	cx = 0;
@@ -530,6 +542,9 @@
 	struct css_length size;
 	size.unit = CSS_UNIT_EM;
 	size.value = 10;
+	struct css_length gadget_size; /* Checkbox / radio buttons */
+	gadget_size.unit = CSS_UNIT_EM;
+	gadget_size.value = 1;
 
 	assert(block->type == BOX_BLOCK ||
 			block->type == BOX_INLINE_BLOCK ||
@@ -546,6 +561,15 @@
 			block->style &&
 			block->style->width.width == CSS_WIDTH_AUTO) {
 		min = max = css_len2px(&size, block->style);
+	}
+
+	if (block->gadget && (block->gadget->type == GADGET_RADIO ||
+			block->gadget->type == GADGET_CHECKBOX) &&
+			block->style &&
+			block->style->width.width == CSS_WIDTH_AUTO) {
+		/* form checkbox or radio button
+		 * if width is AUTO, set it to 1em */
+		min = max = css_len2px(&gadget_size, block->style);
 	}
 
 	if (block->object) {




More information about the netsurf-commits mailing list