Diff
Modified: trunk/LayoutTests/ChangeLog (95202 => 95203)
--- trunk/LayoutTests/ChangeLog 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/LayoutTests/ChangeLog 2011-09-15 18:27:48 UTC (rev 95203)
@@ -1,3 +1,24 @@
+2011-09-14 Sam Weinig <s...@webkit.org>
+
+ Experiment with removing ability to call a collection (except document.all)
+ https://bugs.webkit.org/show_bug.cgi?id=67579
+
+ Reviewed by Anders Carlsson.
+
+ * fast/dom/Element/id-in-formcollection-expected.txt:
+ * fast/dom/Element/id-in-formcollection.html:
+ * fast/dom/HTMLOptionElement/collection-setter-getter-expected.txt:
+ * fast/dom/HTMLOptionElement/collection-setter-getter.html:
+ Don't use call syntax for tests that aren't explicitly testing it.
+
+ * fast/dom/NodeList/nodelist-item-call-as-function-expected.txt:
+ * fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js:
+ Update test to show that we throw on call.
+
+ * fast/profiler/call-nodelist-as-function-expected.txt: Removed.
+ * fast/profiler/call-nodelist-as-function.html: Removed.
+ Remove test of removed feature.
+
2011-09-15 David Levin <le...@chromium.org>
[chromium] Add expectation for flaky tests.
Modified: trunk/LayoutTests/fast/dom/Element/id-in-formcollection-expected.txt (95202 => 95203)
--- trunk/LayoutTests/fast/dom/Element/id-in-formcollection-expected.txt 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/LayoutTests/fast/dom/Element/id-in-formcollection-expected.txt 2011-09-15 18:27:48 UTC (rev 95203)
@@ -3,7 +3,7 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS elems("ids1",1).getAttribute("name") is "name2"
+PASS elems["ids1"][1].getAttribute("name") is "name2"
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/dom/Element/id-in-formcollection.html (95202 => 95203)
--- trunk/LayoutTests/fast/dom/Element/id-in-formcollection.html 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/LayoutTests/fast/dom/Element/id-in-formcollection.html 2011-09-15 18:27:48 UTC (rev 95203)
@@ -16,7 +16,7 @@
description("Test using id in HTMLFormCollection");
var elems = document.getElementById("idf1").elements;
-shouldBe('elems("ids1",1).getAttribute("name")', '"name2"');
+shouldBe('elems["ids1"][1].getAttribute("name")', '"name2"');
var successfullyParsed = true;
</script>
Modified: trunk/LayoutTests/fast/dom/HTMLOptionElement/collection-setter-getter-expected.txt (95202 => 95203)
--- trunk/LayoutTests/fast/dom/HTMLOptionElement/collection-setter-getter-expected.txt 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/LayoutTests/fast/dom/HTMLOptionElement/collection-setter-getter-expected.txt 2011-09-15 18:27:48 UTC (rev 95203)
@@ -4,8 +4,8 @@
PASS my_form.set_sel.options.length is 3
-PASS options(0) is document.getElementById('one')
-PASS options(1) is document.getElementById('two')
+PASS options[0] is document.getElementById('one')
+PASS options[1] is document.getElementById('two')
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/dom/HTMLOptionElement/collection-setter-getter.html (95202 => 95203)
--- trunk/LayoutTests/fast/dom/HTMLOptionElement/collection-setter-getter.html 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/LayoutTests/fast/dom/HTMLOptionElement/collection-setter-getter.html 2011-09-15 18:27:48 UTC (rev 95203)
@@ -26,8 +26,8 @@
shouldBe("my_form.set_sel.options.length", "3");
var options = document.my_form.get_sel.options;
-shouldBe("options(0)", "document.getElementById('one')");
-shouldBe("options(1)", "document.getElementById('two')");
+shouldBe("options[0]", "document.getElementById('one')");
+shouldBe("options[1]", "document.getElementById('two')");
var successfullyParsed = true;
</script>
Modified: trunk/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt (95202 => 95203)
--- trunk/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt 2011-09-15 18:27:48 UTC (rev 95203)
@@ -1,11 +1,9 @@
-This tests that items in a NodeList can be retrieved directly by calling as a function with an integral index parameter, starting from 0.
-It means NodeList[0] and NodeList(0) both work.
+This tests that items in a NodeList cannot be called indexed using [[Call]].
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS nodeList[0] is nodeList(0)
-PASS !nodeList[nodeList.length] is !nodeList(nodeList.length)
+PASS nodeList(0) threw exception TypeError: '[object NodeList]' is not a function (evaluating 'nodeList(0)').
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js (95202 => 95203)
--- trunk/LayoutTests/fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/LayoutTests/fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js 2011-09-15 18:27:48 UTC (rev 95203)
@@ -1,8 +1,7 @@
-description('This tests that items in a NodeList can be retrieved directly by calling as a function with an integral index parameter, starting from 0.<br>It means NodeList[0] and NodeList(0) both work.');
+description('This tests that items in a NodeList cannot be called indexed using [[Call]].');
var nodeList = document.getElementsByTagName('div');
-shouldBe("nodeList[0]", "nodeList(0)");
-shouldBe("!nodeList[nodeList.length]", "!nodeList(nodeList.length)");
+shouldThrow("nodeList(0)");
var successfullyParsed = true;
Deleted: trunk/LayoutTests/fast/profiler/call-nodelist-as-function-expected.txt (95202 => 95203)
--- trunk/LayoutTests/fast/profiler/call-nodelist-as-function-expected.txt 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/LayoutTests/fast/profiler/call-nodelist-as-function-expected.txt 2011-09-15 18:27:48 UTC (rev 95203)
@@ -1,12 +0,0 @@
-This page calls a NodeList as a function (e.g., list(0)).
-
-To run this test manually, load it in a debug build in the browser. You should see a (NodeList object) entry in the profile.
-
-Profile title: Call NodeList as function
-Thread_1 (no file) (line 0)
- startTest call-nodelist-as-function.html (line 11)
- getElementsByTagName (no file) (line 0)
- (NodeList object) (no file) (line 0)
- endTest profiler-test-JS-resources.js (line 1)
-
-
Deleted: trunk/LayoutTests/fast/profiler/call-nodelist-as-function.html (95202 => 95203)
--- trunk/LayoutTests/fast/profiler/call-nodelist-as-function.html 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/LayoutTests/fast/profiler/call-nodelist-as-function.html 2011-09-15 18:27:48 UTC (rev 95203)
@@ -1,30 +0,0 @@
-<html>
-<head>
-<script src=""
-<script>
-if (window.layoutTestController) {
- layoutTestController.dumpAsText();
- layoutTestController.setJavaScriptProfilingEnabled(true);
-}
-
-function startTest()
-{
- console.profile("Call NodeList as function");
-
- var brs = document.getElementsByTagName("br");
- var br0 = brs(0);
-
- endTest();
-}
-
-</script>
-</head>
-
-<body _onload_="startTest()">
-This page calls a NodeList as a function (e.g., <code>list(0)</code>).
-<br>
-<br>
-To run this test manually, load it in a debug build in the browser. You should see a <code>(NodeList object)</code> entry in the profile.
-<div id="output"></div>
-</body>
-</html>
Modified: trunk/Source/WebCore/ChangeLog (95202 => 95203)
--- trunk/Source/WebCore/ChangeLog 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/Source/WebCore/ChangeLog 2011-09-15 18:27:48 UTC (rev 95203)
@@ -1,3 +1,32 @@
+2011-09-15 Sam Weinig <s...@webkit.org>
+
+ Experiment with removing ability to call a collection (except document.all)
+ https://bugs.webkit.org/show_bug.cgi?id=67579
+
+ Reviewed by Anders Carlsson.
+
+ At the request of the public-script-coord mailing list (specifically Brendan Eich, see
+ http://lists.w3.org/Archives/Public/public-script-coord/2011JulSep/0360.html), this
+ patch removes the ability to call a collection (either a NodeList or HTMLCollection,
+ but not an HTMLAllCollection) as function, a syntax that we adopted to emulate IE.
+ It is being landed to find out if there are any sites relying on this behavior of WebKit,
+ or, if it is only used in IE only paths. If we find sites are breaking, it should be rolled
+ out and we should inform the public-script-coord mailing list.
+
+ * bindings/js/JSHTMLAllCollectionCustom.cpp:
+ Update comment.
+
+ * bindings/js/JSHTMLCollectionCustom.cpp:
+ * bindings/js/JSNodeListCustom.cpp:
+ Remove custom call code.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ Add support for V8CustomCall.
+
+ * dom/NodeList.idl:
+ * html/HTMLCollection.idl:
+ Remove CustomCall.
+
2011-09-15 Andreas Kling <kl...@webkit.org>
CanvasRenderingContext2D::State copy ctor should use initializer list.
Modified: trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp (95202 => 95203)
--- trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp 2011-09-15 18:27:48 UTC (rev 95203)
@@ -57,8 +57,7 @@
return toJS(exec, collection->globalObject(), StaticNodeList::adopt(namedItems).get());
}
-// HTMLCollections are strange objects, they support both get and call,
-// so that document.forms.item(0) and document.forms(0) both work.
+// HTMLAllCollections are strange objects, they support both get and call.
static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec)
{
if (exec->argumentCount() < 1)
Modified: trunk/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp (95202 => 95203)
--- trunk/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp 2011-09-15 18:27:48 UTC (rev 95203)
@@ -53,55 +53,6 @@
return toJS(exec, collection->globalObject(), StaticNodeList::adopt(namedItems).get());
}
-// HTMLCollections are strange objects, they support both get and call,
-// so that document.forms.item(0) and document.forms(0) both work.
-static EncodedJSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec)
-{
- if (exec->argumentCount() < 1)
- return JSValue::encode(jsUndefined());
-
- // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
- JSHTMLCollection* jsCollection = static_cast<JSHTMLCollection*>(exec->callee());
- HTMLCollection* collection = jsCollection->impl();
-
- // Also, do we need the TypeError test here ?
-
- if (exec->argumentCount() == 1) {
- // Support for document.all(<index>) etc.
- bool ok;
- UString string = exec->argument(0).toString(exec);
- unsigned index = Identifier::toUInt32(string, ok);
- if (ok)
- return JSValue::encode(toJS(exec, jsCollection->globalObject(), collection->item(index)));
-
- // Support for document.images('<name>') etc.
- return JSValue::encode(getNamedItems(exec, jsCollection, Identifier(exec, string)));
- }
-
- // The second arg, if set, is the index of the item we want
- bool ok;
- UString string = exec->argument(0).toString(exec);
- unsigned index = Identifier::toUInt32(exec->argument(1).toString(exec), ok);
- if (ok) {
- AtomicString pstr = ustringToAtomicString(string);
- Node* node = collection->namedItem(pstr);
- while (node) {
- if (!index)
- return JSValue::encode(toJS(exec, jsCollection->globalObject(), node));
- node = collection->nextNamedItem(pstr);
- --index;
- }
- }
-
- return JSValue::encode(jsUndefined());
-}
-
-CallType JSHTMLCollection::getCallData(CallData& callData)
-{
- callData.native.function = callHTMLCollection;
- return CallTypeHost;
-}
-
bool JSHTMLCollection::canGetItemsForName(ExecState*, HTMLCollection* collection, const Identifier& propertyName)
{
Vector<RefPtr<Node> > namedItems;
Modified: trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp (95202 => 95203)
--- trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp 2011-09-15 18:27:48 UTC (rev 95203)
@@ -46,23 +46,6 @@
return visitor.containsOpaqueRoot(root(static_cast<DynamicNodeList*>(jsNodeList->impl())->rootNode()));
}
-// Need to support call so that list(0) works.
-static EncodedJSValue JSC_HOST_CALL callNodeList(ExecState* exec)
-{
- bool ok;
- unsigned index = Identifier::toUInt32(exec->argument(0).toString(exec), ok);
- if (!ok)
- return JSValue::encode(jsUndefined());
- JSNodeList* thisObj = static_cast<JSNodeList*>(exec->callee());
- return JSValue::encode(toJS(exec, thisObj->globalObject(), thisObj->impl()->item(index)));
-}
-
-CallType JSNodeList::getCallData(CallData& callData)
-{
- callData.native.function = callNodeList;
- return CallTypeHost;
-}
-
bool JSNodeList::canGetItemsForName(ExecState*, NodeList* impl, const Identifier& propertyName)
{
return impl->itemWithName(identifierToAtomicString(propertyName));
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (95202 => 95203)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-09-15 18:27:48 UTC (rev 95203)
@@ -622,7 +622,7 @@
{
my $dataNode = shift;
- if ($dataNode->extendedAttributes->{"CustomCall"}) {
+ if ($dataNode->extendedAttributes->{"CustomCall"} || $dataNode->extendedAttributes->{"V8CustomCall"}) {
push(@headerContent, " static v8::Handle<v8::Value> callAsFunctionCallback(const v8::Arguments&);\n");
}
if ($dataNode->name eq "Event") {
@@ -1872,7 +1872,7 @@
{
my $dataNode = shift;
my $interfaceName = $dataNode->name;
- my $hasCustomCall = $dataNode->extendedAttributes->{"CustomCall"};
+ my $hasCustomCall = $dataNode->extendedAttributes->{"CustomCall"} || $dataNode->extendedAttributes->{"V8CustomCall"};
# FIXME: Remove hard-coded HTMLOptionsCollection reference.
if ($interfaceName eq "HTMLOptionsCollection") {
Modified: trunk/Source/WebCore/dom/NodeList.idl (95202 => 95203)
--- trunk/Source/WebCore/dom/NodeList.idl 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/Source/WebCore/dom/NodeList.idl 2011-09-15 18:27:48 UTC (rev 95203)
@@ -24,7 +24,7 @@
CustomIsReachable,
HasIndexGetter,
HasNameGetter,
- CustomCall
+ V8CustomCall
] NodeList {
Node item(in [IsIndex,Optional=CallWithDefaultValue] unsigned long index);
Modified: trunk/Source/WebCore/html/HTMLCollection.idl (95202 => 95203)
--- trunk/Source/WebCore/html/HTMLCollection.idl 2011-09-15 18:17:50 UTC (rev 95202)
+++ trunk/Source/WebCore/html/HTMLCollection.idl 2011-09-15 18:27:48 UTC (rev 95203)
@@ -23,7 +23,7 @@
interface [
HasIndexGetter,
HasNameGetter,
- CustomCall,
+ V8CustomCall,
CustomToJS,
GenerateIsReachable,
Polymorphic