Changeset 202303 in webkit


Ignore:
Timestamp:
Jun 21, 2016 4:24:37 PM (8 years ago)
Author:
jiewen_tan@apple.com
Message:

Unreviewed, rolling out r200619.

This incompleted feature broke http://m.yahoo.co.jp. Roll it
out together with r200678.

Reverted changeset:

"NodeList should be iterable"
https://bugs.webkit.org/show_bug.cgi?id=131443
http://trac.webkit.org/changeset/200619

Location:
trunk
Files:
2 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202302 r202303  
     12016-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
    1142016-06-21  Jiewen Tan  <jiewen_tan@apple.com>
    215
  • trunk/LayoutTests/fast/dom/domListEnumeration-expected.txt

    r200619 r202303  
    66
    77[object NodeList]
    8 PASS resultArray.length is 15
     8PASS resultArray.length is 11
    99PASS resultArray[0].i is '0'
    1010PASS resultArray[0].item is nodeList.item(0)
  • trunk/LayoutTests/fast/dom/script-tests/domListEnumeration.js

    r200619 r202303  
    9898resultArray = iterateList(nodeList);
    9999
    100 shouldBe("resultArray.length", "15");
     100shouldBe("resultArray.length", "11");
    101101shouldBe("resultArray[0].i", "'0'");
    102102shouldBe("resultArray[0].item", "nodeList.item(0)");
  • trunk/LayoutTests/fast/text/font-face-set-javascript-expected.txt

    r202302 r202303  
    44PASS fontFaceSet.status is "loaded"
    55PASS 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
     6PASS item.value is [fontFace1, fontFace1]
    97PASS item.done is true
    10 PASS item.value is undefined
    118PASS item.done is false
    129PASS item.value is fontFace1
  • trunk/LayoutTests/fast/text/font-face-set-javascript.html

    r200619 r202303  
    2424var item = iterator.next();
    2525shouldBeFalse("item.done");
    26 shouldBe("item.value.length", "2");
    27 shouldBe("item.value[0]", "0");
    28 shouldBe("item.value[1]", "fontFace1");
     26shouldBe("item.value", "[fontFace1, fontFace1]");
    2927item = iterator.next();
    3028shouldBeTrue("item.done");
    31 shouldBe("item.value", "undefined");
    3229
    3330iterator = fontFaceSet.keys();
  • trunk/Source/WebCore/ChangeLog

    r202302 r202303  
     12016-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
    1142016-06-21  Jiewen Tan  <jiewen_tan@apple.com>
    215
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r202028 r202303  
    268268WEBCORE_EXPORT JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, DOMStringList*);
    269269
    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&);
     270template<typename Value1, typename Value2> JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, const Value1&, const Value2&);
    272271
    273272RefPtr<JSC::ArrayBufferView> toArrayBufferView(JSC::JSValue);
     
    627626}
    628627
    629 inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, JSC::JSValue value1, JSC::JSValue value2)
     628template<typename Value1, typename Value2> inline JSC::JSValue jsPair(JSC::ExecState& state, JSDOMGlobalObject* globalObject, const Value1& value1, const Value2& value2)
    630629{
    631630    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));
    634633    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));
    640634}
    641635
  • trunk/Source/WebCore/bindings/js/JSDOMIterator.h

    r202302 r202303  
    6161};
    6262
    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 
    7363enum class IterationKind { Key, Value, KeyValue };
    7464
     
    116106
    117107template<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)
     108JSC::EncodedJSValue createKeyValueIterator(JSC::ExecState& state, IterationKind kind, const char* propertyName)
    124109{
    125110    auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue());
     
    130115}
    131116
    132 template<typename IteratorValue> typename std::enable_if<IteratorInspector<IteratorValue>::isMap, JSC::JSValue>::type
    133 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>::type
    143 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>::type
    155 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>::type
    163 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 
    171117template<typename JSWrapper>
    172 JSC::EncodedJSValue iteratorForEach(JSC::ExecState& state, const char* propertyName)
     118JSC::EncodedJSValue keyValueIteratorForEach(JSC::ExecState& state, const char* propertyName)
    173119{
    174120    auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue());
     
    184130    while (auto value = iterator.next()) {
    185131        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));
    187134        arguments.append(wrapper);
    188135        JSC::call(&state, state.argument(0), callType, callData, wrapper, arguments);
     
    206153    if (!iteratorValue)
    207154        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);
    209165}
    210166
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r202281 r202303  
    41824182    my $interface = shift;
    41834183
     4184    if (not $interface->iterable->isKeyValue) {
     4185        die "No support yet for set iterators";
     4186    }
     4187
    41844188    my $interfaceName = $interface->name;
    41854189    my $className = "JS$interfaceName";
     
    42084212            $iterationKind = "Key" if $propertyName eq "keys";
    42094213            $iterationKind = "Value" if $propertyName eq "values";
    4210             $iterationKind = "Value" if $propertyName eq "[Symbol.Iterator]" and not $interface->iterable->isKeyValue;
    42114214            push(@implContent,  <<END);
    42124215JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state)
    42134216{
    4214     return iteratorCreate<${className}>(*state, IterationKind::${iterationKind}, "${propertyName}");
     4217    return createKeyValueIterator<${className}>(*state, IterationKind::${iterationKind}, "${propertyName}");
    42154218}
    42164219
     
    42204223JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state)
    42214224{
    4222     return iteratorForEach<${className}>(*state, "${propertyName}");
     4225    return keyValueIteratorForEach<${className}>(*state, "${propertyName}");
    42234226}
    42244227
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp

    r202281 r202303  
    2525#include "JSDOMBinding.h"
    2626#include "JSDOMConstructor.h"
    27 #include "JSDOMIterator.h"
    2827#include "URL.h"
    2928#include <runtime/Error.h>
     
    3433
    3534namespace WebCore {
    36 
    37 // Functions
    38 
    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*);
    4435
    4536// Attributes
     
    10495    { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeConstructor) } },
    10596    { "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) } },
    11097};
    11198
     
    116103    Base::finishCreation(vm);
    117104    reifyStaticProperties(vm, JSTestNodePrototypeTableValues, *this);
    118     putDirect(vm, vm.propertyNames->iteratorSymbol, JSFunction::create(vm, globalObject(), 0, ASCIILiteral("[Symbol.Iterator]"), jsTestNodePrototypeFunctionSymbolIterator), ReadOnly | DontEnum);
    119105}
    120106
     
    191177{
    192178    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");
    227179}
    228180
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r202281 r202303  
    62186218JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSymbolIterator(JSC::ExecState* state)
    62196219{
    6220     return iteratorCreate<JSTestObj>(*state, IterationKind::KeyValue, "[Symbol.Iterator]");
     6220    return createKeyValueIterator<JSTestObj>(*state, IterationKind::KeyValue, "[Symbol.Iterator]");
    62216221}
    62226222
    62236223JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionEntries(JSC::ExecState* state)
    62246224{
    6225     return iteratorCreate<JSTestObj>(*state, IterationKind::KeyValue, "entries");
     6225    return createKeyValueIterator<JSTestObj>(*state, IterationKind::KeyValue, "entries");
    62266226}
    62276227
    62286228JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionKeys(JSC::ExecState* state)
    62296229{
    6230     return iteratorCreate<JSTestObj>(*state, IterationKind::Key, "keys");
     6230    return createKeyValueIterator<JSTestObj>(*state, IterationKind::Key, "keys");
    62316231}
    62326232
    62336233JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionValues(JSC::ExecState* state)
    62346234{
    6235     return iteratorCreate<JSTestObj>(*state, IterationKind::Value, "values");
     6235    return createKeyValueIterator<JSTestObj>(*state, IterationKind::Value, "values");
    62366236}
    62376237
    62386238JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionForEach(JSC::ExecState* state)
    62396239{
    6240     return iteratorForEach<JSTestObj>(*state, "forEach");
     6240    return keyValueIteratorForEach<JSTestObj>(*state, "forEach");
    62416241}
    62426242
  • trunk/Source/WebCore/bindings/scripts/test/TestNode.idl

    r200619 r202303  
    2424] interface TestNode : Node {
    2525    attribute DOMString name;
    26 
    27     iterable<TestNode>;
    2826};
    2927
  • trunk/Source/WebCore/css/FontFaceSet.cpp

    r201080 r202303  
    7777}
    7878
    79 RefPtr<FontFace> FontFaceSet::Iterator::next()
     79Optional<WTF::KeyValuePair<RefPtr<FontFace>, RefPtr<FontFace>>> FontFaceSet::Iterator::next()
    8080{
    8181    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);
    8485}
    8586
  • trunk/Source/WebCore/css/FontFaceSet.h

    r201013 r202303  
    6363    public:
    6464        explicit Iterator(FontFaceSet&);
    65         RefPtr<FontFace> next();
     65        Optional<WTF::KeyValuePair<RefPtr<FontFace>, RefPtr<FontFace>>> next();
    6666
    6767    private:
  • trunk/Source/WebCore/css/FontFaceSet.idl

    r200619 r202303  
    3636
    3737    // 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>;
    3940
    4041    readonly attribute long size;
  • trunk/Source/WebCore/dom/NodeList.h

    r200619 r202303  
    4141    virtual Node* item(unsigned index) const = 0;
    4242
    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 
    5443    // Other methods (not part of DOM)
    5544    virtual bool isLiveNodeList() const { return false; }
  • trunk/Source/WebCore/dom/NodeList.idl

    r200619 r202303  
    2828    getter Node item(unsigned long index);
    2929    readonly attribute unsigned long length;
    30     iterable<Node>;
    3130};
    3231
Note: See TracChangeset for help on using the changeset viewer.