Add support for [ArrayClass] and use that on NodeList
authorarv@chromium.org <arv@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2012 21:15:55 +0000 (21:15 +0000)
committerarv@chromium.org <arv@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2012 21:15:55 +0000 (21:15 +0000)
commit32b59e861ab7a91c1ee63ad59eebd37101e40681
tree32c5e45ce96e42bd81fb473d5fd518df6d6d949f
parent671ef684b888bc7ef057b6af7edbd6095baf141a
Add support for [ArrayClass] and use that on NodeList
https://bugs.webkit.org/show_bug.cgi?id=

Reviewed by Adam Barth.

Attempt to reland r113931. Now with more updated test expectations.

With this patch NodeLists now have Array.prototype on their prototype chain which allows
methods such as forEach and map to work on NodeLists.

http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-nodelist

For V8 we need to set a flag on the WrapperTypeInfo since V8 uses FunctionTemplates which
does not allow setting the prototype to a non FunctionTemplate so the prototype is therefore
set when the constructor is created.

For JSC we just pass the right prototype object when creating the NodeList prototype. JSC has
a bug (81588) that prevents toString to work as specced on Array.prototype.toString. This
causes test failures in the tests until that has been fixed.

Source/WebCore:

Test: fast/dom/NodeList/node-list-array-class.html

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader): Include ArrayPrototype.h if an ArrayClass.
(GenerateImplementation): If ArrayClass use arrayPrototype as prototype.
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNamedConstructorCallback):
(GenerateImplementation): Adds a flag to the WrapperTypeInfo.
* bindings/scripts/IDLAttributes.txt:: Adds new attribute: ArrayClass.
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObj::createPrototype):
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/TestObj.idl:
* bindings/scripts/test/V8/V8Float64Array.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestEventConstructor.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestEventTarget.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestInterface.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestNode.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore):
* bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
(WebCore):
* bindings/v8/NPV8Object.cpp:
(WebCore::npObjectTypeInfo):
* bindings/v8/V8BindingPerContextData.cpp:
(WebCore::V8BindingPerContextData::init): Get the array prototype too.
(WebCore::V8BindingPerContextData::createWrapperFromCacheSlowCase):
(WebCore::V8BindingPerContextData::constructorForTypeSlowCase): If this is an ArrayClass we need to
set the `[[Prototype]]`.
* bindings/v8/V8BindingPerContextData.h:
(V8BindingPerContextData):
* bindings/v8/V8HiddenPropertyName.h:
(WebCore):
* bindings/v8/WrapperTypeInfo.h:
(WrapperTypeInfo):
* bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
(WebCore):
* dom/NodeList.idl:

LayoutTests:

* fast/dom/HTMLSelectElement/named-options-expected.txt:
* fast/dom/HTMLSelectElement/script-tests/named-options.js:
* fast/dom/NodeList/node-list-array-class-expected.txt: Added.
* fast/dom/NodeList/node-list-array-class.html: Added.
* fast/dom/NodeList/nodelist-item-call-as-function-expected.txt:
* fast/dom/everything-to-string-expected.txt:
* fast/dom/prototype-inheritance-2-expected.txt:
* fast/js/recursion-limit-equal-expected.txt:
* inspector/console/command-line-api-expected.txt:
* inspector/console/console-dir-expected.txt:
* inspector/console/console-format-collections-expected.txt:
* jquery/traversing-expected.txt:
* platform/chromium/fast/dom/HTMLSelectElement/named-options-expected.txt: Copied from LayoutTests/fast/dom/HTMLSelectElement/named-options-expected.txt.
* platform/chromium/fast/dom/everything-to-string-expected.txt: Copied from LayoutTests/fast/dom/everything-to-string-expected.txt.
* platform/chromium/inspector/console/command-line-api-expected.txt: Copied from LayoutTests/inspector/console/command-line-api-expected.txt.
* platform/chromium/inspector/console/console-dir-expected.txt:
* platform/chromium/inspector/console/console-format-collections-expected.txt:
* platform/chromium/jquery/traversing-expected.txt: Copied from LayoutTests/jquery/traversing-expected.txt.
* platform/mac/fast/dom/prototype-inheritance-2-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
45 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLSelectElement/named-options-expected.txt
LayoutTests/fast/dom/HTMLSelectElement/script-tests/named-options.js
LayoutTests/fast/dom/NodeList/node-list-array-class-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/NodeList/node-list-array-class.html [new file with mode: 0644]
LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt
LayoutTests/fast/dom/everything-to-string-expected.txt
LayoutTests/fast/dom/prototype-inheritance-2-expected.txt
LayoutTests/fast/js/recursion-limit-equal-expected.txt
LayoutTests/inspector/console/command-line-api-expected.txt
LayoutTests/inspector/console/console-dir-expected.txt
LayoutTests/inspector/console/console-format-collections-expected.txt
LayoutTests/jquery/traversing-expected.txt
LayoutTests/platform/chromium/fast/dom/HTMLSelectElement/named-options-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/dom/everything-to-string-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/inspector/console/command-line-api-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/inspector/console/console-dir-expected.txt
LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt
LayoutTests/platform/chromium/jquery/traversing-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/dom/prototype-inheritance-2-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp
Source/WebCore/bindings/v8/NPV8Object.cpp
Source/WebCore/bindings/v8/V8BindingPerContextData.cpp
Source/WebCore/bindings/v8/V8BindingPerContextData.h
Source/WebCore/bindings/v8/V8HiddenPropertyName.h
Source/WebCore/bindings/v8/WrapperTypeInfo.h
Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
Source/WebCore/dom/NodeList.idl