Changeset 105870 in webkit


Ignore:
Timestamp:
Jan 25, 2012 5:04:24 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Fix incorrect behavior in HTMLCollection.prototype.item().
https://bugs.webkit.org/show_bug.cgi?id=74468

Patch by Pablo Flouret <pablof@motorola.com> on 2012-01-25
Reviewed by Adam Barth.

HTMLCollection.prototype.item("someString") was falling back to
.namedItem("someString"), which is wrong per spec. Also align the
handling of various other types of objects passed as the argument with
the spec and the rest of the browsers.

Source/WebCore:

Test: fast/dom/collection-item.html

  • bindings/js/JSHTMLCollectionCustom.cpp: Remove custom implementation of item().
  • bindings/v8/custom/V8HTMLCollectionCustom.cpp: Ditto.
  • html/HTMLCollection.idl: Remove [Custom] in item(), it's not needed.

LayoutTests:

  • fast/dom/collection-item-expected.txt: Added.
  • fast/dom/collection-item.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r105869 r105870  
     12012-01-25  Pablo Flouret  <pablof@motorola.com>
     2
     3        Fix incorrect behavior in HTMLCollection.prototype.item().
     4        https://bugs.webkit.org/show_bug.cgi?id=74468
     5
     6        Reviewed by Adam Barth.
     7
     8        HTMLCollection.prototype.item("someString") was falling back to
     9        .namedItem("someString"), which is wrong per spec. Also align the
     10        handling of various other types of objects passed as the argument with
     11        the spec and the rest of the browsers.
     12
     13        * fast/dom/collection-item-expected.txt: Added.
     14        * fast/dom/collection-item.html: Added.
     15
    1162012-01-25  Mike Lawther  <mikelawther@chromium.org>
    217
  • trunk/Source/WebCore/ChangeLog

    r105868 r105870  
     12012-01-25  Pablo Flouret  <pablof@motorola.com>
     2
     3        Fix incorrect behavior in HTMLCollection.prototype.item().
     4        https://bugs.webkit.org/show_bug.cgi?id=74468
     5
     6        Reviewed by Adam Barth.
     7
     8        HTMLCollection.prototype.item("someString") was falling back to
     9        .namedItem("someString"), which is wrong per spec. Also align the
     10        handling of various other types of objects passed as the argument with
     11        the spec and the rest of the browsers.
     12
     13        Test: fast/dom/collection-item.html
     14
     15        * bindings/js/JSHTMLCollectionCustom.cpp: Remove custom implementation of item().
     16        * bindings/v8/custom/V8HTMLCollectionCustom.cpp: Ditto.
     17        * html/HTMLCollection.idl: Remove [Custom] in item(), it's not needed.
     18
    1192012-01-25  Sheriff Bot  <webkit.review.bot@gmail.com>
    220
  • trunk/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp

    r105698 r105870  
    7070}
    7171
    72 JSValue JSHTMLCollection::item(ExecState* exec)
    73 {
    74     bool ok;
    75     uint32_t index = Identifier::toUInt32(exec->argument(0).toString(exec)->value(exec), ok);
    76     if (ok)
    77         return toJS(exec, globalObject(), impl()->item(index));
    78     return getNamedItems(exec, this, Identifier(exec, exec->argument(0).toString(exec)->value(exec)));
    79 }
    80 
    8172JSValue JSHTMLCollection::namedItem(ExecState* exec)
    8273{
  • trunk/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp

    r99958 r105870  
    5656}
    5757
    58 static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8::Value> argument)
    59 {
    60     v8::Local<v8::Uint32> index = argument->ToArrayIndex();
    61     if (index.IsEmpty()) {
    62         v8::Local<v8::String> asString = argument->ToString();
    63         if (asString.IsEmpty())
    64             return v8::Handle<v8::Value>();
    65         v8::Handle<v8::Value> result = getNamedItems(collection, toWebCoreString(asString));
    66 
    67         if (result.IsEmpty())
    68             return v8::Undefined();
    69 
    70         return result;
    71     }
    72 
    73     RefPtr<Node> result = collection->item(index->Uint32Value());
    74     return toV8(result.release());
    75 }
    76 
    7758v8::Handle<v8::Value> V8HTMLCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
    7859{
     
    8667    HTMLCollection* imp = V8HTMLCollection::toNative(info.Holder());
    8768    return getNamedItems(imp, v8StringToAtomicWebCoreString(name));
    88 }
    89 
    90 v8::Handle<v8::Value> V8HTMLCollection::itemCallback(const v8::Arguments& args)
    91 {
    92     INC_STATS("DOM.HTMLCollection.item()");
    93     HTMLCollection* imp = V8HTMLCollection::toNative(args.Holder());
    94     return getItem(imp, args[0]);
    9569}
    9670
  • trunk/Source/WebCore/html/HTMLCollection.idl

    r99958 r105870  
    2929    ] HTMLCollection {
    3030        readonly attribute unsigned long length;
    31         [Custom] Node item(in [Optional=CallWithDefaultValue] unsigned long index);
     31        Node item(in [Optional=CallWithDefaultValue] unsigned long index);
    3232        [Custom] Node namedItem(in [Optional=CallWithDefaultValue] DOMString name);
    3333
Note: See TracChangeset for help on using the changeset viewer.