Changeset 202303 in webkit
- Timestamp:
- Jun 21, 2016 4:24:37 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r202302 r202303 1 2016-06-21 Jiewen Tan <jiewen_tan@apple.com> 2 3 Unreviewed, rolling out r200619. 4 5 This incompleted feature broke http://m.yahoo.co.jp. Roll it 6 out together with r200678. 7 8 Reverted changeset: 9 10 "NodeList should be iterable" 11 https://bugs.webkit.org/show_bug.cgi?id=131443 12 http://trac.webkit.org/changeset/200619 13 1 14 2016-06-21 Jiewen Tan <jiewen_tan@apple.com> 2 15 -
trunk/LayoutTests/fast/dom/domListEnumeration-expected.txt
r200619 r202303 6 6 7 7 [object NodeList] 8 PASS resultArray.length is 1 58 PASS resultArray.length is 11 9 9 PASS resultArray[0].i is '0' 10 10 PASS resultArray[0].item is nodeList.item(0) -
trunk/LayoutTests/fast/dom/script-tests/domListEnumeration.js
r200619 r202303 98 98 resultArray = iterateList(nodeList); 99 99 100 shouldBe("resultArray.length", "1 5");100 shouldBe("resultArray.length", "11"); 101 101 shouldBe("resultArray[0].i", "'0'"); 102 102 shouldBe("resultArray[0].item", "nodeList.item(0)"); -
trunk/LayoutTests/fast/text/font-face-set-javascript-expected.txt
r202302 r202303 4 4 PASS fontFaceSet.status is "loaded" 5 5 PASS item.done is false 6 PASS item.value.length is 2 7 FAIL item.value[0] should be 0 (of type number). Was [object FontFace] (of type object). 8 PASS item.value[1] is fontFace1 6 PASS item.value is [fontFace1, fontFace1] 9 7 PASS item.done is true 10 PASS item.value is undefined11 8 PASS item.done is false 12 9 PASS item.value is fontFace1 -
trunk/LayoutTests/fast/text/font-face-set-javascript.html
r200619 r202303 24 24 var item = iterator.next(); 25 25 shouldBeFalse("item.done"); 26 shouldBe("item.value.length", "2"); 27 shouldBe("item.value[0]", "0"); 28 shouldBe("item.value[1]", "fontFace1"); 26 shouldBe("item.value", "[fontFace1, fontFace1]"); 29 27 item = iterator.next(); 30 28 shouldBeTrue("item.done"); 31 shouldBe("item.value", "undefined");32 29 33 30 iterator = fontFaceSet.keys(); -
trunk/Source/WebCore/ChangeLog
r202302 r202303 1 2016-06-21 Jiewen Tan <jiewen_tan@apple.com> 2 3 Unreviewed, rolling out r200619. 4 5 This incompleted feature broke http://m.yahoo.co.jp. Roll it 6 out together with r200678. 7 8 Reverted changeset: 9 10 "NodeList should be iterable" 11 https://bugs.webkit.org/show_bug.cgi?id=131443 12 http://trac.webkit.org/changeset/200619 13 1 14 2016-06-21 Jiewen Tan <jiewen_tan@apple.com> 2 15 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r202028 r202303 268 268 WEBCORE_EXPORT JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, DOMStringList*); 269 269 270 JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, JSC::JSValue, JSC::JSValue); 271 template<typename FirstType, typename SecondType> JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, const FirstType&, const SecondType&); 270 template<typename Value1, typename Value2> JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, const Value1&, const Value2&); 272 271 273 272 RefPtr<JSC::ArrayBufferView> toArrayBufferView(JSC::JSValue); … … 627 626 } 628 627 629 inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, JSC::JSValue value1, JSC::JSValuevalue2)628 template<typename Value1, typename Value2> inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, const Value1& value1, const Value2& value2) 630 629 { 631 630 JSC::MarkedArgumentBuffer args; 632 args.append( value1);633 args.append( value2);631 args.append(toJS(&state, globalObject, value1)); 632 args.append(toJS(&state, globalObject, value2)); 634 633 return constructArray(&state, 0, globalObject, args); 635 }636 637 template<typename FirstType, typename SecondType> inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, const FirstType& value1, const SecondType& value2)638 {639 return jsPair(state, globalObject, toJS(&state, globalObject, value1), toJS(&state, globalObject, value2));640 634 } 641 635 -
trunk/Source/WebCore/bindings/js/JSDOMIterator.h
r202302 r202303 61 61 }; 62 62 63 template<typename IteratorValue>64 class IteratorInspector {65 private:66 template<typename T> static constexpr auto test(int) -> decltype(std::declval<T>()->key, std::declval<T>()->value, bool()) { return true; }67 template<typename T> static constexpr bool test(...) { return false; }68 public:69 static constexpr bool isMap = test<IteratorValue>(0);70 static constexpr bool isSet = !isMap;71 };72 73 63 enum class IterationKind { Key, Value, KeyValue }; 74 64 … … 116 106 117 107 template<typename JSWrapper> 118 JSC::EncodedJSValue iteratorCreate(JSC::ExecState&, IterationKind, const char*); 119 template<typename JSWrapper> 120 JSC::EncodedJSValue iteratorForEach(JSC::ExecState&, const char*); 121 122 template<typename JSWrapper> 123 JSC::EncodedJSValue iteratorCreate(JSC::ExecState& state, IterationKind kind, const char* propertyName) 108 JSC::EncodedJSValue createKeyValueIterator(JSC::ExecState& state, IterationKind kind, const char* propertyName) 124 109 { 125 110 auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue()); … … 130 115 } 131 116 132 template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isMap, JSC::JSValue>::type133 toJS(JSC::ExecState& state, JSDOMGlobalObject* globalObject, IteratorValue& value, IterationKind kind)134 {135 ASSERT(value);136 if (kind != IterationKind::KeyValue)137 return toJS(&state, globalObject, (kind == IterationKind::Key) ? value->key : value->value);138 139 return jsPair(state, globalObject, value->key, value->value);140 }141 142 template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isSet, JSC::JSValue>::type143 toJS(JSC::ExecState& state, JSDOMGlobalObject* globalObject, IteratorValue& value, IterationKind kind)144 {145 ASSERT(value);146 JSC::JSValue result = toJS(&state, globalObject, *value);147 if (kind != IterationKind::KeyValue)148 return result;149 150 // FIXME: first pair value should be the index of result.151 return jsPair(state, globalObject, result, result);152 }153 154 template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isMap, void>::type155 appendForEachArguments(JSC::ExecState& state, JSDOMGlobalObject* globalObject, JSC::MarkedArgumentBuffer& arguments, IteratorValue& value)156 {157 ASSERT(value);158 arguments.append(toJS(&state, globalObject, value->value));159 arguments.append(toJS(&state, globalObject, value->key));160 }161 162 template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isSet, void>::type163 appendForEachArguments(JSC::ExecState& state, JSDOMGlobalObject* globalObject, JSC::MarkedArgumentBuffer& arguments, IteratorValue& value)164 {165 ASSERT(value);166 JSC::JSValue argument = toJS(&state, globalObject, *value);167 arguments.append(argument);168 arguments.append(argument);169 }170 171 117 template<typename JSWrapper> 172 JSC::EncodedJSValue iteratorForEach(JSC::ExecState& state, const char* propertyName)118 JSC::EncodedJSValue keyValueIteratorForEach(JSC::ExecState& state, const char* propertyName) 173 119 { 174 120 auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue()); … … 184 130 while (auto value = iterator.next()) { 185 131 JSC::MarkedArgumentBuffer arguments; 186 appendForEachArguments(state, wrapper->globalObject(), arguments, value); 132 arguments.append(toJS(&state, wrapper->globalObject(), value.value().value)); 133 arguments.append(toJS(&state, wrapper->globalObject(), value.value().key)); 187 134 arguments.append(wrapper); 188 135 JSC::call(&state, state.argument(0), callType, callData, wrapper, arguments); … … 206 153 if (!iteratorValue) 207 154 return createIteratorResultObject(&state, JSC::jsUndefined(), true); 208 return createIteratorResultObject(&state, toJS(state, globalObject(), iteratorValue, m_kind), false); 155 156 JSC::JSValue value; 157 if (m_kind == IterationKind::Value) 158 value = toJS(&state, globalObject(), iteratorValue.value().value); 159 else if (m_kind == IterationKind::Key) 160 value = toJS(&state, globalObject(), iteratorValue.value().key); 161 else 162 value = jsPair(state, globalObject(), iteratorValue.value().key, iteratorValue.value().value); 163 164 return createIteratorResultObject(&state, value, false); 209 165 } 210 166 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r202281 r202303 4182 4182 my $interface = shift; 4183 4183 4184 if (not $interface->iterable->isKeyValue) { 4185 die "No support yet for set iterators"; 4186 } 4187 4184 4188 my $interfaceName = $interface->name; 4185 4189 my $className = "JS$interfaceName"; … … 4208 4212 $iterationKind = "Key" if $propertyName eq "keys"; 4209 4213 $iterationKind = "Value" if $propertyName eq "values"; 4210 $iterationKind = "Value" if $propertyName eq "[Symbol.Iterator]" and not $interface->iterable->isKeyValue;4211 4214 push(@implContent, <<END); 4212 4215 JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state) 4213 4216 { 4214 return iteratorCreate<${className}>(*state, IterationKind::${iterationKind}, "${propertyName}");4217 return createKeyValueIterator<${className}>(*state, IterationKind::${iterationKind}, "${propertyName}"); 4215 4218 } 4216 4219 … … 4220 4223 JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state) 4221 4224 { 4222 return iteratorForEach<${className}>(*state, "${propertyName}");4225 return keyValueIteratorForEach<${className}>(*state, "${propertyName}"); 4223 4226 } 4224 4227 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
r202281 r202303 25 25 #include "JSDOMBinding.h" 26 26 #include "JSDOMConstructor.h" 27 #include "JSDOMIterator.h"28 27 #include "URL.h" 29 28 #include <runtime/Error.h> … … 34 33 35 34 namespace WebCore { 36 37 // Functions38 39 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState*);40 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState*);41 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState*);42 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState*);43 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState*);44 35 45 36 // Attributes … … 104 95 { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeConstructor) } }, 105 96 { "name", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeName) } }, 106 { "entries", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionEntries), (intptr_t) (0) } },107 { "keys", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionKeys), (intptr_t) (0) } },108 { "values", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionValues), (intptr_t) (0) } },109 { "forEach", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionForEach), (intptr_t) (1) } },110 97 }; 111 98 … … 116 103 Base::finishCreation(vm); 117 104 reifyStaticProperties(vm, JSTestNodePrototypeTableValues, *this); 118 putDirect(vm, vm.propertyNames->iteratorSymbol, JSFunction::create(vm, globalObject(), 0, ASCIILiteral("[Symbol.Iterator]"), jsTestNodePrototypeFunctionSymbolIterator), ReadOnly | DontEnum);119 105 } 120 106 … … 191 177 { 192 178 return getDOMConstructor<JSTestNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); 193 }194 195 using TestNodeIterator = JSDOMIterator<JSTestNode>;196 using TestNodeIteratorPrototype = JSDOMIteratorPrototype<JSTestNode>;197 198 template<>199 const JSC::ClassInfo TestNodeIterator::s_info = { "TestNode Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestNodeIterator) };200 201 template<>202 const JSC::ClassInfo TestNodeIteratorPrototype::s_info = { "TestNode Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestNodeIteratorPrototype) };203 204 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState* state)205 {206 return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "[Symbol.Iterator]");207 }208 209 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState* state)210 {211 return iteratorCreate<JSTestNode>(*state, IterationKind::KeyValue, "entries");212 }213 214 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState* state)215 {216 return iteratorCreate<JSTestNode>(*state, IterationKind::Key, "keys");217 }218 219 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState* state)220 {221 return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "values");222 }223 224 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState* state)225 {226 return iteratorForEach<JSTestNode>(*state, "forEach");227 179 } 228 180 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r202281 r202303 6218 6218 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSymbolIterator(JSC::ExecState* state) 6219 6219 { 6220 return iteratorCreate<JSTestObj>(*state, IterationKind::KeyValue, "[Symbol.Iterator]");6220 return createKeyValueIterator<JSTestObj>(*state, IterationKind::KeyValue, "[Symbol.Iterator]"); 6221 6221 } 6222 6222 6223 6223 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionEntries(JSC::ExecState* state) 6224 6224 { 6225 return iteratorCreate<JSTestObj>(*state, IterationKind::KeyValue, "entries");6225 return createKeyValueIterator<JSTestObj>(*state, IterationKind::KeyValue, "entries"); 6226 6226 } 6227 6227 6228 6228 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionKeys(JSC::ExecState* state) 6229 6229 { 6230 return iteratorCreate<JSTestObj>(*state, IterationKind::Key, "keys");6230 return createKeyValueIterator<JSTestObj>(*state, IterationKind::Key, "keys"); 6231 6231 } 6232 6232 6233 6233 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionValues(JSC::ExecState* state) 6234 6234 { 6235 return iteratorCreate<JSTestObj>(*state, IterationKind::Value, "values");6235 return createKeyValueIterator<JSTestObj>(*state, IterationKind::Value, "values"); 6236 6236 } 6237 6237 6238 6238 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionForEach(JSC::ExecState* state) 6239 6239 { 6240 return iteratorForEach<JSTestObj>(*state, "forEach");6240 return keyValueIteratorForEach<JSTestObj>(*state, "forEach"); 6241 6241 } 6242 6242 -
trunk/Source/WebCore/bindings/scripts/test/TestNode.idl
r200619 r202303 24 24 ] interface TestNode : Node { 25 25 attribute DOMString name; 26 27 iterable<TestNode>;28 26 }; 29 27 -
trunk/Source/WebCore/css/FontFaceSet.cpp
r201080 r202303 77 77 } 78 78 79 RefPtr<FontFace> FontFaceSet::Iterator::next()79 Optional<WTF::KeyValuePair<RefPtr<FontFace>, RefPtr<FontFace>>> FontFaceSet::Iterator::next() 80 80 { 81 81 if (m_index == m_target->size()) 82 return nullptr; 83 return m_target->backing()[m_index++].wrapper(); 82 return Nullopt; 83 RefPtr<FontFace> item = m_target->backing()[m_index++].wrapper(); 84 return WTF::KeyValuePair<RefPtr<FontFace>, RefPtr<FontFace>>(item, item); 84 85 } 85 86 -
trunk/Source/WebCore/css/FontFaceSet.h
r201013 r202303 63 63 public: 64 64 explicit Iterator(FontFaceSet&); 65 RefPtr<FontFace> next();65 Optional<WTF::KeyValuePair<RefPtr<FontFace>, RefPtr<FontFace>>> next(); 66 66 67 67 private: -
trunk/Source/WebCore/css/FontFaceSet.idl
r200619 r202303 36 36 37 37 // FIXME: We should add support for the setlike declaration. 38 iterable<FontFace>; 38 // As a first step this map iterable declaration should be changed to a set iterable. 39 iterable<FontFace, FontFace>; 39 40 40 41 readonly attribute long size; -
trunk/Source/WebCore/dom/NodeList.h
r200619 r202303 41 41 virtual Node* item(unsigned index) const = 0; 42 42 43 class Iterator {44 public:45 explicit Iterator(NodeList& list) : m_list(list) { }46 Node* next() { return m_list->item(m_index++); }47 48 private:49 size_t m_index { 0 };50 Ref<NodeList> m_list;51 };52 Iterator createIterator() { return Iterator(*this); }53 54 43 // Other methods (not part of DOM) 55 44 virtual bool isLiveNodeList() const { return false; } -
trunk/Source/WebCore/dom/NodeList.idl
r200619 r202303 28 28 getter Node item(unsigned long index); 29 29 readonly attribute unsigned long length; 30 iterable<Node>;31 30 }; 32 31
Note: See TracChangeset
for help on using the changeset viewer.