Bug 162369

Summary: Align HTMLLabelElement.prototype.form with the HTML specification
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, ap, buildbot, cdumez, darin, rniwa, ryanhaddad, sam
Priority: P2 Keywords: WebExposed
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://html.spec.whatwg.org/#dom-label-form
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews122 for ios-simulator-elcapitan-wk2
none
Patch
none
Archive of layout-test-results from ews104 for mac-yosemite-wk2
none
Patch none

Description Chris Dumez 2016-09-21 19:12:55 PDT
Align HTMLLabelElement.prototype.label with the HTML specification:
- https://html.spec.whatwg.org/#dom-label-form

Firefox and Chrome match the specification.
Comment 1 Chris Dumez 2016-09-21 19:20:31 PDT
Created attachment 289506 [details]
Patch
Comment 2 Build Bot 2016-09-21 20:39:31 PDT
Comment on attachment 289506 [details]
Patch

Attachment 289506 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/2122464

New failing tests:
imported/w3c/web-platform-tests/html/semantics/forms/form-control-infrastructure/form.html
Comment 3 Build Bot 2016-09-21 20:39:34 PDT
Created attachment 289512 [details]
Archive of layout-test-results from ews122 for ios-simulator-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews122  Port: ios-simulator-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 4 Chris Dumez 2016-09-21 20:42:55 PDT
Created attachment 289513 [details]
Patch
Comment 5 Build Bot 2016-09-21 22:36:24 PDT
Comment on attachment 289513 [details]
Patch

Attachment 289513 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/2123128

New failing tests:
fast/images/move-image-to-new-document.html
Comment 6 Build Bot 2016-09-21 22:36:27 PDT
Created attachment 289520 [details]
Archive of layout-test-results from ews104 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 7 Chris Dumez 2016-09-21 22:52:42 PDT
(In reply to comment #6)
> Created attachment 289520 [details]
> Archive of layout-test-results from ews104 for mac-yosemite-wk2
> 
> The attached test failures were seen while running run-webkit-tests on the
> mac-wk2-ews.
> Bot: ews104  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5

(In reply to comment #5)
> Comment on attachment 289513 [details]
> Patch
> 
> Attachment 289513 [details] did not pass mac-wk2-ews (mac-wk2):
> Output: http://webkit-queues.webkit.org/results/2123128
> 
> New failing tests:
> fast/images/move-image-to-new-document.html

This test seems flaky, it also failed on my other patch.
Comment 8 Alexey Proskuryakov 2016-09-21 22:57:46 PDT
Caused by r206244, rolling it out.
Comment 9 Alexey Proskuryakov 2016-09-21 23:03:59 PDT
Rolled out in r206249.
Comment 10 Chris Dumez 2016-09-22 08:58:04 PDT
(In reply to comment #8)
> Caused by r206244, rolling it out.

Thanks Alexey!
Comment 11 Chris Dumez 2016-09-22 15:53:53 PDT
Created attachment 289619 [details]
Patch
Comment 12 Chris Dumez 2016-09-23 09:29:10 PDT
Anyone interested in reviewing? The new implementation matches the specification exactly. Also this aligns our behavior with both Chrome and Firefox, thus improving interoperability.
Comment 13 Alex Christensen 2016-09-23 10:51:16 PDT
Comment on attachment 289619 [details]
Patch

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

> Source/WebCore/html/HTMLLabelElement.h:35
>      WEBCORE_EXPORT LabelableElement* control();
> -    WEBCORE_EXPORT HTMLFormElement* form() const;
> +    WEBCORE_EXPORT HTMLFormElement* form();

We should make control const instead of form non-const.
Comment 14 Chris Dumez 2016-09-23 11:23:00 PDT
(In reply to comment #13)
> Comment on attachment 289619 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=289619&action=review
> 
> > Source/WebCore/html/HTMLLabelElement.h:35
> >      WEBCORE_EXPORT LabelableElement* control();
> > -    WEBCORE_EXPORT HTMLFormElement* form() const;
> > +    WEBCORE_EXPORT HTMLFormElement* form();
> 
> We should make control const instead of form non-const.

I don't mind either way but you do realize this means I'll have to add a const_cast inside control(), right? In the past, you have complained about those.
Comment 15 Ryosuke Niwa 2016-09-23 14:32:12 PDT
Comment on attachment 289619 [details]
Patch

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

>>> Source/WebCore/html/HTMLLabelElement.h:35
>>> +    WEBCORE_EXPORT HTMLFormElement* form();
>> 
>> We should make control const instead of form non-const.
> 
> I don't mind either way but you do realize this means I'll have to add a const_cast inside control(), right? In the past, you have complained about those.

I think the patch is fine as is but change const-ness if Alex feels strongly either way.
Comment 16 Chris Dumez 2016-09-23 14:47:59 PDT
(In reply to comment #15)
> Comment on attachment 289619 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=289619&action=review
> 
> >>> Source/WebCore/html/HTMLLabelElement.h:35
> >>> +    WEBCORE_EXPORT HTMLFormElement* form();
> >> 
> >> We should make control const instead of form non-const.
> > 
> > I don't mind either way but you do realize this means I'll have to add a const_cast inside control(), right? In the past, you have complained about those.
> 
> I think the patch is fine as is but change const-ness if Alex feels strongly
> either way.

The issue with making form() const is that it requires control() to be const as well. However, control() uses descendantsOfType() internally which uses a const iterator if |this| is const. Therefore, to make control() const I would need to either const_cast |this| before calling descendantsOfType() or const_cast the Element pointed to by the const_iterator returned by descendantsOfType().
Comment 17 Chris Dumez 2016-09-23 14:48:44 PDT
Comment on attachment 289619 [details]
Patch

Clearing flags on attachment: 289619

Committed r206332: <http://trac.webkit.org/changeset/206332>
Comment 18 Chris Dumez 2016-09-23 14:48:52 PDT
All reviewed patches have been landed.  Closing bug.