diff --git a/NEWS b/NEWS index 83e48d4c..744073d8 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,8 @@ Miscellaneous: document.css.media. * bug 638: Propagate the existence of $DISPLAY from slave terminals to mailcap test commands. +* bug 698: Attach controls to the intended form even if it is + incorrectly nested in a table. (Was broken in 0.11.4.) * bug 963: New option document.css.ignore_display_none. * bug 977: Fixed crash when opening in new tab a non link with onclick attribute. diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index f3979e9e..bbb4e4c1 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -1783,7 +1783,11 @@ end: static void html_special_form(struct part *part, struct form *form) { + struct form *nform; + assert(part && form); + assert(form->form_num > 0); + assert(form->form_end == INT_MAX); if_assert_failed return; if (!part->document) { @@ -1791,50 +1795,60 @@ html_special_form(struct part *part, struct form *form) return; } - if (!list_empty(part->document->forms)) { - struct form *nform; - - /* Make sure the new form ``claims'' its slice of the form range - * maintained in the form_num and form_end variables. */ - foreach (nform, part->document->forms) { - if (form->form_num < nform->form_num - || nform->form_end < form->form_num) - continue; - - /* First check if the form has identical form numbers. - * That should only be the case when the form being - * added is in fact the same form in which case it - * should be dropped. The fact that this can happen - * suggests that the table renderering can be confused. - * See bug 647 for a test case. */ - if (nform->form_num == form->form_num - && nform->form_end == form->form_end) { - done_form(form); - return; - } - - /* The form start is inside an already added form, so - * partition the space of the existing form and get - * |old|new|. */ - nform->form_end = form->form_num - 1; - assertm(nform->form_num <= nform->form_end, - "[%d:%d] [%d:%d]", nform->form_num, nform->form_end, - form->form_num, form->form_end); - break; + /* Make a fake form with form_num == 0 so that there is + * something to use if form controls appear above the first + * actual FORM element. There can never be a real form with + * form_num == 0 because the form_num is the position after the + * "