[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
eric at webkit.org
eric at webkit.org
Wed Jan 6 00:09:35 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 3e70b5064a7e71b7d82235795bac0b2ca7440aa1
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Dec 29 19:25:08 2009 +0000
2009-12-29 Johnny Ding <jnd at chromium.org>
Reviewed by Dimitri Glazkov.
https://bugs.webkit.org/show_bug.cgi?id=32863
Make NodeList support call-as-function
Test: fast/dom/NodeList/nodelist-item-call-as-function.html
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::getTemplate):
* bindings/v8/custom/V8NodeListCustom.cpp:
(WebCore::V8NodeList::callAsFunctionCallback):
2009-12-29 Johnny Ding <jnd at chromium.org>
Reviewed by Dimitri Glazkov.
https://bugs.webkit.org/show_bug.cgi?id=32863
Make NodeList support call-as-function.
* fast/dom/NodeList/nodelist-item-call-as-function-expected.txt: Added.
* fast/dom/NodeList/nodelist-item-call-as-function.html: Added.
* fast/dom/NodeList/script-tests: Added.
* fast/dom/NodeList/script-tests/TEMPLATE.html: Added.
* fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 0159ab9..47eec9a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2009-12-29 Johnny Ding <jnd at chromium.org>
+
+ Reviewed by Dimitri Glazkov.
+
+ https://bugs.webkit.org/show_bug.cgi?id=32863
+ Make NodeList support call-as-function.
+
+ * fast/dom/NodeList/nodelist-item-call-as-function-expected.txt: Added.
+ * fast/dom/NodeList/nodelist-item-call-as-function.html: Added.
+ * fast/dom/NodeList/script-tests: Added.
+ * fast/dom/NodeList/script-tests/TEMPLATE.html: Added.
+ * fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js: Added.
+
2009-12-29 Robert Hogan <robert at roberthogan.net>
Reviewed by Eric Seidel.
diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt b/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt
new file mode 100644
index 0000000..96549e8
--- /dev/null
+++ b/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt
@@ -0,0 +1,12 @@
+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.
+
+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 successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function.html b/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function.html
new file mode 100644
index 0000000..ae1cf36
--- /dev/null
+++ b/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/nodelist-item-call-as-function.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html b/LayoutTests/fast/dom/NodeList/script-tests/TEMPLATE.html
similarity index 100%
copy from LayoutTests/fast/backgrounds/repeat/script-tests/TEMPLATE.html
copy to LayoutTests/fast/dom/NodeList/script-tests/TEMPLATE.html
diff --git a/LayoutTests/fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js b/LayoutTests/fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js
new file mode 100644
index 0000000..a12a2c9
--- /dev/null
+++ b/LayoutTests/fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js
@@ -0,0 +1,8 @@
+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.');
+
+var nodeList = document.getElementsByTagName('div');
+shouldBe("nodeList[0]", "nodeList(0)");
+shouldBe("!nodeList[nodeList.length]", "!nodeList(nodeList.length)");
+
+var successfullyParsed = true;
+
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index a2e0b04..d75ad29 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2009-12-29 Johnny Ding <jnd at chromium.org>
+
+ Reviewed by Dimitri Glazkov.
+
+ https://bugs.webkit.org/show_bug.cgi?id=32863
+ Make NodeList support call-as-function
+
+ Test: fast/dom/NodeList/nodelist-item-call-as-function.html
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ * bindings/v8/V8DOMWrapper.cpp:
+ (WebCore::V8DOMWrapper::getTemplate):
+ * bindings/v8/custom/V8NodeListCustom.cpp:
+ (WebCore::V8NodeList::callAsFunctionCallback):
+
2009-12-29 Simon Fraser <simon.fraser at apple.com>
Reviewed by Dan Bernstein.
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 71c650e..292e750 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -312,7 +312,7 @@ sub GenerateSpecialCaseHeaderDeclarations
{
my $dataNode = shift;
- if ($dataNode->name eq "HTMLCollection" || $dataNode->name eq "HTMLAllCollection") {
+ if ($dataNode->name eq "HTMLCollection" || $dataNode->name eq "HTMLAllCollection" || $dataNode->name eq "NodeList") {
push(@headerContent, " static v8::Handle<v8::Value> callAsFunctionCallback(const v8::Arguments&);\n");
}
}
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index c62c9a7..eef7ec1 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -51,6 +51,7 @@
#include "V8HTMLPlugInElementCustom.h"
#include "V8Index.h"
#include "V8IsolatedWorld.h"
+#include "V8NodeList.h"
#include "V8Proxy.h"
#include "WebGLArray.h"
#include "WebGLUniformLocation.h"
@@ -348,6 +349,9 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W
instanceTemplate->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(NamedNodeMap), 0, 0, 0, collectionIndexedPropertyEnumerator<NamedNodeMap>, v8::Integer::New(V8ClassIndex::NODE));
break;
}
+ case V8ClassIndex::NODELIST:
+ descriptor->InstanceTemplate()->SetCallAsFunctionHandler(V8NodeList::callAsFunctionCallback);
+ break;
#if ENABLE(DOM_STORAGE)
case V8ClassIndex::STORAGE:
descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(Storage), USE_INDEXED_PROPERTY_SETTER(Storage), 0, USE_INDEXED_PROPERTY_DELETER(Storage));
diff --git a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
index ad10952..2867936 100644
--- a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp
@@ -29,6 +29,8 @@
*/
#include "config.h"
+#include "V8NodeList.h"
+
#include "NodeList.h"
#include "V8Binding.h"
@@ -58,4 +60,22 @@ NAMED_PROPERTY_GETTER(NodeList)
return V8DOMWrapper::convertNodeToV8Object(result.release());
}
+// Need to support call so that list(0) works.
+v8::Handle<v8::Value> V8NodeList::callAsFunctionCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.NodeList.callAsFunction()");
+ if (args.Length() < 1)
+ return v8::Undefined();
+
+ NodeList* list = V8DOMWrapper::convertToNativeObject<NodeList>(V8ClassIndex::NODELIST, args.Holder());
+
+ // The first argument must be a number.
+ v8::Local<v8::Uint32> index = args[0]->ToArrayIndex();
+ if (index.IsEmpty())
+ return v8::Undefined();
+
+ RefPtr<Node> result = list->item(index->Uint32Value());
+ return V8DOMWrapper::convertNodeToV8Object(result.release());
+}
+
} // namespace WebCore
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list