DOM4: Add support for rest parameters to DOMTokenList
authorarv@chromium.org <arv@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Sep 2012 18:05:28 +0000 (18:05 +0000)
committerarv@chromium.org <arv@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Sep 2012 18:05:28 +0000 (18:05 +0000)
commit6adbe0b3c427da990e527d0a09766f87146923fd
treee53da9471b520b460ebbd1035b5bf172f4874d81
parent2b7a5a2e23321feb7d980735b7be3f94a7d03b6e
DOM4: Add support for rest parameters to DOMTokenList
https://bugs.webkit.org/show_bug.cgi?id=97335

Reviewed by Ojan Vafai.

This adds support for rest paramaters to DOMTokenList add and remove.
http://dom.spec.whatwg.org/#domtokenlist

The code generator has been updated to understand variadic methods.
When a method has a rest parameter the remaining arguments are collected
into a WTF::Vector.

DOMTokenList, DOMSettableTokenList and ClassList were restructured a bit to
allow code to be shared better.

Source/WebCore:

Updated existing tests and includes new binding tests.

* bindings/js/JSDOMBinding.h:
(WebCore::toNativeArray):
(WebCore):
(WebCore::toNativeArguments): Similar to toNativeArray but extracts the arguments instead.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateArgumentsCountCheck): Updated to treat rest paramaters as optional.
(GenerateParametersCheck): Generate code for rest params.
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateFunctionParametersCheck): Updated to treat rest paramaters as optional.
(GenerateArgumentsCountCheck): Ditto.
(GenerateParametersCheck):  Generate code for rest params.
* bindings/scripts/IDLParser.pm:
(parseOptionalOrRequiredArgument):
* bindings/scripts/IDLStructure.pm:
* bindings/scripts/test/CPP/WebDOMTestObj.cpp:
(WebDOMTestObj::variadicStringMethod):
(WebDOMTestObj::variadicDoubleMethod):
(WebDOMTestObj::variadicNodeMethod):
* bindings/scripts/test/CPP/WebDOMTestObj.h:
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
(webkit_dom_test_obj_variadic_string_method):
(webkit_dom_test_obj_variadic_double_method):
(webkit_dom_test_obj_variadic_node_method):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore):
(WebCore::jsTestObjPrototypeFunctionVariadicStringMethod):
(WebCore::jsTestObjPrototypeFunctionVariadicDoubleMethod):
(WebCore::jsTestObjPrototypeFunctionVariadicNodeMethod):
* bindings/scripts/test/JS/JSTestObj.h:
(WebCore):
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
(-[DOMTestObj variadicStringMethod:tail:]):
(-[DOMTestObj variadicDoubleMethod:tail:]):
(-[DOMTestObj variadicNodeMethod:tail:]):
* bindings/scripts/test/TestObj.idl:
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::variadicStringMethodCallback):
(TestObjV8Internal):
(WebCore::TestObjV8Internal::variadicDoubleMethodCallback):
(WebCore::TestObjV8Internal::variadicNodeMethodCallback):
(WebCore):
(WebCore::ConfigureV8TestObjTemplate):
* bindings/v8/V8Binding.h:
(WebCore::toNativeArray):
(WebCore):
(WebCore::toNativeArguments): Similar to toNativeArray but extracts the arguments instead.
* html/ClassList.cpp:
(WebCore::ClassList::ClassList):
* html/ClassList.h:
(WebCore):
(ClassList):
* html/DOMSettableTokenList.cpp:
(WebCore::DOMSettableTokenList::containsInternal):
(WebCore::DOMSettableTokenList::add):
(WebCore::DOMSettableTokenList::addInternal):
(WebCore::DOMSettableTokenList::remove):
(WebCore::DOMSettableTokenList::removeInternal):
(WebCore::DOMSettableTokenList::setValue):
* html/DOMSettableTokenList.h:
(DOMSettableTokenList):
* html/DOMTokenList.cpp:
(WebCore::DOMTokenList::validateTokens):
(WebCore):
(WebCore::DOMTokenList::contains): Moved implementation to base class to allow code sharing.
(WebCore::DOMTokenList::add): Ditto.
(WebCore::DOMTokenList::remove): Ditto.
(WebCore::DOMTokenList::toggle): Ditto.
(WebCore::DOMTokenList::addInternal): Ditto.
(WebCore::DOMTokenList::removeInternal): Ditto.
(WebCore::DOMTokenList::addToken): Ditto.
(WebCore::DOMTokenList::addTokens):
(WebCore::DOMTokenList::removeToken): Ditto.
(WebCore::DOMTokenList::removeTokens):
* html/DOMTokenList.h:
(DOMTokenList):
(WebCore::DOMTokenList::toString):
* html/DOMTokenList.idl:

LayoutTests:

* fast/dom/HTMLElement/class-list-expected.txt:
* fast/dom/HTMLElement/class-list-quirks-expected.txt:
* fast/dom/HTMLElement/script-tests/class-list.js:
(element.classList.add):
(createElement):
(shouldBeEqualToString):
(element.classList.remove):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLElement/class-list-expected.txt
LayoutTests/fast/dom/HTMLElement/class-list-quirks-expected.txt
LayoutTests/fast/dom/HTMLElement/script-tests/class-list.js
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/IDLStructure.pm
Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp
Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
Source/WebCore/bindings/v8/V8Binding.h
Source/WebCore/html/ClassList.cpp
Source/WebCore/html/ClassList.h
Source/WebCore/html/DOMSettableTokenList.cpp
Source/WebCore/html/DOMSettableTokenList.h
Source/WebCore/html/DOMTokenList.cpp
Source/WebCore/html/DOMTokenList.h
Source/WebCore/html/DOMTokenList.idl