Bug 50195 - Progress and meter elements should take a form in their constructor like any other form control.
Summary: Progress and meter elements should take a form in their constructor like any ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-29 17:27 PST by Yael
Modified: 2010-11-30 16:16 PST (History)
9 users (show)

See Also:


Attachments
Patch. (3.44 KB, patch)
2010-11-29 17:31 PST, Yael
darin: review-
Details | Formatted Diff | Diff
Patch. (10.12 KB, patch)
2010-11-30 06:35 PST, Yael
no flags Details | Formatted Diff | Diff
Patch. (10.54 KB, patch)
2010-11-30 07:38 PST, Yael
no flags Details | Formatted Diff | Diff
Patch. (7.57 KB, patch)
2010-11-30 14:39 PST, Yael
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yael 2010-11-29 17:27:35 PST
Progress and meter elements should take a form in their constructor like any other form control.
Comment 1 Yael 2010-11-29 17:31:36 PST
Created attachment 75090 [details]
Patch.
Comment 2 Darin Adler 2010-11-29 17:38:38 PST
Comment on attachment 75090 [details]
Patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=75090&action=review

review- because this bug does require a test case

> WebCore/ChangeLog:8
> +        No new tests since this is a code cleanup only.

That is incorrect. The reason form elements get a form argument is so that they are correctly associated with the form in cases when the form is not an ancestor of the form element. We need to construct a test case that demonstrates this not occurring for meter elements before and happening correctly for meter elements after the patch.
Comment 3 Early Warning System Bot 2010-11-29 17:54:24 PST
Attachment 75090 [details] did not build on qt:
Build output: http://queues.webkit.org/results/6372115
Comment 4 Eric Seidel (no email) 2010-11-29 18:07:11 PST
Attachment 75090 [details] did not build on mac:
Build output: http://queues.webkit.org/results/6338113
Comment 5 WebKit Review Bot 2010-11-29 18:08:05 PST
Attachment 75090 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/6414110
Comment 6 Yael 2010-11-29 18:10:43 PST
(In reply to comment #2)
> (From update of attachment 75090 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=75090&action=review
> 
> review- because this bug does require a test case
> 
> > WebCore/ChangeLog:8
> > +        No new tests since this is a code cleanup only.
> 
> That is incorrect. The reason form elements get a form argument is so that they are correctly associated with the form in cases when the form is not an ancestor of the form element. We need to construct a test case that demonstrates this not occurring for meter elements before and happening correctly for meter elements after the patch.

Sorry, I thought that HTMLElement::findFormAncestor() was taking care of associating the correct form. I'll add a test.

I also need to touch some header file to force a rebuild on the buildbots.
Comment 7 Eric Seidel (no email) 2010-11-29 19:03:03 PST
Attachment 75090 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/6444040
Comment 8 Yael 2010-11-29 19:25:14 PST
Any suggestion which file to touch in order to trigger a clean build?
thanks!
Comment 9 Build Bot 2010-11-29 19:51:04 PST
Attachment 75090 [details] did not build on win:
Build output: http://queues.webkit.org/results/6450028
Comment 10 WebKit Review Bot 2010-11-30 00:10:25 PST
Attachment 75090 [details] did not build on gtk:
Build output: http://queues.webkit.org/results/6384111
Comment 11 Yael 2010-11-30 06:35:07 PST
Created attachment 75136 [details]
Patch.

Added tests and also touch HTMLTagNames.in, to trigger re-generating HTMLElementFactory.cpp, to keep buildbots happy.

Please note that the tests are passing even without this patch because HTMLFormControlElement::insertedIntoTree will associate the form control with the form if the form was inserted first. HTMLFormElement::insertedIntoDocument will associate the form control with the form if the form is inserted after the form control.
Comment 12 Early Warning System Bot 2010-11-30 06:50:47 PST
Attachment 75136 [details] did not build on qt:
Build output: http://queues.webkit.org/results/6365122
Comment 13 Eric Seidel (no email) 2010-11-30 07:07:52 PST
Attachment 75136 [details] did not build on mac:
Build output: http://queues.webkit.org/results/6299141
Comment 14 WebKit Review Bot 2010-11-30 07:09:02 PST
Attachment 75136 [details] did not build on gtk:
Build output: http://queues.webkit.org/results/6311113
Comment 15 Yael 2010-11-30 07:38:20 PST
Created attachment 75146 [details]
Patch.

Fix the build.
Comment 16 Darin Adler 2010-11-30 07:40:09 PST
(In reply to comment #11)
> Please note that the tests are passing even without this patch because HTMLFormControlElement::insertedIntoTree will associate the form control with the form if the form was inserted first. HTMLFormElement::insertedIntoDocument will associate the form control with the form if the form is inserted after the form control.

Then the tests are incorrect. The whole point is to create tests that show the behavior that requires passing the form pointer.

If there is no behavior that requires passing a form pointer, then we should eliminate the form pointer from WebKit or at least eliminate it from the constructor arguments for form elements.
Comment 17 Darin Adler 2010-11-30 07:40:56 PST
Comment on attachment 75146 [details]
Patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=75146&action=review

Thanks very much for writing these tests. But we need tests that fail to prove there is a bug to fix, not tests that already pass!

> LayoutTests/fast/dom/HTMLMeterElement/script-tests/meter-element-outside-form.js:1
> +description('Test that a meter element is correctly associated with its for even if the form is not its ancestor.');

Typo "with its for".

> LayoutTests/fast/dom/HTMLProgressElement/script-tests/progress-element-outside-form.js:1
> +description('Test that a progress element is correctly associated with its for even if the form is not its ancestor.');

Same typo here.
Comment 18 Yael 2010-11-30 08:06:48 PST
(In reply to comment #17)
> (From update of attachment 75146 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=75146&action=review
> 
> Thanks very much for writing these tests. But we need tests that fail to prove there is a bug to fix, not tests that already pass!
> 

Darin, could you please elaborate on the bug? It seems to me that the form association of meter element and the form is done correctly even if the constructor does not take form as an argument. This is done when the meter element is inserted into the tree. HTMLFormControlElement::insertedIntoTree()  line 163 :

m_form = static_cast<HTMLFormElement*>(element)

If the meter element is created with createElement('meter') and not inserted into the tree, then we are not passing a form attribute to the constructor anyways.

What am I missing?
Comment 19 Darin Adler 2010-11-30 10:23:00 PST
(In reply to comment #18)
> Darin, could you please elaborate on the bug?

To find tests that depend on passing the form in when creating an element you could change HTMLConstructionSite::createHTMLElement so it passes 0 instead of form(). Then you will see some tests fail, which might give you a hint about the types of cases that require this. Then you could make similar tests with these element types. Or just add these element types to the existing test.
Comment 20 Alexey Proskuryakov 2010-11-30 10:49:11 PST
An input can be associated with a form even when it's not a descendant of the form element in DOM. Darin's suggestion above is certainly the best way to discover more detail.
Comment 21 Yael 2010-11-30 14:39:23 PST
Created attachment 75207 [details]
Patch.

Thank you for the advice, it helped me find that forms were not handled correctly e.g. when they are directly inside a table.
Modified tests are attached.
Comment 22 Yael 2010-11-30 16:16:11 PST
Committed r72976: <http://trac.webkit.org/changeset/72976>