Unreviewed, rolling out r202302, r202303, r202305, and
r202306.
Roll out the rollouts because of breaking the build.
Reverted changesets:
"Unreviewed, rolling out r200678."
https://bugs.webkit.org/show_bug.cgi?id=157453
http://trac.webkit.org/changeset/202302
"Unreviewed, rolling out r200619."
https://bugs.webkit.org/show_bug.cgi?id=131443
http://trac.webkit.org/changeset/202303
"Unreviewed, attempt to fix the build after r202303."
http://trac.webkit.org/changeset/202305
"Unreviewed, attempt to fix the build after r202303."
http://trac.webkit.org/changeset/202306
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@202307 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5c5d4b5..c7934ff 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,26 @@
+2016-06-21 Jiewen Tan <jiewen_tan@apple.com>
+
+ Unreviewed, rolling out r202302, r202303, r202305, and
+ r202306.
+
+ Roll out the rollouts because of breaking the build.
+
+ Reverted changesets:
+
+ "Unreviewed, rolling out r200678."
+ https://bugs.webkit.org/show_bug.cgi?id=157453
+ http://trac.webkit.org/changeset/202302
+
+ "Unreviewed, rolling out r200619."
+ https://bugs.webkit.org/show_bug.cgi?id=131443
+ http://trac.webkit.org/changeset/202303
+
+ "Unreviewed, attempt to fix the build after r202303."
+ http://trac.webkit.org/changeset/202305
+
+ "Unreviewed, attempt to fix the build after r202303."
+ http://trac.webkit.org/changeset/202306
+
2016-06-21 Zalan Bujtas <zalan@apple.com>
LayoutTest tiled-drawing/scrolling/latched-div-with-scroll-snap.html is flaky
diff --git a/LayoutTests/fast/dom/domListEnumeration-expected.txt b/LayoutTests/fast/dom/domListEnumeration-expected.txt
index b26da3f..310a12d 100644
--- a/LayoutTests/fast/dom/domListEnumeration-expected.txt
+++ b/LayoutTests/fast/dom/domListEnumeration-expected.txt
@@ -5,7 +5,7 @@
[object NodeList]
-PASS resultArray.length is 11
+PASS resultArray.length is 15
PASS resultArray[0].i is '0'
PASS resultArray[0].item is nodeList.item(0)
PASS resultArray[1].i is '1'
diff --git a/LayoutTests/fast/dom/nodeListIterator-expected.txt b/LayoutTests/fast/dom/nodeListIterator-expected.txt
new file mode 100644
index 0000000..7681562
--- /dev/null
+++ b/LayoutTests/fast/dom/nodeListIterator-expected.txt
@@ -0,0 +1,38 @@
+Testing of NodeList iterable capacities.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS nodeList.length is 2
+PASS item is children[index++]
+PASS item is children[index++]
+PASS pair[0] is children[0]
+PASS pair[1] is children[1]
+PASS forEachContainer is nodeList
+PASS forEachIndex is index
+PASS node is children[index++]
+PASS forEachContainer is nodeList
+PASS forEachIndex is index
+PASS node is children[index++]
+PASS iterator.next().value is children[0]
+PASS iterator.next().value is children[1]
+PASS end.done is true
+PASS end.value is undefined
+PASS iterator.next().value is children[0]
+PASS iterator.next().value is children[1]
+PASS end.done is true
+PASS end.value is undefined
+PASS pair.length is 2
+PASS pair[0] is 0
+PASS pair[1] is children[0]
+PASS pair.length is 2
+PASS pair[0] is 1
+PASS pair[1] is children[1]
+PASS end.done is true
+PASS end.value is undefined
+PASS end.done is true
+PASS end.value is undefined
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/nodeListIterator.html b/LayoutTests/fast/dom/nodeListIterator.html
new file mode 100644
index 0000000..82a37b1
--- /dev/null
+++ b/LayoutTests/fast/dom/nodeListIterator.html
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <script src="../../resources/js-test-pre.js"></script>
+ </head>
+ <body>
+ <script>
+ description('Testing of NodeList iterable capacities.');
+
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ var end;
+ function checkEndIterator(iteratorValue) {
+ end = iteratorValue;
+ shouldBe('end.done', 'true');
+ shouldBe('end.value', 'undefined');
+ }
+
+ var testingGround = document.createElement('div');
+ var children = [document.createElement('div'), document.createElement('ol')];
+ testingGround.appendChild(children[0]);
+ testingGround.appendChild(children[1]);
+ document.body.appendChild(testingGround);
+
+ var nodeList = testingGround.childNodes;
+
+ shouldBe("nodeList.length", "2");
+
+ var index = 0;
+ for (var item of nodeList)
+ shouldBe('item', 'children[index++]');
+
+ pair = Array.from(nodeList);
+ shouldBe('pair[0]', 'children[0]');
+ shouldBe('pair[1]', 'children[1]');
+
+ index = 0;
+ var node;
+ var forEachIndex;
+ var forEachContainer;
+ nodeList.forEach(function(n, i, c) {
+ node = n;
+ forEachIndex = i;
+ forEachContainer = c;
+ shouldBe('forEachContainer', 'nodeList');
+ shouldBe('forEachIndex', 'index');
+ shouldBe('node', 'children[index++]');
+ });
+
+ var iterator = nodeList.keys();
+ shouldBe('iterator.next().value', 'children[0]');
+ shouldBe('iterator.next().value', 'children[1]');
+ checkEndIterator(iterator.next());
+
+ var iterator = nodeList.values();
+ shouldBe('iterator.next().value', 'children[0]');
+ shouldBe('iterator.next().value', 'children[1]');
+ checkEndIterator(iterator.next());
+
+ var iterator = nodeList.entries();
+ var pair = iterator.next().value;
+ shouldBe('pair.length', '2');
+ shouldBe('pair[0]', '0');
+ shouldBe('pair[1]', 'children[0]');
+ pair = iterator.next().value;
+ shouldBe('pair.length', '2');
+ shouldBe('pair[0]', '1');
+ shouldBe('pair[1]', 'children[1]');
+ checkEndIterator(iterator.next());
+
+ testingGround.appendChild(document.createElement('ul'));
+ testingGround.appendChild(document.createElement('p'));
+ checkEndIterator(iterator.next());
+
+ </script>
+ <script src="../../resources/js-test-post.js"></script>
+ </body>
+</html>
diff --git a/LayoutTests/fast/dom/script-tests/domListEnumeration.js b/LayoutTests/fast/dom/script-tests/domListEnumeration.js
index d614b5b..d60551e 100644
--- a/LayoutTests/fast/dom/script-tests/domListEnumeration.js
+++ b/LayoutTests/fast/dom/script-tests/domListEnumeration.js
@@ -97,7 +97,7 @@
var nodeList = testingGround.childNodes;
resultArray = iterateList(nodeList);
-shouldBe("resultArray.length", "11");
+shouldBe("resultArray.length", "15");
shouldBe("resultArray[0].i", "'0'");
shouldBe("resultArray[0].item", "nodeList.item(0)");
shouldBe("resultArray[1].i", "'1'");
diff --git a/LayoutTests/fast/text/font-face-set-javascript-expected.txt b/LayoutTests/fast/text/font-face-set-javascript-expected.txt
index 9554d12..99eb125 100644
--- a/LayoutTests/fast/text/font-face-set-javascript-expected.txt
+++ b/LayoutTests/fast/text/font-face-set-javascript-expected.txt
@@ -3,8 +3,11 @@
PASS new FontFaceSet([fontFace1]).size is 1
PASS fontFaceSet.status is "loaded"
PASS item.done is false
-PASS item.value is [fontFace1, fontFace1]
+PASS item.value.length is 2
+PASS item.value[0] is 0
+PASS item.value[1] is fontFace1
PASS item.done is true
+PASS item.value is undefined
PASS item.done is false
PASS item.value is fontFace1
PASS item.done is true
diff --git a/LayoutTests/fast/text/font-face-set-javascript.html b/LayoutTests/fast/text/font-face-set-javascript.html
index 5489a2d..4e64517 100644
--- a/LayoutTests/fast/text/font-face-set-javascript.html
+++ b/LayoutTests/fast/text/font-face-set-javascript.html
@@ -23,9 +23,12 @@
var iterator = fontFaceSet.entries();
var item = iterator.next();
shouldBeFalse("item.done");
-shouldBe("item.value", "[fontFace1, fontFace1]");
+shouldBe("item.value.length", "2");
+shouldBe("item.value[0]", "0");
+shouldBe("item.value[1]", "fontFace1");
item = iterator.next();
shouldBeTrue("item.done");
+shouldBe("item.value", "undefined");
iterator = fontFaceSet.keys();
item = iterator.next();
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 7ce65ef..ae35eb6 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2016-06-21 Jiewen Tan <jiewen_tan@apple.com>
+
+ Unreviewed, rolling out r202302, r202303, r202305, and
+ r202306.
+
+ Roll out the rollouts because of breaking the build.
+
+ Reverted changesets:
+
+ "Unreviewed, rolling out r200678."
+ https://bugs.webkit.org/show_bug.cgi?id=157453
+ http://trac.webkit.org/changeset/202302
+
+ "Unreviewed, rolling out r200619."
+ https://bugs.webkit.org/show_bug.cgi?id=131443
+ http://trac.webkit.org/changeset/202303
+
+ "Unreviewed, attempt to fix the build after r202303."
+ http://trac.webkit.org/changeset/202305
+
+ "Unreviewed, attempt to fix the build after r202303."
+ http://trac.webkit.org/changeset/202306
+
2016-06-21 Chris Dumez <cdumez@apple.com>
Unreviewed, attempt to fix the build after r202303.
diff --git a/Source/WebCore/bindings/js/JSDOMBinding.h b/Source/WebCore/bindings/js/JSDOMBinding.h
index 6947674..c62dbb2 100644
--- a/Source/WebCore/bindings/js/JSDOMBinding.h
+++ b/Source/WebCore/bindings/js/JSDOMBinding.h
@@ -267,7 +267,8 @@
template<typename T, size_t inlineCapacity> JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, const Vector<T, inlineCapacity>*);
WEBCORE_EXPORT JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, DOMStringList*);
-template<typename Value1, typename Value2> JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, const Value1&, const Value2&);
+JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, JSC::JSValue, JSC::JSValue);
+template<typename FirstType, typename SecondType> JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, const FirstType&, const SecondType&);
RefPtr<JSC::ArrayBufferView> toArrayBufferView(JSC::JSValue);
RefPtr<JSC::Int8Array> toInt8Array(JSC::JSValue);
@@ -625,14 +626,19 @@
return jsArray(exec, globalObject, *vector);
}
-template<typename Value1, typename Value2> inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, const Value1& value1, const Value2& value2)
+inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, JSC::JSValue value1, JSC::JSValue value2)
{
JSC::MarkedArgumentBuffer args;
- args.append(toJS(&state, globalObject, value1));
- args.append(toJS(&state, globalObject, value2));
+ args.append(value1);
+ args.append(value2);
return constructArray(&state, 0, globalObject, args);
}
+template<typename FirstType, typename SecondType> inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, const FirstType& value1, const SecondType& value2)
+{
+ return jsPair(state, globalObject, toJS(&state, globalObject, value1), toJS(&state, globalObject, value2));
+}
+
inline RefPtr<JSC::ArrayBufferView> toArrayBufferView(JSC::JSValue value)
{
auto* wrapper = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(value);
diff --git a/Source/WebCore/bindings/js/JSDOMIterator.h b/Source/WebCore/bindings/js/JSDOMIterator.h
index 4cad3d3..30372eb 100644
--- a/Source/WebCore/bindings/js/JSDOMIterator.h
+++ b/Source/WebCore/bindings/js/JSDOMIterator.h
@@ -108,14 +108,25 @@
{
}
+ template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isMap, JSC::JSValue>::type
+ asJS(JSC::ExecState&, IteratorValue&);
+ template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isSet, JSC::JSValue>::type
+ asJS(JSC::ExecState&, IteratorValue&);
+
static void destroy(JSC::JSCell*);
- typename DOMWrapped::Iterator m_iterator;
+ Optional<typename DOMWrapped::Iterator> m_iterator;
IterationKind m_kind;
+ size_t m_index { 0 };
};
template<typename JSWrapper>
-JSC::EncodedJSValue createKeyValueIterator(JSC::ExecState& state, IterationKind kind, const char* propertyName)
+JSC::EncodedJSValue iteratorCreate(JSC::ExecState&, IterationKind, const char*);
+template<typename JSWrapper>
+JSC::EncodedJSValue iteratorForEach(JSC::ExecState&, const char*);
+
+template<typename JSWrapper>
+JSC::EncodedJSValue iteratorCreate(JSC::ExecState& state, IterationKind kind, const char* propertyName)
{
auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue());
if (UNLIKELY(!wrapper))
@@ -124,30 +135,48 @@
return JSC::JSValue::encode(JSDOMIterator<JSWrapper>::create(globalObject.vm(), getDOMStructure<JSDOMIterator<JSWrapper>>(globalObject.vm(), globalObject), *wrapper, kind));
}
-template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isMap, JSC::JSValue>::type
-toJS(JSC::ExecState& state, JSDOMGlobalObject* globalObject, IteratorValue& value, IterationKind kind)
+template<typename JSWrapper>
+template<typename IteratorValue> inline typename std::enable_if<IteratorInspector<IteratorValue>::isMap, JSC::JSValue>::type
+JSDOMIterator<JSWrapper>::asJS(JSC::ExecState& state, IteratorValue& value)
{
ASSERT(value);
- if (kind != IterationKind::KeyValue)
- return toJS(&state, globalObject, (kind == IterationKind::Key) ? value->key : value->value);
+ if (m_kind != IterationKind::KeyValue)
+ return toJS(&state, globalObject(), (m_kind == IterationKind::Key) ? value->key : value->value);
- return jsPair(state, globalObject, value->key, value->value);
-}
-
-template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isSet, JSC::JSValue>::type
-toJS(JSC::ExecState& state, JSDOMGlobalObject* globalObject, IteratorValue& value, IterationKind kind)
-{
- ASSERT(value);
- JSC::JSValue result = toJS(&state, globalObject, *value);
- if (kind != IterationKind::KeyValue)
- return result;
-
- // FIXME: first pair value should be the index of result.
- return jsPair(state, globalObject, result, result);
+ return jsPair(state, globalObject(), value->key, value->value);
}
template<typename JSWrapper>
-JSC::EncodedJSValue keyValueIteratorForEach(JSC::ExecState& state, const char* propertyName)
+template<typename IteratorValue> inline typename std::enable_if<IteratorInspector<IteratorValue>::isSet, JSC::JSValue>::type
+JSDOMIterator<JSWrapper>::asJS(JSC::ExecState& state, IteratorValue& value)
+{
+ ASSERT(value);
+ JSC::JSValue result = toJS(&state, globalObject(), *value);
+ if (m_kind != IterationKind::KeyValue)
+ return result;
+
+ return jsPair(state, globalObject(), JSC::jsNumber(m_index++), result);
+}
+
+template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isMap, void>::type
+appendForEachArguments(JSC::ExecState& state, JSDOMGlobalObject* globalObject, JSC::MarkedArgumentBuffer& arguments, IteratorValue& value, size_t&)
+{
+ ASSERT(value);
+ arguments.append(toJS(&state, globalObject, value->value));
+ arguments.append(toJS(&state, globalObject, value->key));
+}
+
+template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isSet, void>::type
+appendForEachArguments(JSC::ExecState& state, JSDOMGlobalObject* globalObject, JSC::MarkedArgumentBuffer& arguments, IteratorValue& value, size_t& index)
+{
+ ASSERT(value);
+ JSC::JSValue argument = toJS(&state, globalObject, *value);
+ arguments.append(argument);
+ arguments.append(JSC::jsNumber(index++));
+}
+
+template<typename JSWrapper>
+JSC::EncodedJSValue iteratorForEach(JSC::ExecState& state, const char* propertyName)
{
auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue());
if (UNLIKELY(!wrapper))
@@ -158,11 +187,11 @@
if (callType == JSC::CallType::None)
return throwVMTypeError(&state);
+ size_t index = 0;
auto iterator = wrapper->wrapped().createIterator();
while (auto value = iterator.next()) {
JSC::MarkedArgumentBuffer arguments;
- arguments.append(toJS(&state, wrapper->globalObject(), value.value().value));
- arguments.append(toJS(&state, wrapper->globalObject(), value.value().key));
+ appendForEachArguments(state, wrapper->globalObject(), arguments, value, index);
arguments.append(wrapper);
JSC::call(&state, state.argument(0), callType, callData, wrapper, arguments);
if (state.hadException())
@@ -181,19 +210,13 @@
template<typename JSWrapper>
JSC::JSValue JSDOMIterator<JSWrapper>::next(JSC::ExecState& state)
{
- auto iteratorValue = m_iterator.next();
- if (!iteratorValue)
- return createIteratorResultObject(&state, JSC::jsUndefined(), true);
-
- JSC::JSValue value;
- if (m_kind == IterationKind::Value)
- value = toJS(&state, globalObject(), iteratorValue.value().value);
- else if (m_kind == IterationKind::Key)
- value = toJS(&state, globalObject(), iteratorValue.value().key);
- else
- value = jsPair(state, globalObject(), iteratorValue.value().key, iteratorValue.value().value);
-
- return createIteratorResultObject(&state, value, false);
+ if (m_iterator) {
+ auto iteratorValue = m_iterator->next();
+ if (iteratorValue)
+ return createIteratorResultObject(&state, asJS(state, iteratorValue), false);
+ m_iterator = Nullopt;
+ }
+ return createIteratorResultObject(&state, JSC::jsUndefined(), true);
}
template<typename JSWrapper>
diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
index b87248b..afb6f76 100644
--- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -4181,10 +4181,6 @@
{
my $interface = shift;
- if (not $interface->iterable->isKeyValue) {
- die "No support yet for set iterators";
- }
-
my $interfaceName = $interface->name;
my $className = "JS$interfaceName";
my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
@@ -4211,10 +4207,11 @@
my $iterationKind = "KeyValue";
$iterationKind = "Key" if $propertyName eq "keys";
$iterationKind = "Value" if $propertyName eq "values";
+ $iterationKind = "Value" if $propertyName eq "[Symbol.Iterator]" and not $interface->iterable->isKeyValue;
push(@implContent, <<END);
JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state)
{
- return createKeyValueIterator<${className}>(*state, IterationKind::${iterationKind}, "${propertyName}");
+ return iteratorCreate<${className}>(*state, IterationKind::${iterationKind}, "${propertyName}");
}
END
@@ -4222,7 +4219,7 @@
push(@implContent, <<END);
JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state)
{
- return keyValueIteratorForEach<${className}>(*state, "${propertyName}");
+ return iteratorForEach<${className}>(*state, "${propertyName}");
}
END
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
index a844799..3313d2d 100644
--- a/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
+++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
@@ -24,6 +24,7 @@
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
+#include "JSDOMIterator.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
@@ -33,6 +34,14 @@
namespace WebCore {
+// Functions
+
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState*);
+
// Attributes
JSC::EncodedJSValue jsTestNodeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
@@ -94,6 +103,10 @@
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeConstructor) } },
{ "name", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeName) } },
+ { "entries", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionEntries), (intptr_t) (0) } },
+ { "keys", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionKeys), (intptr_t) (0) } },
+ { "values", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionValues), (intptr_t) (0) } },
+ { "forEach", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionForEach), (intptr_t) (1) } },
};
const ClassInfo JSTestNodePrototype::s_info = { "TestNodePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestNodePrototype) };
@@ -102,6 +115,7 @@
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSTestNodePrototypeTableValues, *this);
+ putDirect(vm, vm.propertyNames->iteratorSymbol, JSFunction::create(vm, globalObject(), 0, ASCIILiteral("[Symbol.Iterator]"), jsTestNodePrototypeFunctionSymbolIterator), ReadOnly | DontEnum);
}
const ClassInfo JSTestNode::s_info = { "TestNode", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestNode) };
@@ -178,6 +192,40 @@
return getDOMConstructor<JSTestNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
+using TestNodeIterator = JSDOMIterator<JSTestNode>;
+using TestNodeIteratorPrototype = JSDOMIteratorPrototype<JSTestNode>;
+
+template<>
+const JSC::ClassInfo TestNodeIterator::s_info = { "TestNode Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestNodeIterator) };
+
+template<>
+const JSC::ClassInfo TestNodeIteratorPrototype::s_info = { "TestNode Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestNodeIteratorPrototype) };
+
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState* state)
+{
+ return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "[Symbol.Iterator]");
+}
+
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState* state)
+{
+ return iteratorCreate<JSTestNode>(*state, IterationKind::KeyValue, "entries");
+}
+
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState* state)
+{
+ return iteratorCreate<JSTestNode>(*state, IterationKind::Key, "keys");
+}
+
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState* state)
+{
+ return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "values");
+}
+
+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState* state)
+{
+ return iteratorForEach<JSTestNode>(*state, "forEach");
+}
+
void JSTestNode::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSTestNode*>(cell);
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
index bb11eea..13c12b9 100644
--- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
+++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
@@ -6217,27 +6217,27 @@
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSymbolIterator(JSC::ExecState* state)
{
- return createKeyValueIterator<JSTestObj>(*state, IterationKind::KeyValue, "[Symbol.Iterator]");
+ return iteratorCreate<JSTestObj>(*state, IterationKind::KeyValue, "[Symbol.Iterator]");
}
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionEntries(JSC::ExecState* state)
{
- return createKeyValueIterator<JSTestObj>(*state, IterationKind::KeyValue, "entries");
+ return iteratorCreate<JSTestObj>(*state, IterationKind::KeyValue, "entries");
}
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionKeys(JSC::ExecState* state)
{
- return createKeyValueIterator<JSTestObj>(*state, IterationKind::Key, "keys");
+ return iteratorCreate<JSTestObj>(*state, IterationKind::Key, "keys");
}
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionValues(JSC::ExecState* state)
{
- return createKeyValueIterator<JSTestObj>(*state, IterationKind::Value, "values");
+ return iteratorCreate<JSTestObj>(*state, IterationKind::Value, "values");
}
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionForEach(JSC::ExecState* state)
{
- return keyValueIteratorForEach<JSTestObj>(*state, "forEach");
+ return iteratorForEach<JSTestObj>(*state, "forEach");
}
void JSTestObj::visitChildren(JSCell* cell, SlotVisitor& visitor)
diff --git a/Source/WebCore/bindings/scripts/test/TestNode.idl b/Source/WebCore/bindings/scripts/test/TestNode.idl
index f3795f1..1e4852a 100644
--- a/Source/WebCore/bindings/scripts/test/TestNode.idl
+++ b/Source/WebCore/bindings/scripts/test/TestNode.idl
@@ -23,5 +23,7 @@
ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
] interface TestNode : Node {
attribute DOMString name;
+
+ iterable<TestNode>;
};
diff --git a/Source/WebCore/css/FontFaceSet.cpp b/Source/WebCore/css/FontFaceSet.cpp
index a995a64..e50a3af 100644
--- a/Source/WebCore/css/FontFaceSet.cpp
+++ b/Source/WebCore/css/FontFaceSet.cpp
@@ -76,12 +76,11 @@
{
}
-Optional<WTF::KeyValuePair<RefPtr<FontFace>, RefPtr<FontFace>>> FontFaceSet::Iterator::next()
+RefPtr<FontFace> FontFaceSet::Iterator::next()
{
if (m_index == m_target->size())
- return Nullopt;
- RefPtr<FontFace> item = m_target->backing()[m_index++].wrapper();
- return WTF::KeyValuePair<RefPtr<FontFace>, RefPtr<FontFace>>(item, item);
+ return nullptr;
+ return m_target->backing()[m_index++].wrapper();
}
FontFaceSet::PendingPromise::PendingPromise(LoadPromise&& promise)
diff --git a/Source/WebCore/css/FontFaceSet.h b/Source/WebCore/css/FontFaceSet.h
index d7fceaa..89ad08d 100644
--- a/Source/WebCore/css/FontFaceSet.h
+++ b/Source/WebCore/css/FontFaceSet.h
@@ -62,7 +62,7 @@
class Iterator {
public:
explicit Iterator(FontFaceSet&);
- Optional<WTF::KeyValuePair<RefPtr<FontFace>, RefPtr<FontFace>>> next();
+ RefPtr<FontFace> next();
private:
Ref<FontFaceSet> m_target;
diff --git a/Source/WebCore/css/FontFaceSet.idl b/Source/WebCore/css/FontFaceSet.idl
index 60c98eb..ab5cb89 100644
--- a/Source/WebCore/css/FontFaceSet.idl
+++ b/Source/WebCore/css/FontFaceSet.idl
@@ -35,8 +35,7 @@
boolean has(FontFace font);
// FIXME: We should add support for the setlike declaration.
- // As a first step this map iterable declaration should be changed to a set iterable.
- iterable<FontFace, FontFace>;
+ iterable<FontFace>;
readonly attribute long size;
diff --git a/Source/WebCore/dom/NodeList.h b/Source/WebCore/dom/NodeList.h
index 822a892..019bd22 100644
--- a/Source/WebCore/dom/NodeList.h
+++ b/Source/WebCore/dom/NodeList.h
@@ -40,6 +40,17 @@
virtual unsigned length() const = 0;
virtual Node* item(unsigned index) const = 0;
+ class Iterator {
+ public:
+ explicit Iterator(NodeList& list) : m_list(list) { }
+ Node* next() { return m_list->item(m_index++); }
+
+ private:
+ size_t m_index { 0 };
+ Ref<NodeList> m_list;
+ };
+ Iterator createIterator() { return Iterator(*this); }
+
// Other methods (not part of DOM)
virtual bool isLiveNodeList() const { return false; }
virtual bool isChildNodeList() const { return false; }
diff --git a/Source/WebCore/dom/NodeList.idl b/Source/WebCore/dom/NodeList.idl
index 7ed36ee..0cd146d 100644
--- a/Source/WebCore/dom/NodeList.idl
+++ b/Source/WebCore/dom/NodeList.idl
@@ -27,5 +27,6 @@
] interface NodeList {
getter Node item(unsigned long index);
readonly attribute unsigned long length;
+ iterable<Node>;
};