Changeset 50037 in webkit


Ignore:
Timestamp:
Oct 24, 2009 7:44:50 PM (14 years ago)
Author:
weinig@apple.com
Message:

WebCore: Fix for https://bugs.webkit.org/show_bug.cgi?id=30751
HTMLOptionsCollection should not inherit from HTMLCollection

Reviewed by Dan Bernstein.

  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:

Added JSHTMLCollectionFunctions.h

  • bindings/js/JSHTMLAllCollectionCustom.cpp:

(WebCore::callHTMLAllCollection):
(WebCore::JSHTMLAllCollection::nameGetter):
(WebCore::JSHTMLAllCollection::item):
(WebCore::JSHTMLAllCollection::namedItem):

  • bindings/js/JSHTMLCollectionCustom.cpp:

(WebCore::callHTMLCollection):
(WebCore::JSHTMLCollection::nameGetter):
(WebCore::JSHTMLCollection::item):
(WebCore::JSHTMLCollection::namedItem):

  • bindings/js/JSHTMLOptionsCollectionCustom.cpp:

(WebCore::callHTMLCollection):
(WebCore::JSHTMLOptionsCollection::getCallData):
(WebCore::JSHTMLOptionsCollection::canGetItemsForName):
(WebCore::JSHTMLOptionsCollection::nameGetter):
(WebCore::JSHTMLOptionsCollection::indexSetter):
(WebCore::JSHTMLOptionsCollection::item):
(WebCore::JSHTMLOptionsCollection::namedItem):
Refactor to use generic implementation of HTMLCollection bindings functions
from JSHTMLCollectionFunctions.h

  • bindings/js/JSHTMLCollectionFunctions.h: Added.

(WebCore::getCollectionNamedItems):
(WebCore::getCollectionItems):
(WebCore::callHTMLCollectionGeneric):
Added generic functions that JSHTMLCollection, JSHTMLAllCollection and
JSHTMLOptionsCollection can all use.

  • bindings/js/JSHTMLDocumentCustom.cpp: Add include of JSHTMLAllCollection.h

for toJS on document.all.

  • bindings/objc/DOMHTML.mm:
  • bindings/objc/DOMUtility.mm:

(JSC::createDOMWrapper):
Remove special cases for HTMLOptionsCollection.

  • bindings/scripts/CodeGeneratorJS.pm:
  • html/HTMLAllCollection.idl:
  • html/HTMLCollection.idl:
  • html/HTMLOptionsCollection.idl:

LayoutTests: Update tests for https://bugs.webkit.org/show_bug.cgi?id=30751
HTMLOptionsCollection should not inherit from HTMLCollection

Reviewed by Dan Bernstein.

  • fast/dom/wrapper-classes-expected.txt:
Location:
trunk
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r50029 r50037  
     12009-10-24  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Update tests for https://bugs.webkit.org/show_bug.cgi?id=30751
     6        HTMLOptionsCollection should not inherit from HTMLCollection
     7
     8        * fast/dom/wrapper-classes-expected.txt:
     9
    1102009-10-24  Dan Bernstein  <mitz@apple.com>
    211
  • trunk/LayoutTests/fast/dom/wrapper-classes-expected.txt

    r46211 r50037  
    142142PASS jsWrapperClass(document.constructor) is 'HTMLDocumentConstructor'
    143143PASS jsWrapperClass(document.createElement('select').options) is 'HTMLOptionsCollection'
    144 FAIL jsWrapperClass(document.createElement('select').options.__proto__) should be HTMLOptionsCollectionPrototype. Was HTMLCollectionPrototype.
    145 FAIL jsWrapperClass(document.createElement('select').options.constructor) should be HTMLOptionsCollectionConstructor. Was Function.
     144PASS jsWrapperClass(document.createElement('select').options.__proto__) is 'HTMLOptionsCollectionPrototype'
     145PASS jsWrapperClass(document.createElement('select').options.constructor) is 'HTMLOptionsCollectionConstructor'
    146146
    147147HTML Elements
  • trunk/WebCore/ChangeLog

    r50036 r50037  
     12009-10-24  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=30751
     6        HTMLOptionsCollection should not inherit from HTMLCollection
     7
     8        * GNUmakefile.am:
     9        * WebCore.gypi:
     10        * WebCore.pro:
     11        * WebCore.vcproj/WebCore.vcproj:
     12        * WebCore.xcodeproj/project.pbxproj:
     13        Added JSHTMLCollectionFunctions.h
     14
     15        * bindings/js/JSHTMLAllCollectionCustom.cpp:
     16        (WebCore::callHTMLAllCollection):
     17        (WebCore::JSHTMLAllCollection::nameGetter):
     18        (WebCore::JSHTMLAllCollection::item):
     19        (WebCore::JSHTMLAllCollection::namedItem):
     20        * bindings/js/JSHTMLCollectionCustom.cpp:
     21        (WebCore::callHTMLCollection):
     22        (WebCore::JSHTMLCollection::nameGetter):
     23        (WebCore::JSHTMLCollection::item):
     24        (WebCore::JSHTMLCollection::namedItem):
     25        * bindings/js/JSHTMLOptionsCollectionCustom.cpp:
     26        (WebCore::callHTMLCollection):
     27        (WebCore::JSHTMLOptionsCollection::getCallData):
     28        (WebCore::JSHTMLOptionsCollection::canGetItemsForName):
     29        (WebCore::JSHTMLOptionsCollection::nameGetter):
     30        (WebCore::JSHTMLOptionsCollection::indexSetter):
     31        (WebCore::JSHTMLOptionsCollection::item):
     32        (WebCore::JSHTMLOptionsCollection::namedItem):
     33        Refactor to use generic implementation of HTMLCollection bindings functions
     34        from JSHTMLCollectionFunctions.h
     35
     36        * bindings/js/JSHTMLCollectionFunctions.h: Added.
     37        (WebCore::getCollectionNamedItems):
     38        (WebCore::getCollectionItems):
     39        (WebCore::callHTMLCollectionGeneric):
     40        Added generic functions that JSHTMLCollection, JSHTMLAllCollection and
     41        JSHTMLOptionsCollection can all use.
     42
     43        * bindings/js/JSHTMLDocumentCustom.cpp: Add include of JSHTMLAllCollection.h
     44        for toJS on document.all.
     45
     46        * bindings/objc/DOMHTML.mm:
     47        * bindings/objc/DOMUtility.mm:
     48        (JSC::createDOMWrapper):
     49        Remove special cases for HTMLOptionsCollection.
     50
     51        * bindings/scripts/CodeGeneratorJS.pm:
     52        * html/HTMLAllCollection.idl:
     53        * html/HTMLCollection.idl:
     54        * html/HTMLOptionsCollection.idl:
     55
    1562009-10-24  Timothy Hatcher  <timothy@apple.com>
    257
  • trunk/WebCore/GNUmakefile.am

    r50013 r50037  
    377377        WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp \
    378378        WebCore/bindings/js/JSHTMLCollectionCustom.cpp \
     379        WebCore/bindings/js/JSHTMLCollectionFunctions.h \
    379380        WebCore/bindings/js/JSHTMLDataGridElementCustom.cpp \
    380381        WebCore/bindings/js/JSHTMLDocumentCustom.cpp \
  • trunk/WebCore/WebCore.gypi

    r50027 r50037  
    497497            'bindings/js/JSHTMLCanvasElementCustom.cpp',
    498498            'bindings/js/JSHTMLCollectionCustom.cpp',
     499            'bindings/js/JSHTMLCollectionFunctions.h',
    499500            'bindings/js/JSHTMLDataGridElementCustom.cpp',
    500501            'bindings/js/JSHTMLDocumentCustom.cpp',
  • trunk/WebCore/WebCore.pro

    r50028 r50037  
    710710    bindings/js/JSHTMLAllCollectionCustom.cpp \
    711711    bindings/js/JSHTMLCollectionCustom.cpp \
     712    bindings/js/JSHTMLCollectionFunctions.h \
    712713    bindings/js/JSHTMLDataGridElementCustom.cpp \
    713714    bindings/js/JSHTMLDocumentCustom.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r50015 r50037  
    3393933939                                </File>
    3394033940                                <File
     33941                                        RelativePath="..\bindings\js\JSHTMLCollectionFunctions.h"
     33942                                        >
     33943                                </File>
     33944                                <File
    3394133945                                        RelativePath="..\bindings\js\JSHTMLDataGridElementCustom.cpp"
    3394233946                                        >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r50013 r50037  
    43294329                BC97E413109154FA0010D361 /* JSHTMLAllCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = BC97E411109154FA0010D361 /* JSHTMLAllCollection.h */; };
    43304330                BC97E42C10915B060010D361 /* JSHTMLAllCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC97E42B10915B060010D361 /* JSHTMLAllCollectionCustom.cpp */; };
     4331                BC97E53F10926C870010D361 /* JSHTMLCollectionFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC97E53E10926C870010D361 /* JSHTMLCollectionFunctions.h */; };
    43314332                BC98543D0CD3D98B00069BC1 /* JSConsole.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC98543B0CD3D98B00069BC1 /* JSConsole.cpp */; };
    43324333                BC98543E0CD3D98C00069BC1 /* JSConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = BC98543C0CD3D98B00069BC1 /* JSConsole.h */; };
     
    94629463                BC97E411109154FA0010D361 /* JSHTMLAllCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLAllCollection.h; sourceTree = "<group>"; };
    94639464                BC97E42B10915B060010D361 /* JSHTMLAllCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLAllCollectionCustom.cpp; sourceTree = "<group>"; };
     9465                BC97E53E10926C870010D361 /* JSHTMLCollectionFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLCollectionFunctions.h; sourceTree = "<group>"; };
    94649466                BC98543B0CD3D98B00069BC1 /* JSConsole.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSConsole.cpp; sourceTree = "<group>"; };
    94659467                BC98543C0CD3D98B00069BC1 /* JSConsole.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSConsole.h; sourceTree = "<group>"; };
     
    1427114273                                3314ACE910892086000F0E56 /* JSExceptionBase.cpp */,
    1427214274                                3314ACEA10892086000F0E56 /* JSExceptionBase.h */,
     14275                                BC97E53E10926C870010D361 /* JSHTMLCollectionFunctions.h */,
    1427314276                                C09158840DB4209200E55AF4 /* JSInspectedObjectWrapper.cpp */,
    1427414277                                C09158850DB4209200E55AF4 /* JSInspectedObjectWrapper.h */,
     
    1806918072                                BC97E23A109144950010D361 /* HTMLAllCollection.h in Headers */,
    1807018073                                BC97E413109154FA0010D361 /* JSHTMLAllCollection.h in Headers */,
     18074                                BC97E53F10926C870010D361 /* JSHTMLCollectionFunctions.h in Headers */,
    1807118075                        );
    1807218076                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp

    r49998 r50037  
    3131#include "JSDOMBinding.h"
    3232#include "JSHTMLAllCollection.h"
     33#include "JSHTMLCollectionFunctions.h"
    3334#include "JSNode.h"
    3435#include "JSNodeList.h"
    3536#include "Node.h"
    36 #include "StaticNodeList.h"
    37 #include <wtf/Vector.h>
    3837
    3938using namespace JSC;
     
    4140namespace WebCore {
    4241
    43 static JSValue getNamedItems(ExecState* exec, JSHTMLAllCollection* collection, const Identifier& propertyName)
    44 {
    45     Vector<RefPtr<Node> > namedItems;
    46     collection->impl()->namedItems(propertyName, namedItems);
    47 
    48     if (namedItems.isEmpty())
    49         return jsUndefined();
    50     if (namedItems.size() == 1)
    51         return toJS(exec, collection->globalObject(), namedItems[0].get());
    52 
    53     // FIXME: HTML5 specifies that this should be a DynamicNodeList.
    54     // FIXME: HTML5 specifies that non-HTMLOptionsCollection collections should return
    55     // the first matching item instead of a NodeList.
    56     return toJS(exec, collection->globalObject(), StaticNodeList::adopt(namedItems).get());
    57 }
    58 
    59 // HTMLCollections are strange objects, they support both get and call,
    60 // so that document.forms.item(0) and document.forms(0) both work.
    6142static JSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec, JSObject* function, JSValue, const ArgList& args)
    6243{
    63     if (args.size() < 1)
    64         return jsUndefined();
    65 
    66     // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
    67     JSHTMLAllCollection* jsCollection = static_cast<JSHTMLAllCollection*>(function);
    68     HTMLAllCollection* collection = jsCollection->impl();
    69 
    70     // Also, do we need the TypeError test here ?
    71 
    72     if (args.size() == 1) {
    73         // Support for document.all(<index>) etc.
    74         bool ok;
    75         UString string = args.at(0).toString(exec);
    76         unsigned index = string.toUInt32(&ok, false);
    77         if (ok)
    78             return toJS(exec, jsCollection->globalObject(), collection->item(index));
    79 
    80         // Support for document.images('<name>') etc.
    81         return getNamedItems(exec, jsCollection, Identifier(exec, string));
    82     }
    83 
    84     // The second arg, if set, is the index of the item we want
    85     bool ok;
    86     UString string = args.at(0).toString(exec);
    87     unsigned index = args.at(1).toString(exec).toUInt32(&ok, false);
    88     if (ok) {
    89         String pstr = string;
    90         Node* node = collection->namedItem(pstr);
    91         while (node) {
    92             if (!index)
    93                 return toJS(exec, jsCollection->globalObject(), node);
    94             node = collection->nextNamedItem(pstr);
    95             --index;
    96         }
    97     }
    98 
    99     return jsUndefined();
     44    return callHTMLCollectionGeneric<HTMLAllCollection, JSHTMLAllCollection>(exec, function, args);
    10045}
    10146
     
    11661{
    11762    JSHTMLAllCollection* thisObj = static_cast<JSHTMLAllCollection*>(asObject(slot.slotBase()));
    118     return getNamedItems(exec, thisObj, propertyName);
     63    return getCollectionNamedItems<JSHTMLAllCollection>(exec, thisObj, propertyName);
    11964}
    12065
    12166JSValue JSHTMLAllCollection::item(ExecState* exec, const ArgList& args)
    12267{
    123     bool ok;
    124     uint32_t index = args.at(0).toString(exec).toUInt32(&ok, false);
    125     if (ok)
    126         return toJS(exec, globalObject(), impl()->item(index));
    127     return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
     68    return getCollectionItems<JSHTMLAllCollection>(exec, this, args.at(0));
    12869}
    12970
    13071JSValue JSHTMLAllCollection::namedItem(ExecState* exec, const ArgList& args)
    13172{
    132     return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
     73    return getCollectionNamedItems<JSHTMLAllCollection>(exec, this, Identifier(exec, args.at(0).toString(exec)));
    13374}
    13475
  • trunk/WebCore/bindings/js/JSHTMLCollectionCustom.cpp

    r49998 r50037  
    2222
    2323#include "AtomicString.h"
     24#include "HTMLAllCollection.h"
    2425#include "HTMLCollection.h"
    2526#include "HTMLOptionsCollection.h"
    26 #include "HTMLAllCollection.h"
    2727#include "JSDOMBinding.h"
    2828#include "JSHTMLAllCollection.h"
     29#include "JSHTMLCollectionFunctions.h"
    2930#include "JSHTMLOptionsCollection.h"
    3031#include "JSNode.h"
     
    3839namespace WebCore {
    3940
    40 static JSValue getNamedItems(ExecState* exec, JSHTMLCollection* collection, const Identifier& propertyName)
    41 {
    42     Vector<RefPtr<Node> > namedItems;
    43     collection->impl()->namedItems(propertyName, namedItems);
    44 
    45     if (namedItems.isEmpty())
    46         return jsUndefined();
    47     if (namedItems.size() == 1)
    48         return toJS(exec, collection->globalObject(), namedItems[0].get());
    49 
    50     // FIXME: HTML5 specifies that this should be a DynamicNodeList.
    51     // FIXME: HTML5 specifies that non-HTMLOptionsCollection collections should return
    52     // the first matching item instead of a NodeList.
    53     return toJS(exec, collection->globalObject(), StaticNodeList::adopt(namedItems).get());
    54 }
    55 
    56 // HTMLCollections are strange objects, they support both get and call,
    57 // so that document.forms.item(0) and document.forms(0) both work.
    5841static JSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec, JSObject* function, JSValue, const ArgList& args)
    5942{
    60     if (args.size() < 1)
    61         return 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*>(function);
    65     HTMLCollection* collection = jsCollection->impl();
    66 
    67     // Also, do we need the TypeError test here ?
    68 
    69     if (args.size() == 1) {
    70         // Support for document.all(<index>) etc.
    71         bool ok;
    72         UString string = args.at(0).toString(exec);
    73         unsigned index = string.toUInt32(&ok, false);
    74         if (ok)
    75             return toJS(exec, jsCollection->globalObject(), collection->item(index));
    76 
    77         // Support for document.images('<name>') etc.
    78         return 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 = args.at(0).toString(exec);
    84     unsigned index = args.at(1).toString(exec).toUInt32(&ok, false);
    85     if (ok) {
    86         String pstr = string;
    87         Node* node = collection->namedItem(pstr);
    88         while (node) {
    89             if (!index)
    90                 return toJS(exec, jsCollection->globalObject(), node);
    91             node = collection->nextNamedItem(pstr);
    92             --index;
    93         }
    94     }
    95 
    96     return jsUndefined();
     43    return callHTMLCollectionGeneric<HTMLCollection, JSHTMLCollection>(exec, function, args);
    9744}
    9845
     
    11360{
    11461    JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slot.slotBase()));
    115     return getNamedItems(exec, thisObj, propertyName);
     62    return getCollectionNamedItems<JSHTMLCollection>(exec, thisObj, propertyName);
    11663}
    11764
    11865JSValue JSHTMLCollection::item(ExecState* exec, const ArgList& args)
    11966{
    120     bool ok;
    121     uint32_t index = args.at(0).toString(exec).toUInt32(&ok, false);
    122     if (ok)
    123         return toJS(exec, globalObject(), impl()->item(index));
    124     return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
     67    return getCollectionItems<JSHTMLCollection>(exec, this, args.at(0));
    12568}
    12669
    12770JSValue JSHTMLCollection::namedItem(ExecState* exec, const ArgList& args)
    12871{
    129     return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
    130 }
    131 
    132 JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, HTMLCollection* collection)
    133 {
    134     if (!collection)
    135         return jsNull();
    136 
    137     DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), collection);
    138 
    139     if (wrapper)
    140         return wrapper;
    141 
    142     switch (collection->type()) {
    143         case SelectOptions:
    144             wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLOptionsCollection, collection);
    145             break;
    146         case DocAll:
    147             wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLAllCollection, collection);
    148             break;
    149         default:
    150             wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLCollection, collection);
    151             break;
    152     }
    153 
    154     return wrapper;
     72    return getCollectionNamedItems<JSHTMLCollection>(exec, this, Identifier(exec, args.at(0).toString(exec)));
    15573}
    15674
  • trunk/WebCore/bindings/js/JSHTMLDocumentCustom.cpp

    r49998 r50037  
    3939#include "JSDOMWindowCustom.h"
    4040#include "JSDOMWindowShell.h"
     41#include "JSHTMLAllCollection.h"
    4142#include "JSHTMLCollection.h"
    4243#include "SegmentedString.h"
  • trunk/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp

    r46444 r50037  
    2626#include "HTMLOptionsCollection.h"
    2727#include "HTMLSelectElement.h"
     28#include "JSHTMLCollection.h"
     29#include "JSHTMLCollectionFunctions.h"
    2830#include "JSHTMLOptionElement.h"
    2931#include "JSHTMLSelectElement.h"
    3032#include "JSHTMLSelectElementCustom.h"
    31 
    3233#include <wtf/MathExtras.h>
    3334
     
    3637namespace WebCore {
    3738
    38 JSValue JSHTMLOptionsCollection::length(ExecState* exec) const
     39static JSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec, JSObject* function, JSValue, const ArgList& args)
     40{
     41    return callHTMLCollectionGeneric<HTMLOptionsCollection, JSHTMLOptionsCollection>(exec, function, args);
     42}
     43
     44CallType JSHTMLOptionsCollection::getCallData(CallData& callData)
     45{
     46    callData.native.function = callHTMLCollection;
     47    return CallTypeHost;
     48}
     49
     50bool JSHTMLOptionsCollection::canGetItemsForName(ExecState*, HTMLOptionsCollection* collection, const Identifier& propertyName)
     51{
     52    Vector<RefPtr<Node> > namedItems;
     53    collection->namedItems(propertyName, namedItems);
     54    return !namedItems.isEmpty();
     55}
     56
     57JSValue JSHTMLOptionsCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
     58{
     59    JSHTMLOptionsCollection* thisObj = static_cast<JSHTMLOptionsCollection*>(asObject(slot.slotBase()));
     60    return getCollectionNamedItems<JSHTMLOptionsCollection>(exec, thisObj, propertyName);
     61}
     62
     63void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue value)
    3964{
    4065    HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
    41     return jsNumber(exec, imp->length());
     66    HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
     67    selectIndexSetter(base, exec, index, value);
     68}
     69
     70JSValue JSHTMLOptionsCollection::item(ExecState* exec, const ArgList& args)
     71{
     72    return getCollectionItems<JSHTMLOptionsCollection>(exec, this, args.at(0));
     73}
     74
     75JSValue JSHTMLOptionsCollection::namedItem(ExecState* exec, const ArgList& args)
     76{
     77    return getCollectionNamedItems<JSHTMLOptionsCollection>(exec, this, Identifier(exec, args.at(0).toString(exec)));
    4278}
    4379
     
    5995        imp->setLength(newLength, ec);
    6096    setDOMException(exec, ec);
    61 }
    62 
    63 void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue value)
    64 {
    65     HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
    66     HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
    67     selectIndexSetter(base, exec, index, value);
    6897}
    6998
     
    96125}
    97126
    98 }
     127} // namespace WebCore
  • trunk/WebCore/bindings/objc/DOMHTML.mm

    r45947 r50037  
    2929#import "DOMDocumentFragmentInternal.h"
    3030#import "DOMExtensions.h"
    31 #import "DOMHTMLCollectionInternal.h"
    3231#import "DOMHTMLDocumentInternal.h"
    3332#import "DOMHTMLInputElementInternal.h"
     
    3837#import "DocumentFragment.h"
    3938#import "FrameView.h"
    40 #import "HTMLCollection.h"
    4139#import "HTMLDocument.h"
    4240#import "HTMLInputElement.h"
     
    182180
    183181@end
    184 
    185 Class kitClass(WebCore::HTMLCollection* collection)
    186 {
    187     if (collection->type() == WebCore::SelectOptions)
    188         return [DOMHTMLOptionsCollection class];
    189     return [DOMHTMLCollection class];
    190 }
  • trunk/WebCore/bindings/objc/DOMUtility.mm

    r42618 r50037  
    3535#import "DOMEventInternal.h"
    3636#import "DOMHTMLCollectionInternal.h"
     37#import "DOMHTMLOptionsCollectionInternal.h"
    3738#import "DOMImplementationFront.h"
    3839#import "DOMInternal.h"
     
    106107    WRAP(Counter)
    107108    WRAP(Event)
     109    WRAP(HTMLCollection)
    108110    WRAP(HTMLOptionsCollection)
    109111    WRAP(MediaList)
     
    118120    WRAP(StyleSheetList)
    119121    WRAP(TreeWalker)
     122    WRAP(DOMWindowShell)
    120123#if ENABLE(XPATH)
    121124    WRAP(XPathExpression)
     
    123126#endif
    124127
    125     // This must be after the HTMLOptionsCollection check, because it's a subclass in the JavaScript
    126     // binding, but not a subclass in the ObjC binding.
    127     WRAP(HTMLCollection)
    128 
    129128    #undef WRAP
    130 
    131     if (object->inherits(&WebCore::JSDOMWindowShell::s_info))
    132         return kit(static_cast<WebCore::JSDOMWindowShell*>(object)->impl());
    133129
    134130    if (object->inherits(&WebCore::JSDOMImplementation::s_info))
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r49998 r50037  
    17091709        }
    17101710        push(@implContent, "}\n");
    1711         if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
     1711        if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection" or $interfaceName eq "HTMLOptionsCollection") {
    17121712            $implIncludes{"JSNode.h"} = 1;
    17131713            $implIncludes{"Node.h"} = 1;
     
    17201720        push(@implContent, "    return jsNumber(exec, static_cast<$implClassName*>(impl())->item(index));\n");
    17211721        push(@implContent, "}\n");
    1722         if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
     1722        if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection" or $interfaceName eq "HTMLOptionsCollection") {
    17231723            $implIncludes{"JSNode.h"} = 1;
    17241724            $implIncludes{"Node.h"} = 1;
  • trunk/WebCore/html/HTMLAllCollection.idl

    r49998 r50037  
    3131        HasNameGetter,
    3232        CustomCall,
    33         CustomToJS,
    3433        MasqueradesAsUndefined
    3534    ] HTMLAllCollection {
  • trunk/WebCore/html/HTMLCollection.idl

    r49998 r50037  
    2626        HasNameGetter,
    2727        CustomCall,
    28         CustomToJS,
    29         Polymorphic,
    3028        InterfaceUUID=b0d215ff-6f9c-4d1f-86c3-f200a65a5134,
    3129        ImplementationUUID=8e81b17f-7f74-4121-8f2f-a339a7e66447
  • trunk/WebCore/html/HTMLOptionsCollection.idl

    r50001 r50037  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    2121module html {
    2222
    23     // FIXME: The W3C spec says that HTMLOptionsCollection should not have a parent class.
    2423    interface [
    25         GenerateNativeConverter,
     24        GenerateConstructor,
     25        HasIndexGetter,
    2626        HasCustomIndexSetter,
     27        HasNameGetter,
     28        CustomCall,
    2729        InterfaceUUID=a03aaeac-e47d-4bb3-acb4-f1897ae74237,
    2830        ImplementationUUID=99c11fde-6f9f-44a4-a041-49a894c52e70
    29     ] HTMLOptionsCollection : HTMLCollection {
    30                  attribute long selectedIndex;
    31                  attribute [Custom] unsigned long length
     31    ] HTMLOptionsCollection {
     32                 attribute [CustomSetter] unsigned long length
    3233                        setter raises (DOMException);
     34        [Custom] Node item(in unsigned long index);
     35        [Custom] Node namedItem(in DOMString name);
    3336
    3437        [Custom] void add(in HTMLOptionElement option, in [Optional] unsigned long index)
     
    3639        [Custom] void remove(in unsigned long index);
    3740
    38 #if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT
    39         Node item(in unsigned long index);
    40         Node namedItem(in DOMString name);
    41 #endif
     41        // Extension
     42                 attribute long selectedIndex;
    4243    };
    4344
Note: See TracChangeset for help on using the changeset viewer.