Author: tlsa
Date: Sat Feb 2 00:13:19 2008
New Revision: 3813
URL:
http://source.netsurf-browser.org?rev=3813&view=rev
Log:
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.
Modified:
trunk/netsurf/!NetSurf/Resources/CSS,f79
trunk/netsurf/css/css.c
trunk/netsurf/gtk/res/gtkdefault.css
trunk/netsurf/render/layout.c
Modified: trunk/netsurf/!NetSurf/Resources/CSS,f79
URL:
http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/CSS%...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/CSS,f79 (original)
+++ trunk/netsurf/!NetSurf/Resources/CSS,f79 Sat Feb 2 00:13:19 2008
@@ -152,30 +152,30 @@
form > * { margin-left: inherit; margin-right: inherit; }
input { background-color: #fff; color: #000; text-align: left;
- font-family: sans-serif; width: 10em; height: 1.5em; overflow: hidden;
- margin: 1px; border: 1px solid #000; padding: 0 2px; }
+ font-family: sans-serif; width: 10em; height: auto; overflow: hidden;
+ margin: 1px; border: 2px solid #333; padding: 1px 2px; }
input[type=button], input[type=reset], input[type=submit], button {
background-color: #d9d9d9; color: #000; text-align: center;
width: auto; height: auto;
- border: medium outset #d9d9d9; padding: 0 0.5em; }
+ border: medium outset #d9d9d9; padding: 1px 0.5em; }
input[type=image] { background-color: transparent; color: #000;
- width: auto; height: auto; border: none; }
+ width: auto; height: auto; border: none; padding: 0 2px; }
input[type=checkbox], input[type=radio] { background-color: transparent;
width: 1em; height: 1em; border: none; padding: 0 0.1em; }
input[type=file] { background-color: #d9d9d9; color: #000;
width: 10em; height: 1.5em; font-style: italic;
- border: medium inset #d9d9d9; }
+ border: medium inset #d9d9d9; padding: 1px 2px;}
input[align=left] { float: left; }
input[align=right] { float: right; }
select { background-color: #d9d9d9; color: #000; text-align: left;
- font-family: sans-serif; width: 10em; height: 1.5em; overflow: hidden;
- margin: 1px; border: medium inset #d9d9d9; padding: 0 2px; }
+ font-family: sans-serif; width: 10em; height: auto; overflow: hidden;
+ margin: 1px; border: medium inset #d9d9d9; padding: 1px 2px; }
select:after { content: "\25bc"; border-left: 4px ridge #d9d9d9; }
textarea { background-color: #fff; color: #000; text-align: left;
font-family: monospace; overflow: scroll;
- margin: 1px; border: 1px solid #000; padding: 0 2px; }
+ margin: 1px; border: 2px solid #333; padding: 0 2px; }
fieldset { display: block; border: thin solid #888; margin: 1.12em 0; }
Modified: trunk/netsurf/css/css.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/css/css.c?rev=3813&r1...
==============================================================================
--- trunk/netsurf/css/css.c (original)
+++ trunk/netsurf/css/css.c Sat Feb 2 00:13:19 2008
@@ -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 @@
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;
Modified: trunk/netsurf/gtk/res/gtkdefault.css
URL:
http://source.netsurf-browser.org/trunk/netsurf/gtk/res/gtkdefault.css?re...
==============================================================================
--- trunk/netsurf/gtk/res/gtkdefault.css (original)
+++ trunk/netsurf/gtk/res/gtkdefault.css Sat Feb 2 00:13:19 2008
@@ -11,14 +11,11 @@
input { font-size: 95%; }
input[type=button], input[type=reset], input[type=submit], button {
background-color: #ddd; border: medium outset #ddd; }
-input[type=image] { background-color: transparent; color: #000; width: auto;
- height: auto; border: 0; }
input[type=checkbox], input[type=radio] { font-size: 105%; }
-input[type=file] { background-color: #ddd; border: medium inset #ddd;
- font-style: italic; }
+input[type=file] { background-color: #ddd; border: medium inset #ddd; }
select { background-color: #ddd; border: medium inset #ddd; font-size: 95%; }
-select:after { content: "\25bc"; border-left:4px ridge #ddd; }
+select:after { border-left:4px ridge #ddd; }
textarea { font-size: 95%; }
Modified: trunk/netsurf/render/layout.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/render/layout.c?rev=3813&...
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Sat Feb 2 00:13:19 2008
@@ -46,7 +46,6 @@
#include "desktop/options.h"
#include "render/box.h"
#include "render/font.h"
-#include "render/form.h"
#include "render/layout.h"
#define NDEBUG
#include "utils/log.h"
@@ -1028,7 +1027,6 @@
int space_before = 0, space_after = 0;
unsigned int inline_count = 0;
unsigned int i;
- int min_gadget_size = 0;
LOG(("first %p, first->text '%.*s', width %i, y %i, cx %i, cy %i",
first, (int) first->length, first->text, *width,
@@ -1047,8 +1045,10 @@
if (x1 < x0)
x1 = x0;
- /* get minimum line height from containing block */
- if (has_text_children)
+ /* get minimum line height from containing block.
+ * this is the line-height if there are text children and also in the
+ * case of an initially empty text input */
+ if (has_text_children || first->parent->parent->gadget)
used_height = height = line_height(first->parent->parent->style);
else
/* inline containers with no text are usually for layout and
@@ -1159,24 +1159,11 @@
/* inline replaced, 10.3.2 and 10.6.2 */
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 */
switch (b->style->width.width) {
case CSS_WIDTH_LENGTH:
- b->width = min_gadget_size ? min_gadget_size :
- css_len2px(&b->style->width.value.
- length, b->style);
+ b->width = css_len2px(&b->style->width.value.
+ length, b->style);
break;
case CSS_WIDTH_PERCENT:
b->width = *width *
@@ -1192,9 +1179,8 @@
/* height */
switch (b->style->height.height) {
case CSS_HEIGHT_LENGTH:
- b->height = min_gadget_size ? min_gadget_size :
- css_len2px(&b->style->height.length,
- b->style);
+ b->height = css_len2px(&b->style->height.length,
+ b->style);
break;
case CSS_HEIGHT_AUTO:
default:
@@ -1577,7 +1563,6 @@
float frac;
size_t i, j;
struct box *b;
- int min_gadget_size = 0;
/* corresponds to the pass 1 loop in layout_line() */
for (b = first; b; b = b->next) {
@@ -1672,24 +1657,11 @@
/* inline replaced, 10.3.2 and 10.6.2 */
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 */
switch (b->style->width.width) {
case CSS_WIDTH_LENGTH:
- width = min_gadget_size ? min_gadget_size :
- css_len2px(&b->style->width.value.
- length, b->style);
+ width = css_len2px(&b->style->width.value.
+ length, b->style);
if (width < 0)
width = 0;
break;
@@ -1707,9 +1679,8 @@
/* height */
switch (b->style->height.height) {
case CSS_HEIGHT_LENGTH:
- height = min_gadget_size ? min_gadget_size :
- css_len2px(&b->style->height.length,
- b->style);
+ height = css_len2px(&b->style->height.length,
+ b->style);
break;
case CSS_HEIGHT_AUTO:
default: