2005-09-15 09:58:31 -04:00
|
|
|
#ifndef EL__DOCUMENT_FORMS_H
|
|
|
|
#define EL__DOCUMENT_FORMS_H
|
|
|
|
|
|
|
|
#include "util/lists.h"
|
|
|
|
|
|
|
|
struct document;
|
|
|
|
struct menu_item;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum form_method {
|
|
|
|
FORM_METHOD_GET,
|
|
|
|
FORM_METHOD_POST,
|
|
|
|
FORM_METHOD_POST_MP,
|
|
|
|
FORM_METHOD_POST_TEXT_PLAIN,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct form {
|
|
|
|
LIST_HEAD(struct form);
|
|
|
|
|
|
|
|
/* The value of @form_num serves both as a unique ID of the form.
|
|
|
|
* However @form_num and @form_end also stores information about where
|
|
|
|
* in the source the form is positioned. Combined they are used to
|
|
|
|
* figured which form items belong to which forms after rendering
|
|
|
|
* tables.
|
|
|
|
*
|
|
|
|
* Initially the range between @form_num and @form_end will stretch from
|
|
|
|
* 0 to INT_MAX. When a new form is added the range is partitioned so
|
|
|
|
* the forms each has unique source ranges. */
|
|
|
|
int form_num;
|
|
|
|
int form_end;
|
|
|
|
|
|
|
|
unsigned char *action;
|
|
|
|
unsigned char *name;
|
2006-01-28 05:17:22 -05:00
|
|
|
unsigned char *onsubmit;
|
2005-09-15 09:58:31 -04:00
|
|
|
unsigned char *target;
|
|
|
|
enum form_method method;
|
|
|
|
|
2007-07-26 12:04:35 -04:00
|
|
|
LIST_OF(struct form_control) items;
|
2005-09-15 09:58:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum form_type {
|
|
|
|
FC_TEXT,
|
|
|
|
FC_PASSWORD,
|
|
|
|
FC_FILE,
|
|
|
|
FC_TEXTAREA,
|
|
|
|
FC_CHECKBOX,
|
|
|
|
FC_RADIO,
|
|
|
|
FC_SELECT,
|
|
|
|
FC_SUBMIT,
|
|
|
|
FC_IMAGE,
|
|
|
|
FC_RESET,
|
|
|
|
FC_BUTTON,
|
|
|
|
FC_HIDDEN,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum form_mode {
|
|
|
|
FORM_MODE_NORMAL,
|
|
|
|
FORM_MODE_READONLY,
|
|
|
|
FORM_MODE_DISABLED,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define form_field_is_readonly(field) ((field)->mode != FORM_MODE_NORMAL)
|
|
|
|
|
|
|
|
enum form_wrap {
|
|
|
|
FORM_WRAP_NONE,
|
|
|
|
FORM_WRAP_SOFT,
|
|
|
|
FORM_WRAP_HARD,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct form_control {
|
|
|
|
LIST_HEAD(struct form_control);
|
|
|
|
|
|
|
|
struct form *form;
|
|
|
|
int g_ctrl_num;
|
|
|
|
|
|
|
|
/* The value of @position is relative to the place of the form item in
|
|
|
|
* the source. */
|
|
|
|
int position;
|
|
|
|
|
|
|
|
enum form_type type;
|
|
|
|
enum form_mode mode;
|
|
|
|
|
2006-05-01 13:22:07 -04:00
|
|
|
unsigned char *id; /* used by scripts */
|
2005-09-15 09:58:31 -04:00
|
|
|
unsigned char *name;
|
|
|
|
unsigned char *alt;
|
Bug 784: Keep form_control.default_value in the document charset.
Previously, html_special_form_control converted
form_control.default_value to the terminal charset, and init_form_state
then copied the value to form_state.value. However, when CONFIG_UTF8
is defined and UTF-8 I/O is enabled, form_state.value is supposed to
be in UTF-8, rather than in the terminal charset.
This mismatch could not be conveniently fixed in
html_special_form_control because that does not know which terminal is
being used and whether UTF-8 I/O is enabled there. Also, constructing
a conversion table from the document charset to form_state.value could
have ruined renderer_context.convert_table, because src/intl/charsets.c
does not support multiple concurrent conversion tables.
So instead, we now keep form_control.default_value in the document
charset, and convert it in the viewer each time it is needed. Because
the result of the conversion is kept in form_state.value between
incremental renderings, this shouldn't even slow things down too much.
I am not implementing the proper charset conversions for the DOM
defaultValue property yet, because the current code doesn't have
them for other string properties either, and bug 805 is already open
for that.
2007-04-29 15:01:13 -04:00
|
|
|
/* For FC_TEXT, FC_PASSWORD, and FC_TEXTAREA: @default_value
|
|
|
|
* is in the charset of the document.
|
|
|
|
*
|
|
|
|
* For FC_FILE: The parser does not set @default_value. */
|
2005-09-15 09:58:31 -04:00
|
|
|
unsigned char *default_value;
|
|
|
|
int default_state;
|
|
|
|
int size;
|
|
|
|
int cols, rows;
|
|
|
|
enum form_wrap wrap;
|
|
|
|
int maxlength;
|
|
|
|
int nvalues;
|
|
|
|
unsigned char **values;
|
2007-05-20 08:31:02 -04:00
|
|
|
/* For FC_SELECT: @labels are in the charset of the terminal.
|
|
|
|
* (That charset can be UTF-8 only if CONFIG_UTF8 is defined,
|
|
|
|
* and is assumed to be unibyte otherwise.) The charset of
|
|
|
|
* the document and the UTF-8 I/O option have no effect
|
|
|
|
* here. */
|
2005-09-15 09:58:31 -04:00
|
|
|
unsigned char **labels;
|
|
|
|
struct menu_item *menu;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Numerical form type <-> form type name */
|
|
|
|
int str2form_type(unsigned char *s);
|
|
|
|
unsigned char *form_type2str(enum form_type num);
|
|
|
|
|
|
|
|
struct form *init_form(void);
|
|
|
|
void done_form(struct form *form);
|
|
|
|
int has_form_submit(struct form *form);
|
|
|
|
|
|
|
|
int get_form_control_link(struct document *document, struct form_control *fc);
|
|
|
|
void done_form_control(struct form_control *fc);
|
|
|
|
|
|
|
|
#endif
|