NetSurf
|
Interface to form handling functions internal to HTML content handler. More...
Go to the source code of this file.
Data Structures | |
struct | form_textarea_data |
Data for textarea. More... | |
struct | image_input_coords |
struct | form_control |
Form control. More... | |
struct | form |
HTML form. More... | |
Typedefs | |
typedef void(* | select_menu_redraw_callback) (void *client_data, int x, int y, int width, int height) |
Called by the select menu when it wants an area to be redrawn. More... | |
Enumerations | |
enum | form_control_type { GADGET_HIDDEN , GADGET_TEXTBOX , GADGET_RADIO , GADGET_CHECKBOX , GADGET_SELECT , GADGET_TEXTAREA , GADGET_IMAGE , GADGET_PASSWORD , GADGET_SUBMIT , GADGET_RESET , GADGET_FILE , GADGET_BUTTON } |
Type of a struct form_control. More... | |
enum | form_method { method_GET , method_POST_URLENC , method_POST_MULTIPART } |
Form submit method. More... | |
Functions | |
struct form * | form_new (void *node, const char *action, const char *target, form_method method, const char *charset, const char *doc_charset) |
Create a struct form. More... | |
void | form_free (struct form *form) |
Free a form and any controls it owns. More... | |
struct form_control * | form_new_control (void *node, form_control_type type) |
Create a struct form_control. More... | |
void | form_add_control (struct form *form, struct form_control *control) |
Add a control to the list of controls in a form. More... | |
void | form_free_control (struct form_control *control) |
Free a struct form_control. More... | |
bool | form_add_option (struct form_control *control, char *value, char *text, bool selected, void *node) |
Add an option to a form select control. More... | |
nserror | form_open_select_menu (void *client_data, struct form_control *control, select_menu_redraw_callback redraw_callback, struct content *c) |
Open a select menu for a select form control, creating it if necessary. More... | |
void | form_free_select_menu (struct form_control *control) |
Destroy a select menu and free allocated memory. More... | |
bool | form_redraw_select_menu (struct form_control *control, int x, int y, float scale, const struct rect *clip, const struct redraw_context *ctx) |
Redraw an opened select menu. More... | |
bool | form_clip_inside_select_menu (struct form_control *control, float scale, const struct rect *clip) |
Check whether a clipping rectangle is completely contained in the select menu. More... | |
const char * | form_select_mouse_action (struct form_control *control, enum browser_mouse_state mouse, int x, int y) |
Handle mouse action for the currently opened select menu. More... | |
void | form_select_mouse_drag_end (struct form_control *control, enum browser_mouse_state mouse, int x, int y) |
Handle mouse drag end for the currently opened select menu. More... | |
void | form_select_get_dimensions (struct form_control *control, int *width, int *height) |
Get the dimensions of a select menu. More... | |
void | form_select_menu_callback (void *client_data, int x, int y, int width, int height) |
Callback for the core select menu. More... | |
void | form_radio_set (struct form_control *radio) |
Set a radio form control and clear the others in the group. More... | |
nserror | form_submit (struct nsurl *page_url, struct browser_window *target, struct form *form, struct form_control *submit_button) |
navigate browser window based on form submission. More... | |
void | form_gadget_update_value (struct form_control *control, char *value) |
Update gadget value. More... | |
void | form_gadget_sync_with_dom (struct form_control *control) |
Synchronise this gadget with its associated DOM node. More... | |
Interface to form handling functions internal to HTML content handler.
Definition in file form_internal.h.
typedef void(* select_menu_redraw_callback) (void *client_data, int x, int y, int width, int height) |
Called by the select menu when it wants an area to be redrawn.
The coordinates are menu origin relative.
client_data | data which was passed to form_open_select_menu |
x | X coordinate of redraw rectangle |
y | Y coordinate of redraw rectangle |
width | width of redraw rectangle |
height | height of redraw rectangle |
Definition at line 152 of file form_internal.h.
enum form_control_type |
Type of a struct form_control.
Enumerator | |
---|---|
GADGET_HIDDEN | |
GADGET_TEXTBOX | |
GADGET_RADIO | |
GADGET_CHECKBOX | |
GADGET_SELECT | |
GADGET_TEXTAREA | |
GADGET_IMAGE | |
GADGET_PASSWORD | |
GADGET_SUBMIT | |
GADGET_RESET | |
GADGET_FILE | |
GADGET_BUTTON |
Definition at line 47 of file form_internal.h.
enum form_method |
Form submit method.
Enumerator | |
---|---|
method_GET | GET, always url encoded. |
method_POST_URLENC | POST, url encoded. |
method_POST_MULTIPART | POST, multipart/form-data. |
Definition at line 121 of file form_internal.h.
void form_add_control | ( | struct form * | form, |
struct form_control * | control | ||
) |
Add a control to the list of controls in a form.
form | The form to add the control to |
control | The control to add |
Definition at line 1433 of file form.c.
References form::controls, form_control::form, form::last_control, form_control::next, and form_control::prev.
Referenced by parse_button_element(), parse_input_element(), parse_select_element(), and parse_textarea_element().
bool form_add_option | ( | struct form_control * | control, |
char * | value, | ||
char * | text, | ||
bool | selected, | ||
void * | node | ||
) |
Add an option to a form select control.
control | form control of type GADGET_SELECT |
value | value of option, used directly (not copied) |
text | text for option, used directly (not copied) |
selected | this option is selected |
node | the DOM node this option is associated with |
Definition at line 1529 of file form.c.
References form_control::data, GADGET_SELECT, form_option::initial_selected, form_option::node, form_option::selected, text(), form_option::text, form_control::type, and form_option::value.
Referenced by box_select_add_option().
bool form_clip_inside_select_menu | ( | struct form_control * | control, |
float | scale, | ||
const struct rect * | clip | ||
) |
Check whether a clipping rectangle is completely contained in the select menu.
control | the select menu to check the clipping rectangle for |
scale | the current browser window scale |
clip | the clipping rectangle |
Definition at line 1807 of file form.c.
References clip(), form_control::data, form_select_menu::height, height, form_select_menu::width, and width.
Referenced by html_redraw().
void form_free | ( | struct form * | form | ) |
Free a form and any controls it owns.
form | The form to free |
Definition at line 2329 of file form.c.
References form::accept_charsets, form::action, form::controls, form::document_charset, form_free_control(), form_control::next, and form::target.
Referenced by html_destroy().
void form_free_control | ( | struct form_control * | control | ) |
Free a struct form_control.
control | structure to free |
Definition at line 1455 of file form.c.
References form::controls, form_control::data, form_control::form, form_free_select_menu(), GADGET_PASSWORD, GADGET_SELECT, GADGET_TEXTAREA, GADGET_TEXTBOX, form_control::initial_value, form::last_control, form_control::last_synced_value, form_control::name, form_control::next, form_option::next, form_control::node_value, NSLOG, form_option::text, textarea_destroy(), form_control::type, form_control::value, and form_option::value.
Referenced by box_free_box(), box_select(), form_free(), invent_fake_gadget(), parse_button_element(), and parse_input_element().
void form_free_select_menu | ( | struct form_control * | control | ) |
Destroy a select menu and free allocated memory.
control | the select form control owning the select menu being destroyed. |
Definition at line 1645 of file form.c.
References form_control::data, and scrollbar_destroy().
Referenced by form_free_control().
void form_gadget_sync_with_dom | ( | struct form_control * | control | ) |
Synchronise this gadget with its associated DOM node.
If the DOM has changed and the gadget has not, the DOM's new value is imported into the gadget. If the gadget's value has changed and the DOM's has not, the gadget's value is pushed into the DOM. If both have changed, the gadget's value wins.
control | The form gadget to synchronise |
Definition at line 2170 of file form.c.
References form_control::data, GADGET_HIDDEN, GADGET_PASSWORD, GADGET_TEXTAREA, GADGET_TEXTBOX, form_control::last_synced_value, form_control::node, form_control::node_value, strndup(), form_control::syncing, textarea_set_text(), form_control::type, fetch_multipart_data::value, and form_control::value.
Referenced by form_gadget_update_value(), html_texty_element_update(), and parse_input_element().
void form_gadget_update_value | ( | struct form_control * | control, |
char * | value | ||
) |
Update gadget value.
Definition at line 2128 of file form.c.
References form_gadget_sync_with_dom(), GADGET_FILE, GADGET_HIDDEN, GADGET_PASSWORD, GADGET_TEXTAREA, GADGET_TEXTBOX, form_control::node, form_control::type, fetch_multipart_data::value, and form_control::value.
Referenced by box_textarea_callback(), and html__set_file_gadget_filename().
struct form * form_new | ( | void * | node, |
const char * | action, | ||
const char * | target, | ||
form_method | method, | ||
const char * | charset, | ||
const char * | doc_charset | ||
) |
Create a struct form.
node | DOM node associated with form |
action | URL to submit form to, or NULL for default |
target | Target frame of form, or NULL for default |
method | method and enctype |
charset | acceptable encodings for form submission, or NULL |
doc_charset | encoding of containing document, or NULL |
Definition at line 2276 of file form.c.
References form::accept_charsets, form::action, form::document_charset, form::method, form::node, and form::target.
Referenced by parse_form_element().
struct form_control * form_new_control | ( | void * | node, |
form_control_type | type | ||
) |
Create a struct form_control.
node | Associated DOM node |
type | control type |
Definition at line 2349 of file form.c.
References form_control::node, form_control::type, and type.
Referenced by invent_fake_gadget(), parse_button_element(), parse_input_element(), parse_select_element(), and parse_textarea_element().
nserror form_open_select_menu | ( | void * | client_data, |
struct form_control * | control, | ||
select_menu_redraw_callback | redraw_callback, | ||
struct content * | c | ||
) |
Open a select menu for a select form control, creating it if necessary.
client_data | data passed to the redraw callback |
control | The select form control for which the menu is being opened |
redraw_callback | The callback to redraw the select menu. |
c | The content the select menu is opening for. |
Definition at line 1569 of file form.c.
References box::border, form_control::box, form_select_menu::c, form_select_menu::callback, form_select_menu::client_data, form_control::data, form_select_menu::f_size, font_plot_style_from_css(), form_select_menu_scroll_callback(), form_select_menu::height, LEFT, form_select_menu::line_height, MAX_SELECT_HEIGHT, NSERROR_NOMEM, NSERROR_OK, box::padding, PLOT_STYLE_SCALE, RIGHT, form_select_menu::scrollbar, scrollbar_create(), SELECT_LINE_SPACING, plot_font_style::size, box::style, html_content::unit_len_ctx, box_border::width, box::width, and form_select_menu::width.
Referenced by gadget_mouse_action().
void form_radio_set | ( | struct form_control * | radio | ) |
Set a radio form control and clear the others in the group.
radio | form control of type GADGET_RADIO |
Definition at line 1994 of file form.c.
References form_control::box, form::controls, form_control::form, GADGET_RADIO, form_control::html, html__redraw_a_box(), form_control::name, form_control::next, form_control::node, form_control::selected, and form_control::type.
Referenced by gadget_mouse_action().
bool form_redraw_select_menu | ( | struct form_control * | control, |
int | x, | ||
int | y, | ||
float | scale, | ||
const struct rect * | clip, | ||
const struct redraw_context * | ctx | ||
) |
Redraw an opened select menu.
control | the select menu being redrawn |
x | the X coordinate to draw the menu at |
y | the Y coordinate to draw the menu at |
scale | current redraw scale |
clip | clipping rectangle |
ctx | current redraw context |
Definition at line 1656 of file form.c.
References box::border, form_control::box, clip(), plotter_table::clip, form_control::data, form_select_menu::f_size, form_select_menu::height, height, LEFT, form_select_menu::line_height, line_height(), form_option::next, NSERROR_OK, box::padding, redraw_context::plot, plot_fstyle_entry, plot_style_fill_lightwbasec, plot_style_fill_selected, plot_style_stroke_darkwbasec, plotter_table::rectangle, form_select_menu::scrollbar, scrollbar_get_offset(), scrollbar_redraw(), SCROLLBAR_WIDTH, SELECT_BORDER_WIDTH, SELECT_LINE_SPACING, form_option::selected, plot_font_style::size, form_option::text, plotter_table::text, box_border::width, form_select_menu::width, width, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by html_redraw().
void form_select_get_dimensions | ( | struct form_control * | control, |
int * | width, | ||
int * | height | ||
) |
Get the dimensions of a select menu.
control | the select menu to get the dimensions of |
width | gets updated to menu width |
height | gets updated to menu height |
Definition at line 1965 of file form.c.
References form_control::data, height, and width.
Referenced by mouse_action_select_menu().
void form_select_menu_callback | ( | void * | client_data, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height | ||
) |
Callback for the core select menu.
Definition at line 1974 of file form.c.
References box::border, BOTTOM, form_control::box, box_coords(), form_select_menu::client_data, content__request_redraw(), box::height, height, LEFT, box::padding, TOP, html_content::visible_select_menu, box_border::width, width, box::x, and box::y.
Referenced by gadget_mouse_action().
const char * form_select_mouse_action | ( | struct form_control * | control, |
enum browser_mouse_state | mouse, | ||
int | x, | ||
int | y | ||
) |
Handle mouse action for the currently opened select menu.
control | the select menu which received the mouse action |
mouse | current mouse state |
x | X coordinate of click |
y | Y coordinate of click |
Definition at line 1874 of file form.c.
References BROWSER_MOUSE_CLICK_1, BROWSER_MOUSE_CLICK_2, form_control::data, form_select_menu_clicked(), form_select_menu::height, messages_get(), form_select_menu::scroll_capture, form_select_menu::scrollbar, scrollbar_mouse_action(), scrollbar_mouse_status_to_message(), SCROLLBAR_WIDTH, and form_select_menu::width.
Referenced by mouse_action_select_menu().
void form_select_mouse_drag_end | ( | struct form_control * | control, |
enum browser_mouse_state | mouse, | ||
int | x, | ||
int | y | ||
) |
Handle mouse drag end for the currently opened select menu.
control | the select menu which received the mouse drag end |
mouse | current mouse state |
x | X coordinate of drag end |
y | Y coordinate of drag end |
Definition at line 1924 of file form.c.
References box::border, BOTTOM, form_control::box, box_coords(), form_control::data, form_select_menu_clicked(), box::height, form_select_menu::height, LEFT, box::padding, form_select_menu::scroll_capture, form_select_menu::scrollbar, scrollbar_mouse_drag_end(), SCROLLBAR_WIDTH, TOP, box_border::width, and form_select_menu::width.
Referenced by mouse_action_select_menu().
nserror form_submit | ( | struct nsurl * | page_url, |
struct browser_window * | target, | ||
struct form * | form, | ||
struct form_control * | submit_button | ||
) |
navigate browser window based on form submission.
page_url | content url |
target | The browsing context in which the navigation will occour. |
form | The form to submit. |
submit_button | The control used to submit the form. |
Definition at line 2047 of file form.c.
References form::action, browser_window_navigate(), BW_NAVIGATE_HISTORY, form_control::data, fetch_multipart_data_destroy(), form_dom_to_data(), form_url_encode(), form::method, method_GET, method_POST_MULTIPART, method_POST_URLENC, NSERROR_OK, nsurl_create(), nsurl_replace_query(), and nsurl_unref().
Referenced by box_textarea_keypress(), and mouse_action_drag_none().