Changeset 95203 in webkit


Ignore:
Timestamp:
Sep 15, 2011 11:27:48 AM (13 years ago)
Author:
weinig@apple.com
Message:

Experiment with removing ability to call a collection (except document.all)
https://bugs.webkit.org/show_bug.cgi?id=67579

Reviewed by Anders Carlsson.

Source/WebCore:

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.

LayoutTests:

  • 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.

Location:
trunk
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95196 r95203  
     12011-09-14  Sam Weinig  <sam@webkit.org>
     2
     3        Experiment with removing ability to call a collection (except document.all)
     4        https://bugs.webkit.org/show_bug.cgi?id=67579
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * fast/dom/Element/id-in-formcollection-expected.txt:
     9        * fast/dom/Element/id-in-formcollection.html:
     10        * fast/dom/HTMLOptionElement/collection-setter-getter-expected.txt:
     11        * fast/dom/HTMLOptionElement/collection-setter-getter.html:
     12        Don't use call syntax for tests that aren't explicitly testing it.
     13
     14        * fast/dom/NodeList/nodelist-item-call-as-function-expected.txt:
     15        * fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js:
     16        Update test to show that we throw on call.
     17
     18        * fast/profiler/call-nodelist-as-function-expected.txt: Removed.
     19        * fast/profiler/call-nodelist-as-function.html: Removed.
     20        Remove test of removed feature.
     21
    1222011-09-15  David Levin  <levin@chromium.org>
    223
  • trunk/LayoutTests/fast/dom/Element/id-in-formcollection-expected.txt

    r52312 r95203  
    44
    55
    6 PASS elems("ids1",1).getAttribute("name") is "name2"
     6PASS elems["ids1"][1].getAttribute("name") is "name2"
    77PASS successfullyParsed is true
    88
  • trunk/LayoutTests/fast/dom/Element/id-in-formcollection.html

    r52312 r95203  
    1717
    1818var elems = document.getElementById("idf1").elements;
    19 shouldBe('elems("ids1",1).getAttribute("name")', '"name2"');
     19shouldBe('elems["ids1"][1].getAttribute("name")', '"name2"');
    2020
    2121var successfullyParsed = true;
  • trunk/LayoutTests/fast/dom/HTMLOptionElement/collection-setter-getter-expected.txt

    r38633 r95203  
    55
    66PASS my_form.set_sel.options.length is 3
    7 PASS options(0) is document.getElementById('one')
    8 PASS options(1) is document.getElementById('two')
     7PASS options[0] is document.getElementById('one')
     8PASS options[1] is document.getElementById('two')
    99PASS successfullyParsed is true
    1010
  • trunk/LayoutTests/fast/dom/HTMLOptionElement/collection-setter-getter.html

    r38633 r95203  
    2727
    2828var options = document.my_form.get_sel.options;
    29 shouldBe("options(0)", "document.getElementById('one')");
    30 shouldBe("options(1)", "document.getElementById('two')");
     29shouldBe("options[0]", "document.getElementById('one')");
     30shouldBe("options[1]", "document.getElementById('two')");
    3131
    3232var successfullyParsed = true;
  • trunk/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt

    r52627 r95203  
    1 This tests that items in a NodeList can be retrieved directly by calling as a function with an integral index parameter, starting from 0.
    2 It means NodeList[0] and NodeList(0) both work.
     1This tests that items in a NodeList cannot be called indexed using [[Call]].
    32
    43On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    54
    65
    7 PASS nodeList[0] is nodeList(0)
    8 PASS !nodeList[nodeList.length] is !nodeList(nodeList.length)
     6PASS nodeList(0) threw exception TypeError: '[object NodeList]' is not a function (evaluating 'nodeList(0)').
    97PASS successfullyParsed is true
    108
  • trunk/LayoutTests/fast/dom/NodeList/script-tests/nodelist-item-call-as-function.js

    r52627 r95203  
    1 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.');
     1description('This tests that items in a NodeList cannot be called indexed using [[Call]].');
    22
    33var nodeList = document.getElementsByTagName('div');
    4 shouldBe("nodeList[0]", "nodeList(0)");
    5 shouldBe("!nodeList[nodeList.length]", "!nodeList(nodeList.length)");
     4shouldThrow("nodeList(0)");
    65
    76var successfullyParsed = true;
  • trunk/Source/WebCore/ChangeLog

    r95198 r95203  
     12011-09-15  Sam Weinig  <sam@webkit.org>
     2
     3        Experiment with removing ability to call a collection (except document.all)
     4        https://bugs.webkit.org/show_bug.cgi?id=67579
     5
     6        Reviewed by Anders Carlsson.
     7
     8        At the request of the public-script-coord mailing list (specifically Brendan Eich, see
     9        http://lists.w3.org/Archives/Public/public-script-coord/2011JulSep/0360.html), this
     10        patch removes the ability to call a collection (either a NodeList or HTMLCollection,
     11        but not an HTMLAllCollection) as function, a syntax that we adopted to emulate IE.
     12        It is being landed to find out if there are any sites relying on this behavior of WebKit,
     13        or, if it is only used in IE only paths.  If we find sites are breaking, it should be rolled
     14        out and we should inform the public-script-coord mailing list.
     15
     16        * bindings/js/JSHTMLAllCollectionCustom.cpp:
     17        Update comment.
     18
     19        * bindings/js/JSHTMLCollectionCustom.cpp:
     20        * bindings/js/JSNodeListCustom.cpp:
     21        Remove custom call code.
     22
     23        * bindings/scripts/CodeGeneratorV8.pm:
     24        Add support for V8CustomCall.
     25
     26        * dom/NodeList.idl:
     27        * html/HTMLCollection.idl:
     28        Remove CustomCall.
     29
    1302011-09-15  Andreas Kling  <kling@webkit.org>
    231
  • trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp

    r91652 r95203  
    5858}
    5959
    60 // HTMLCollections are strange objects, they support both get and call,
    61 // so that document.forms.item(0) and document.forms(0) both work.
     60// HTMLAllCollections are strange objects, they support both get and call.
    6261static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec)
    6362{
  • trunk/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp

    r91652 r95203  
    5454}
    5555
    56 // HTMLCollections are strange objects, they support both get and call,
    57 // so that document.forms.item(0) and document.forms(0) both work.
    58 static EncodedJSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec)
    59 {
    60     if (exec->argumentCount() < 1)
    61         return JSValue::encode(jsUndefined());
    62 
    63     // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
    64     JSHTMLCollection* jsCollection = static_cast<JSHTMLCollection*>(exec->callee());
    65     HTMLCollection* collection = jsCollection->impl();
    66 
    67     // Also, do we need the TypeError test here ?
    68 
    69     if (exec->argumentCount() == 1) {
    70         // Support for document.all(<index>) etc.
    71         bool ok;
    72         UString string = exec->argument(0).toString(exec);
    73         unsigned index = Identifier::toUInt32(string, ok);
    74         if (ok)
    75             return JSValue::encode(toJS(exec, jsCollection->globalObject(), collection->item(index)));
    76 
    77         // Support for document.images('<name>') etc.
    78         return JSValue::encode(getNamedItems(exec, jsCollection, Identifier(exec, string)));
    79     }
    80 
    81     // The second arg, if set, is the index of the item we want
    82     bool ok;
    83     UString string = exec->argument(0).toString(exec);
    84     unsigned index = Identifier::toUInt32(exec->argument(1).toString(exec), ok);
    85     if (ok) {
    86         AtomicString pstr = ustringToAtomicString(string);
    87         Node* node = collection->namedItem(pstr);
    88         while (node) {
    89             if (!index)
    90                 return JSValue::encode(toJS(exec, jsCollection->globalObject(), node));
    91             node = collection->nextNamedItem(pstr);
    92             --index;
    93         }
    94     }
    95 
    96     return JSValue::encode(jsUndefined());
    97 }
    98 
    99 CallType JSHTMLCollection::getCallData(CallData& callData)
    100 {
    101     callData.native.function = callHTMLCollection;
    102     return CallTypeHost;
    103 }
    104 
    10556bool JSHTMLCollection::canGetItemsForName(ExecState*, HTMLCollection* collection, const Identifier& propertyName)
    10657{
  • trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp

    r84699 r95203  
    4747}
    4848
    49 // Need to support call so that list(0) works.
    50 static EncodedJSValue JSC_HOST_CALL callNodeList(ExecState* exec)
    51 {
    52     bool ok;
    53     unsigned index = Identifier::toUInt32(exec->argument(0).toString(exec), ok);
    54     if (!ok)
    55         return JSValue::encode(jsUndefined());
    56     JSNodeList* thisObj = static_cast<JSNodeList*>(exec->callee());
    57     return JSValue::encode(toJS(exec, thisObj->globalObject(), thisObj->impl()->item(index)));
    58 }
    59 
    60 CallType JSNodeList::getCallData(CallData& callData)
    61 {
    62     callData.native.function = callNodeList;
    63     return CallTypeHost;
    64 }
    65 
    6649bool JSNodeList::canGetItemsForName(ExecState*, NodeList* impl, const Identifier& propertyName)
    6750{
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r94891 r95203  
    623623    my $dataNode = shift;
    624624
    625     if ($dataNode->extendedAttributes->{"CustomCall"}) {
     625    if ($dataNode->extendedAttributes->{"CustomCall"} || $dataNode->extendedAttributes->{"V8CustomCall"}) {
    626626        push(@headerContent, "    static v8::Handle<v8::Value> callAsFunctionCallback(const v8::Arguments&);\n");
    627627    }
     
    18731873    my $dataNode = shift;
    18741874    my $interfaceName = $dataNode->name;
    1875     my $hasCustomCall = $dataNode->extendedAttributes->{"CustomCall"};
     1875    my $hasCustomCall = $dataNode->extendedAttributes->{"CustomCall"} || $dataNode->extendedAttributes->{"V8CustomCall"};
    18761876
    18771877    # FIXME: Remove hard-coded HTMLOptionsCollection reference.
  • trunk/Source/WebCore/dom/NodeList.idl

    r92433 r95203  
    2525        HasIndexGetter,
    2626        HasNameGetter,
    27         CustomCall
     27        V8CustomCall
    2828    ] NodeList {
    2929
  • trunk/Source/WebCore/html/HTMLCollection.idl

    r92327 r95203  
    2424        HasIndexGetter,
    2525        HasNameGetter,
    26         CustomCall,
     26        V8CustomCall,
    2727        CustomToJS,
    2828        GenerateIsReachable,
Note: See TracChangeset for help on using the changeset viewer.