1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

Follow right link when link onClick changes docs

When a link had an onClick event handler that changed the current
document and that link was clicked, ELinks would follow the current link
of the document displayed after executing the handler instead of the
link that was clicked.

Factor goto_link out of goto_current_link.

Use goto_link instead of goto_current_link in activate_link to ensure that
the link that is passed in by enter() is followed.
This commit is contained in:
Miciah Dashiel Butler Masters 2008-08-02 00:04:13 +00:00
parent 76de375d3d
commit 9e5d79a803

View File

@ -943,18 +943,14 @@ call_onsubmit_and_submit(struct session *ses, struct document_view *doc_view,
return 1;
}
struct link *
goto_current_link(struct session *ses, struct document_view *doc_view, int do_reload)
static struct link *
goto_link(struct session *ses, struct document_view *doc_view, struct link *link, int do_reload)
{
struct link *link;
struct uri *uri;
assert(doc_view && ses);
assert(link && doc_view && ses);
if_assert_failed return NULL;
link = get_current_link(doc_view);
if (!link) return NULL;
if (link_is_form(link)) {
struct form_control *fc = link->data.form_control;
@ -983,6 +979,20 @@ goto_current_link(struct session *ses, struct document_view *doc_view, int do_re
return link;
}
struct link *
goto_current_link(struct session *ses, struct document_view *doc_view, int do_reload)
{
struct link *link;
assert(doc_view && ses);
if_assert_failed return NULL;
link = get_current_link(doc_view);
if (!link) return NULL;
return goto_link(ses, doc_view, link, do_reload);
}
static enum frame_event_status
activate_link(struct session *ses, struct document_view *doc_view,
struct link *link, int do_reload)
@ -997,7 +1007,7 @@ activate_link(struct session *ses, struct document_view *doc_view,
case LINK_FIELD:
case LINK_AREA:
case LINK_BUTTON:
if (goto_current_link(ses, doc_view, do_reload))
if (goto_link(ses, doc_view, link, do_reload))
return FRAME_EVENT_OK;
break;
case LINK_CHECKBOX: