mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-29 15:29:42 +03:00
Implement form targets (fix 1619094)
svn path=/trunk/netsurf/; revision=3125
This commit is contained in:
parent
98b451ffae
commit
1353585036
@ -842,6 +842,8 @@ void browser_window_destroy_internal(struct browser_window *bw)
|
|||||||
{
|
{
|
||||||
assert(bw);
|
assert(bw);
|
||||||
|
|
||||||
|
LOG(("Destroying window"));
|
||||||
|
|
||||||
if ((bw->children) || (bw->iframes))
|
if ((bw->children) || (bw->iframes))
|
||||||
browser_window_destroy_children(bw);
|
browser_window_destroy_children(bw);
|
||||||
if (bw->loading_content) {
|
if (bw->loading_content) {
|
||||||
@ -1212,6 +1214,8 @@ void browser_window_mouse_action_html(struct browser_window *bw,
|
|||||||
gadget_box = box;
|
gadget_box = box;
|
||||||
gadget_box_x = box_x;
|
gadget_box_x = box_x;
|
||||||
gadget_box_y = box_y;
|
gadget_box_y = box_y;
|
||||||
|
if (gadget->form)
|
||||||
|
target = gadget->form->target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (box->title)
|
if (box->title)
|
||||||
@ -1285,11 +1289,11 @@ void browser_window_mouse_action_html(struct browser_window *bw,
|
|||||||
status = status_buffer;
|
status = status_buffer;
|
||||||
pointer = GUI_POINTER_POINT;
|
pointer = GUI_POINTER_POINT;
|
||||||
if (mouse & BROWSER_MOUSE_CLICK_1)
|
if (mouse & BROWSER_MOUSE_CLICK_1)
|
||||||
browser_form_submit(bw, gadget->form,
|
browser_form_submit(bw, target, gadget->form,
|
||||||
gadget, false);
|
gadget);
|
||||||
else if (mouse & BROWSER_MOUSE_CLICK_2)
|
else if (mouse & BROWSER_MOUSE_CLICK_2)
|
||||||
browser_form_submit(bw, gadget->form,
|
browser_form_submit(bw, "_blank", gadget->form,
|
||||||
gadget, true);
|
gadget);
|
||||||
} else {
|
} else {
|
||||||
status = messages_get("FormBadSubmit");
|
status = messages_get("FormBadSubmit");
|
||||||
}
|
}
|
||||||
@ -2210,12 +2214,12 @@ gui_pointer_shape get_pointer_shape(css_cursor cursor)
|
|||||||
* Collect controls and submit a form.
|
* Collect controls and submit a form.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void browser_form_submit(struct browser_window *bw, struct form *form,
|
void browser_form_submit(struct browser_window *bw, const char *target,
|
||||||
struct form_control *submit_button, bool new_window)
|
struct form *form, struct form_control *submit_button)
|
||||||
{
|
{
|
||||||
char *data = 0, *url = 0;
|
char *data = 0, *url = 0;
|
||||||
struct form_successful_control *success;
|
struct form_successful_control *success;
|
||||||
struct browser_window *target;
|
struct browser_window *bw_form;
|
||||||
|
|
||||||
assert(form);
|
assert(form);
|
||||||
assert(bw->current_content->type == CONTENT_HTML);
|
assert(bw->current_content->type == CONTENT_HTML);
|
||||||
@ -2225,14 +2229,8 @@ void browser_form_submit(struct browser_window *bw, struct form *form,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_window) {
|
bw_form = browser_window_find_target(bw, target);
|
||||||
target = browser_window_create(NULL, bw, NULL, false);
|
assert(bw);
|
||||||
/* any error has already been reported */
|
|
||||||
if (!target)
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
target = bw;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (form->method) {
|
switch (form->method) {
|
||||||
case method_GET:
|
case method_GET:
|
||||||
@ -2255,7 +2253,7 @@ void browser_form_submit(struct browser_window *bw, struct form *form,
|
|||||||
else {
|
else {
|
||||||
sprintf(url, "%s?%s", form->action, data);
|
sprintf(url, "%s?%s", form->action, data);
|
||||||
}
|
}
|
||||||
browser_window_go(target, url, bw->current_content->url,
|
browser_window_go(bw_form, url, bw->current_content->url,
|
||||||
true);
|
true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2266,13 +2264,13 @@ void browser_form_submit(struct browser_window *bw, struct form *form,
|
|||||||
warn_user("NoMemory", 0);
|
warn_user("NoMemory", 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
browser_window_go_post(target, form->action, data, 0,
|
browser_window_go_post(bw_form, form->action, data, 0,
|
||||||
true, bw->current_content->url,
|
true, bw->current_content->url,
|
||||||
false);
|
false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case method_POST_MULTIPART:
|
case method_POST_MULTIPART:
|
||||||
browser_window_go_post(target, form->action, 0, success,
|
browser_window_go_post(bw_form, form->action, 0, success,
|
||||||
true, bw->current_content->url,
|
true, bw->current_content->url,
|
||||||
false);
|
false);
|
||||||
break;
|
break;
|
||||||
|
@ -209,8 +209,8 @@ bool browser_window_paste_text(struct browser_window *bw, const char *utf8,
|
|||||||
void browser_window_form_select(struct browser_window *bw,
|
void browser_window_form_select(struct browser_window *bw,
|
||||||
struct form_control *control, int item);
|
struct form_control *control, int item);
|
||||||
void browser_redraw_box(struct content *c, struct box *box);
|
void browser_redraw_box(struct content *c, struct box *box);
|
||||||
void browser_form_submit(struct browser_window *bw, struct form *form,
|
void browser_form_submit(struct browser_window *bw, const char *target,
|
||||||
struct form_control *submit_button, bool new_window);
|
struct form *form, struct form_control *submit_button);
|
||||||
|
|
||||||
void browser_window_redraw_rect(struct browser_window *bw, int x, int y,
|
void browser_window_redraw_rect(struct browser_window *bw, int x, int y,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
|
@ -920,7 +920,7 @@ void browser_window_input_callback(struct browser_window *bw,
|
|||||||
case 10:
|
case 10:
|
||||||
case 13: /* Return/Enter hit */
|
case 13: /* Return/Enter hit */
|
||||||
if (form)
|
if (form)
|
||||||
browser_form_submit(bw, form, 0, false);
|
browser_form_submit(bw, 0, form, 0);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 11: { /* Shift + Tab */
|
case 11: { /* Shift + Tab */
|
||||||
|
@ -38,7 +38,7 @@ static char *form_acceptable_charset(struct form *form);
|
|||||||
* \return a new structure, or 0 on memory exhaustion
|
* \return a new structure, or 0 on memory exhaustion
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct form *form_new(char *action, form_method method, char *charset,
|
struct form *form_new(char *action, char *target, form_method method, char *charset,
|
||||||
char *doc_charset)
|
char *doc_charset)
|
||||||
{
|
{
|
||||||
struct form *form;
|
struct form *form;
|
||||||
@ -47,6 +47,7 @@ struct form *form_new(char *action, form_method method, char *charset,
|
|||||||
if (!form)
|
if (!form)
|
||||||
return 0;
|
return 0;
|
||||||
form->action = action;
|
form->action = action;
|
||||||
|
form->target = target;
|
||||||
form->method = method;
|
form->method = method;
|
||||||
form->accept_charsets = charset;
|
form->accept_charsets = charset;
|
||||||
form->document_charset = doc_charset;
|
form->document_charset = doc_charset;
|
||||||
|
@ -30,6 +30,7 @@ typedef enum {
|
|||||||
/** HTML form. */
|
/** HTML form. */
|
||||||
struct form {
|
struct form {
|
||||||
char *action; /**< Absolute URL to submit to. */
|
char *action; /**< Absolute URL to submit to. */
|
||||||
|
char *target; /**< Target to submit to. */
|
||||||
form_method method; /**< Method and enctype. */
|
form_method method; /**< Method and enctype. */
|
||||||
char *accept_charsets; /**< Charset to submit form in */
|
char *accept_charsets; /**< Charset to submit form in */
|
||||||
char *document_charset; /**< Charset of document containing form */
|
char *document_charset; /**< Charset of document containing form */
|
||||||
@ -103,7 +104,7 @@ struct form_successful_control {
|
|||||||
struct form_successful_control *next; /**< Next in linked list. */
|
struct form_successful_control *next; /**< Next in linked list. */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct form *form_new(char *action, form_method method, char *charset,
|
struct form *form_new(char *action, char *target, form_method method, char *charset,
|
||||||
char *doc_charset);
|
char *doc_charset);
|
||||||
struct form_control *form_new_control(form_control_type type);
|
struct form_control *form_new_control(form_control_type type);
|
||||||
void form_add_control(struct form *form, struct form_control *control);
|
void form_add_control(struct form *form, struct form_control *control);
|
||||||
|
@ -504,6 +504,7 @@ bool html_head(struct content *c, xmlNode *head)
|
|||||||
if (node->type != XML_ELEMENT_NODE)
|
if (node->type != XML_ELEMENT_NODE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
LOG(("Node: %s", node->name));
|
||||||
if (!c->title && strcmp(node->name, "title") == 0) {
|
if (!c->title && strcmp(node->name, "title") == 0) {
|
||||||
xmlChar *title = xmlNodeGetContent(node);
|
xmlChar *title = xmlNodeGetContent(node);
|
||||||
if (!title)
|
if (!title)
|
||||||
|
Loading…
Reference in New Issue
Block a user