Bug 101311 - Make namedItem return a node list only in HTMLFormControlsCollection and HTMLOptionsCollection
Summary: Make namedItem return a node list only in HTMLFormControlsCollection and HTML...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords:
Depends on:
Blocks: 78909 115150
  Show dependency treegraph
 
Reported: 2012-11-05 23:34 PST by Ryosuke Niwa
Modified: 2013-04-25 00:21 PDT (History)
19 users (show)

See Also:


Attachments
Work in progress (60.19 KB, patch)
2012-11-06 00:39 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Patch (97.08 KB, patch)
2012-11-06 16:13 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Patch (96.86 KB, patch)
2012-11-06 16:16 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Fixed builds (97.03 KB, patch)
2012-11-06 19:32 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Reverted v8::Undefined(isolate) change to fix tests (103.70 KB, patch)
2012-11-07 13:20 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Fixed more tests (104.09 KB, patch)
2012-11-08 20:08 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Synced to ToT (104.88 KB, patch)
2012-11-09 12:13 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Patch (104.78 KB, patch)
2012-11-17 00:18 PST, Ryosuke Niwa
darin: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2012-11-05 23:34:22 PST
DOM4 and HTML5 specifications make HTMLFormControlsCollection and HTMLOptionsCollection’s namedItem and named getter return a node list when there are multiple matches.

However, by default HTMLCollection’s namedItem and named getter returns the first item that matched the name, and this behavior can be much more efficient since it can stop the search as soon as it finds the first match. We should introduce the former two interfaces (they’re currently both implemented as HTMLCollection in WebKit) so that we can confine the said obnoxious, inefficient, behavior to those two interfaces.
Comment 1 Ryosuke Niwa 2012-11-05 23:36:52 PST
HTMLCollection specification:
http://www.w3.org/TR/domcore/#htmlcollection

HTML*Collection specifications:
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#collections-0
Comment 2 Ryosuke Niwa 2012-11-06 00:39:52 PST
Created attachment 172507 [details]
Work in progress

Somehow v8 binding is broken and I don’t know why. I’m gonna just give up for now and come back to it later.
Comment 3 Adam Barth 2012-11-06 00:44:35 PST
Comment on attachment 172507 [details]
Work in progress

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

> Source/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:54
> +        return v8Undefined();

You have the isolate.  You should pass it to v8Undefined.

> Source/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:67
> +        return v8Undefined();

ditto
Comment 4 Ian 'Hixie' Hickson 2012-11-06 12:03:41 PST
(In reply to comment #1)
> HTMLCollection specification:
> http://www.w3.org/TR/domcore/#htmlcollection

That's an obsolete link, the up to date link is: http://dom.spec.whatwg.org/
Comment 5 Ryosuke Niwa 2012-11-06 16:13:38 PST
Created attachment 172670 [details]
Patch
Comment 6 Ryosuke Niwa 2012-11-06 16:16:48 PST
Created attachment 172672 [details]
Patch
Comment 7 Ryosuke Niwa 2012-11-06 16:19:03 PST
I’m getting one test failure like this on fast/dom/wrapper-classes.html:

-PASS jsWrapperClass(document.createElement('select').options.constructor) is 'HTMLOptionsCollectionConstructor'
+FAIL jsWrapperClass(document.createElement('select').options.constructor) should be HTMLOptionsCollectionConstructor. Was Function.

As far as I can tell HTMLCollection has the same failure above. Does anyone know how to fix this?
Comment 8 WebKit Review Bot 2012-11-06 16:21:11 PST
Attachment 172672 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast..." exit_code: 1
Source/WebCore/html/HTMLFormControlsCollection.h:55:  Should have a space between // and comment  [whitespace/comments] [4]
Total errors found: 1 in 35 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 WebKit Review Bot 2012-11-06 16:49:50 PST
Comment on attachment 172672 [details]
Patch

Attachment 172672 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14745493
Comment 10 Build Bot 2012-11-06 17:13:18 PST
Comment on attachment 172672 [details]
Patch

Attachment 172672 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14761140
Comment 11 Peter Beverloo (cr-android ews) 2012-11-06 18:03:04 PST
Comment on attachment 172672 [details]
Patch

Attachment 172672 [details] did not pass cr-android-ews (chromium-android):
Output: http://queues.webkit.org/results/14760170
Comment 12 Ryosuke Niwa 2012-11-06 19:32:22 PST
Created attachment 172703 [details]
Fixed builds
Comment 13 Build Bot 2012-11-06 20:29:44 PST
Comment on attachment 172703 [details]
Fixed builds

Attachment 172703 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14733935
Comment 14 Ryosuke Niwa 2012-11-06 20:55:24 PST
7>c1xx : fatal error C1083: Cannot open source file: '..\html\HTMLFormCollection.cpp': No such file or directory
7>IDBFactoryBackendInterface.cpp

I can fix that easily :) once the review is done.
Comment 15 Build Bot 2012-11-06 22:40:55 PST
Comment on attachment 172703 [details]
Fixed builds

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

New failing tests:
fast/dom/dom-constructors.html
fast/dom/wrapper-classes.html
inspector/console/console-format-collections.html
Comment 16 WebKit Review Bot 2012-11-07 02:40:46 PST
Comment on attachment 172703 [details]
Fixed builds

Attachment 172703 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14765020

New failing tests:
dom/html/level2/html/HTMLCollection06.html
dom/html/level2/html/HTMLCollection04.html
dom/xhtml/level2/html/HTMLCollection09.xhtml
dom/xhtml/level2/html/HTMLCollection05.xhtml
dom/xhtml/level2/html/HTMLCollection07.xhtml
dom/html/level2/html/HTMLDocument07.html
dom/xhtml/level2/html/HTMLCollection04.xhtml
dom/html/level2/html/HTMLCollection10.html
dom/html/level2/html/HTMLDocument08.html
dom/xhtml/level2/html/HTMLCollection11.xhtml
dom/html/level2/html/HTMLCollection12.html
dom/html/level2/html/HTMLCollection09.html
dom/html/level2/html/HTMLDocument09.html
dom/html/level2/html/HTMLDocument10.html
dom/xhtml/level2/html/HTMLCollection12.xhtml
dom/xhtml/level2/html/HTMLCollection03.xhtml
dom/xhtml/level2/html/HTMLCollection08.xhtml
dom/html/level2/html/HTMLCollection11.html
dom/xhtml/level2/html/HTMLCollection10.xhtml
dom/xhtml/level2/html/HTMLCollection01.xhtml
dom/html/level2/html/HTMLCollection08.html
dom/html/level2/html/HTMLDocument11.html
dom/html/level2/html/HTMLCollection02.html
dom/html/level2/html/HTMLCollection03.html
dom/xhtml/level2/html/HTMLCollection06.xhtml
dom/html/level2/html/HTMLCollection07.html
dom/html/level2/html/HTMLCollection01.html
dom/html/level2/html/HTMLCollection05.html
dom/html/level2/html/AppletsCollection.html
dom/xhtml/level2/html/HTMLCollection02.xhtml
Comment 17 Kentaro Hara 2012-11-07 06:12:54 PST
Comment on attachment 172703 [details]
Fixed builds

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

> Source/WebCore/page/DOMWindow.idl:473
> +    attribute HTMLFormControlsCollectionConstructor HTMLFormControlsCollection;
> +    attribute HTMLOptionsCollectionConstructor HTMLOptionsCollection;

I guess the failures are caused by this change. Once you expose HTMLOptionsCollection to DOMWindow, window.HTMLOptionsCollection should look like a Function:

    function HTMLOptionsCollection() { [native code] }

So the right way to fix the problem would be just to update the test cases. You can write a test that just checks if (an instance of HTMLOptionsCollection).constructor === HTMLOptionsCollection.
Comment 18 Ryosuke Niwa 2012-11-07 11:40:07 PST
(In reply to comment #3)
> (From update of attachment 172507 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=172507&action=review
> 
> > Source/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:54
> > +        return v8Undefined();
> 
> You have the isolate.  You should pass it to v8Undefined.
> 
> > Source/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:67
> > +        return v8Undefined();
> 
> ditto

Unfortunately, doing this in namedPropertyGetter results in not falling back to access properties :( So I’m reverting that back.
Comment 19 Ryosuke Niwa 2012-11-07 13:20:57 PST
Created attachment 172864 [details]
Reverted v8::Undefined(isolate) change to fix tests
Comment 20 Build Bot 2012-11-07 14:12:05 PST
Comment on attachment 172864 [details]
Reverted v8::Undefined(isolate) change to fix tests

Attachment 172864 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14745814
Comment 21 WebKit Review Bot 2012-11-08 05:07:31 PST
Comment on attachment 172864 [details]
Reverted v8::Undefined(isolate) change to fix tests

Attachment 172864 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14771135

New failing tests:
fast/dom/htmlcollection-reachable.html
fast/dom/html-collections-named-getter.html
fast/dom/gc-9.html
inspector/console/console-format-collections.html
Comment 22 Ryosuke Niwa 2012-11-08 20:08:31 PST
Created attachment 173182 [details]
Fixed more tests
Comment 23 Erik Arvidsson 2012-11-09 06:56:27 PST
Comment on attachment 173182 [details]
Fixed more tests

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

> Source/WebCore/ChangeLog:10
> +        there are multiple matches. Introducing these two interfaces allow us to "regular" HTMLCollection's named getter

typo

> LayoutTests/fast/dom/html-collections-named-getter.html:30
> +var newDoc = document.implementation.createDocument(null, 'html', null);

This is never used

> LayoutTests/fast/dom/html-collections-named-getter.html:101
> +var successfullyParsed = true;

No need for this line

> LayoutTests/fast/dom/wrapper-classes-expected.txt:145
> +FAIL jsWrapperClass(document.createElement('select').options.constructor) should be HTMLOptionsCollectionConstructor. Was Function.

How come this broke by this change?
Comment 24 Ryosuke Niwa 2012-11-09 11:36:23 PST
(In reply to comment #23)
> (From update of attachment 173182 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=173182&action=review
> 
> > Source/WebCore/ChangeLog:10
> > +        there are multiple matches. Introducing these two interfaces allow us to "regular" HTMLCollection's named getter
> 
> typo

Where?

> > LayoutTests/fast/dom/html-collections-named-getter.html:30
> > +var newDoc = document.implementation.createDocument(null, 'html', null);
> 
> This is never used

Will remove.

> > LayoutTests/fast/dom/html-collections-named-getter.html:101
> > +var successfullyParsed = true;
> 
> No need for this line

Nah… I’d like to keep it there.

> > LayoutTests/fast/dom/wrapper-classes-expected.txt:145
> > +FAIL jsWrapperClass(document.createElement('select').options.constructor) should be HTMLOptionsCollectionConstructor. Was Function.
> 
> How come this broke by this change?

See haraken’s comment #17.
Comment 25 Erik Arvidsson 2012-11-09 12:06:35 PST
Comment on attachment 173182 [details]
Fixed more tests

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

>>> Source/WebCore/ChangeLog:10
>>> +        there are multiple matches. Introducing these two interfaces allow us to "regular" HTMLCollection's named getter
>> 
>> typo
> 
> Where?

allow us to "regular"...

>>> LayoutTests/fast/dom/html-collections-named-getter.html:101
>>> +var successfullyParsed = true;
>> 
>> No need for this line
> 
> Nah… I’d like to keep it there.

Why? This has no effect.;

js-test-*.js takes care of successfullyParsed for you already. If there is a parse error js-test-* will take care of it.
Comment 26 Ryosuke Niwa 2012-11-09 12:09:31 PST
Comment on attachment 173182 [details]
Fixed more tests

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

>>>> Source/WebCore/ChangeLog:10
>>>> +        there are multiple matches. Introducing these two interfaces allow us to "regular" HTMLCollection's named getter
>>> 
>>> typo
>> 
>> Where?
> 
> allow us to "regular"...

regular is spelled correctly, right? I precisely meant http://www.answers.com/topic/regular.
Comment 27 Ryosuke Niwa 2012-11-09 12:13:31 PST
Created attachment 173345 [details]
Synced to ToT
Comment 28 Erik Arvidsson 2012-11-09 12:26:16 PST
(In reply to comment #26)
> (From update of attachment 173182 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=173182&action=review
> 
> >>>> Source/WebCore/ChangeLog:10
> >>>> +        there are multiple matches. Introducing these two interfaces allow us to "regular" HTMLCollection's named getter
> >>> 
> >>> typo
> >> 
> >> Where?
> > 
> > allow us to "regular"...
> 
> regular is spelled correctly, right? I precisely meant http://www.answers.com/topic/regular.

not a typo... just grammar problem. You need a verb somewhere.
Comment 29 Ryosuke Niwa 2012-11-09 12:27:23 PST
Comment on attachment 173182 [details]
Fixed more tests

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

>>>>>> Source/WebCore/ChangeLog:10
>>>>>> +        there are multiple matches. Introducing these two interfaces allow us to "regular" HTMLCollection's named getter
>>>>> 
>>>>> typo
>>>> 
>>>> Where?
>>> 
>>> allow us to "regular"...
>> 
>> regular is spelled correctly, right? I precisely meant http://www.answers.com/topic/regular.
> 
> not a typo... just grammar problem. You need a verb somewhere.

Oh, I see. Yeah, it’s missing "make" there.
Comment 30 WebKit Review Bot 2012-11-09 16:02:56 PST
Comment on attachment 173345 [details]
Synced to ToT

Attachment 173345 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14771839

New failing tests:
inspector/console/console-format-collections.html
Comment 31 WebKit Review Bot 2012-11-09 17:10:27 PST
Comment on attachment 173345 [details]
Synced to ToT

Attachment 173345 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14775752

New failing tests:
inspector/console/console-format-collections.html
Comment 32 Ryosuke Niwa 2012-11-17 00:18:51 PST
Created attachment 174813 [details]
Patch
Comment 33 WebKit Review Bot 2012-11-17 01:56:59 PST
Comment on attachment 174813 [details]
Patch

Attachment 174813 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14875291

New failing tests:
inspector/console/console-format-collections.html
Comment 34 WebKit Review Bot 2012-11-17 02:55:45 PST
Comment on attachment 174813 [details]
Patch

Attachment 174813 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14861514

New failing tests:
inspector/console/console-format-collections.html
Comment 35 Darin Adler 2012-11-17 13:05:14 PST
Comment on attachment 174813 [details]
Patch

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

> Source/WebCore/ChangeLog:59
> +        (WebCore):

Stray change log line here should be removed.

> Source/WebCore/ChangeLog:63
> +        (WebCore):

Stray change log line here should be removed.

> Source/WebCore/ChangeLog:70
> +        (WebCore):

Stray change log line here should be removed.

> Source/WebCore/ChangeLog:74
> +        (WebCore): Removed Document::objects since it was not used anywhere.

Comment should be here, but not the (WebCore): prefix.

> Source/WebCore/ChangeLog:76
> +        (Document):

Stray change log line here should be removed.

> Source/WebCore/ChangeLog:96
> +        (HTMLFormControlsCollection):

Stray change log line here should be removed.

> Source/WebCore/ChangeLog:100
> +        (WebCore):

Stray change log line here should be removed.

> Source/WebCore/html/HTMLFormControlsCollection.h:34
>  // This class is just a big hack to find form elements even in malformed HTML elements.

Should add a blank line before this comment.

> LayoutTests/fast/dom/wrapper-classes-expected.txt:145
> -PASS jsWrapperClass(document.createElement('select').options.constructor) is 'HTMLOptionsCollectionConstructor'
> +FAIL jsWrapperClass(document.createElement('select').options.constructor) should be HTMLOptionsCollectionConstructor. Was Function.

I don’t see any comment about this new expected failure in the change log.
Comment 36 Ryosuke Niwa 2012-11-18 17:19:11 PST
Thanks for the review. Will address the comments before I land the patch.
Comment 37 Ryosuke Niwa 2012-11-18 17:29:13 PST
Committed r135093: <http://trac.webkit.org/changeset/135093>
Comment 38 Chris Dumez 2012-11-19 00:20:41 PST
It appears global-constructors.html needs updated expectation after this patch:
--- /home/buildslave-1/webkit-buildslave/efl-linux-64-debug-wk2/build/layout-test-results/fast/js/global-constructors-expected.txt
+++ /home/buildslave-1/webkit-buildslave/efl-linux-64-debug-wk2/build/layout-test-results/fast/js/global-constructors-actual.txt
@@ -75,6 +75,7 @@
 PASS HTMLEmbedElement.toString() is '[object HTMLEmbedElementConstructor]'
 PASS HTMLFieldSetElement.toString() is '[object HTMLFieldSetElementConstructor]'
 PASS HTMLFontElement.toString() is '[object HTMLFontElementConstructor]'
+PASS HTMLFormControlsCollection.toString() is '[object HTMLFormControlsCollectionConstructor]'
 PASS HTMLFormElement.toString() is '[object HTMLFormElementConstructor]'
 PASS HTMLFrameElement.toString() is '[object HTMLFrameElementConstructor]'
 PASS HTMLFrameSetElement.toString() is '[object HTMLFrameSetElementConstructor]'
@@ -102,6 +103,7 @@
 PASS HTMLObjectElement.toString() is '[object HTMLObjectElementConstructor]'
 PASS HTMLOptGroupElement.toString() is '[object HTMLOptGroupElementConstructor]'
 PASS HTMLOptionElement.toString() is '[object HTMLOptionElementConstructor]'
+PASS HTMLOptionsCollection.toString() is '[object HTMLOptionsCollectionConstructor]'
 PASS HTMLOutputElement.toString() is '[object HTMLOutputElementConstructor]'
 PASS HTMLParagraphElement.toString() is '[object HTMLParagraphElementConstructor]'
 PASS HTMLParamElement.toString() is '[object HTMLParamElementConstructor]'