summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--!NetSurf/Resources/CSS,f792
-rw-r--r--!NetSurf/Resources/en/Messages3
-rw-r--r--desktop/browser.c10
-rw-r--r--render/box.c77
-rw-r--r--render/box.h13
-rw-r--r--render/layout.c26
-rw-r--r--riscos/htmlredraw.c26
7 files changed, 90 insertions, 67 deletions
diff --git a/!NetSurf/Resources/CSS,f79 b/!NetSurf/Resources/CSS,f79
index 614546221..f3bdf7464 100644
--- a/!NetSurf/Resources/CSS,f79
+++ b/!NetSurf/Resources/CSS,f79
@@ -40,3 +40,5 @@ small { font-size: smaller; }
big { font-size: larger; }
input, select { width: 10em; height: 2em; background-color: #eeeebb; }
textarea { display: inline-block; width: 20em; height: 4em; background-color: #eeeebb; }
+button { background-color: #ddd; }
+
diff --git a/!NetSurf/Resources/en/Messages b/!NetSurf/Resources/en/Messages
index 8062c61eb..ffa532ad5 100644
--- a/!NetSurf/Resources/en/Messages
+++ b/!NetSurf/Resources/en/Messages
@@ -27,5 +27,8 @@ Reload:Reload this page
# Download window
Downloaded:Download complete, %lu bytes
+# Forms
+Form_Submit:Submit
+Form_Reset:Reset
Not2xx:Server returned an error
diff --git a/desktop/browser.c b/desktop/browser.c
index 718bdb161..1b0a85d88 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -522,14 +522,8 @@ int browser_window_gadget_click(struct browser_window* bw, unsigned long click_x
g->data.radio.selected = -1;
gui_redraw_gadget(bw, g);
break;
- case GADGET_ACTIONBUTTON:
- /* redraw button */
- g->data.actionbutt.pressed = -1;
- gui_redraw_gadget(bw, g);
- if (stricmp(g->data.actionbutt.butttype,"submit") == 0)
- browser_form_submit(bw, g->form);
- g->data.actionbutt.pressed = 0;
- gui_redraw_gadget(bw,g);
+ case GADGET_SUBMIT:
+ browser_form_submit(bw, g->form);
break;
case GADGET_TEXTAREA:
browser_window_textarea_click(bw,
diff --git a/render/box.c b/render/box.c
index 749815f15..0c67fa8df 100644
--- a/render/box.c
+++ b/render/box.c
@@ -25,6 +25,7 @@
#endif
#define NDEBUG
#include "netsurf/utils/log.h"
+#include "netsurf/utils/messages.h"
#include "netsurf/utils/utils.h"
@@ -64,7 +65,9 @@ static struct result box_textarea(xmlNode *n, struct status *status,
struct css_style *style);
static struct result box_select(xmlNode *n, struct status *status,
struct css_style *style);
-struct result box_input(xmlNode *n, struct status *status,
+static struct result box_input(xmlNode *n, struct status *status,
+ struct css_style *style);
+static struct result box_button(xmlNode *n, struct status *status,
struct css_style *style);
static void add_option(xmlNode* n, struct gui_gadget* current_select, char *text);
static void box_normalise_block(struct box *block);
@@ -100,7 +103,8 @@ static const struct element_entry element_table[] = {
{"a", box_a},
{"applet", box_applet},
{"body", box_body},
- {"embed", box_embed},
+ {"button", box_button},
+ {"embed", box_embed},
{"form", box_form},
{"iframe", box_iframe},
{"img", box_image},
@@ -703,6 +707,7 @@ struct result box_textarea(xmlNode *n, struct status *status,
box->gadget = xcalloc(1, sizeof(struct gui_gadget));
box->gadget->type = GADGET_TEXTAREA;
box->gadget->form = status->current_form;
+ style->display = CSS_DISPLAY_INLINE_BLOCK;
/* split the content at newlines and make an inline container with an
* inline box for each line */
@@ -918,20 +923,24 @@ struct result box_input(xmlNode *n, struct status *status,
}
else if (stricmp(type, "submit") == 0 || stricmp(type, "reset") == 0)
{
- box = box_create(style, NULL, 0);
- box->gadget = gadget = xcalloc(1, sizeof(struct gui_gadget));
- gadget->type = GADGET_ACTIONBUTTON;
-
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) {
- gadget->data.actionbutt.label = s;
- }
+ struct result result = box_button(n, status, style);
+ struct box *inline_container, *inline_box;
+ box = result.box;
+ inline_container = box_create(0, 0, 0);
+ inline_container->type = BOX_INLINE_CONTAINER;
+ inline_box = box_create(style, 0, 0);
+ inline_box->type = BOX_INLINE;
+ inline_box->style_clone = 1;
+ if (box->gadget->value)
+ inline_box->text = tolat1(box->gadget->value);
+ else if (box->gadget->type == GADGET_SUBMIT)
+ inline_box->text = xstrdup(messages_get("Form_Submit"));
else
- {
- gadget->data.actionbutt.label = xstrdup(type);
- gadget->data.actionbutt.label[0] = toupper(type[0]);
- }
-
- box->gadget->data.actionbutt.butttype = strdup(type);
+ inline_box->text = xstrdup(messages_get("Form_Reset"));
+ inline_box->length = strlen(inline_box->text);
+ inline_box->font = font_open(status->content->data.html.fonts, style);
+ box_add_child(inline_container, inline_box);
+ box_add_child(box, inline_container);
}
else if (stricmp(type, "image") == 0)
{
@@ -962,14 +971,42 @@ struct result box_input(xmlNode *n, struct status *status,
if (gadget != 0) {
gadget->form = status->current_form;
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "name")))
- gadget->name = s;
+ gadget->name = (char *) xmlGetProp(n, (const xmlChar *) "name");
add_gadget_element(status->elements, gadget);
}
return (struct result) {box, 0};
}
+struct result box_button(xmlNode *n, struct status *status,
+ struct css_style *style)
+{
+ char *type = (char *) xmlGetProp(n, (const xmlChar *) "type");
+ struct box *box = box_create(style, 0, 0);
+ style->display = CSS_DISPLAY_INLINE_BLOCK;
+
+ if (!type || strcasecmp(type, "submit") == 0) {
+ box->gadget = xcalloc(1, sizeof(struct gui_gadget));
+ box->gadget->type = GADGET_SUBMIT;
+ } else if (strcasecmp(type, "reset") == 0) {
+ box->gadget = xcalloc(1, sizeof(struct gui_gadget));
+ box->gadget->type = GADGET_RESET;
+ } else {
+ /* type="button" or unknown: just render the contents */
+ xmlFree(type);
+ return (struct result) {box, 1};
+ }
+
+ if (type)
+ xmlFree(type);
+
+ box->gadget->form = status->current_form;
+ box->gadget->name = (char *) xmlGetProp(n, (const xmlChar *) "name");
+ box->gadget->value = (char *) xmlGetProp(n, (const xmlChar *) "value");
+
+ return (struct result) {box, 1};
+}
+
/**
* print a box tree to standard output
@@ -1425,6 +1462,8 @@ void gadget_free(struct gui_gadget* g)
if (g->name != 0)
xmlFree(g->name);
+ free(g->value);
+ free(g->initial_value);
switch (g->type)
{
@@ -1452,10 +1491,6 @@ void gadget_free(struct gui_gadget* g)
if (g->data.password.text != 0)
xmlFree(g->data.password.text);
break;
- case GADGET_ACTIONBUTTON:
- if (g->data.actionbutt.label != 0)
- xmlFree(g->data.actionbutt.label);
- break;
case GADGET_IMAGE:
if (g->data.image.n != 0)
xmlFree(g->data.image.n);
diff --git a/render/box.h b/render/box.h
index 9e8ce0599..0dad5400d 100644
--- a/render/box.h
+++ b/render/box.h
@@ -43,9 +43,11 @@ struct box;
struct gui_gadget {
enum { GADGET_HIDDEN = 0, GADGET_TEXTBOX, GADGET_RADIO, GADGET_CHECKBOX,
- GADGET_SELECT, GADGET_TEXTAREA, GADGET_ACTIONBUTTON,
- GADGET_IMAGE, GADGET_PASSWORD } type;
- char* name;
+ GADGET_SELECT, GADGET_TEXTAREA,
+ GADGET_IMAGE, GADGET_PASSWORD, GADGET_SUBMIT, GADGET_RESET } type;
+ char *name;
+ char *value;
+ char *initial_value;
struct form* form;
union {
struct {
@@ -62,11 +64,6 @@ struct gui_gadget {
int size;
} password;
struct {
- char* butttype;
- char* label;
- int pressed;
- } actionbutt;
- struct {
char* name;
char* value;
char* n;
diff --git a/render/layout.c b/render/layout.c
index 3ea45c789..4c9f2a832 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -314,12 +314,6 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
x += b->width + b->space ? b->font->space_width : 0;
else
x += b->width;
-
- } else if (b->type == BOX_INLINE_BLOCK) {
- layout_block(b, width, b, 0, 0);
- if (height < b->height)
- height = b->height;
- x += b->width;
}
}
@@ -331,6 +325,21 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
/* pass 2: place boxes in line */
for (x = x_previous = 0, b = first; x <= x1 - x0 && b != 0; b = b->next) {
if (b->type == BOX_INLINE || b->type == BOX_INLINE_BLOCK) {
+ if (b->type == BOX_INLINE_BLOCK) {
+ unsigned long w = width;
+ if (b->style->width.width == CSS_WIDTH_AUTO) {
+ calculate_widths(b);
+ if (b->max_width < width)
+ w = b->max_width;
+ else
+ w = b->min_width;
+ }
+ layout_node(b, w, b, 0, 0);
+ /* increase height to contain any floats inside */
+ for (fl = b->float_children; fl != 0; fl = fl->next_float)
+ if (b->height < fl->y + fl->height)
+ b->height = fl->y + fl->height;
+ }
x_previous = x;
x += space_after;
b->x = x;
@@ -400,7 +409,7 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
x = x_previous;
- if (!c->object && c->text)
+ if (!c->object && !c->gadget && c->text)
space = strchr(c->text, ' ');
if (space != 0 && c->length <= (unsigned int) (space - c->text))
/* space after end of string */
@@ -849,7 +858,8 @@ void calculate_inline_container_widths(struct box *box)
child->width = font_width(child->font,
child->text, child->length);
max += child->width;
- /* TODO: add spaces */
+ if (child->next && child->space)
+ max += child->font->space_width;
/* min = widest word */
i = 0;
diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c
index 892b49795..fcfd663eb 100644
--- a/riscos/htmlredraw.c
+++ b/riscos/htmlredraw.c
@@ -57,8 +57,6 @@ void html_redraw(struct content *c, long x, long y,
static char validation_textarea[] = "R7;L";
static char validation_textbox[] = "";
static char validation_password[] = "D*";
-static char validation_actionbutton[] = "R5";
-static char validation_actionbutton_pressed[] = "R5,3";
static char validation_select[] = "R2";
static char validation_checkbox_selected[] = "Sopton";
static char validation_checkbox_unselected[] = "Soptoff";
@@ -127,7 +125,10 @@ void html_redraw_box(struct content *content, struct box * box,
if (box->object) {
content_redraw(box->object, x, y, width, height, x0, y0, x1, y1);
- } else if (box->gadget && box->gadget->type != GADGET_TEXTAREA) {
+ } else if (box->gadget &&
+ box->gadget->type != GADGET_TEXTAREA &&
+ box->gadget->type != GADGET_SUBMIT &&
+ box->gadget->type != GADGET_RESET) {
wimp_icon icon;
LOG(("writing GADGET"));
@@ -159,25 +160,6 @@ void html_redraw_box(struct content *content, struct box * box,
wimp_plot_icon(&icon);
break;
- case GADGET_ACTIONBUTTON:
- icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER |
- wimp_ICON_VCENTRED | wimp_ICON_FILLED |
- wimp_ICON_INDIRECTED | wimp_ICON_HCENTRED |
- (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT);
- icon.data.indirected_text.text = box->gadget->data.actionbutt.label;
- icon.data.indirected_text.size = strlen(box->gadget->data.actionbutt.label);
- if (box->gadget->data.actionbutt.pressed) {
- icon.data.indirected_text.validation = validation_actionbutton_pressed;
- icon.flags |=
- (wimp_COLOUR_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT) | wimp_ICON_SELECTED;
- } else {
- icon.data.indirected_text.validation = validation_actionbutton;
- icon.flags |= (wimp_COLOUR_VERY_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT);
- }
- LOG(("writing GADGET ACTION"));
- wimp_plot_icon(&icon);
- break;
-
case GADGET_SELECT:
icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER |
wimp_ICON_VCENTRED | wimp_ICON_FILLED |