[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

bweinstein at apple.com bweinstein at apple.com
Thu Oct 29 20:51:38 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 12add7681aafbfcea3dd727c168242360d4aae32
Author: bweinstein at apple.com <bweinstein at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Oct 25 07:08:03 2009 +0000

    Roll out r50037 as it broke the Windows build.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50040 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6aec0fa..f00cbdf 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,12 +1,3 @@
-2009-10-24  Sam Weinig  <sam at webkit.org>
-
-        Reviewed by Dan Bernstein.
-
-        Update tests for https://bugs.webkit.org/show_bug.cgi?id=30751
-        HTMLOptionsCollection should not inherit from HTMLCollection
-
-        * fast/dom/wrapper-classes-expected.txt:
-
 2009-10-24  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/LayoutTests/fast/dom/wrapper-classes-expected.txt b/LayoutTests/fast/dom/wrapper-classes-expected.txt
index 8af56c4..f3f0080 100644
--- a/LayoutTests/fast/dom/wrapper-classes-expected.txt
+++ b/LayoutTests/fast/dom/wrapper-classes-expected.txt
@@ -141,8 +141,8 @@ PASS jsWrapperClass(document) is 'HTMLDocument'
 PASS jsWrapperClass(document.__proto__) is 'HTMLDocumentPrototype'
 PASS jsWrapperClass(document.constructor) is 'HTMLDocumentConstructor'
 PASS jsWrapperClass(document.createElement('select').options) is 'HTMLOptionsCollection'
-PASS jsWrapperClass(document.createElement('select').options.__proto__) is 'HTMLOptionsCollectionPrototype'
-PASS jsWrapperClass(document.createElement('select').options.constructor) is 'HTMLOptionsCollectionConstructor'
+FAIL jsWrapperClass(document.createElement('select').options.__proto__) should be HTMLOptionsCollectionPrototype. Was HTMLCollectionPrototype.
+FAIL jsWrapperClass(document.createElement('select').options.constructor) should be HTMLOptionsCollectionConstructor. Was Function.
 
 HTML Elements
 
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 62eb4fc..ddb0a5c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -36,61 +36,6 @@
         (WebInspector.ResourcesPanel.prototype.filter):
         (WebInspector.ResourcesPanel.prototype._updateFilter):
 
-2009-10-24  Sam Weinig  <sam at webkit.org>
-
-        Reviewed by Dan Bernstein.
-
-        Fix for https://bugs.webkit.org/show_bug.cgi?id=30751
-        HTMLOptionsCollection should not inherit from HTMLCollection
-
-        * 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:
-
 2009-10-24  Timothy Hatcher  <timothy at apple.com>
 
         Make the scope bars in the Web Inspector match other scope bars in Mac OS X.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index e36fd32..6e8d6d8 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -376,7 +376,6 @@ webcore_sources += \
 	WebCore/bindings/js/JSHTMLAppletElementCustom.h \
 	WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp \
 	WebCore/bindings/js/JSHTMLCollectionCustom.cpp \
-	WebCore/bindings/js/JSHTMLCollectionFunctions.h \
 	WebCore/bindings/js/JSHTMLDataGridElementCustom.cpp \
 	WebCore/bindings/js/JSHTMLDocumentCustom.cpp \
 	WebCore/bindings/js/JSHTMLElementCustom.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 21bca02..3c282f3 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -496,7 +496,6 @@
             'bindings/js/JSHTMLAppletElementCustom.h',
             'bindings/js/JSHTMLCanvasElementCustom.cpp',
             'bindings/js/JSHTMLCollectionCustom.cpp',
-            'bindings/js/JSHTMLCollectionFunctions.h',
             'bindings/js/JSHTMLDataGridElementCustom.cpp',
             'bindings/js/JSHTMLDocumentCustom.cpp',
             'bindings/js/JSHTMLElementCustom.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 662130c..f60cf61 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -709,7 +709,6 @@ SOURCES += \
     bindings/js/JSHTMLCanvasElementCustom.cpp \
     bindings/js/JSHTMLAllCollectionCustom.cpp \
     bindings/js/JSHTMLCollectionCustom.cpp \
-    bindings/js/JSHTMLCollectionFunctions.h \
     bindings/js/JSHTMLDataGridElementCustom.cpp \
     bindings/js/JSHTMLDocumentCustom.cpp \
     bindings/js/JSHTMLElementCustom.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index aea7401..3ecf7d9 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -33938,10 +33938,6 @@
 					>
 				</File>
 				<File
-					RelativePath="..\bindings\js\JSHTMLCollectionFunctions.h"
-					>
-				</File>
-				<File
 					RelativePath="..\bindings\js\JSHTMLDataGridElementCustom.cpp"
 					>
 				</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 5054afc..0a4bd0a 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4328,7 +4328,6 @@
 		BC97E412109154FA0010D361 /* JSHTMLAllCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC97E410109154FA0010D361 /* JSHTMLAllCollection.cpp */; };
 		BC97E413109154FA0010D361 /* JSHTMLAllCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = BC97E411109154FA0010D361 /* JSHTMLAllCollection.h */; };
 		BC97E42C10915B060010D361 /* JSHTMLAllCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC97E42B10915B060010D361 /* JSHTMLAllCollectionCustom.cpp */; };
-		BC97E53F10926C870010D361 /* JSHTMLCollectionFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC97E53E10926C870010D361 /* JSHTMLCollectionFunctions.h */; };
 		BC98543D0CD3D98B00069BC1 /* JSConsole.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC98543B0CD3D98B00069BC1 /* JSConsole.cpp */; };
 		BC98543E0CD3D98C00069BC1 /* JSConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = BC98543C0CD3D98B00069BC1 /* JSConsole.h */; };
 		BC98A27D0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC98A27C0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp */; };
@@ -9462,7 +9461,6 @@
 		BC97E410109154FA0010D361 /* JSHTMLAllCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLAllCollection.cpp; sourceTree = "<group>"; };
 		BC97E411109154FA0010D361 /* JSHTMLAllCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLAllCollection.h; sourceTree = "<group>"; };
 		BC97E42B10915B060010D361 /* JSHTMLAllCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLAllCollectionCustom.cpp; sourceTree = "<group>"; };
-		BC97E53E10926C870010D361 /* JSHTMLCollectionFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLCollectionFunctions.h; sourceTree = "<group>"; };
 		BC98543B0CD3D98B00069BC1 /* JSConsole.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSConsole.cpp; sourceTree = "<group>"; };
 		BC98543C0CD3D98B00069BC1 /* JSConsole.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSConsole.h; sourceTree = "<group>"; };
 		BC98A27C0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStyleSheetCustom.cpp; sourceTree = "<group>"; };
@@ -14272,7 +14270,6 @@
 				BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */,
 				3314ACE910892086000F0E56 /* JSExceptionBase.cpp */,
 				3314ACEA10892086000F0E56 /* JSExceptionBase.h */,
-				BC97E53E10926C870010D361 /* JSHTMLCollectionFunctions.h */,
 				C09158840DB4209200E55AF4 /* JSInspectedObjectWrapper.cpp */,
 				C09158850DB4209200E55AF4 /* JSInspectedObjectWrapper.h */,
 				C09158860DB4209200E55AF4 /* JSInspectorCallbackWrapper.cpp */,
@@ -18071,7 +18068,6 @@
 				7553CFE8108F473F00EA281E /* TimelineItemFactory.h in Headers */,
 				BC97E23A109144950010D361 /* HTMLAllCollection.h in Headers */,
 				BC97E413109154FA0010D361 /* JSHTMLAllCollection.h in Headers */,
-				BC97E53F10926C870010D361 /* JSHTMLCollectionFunctions.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp b/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
index f3ec30d..636a751 100644
--- a/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
@@ -30,18 +30,73 @@
 #include "HTMLAllCollection.h"
 #include "JSDOMBinding.h"
 #include "JSHTMLAllCollection.h"
-#include "JSHTMLCollectionFunctions.h"
 #include "JSNode.h"
 #include "JSNodeList.h"
 #include "Node.h"
+#include "StaticNodeList.h"
+#include <wtf/Vector.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
+static JSValue getNamedItems(ExecState* exec, JSHTMLAllCollection* collection, const Identifier& propertyName)
+{
+    Vector<RefPtr<Node> > namedItems;
+    collection->impl()->namedItems(propertyName, namedItems);
+
+    if (namedItems.isEmpty())
+        return jsUndefined();
+    if (namedItems.size() == 1)
+        return toJS(exec, collection->globalObject(), namedItems[0].get());
+
+    // FIXME: HTML5 specifies that this should be a DynamicNodeList.
+    // FIXME: HTML5 specifies that non-HTMLOptionsCollection collections should return
+    // the first matching item instead of a NodeList.
+    return toJS(exec, collection->globalObject(), StaticNodeList::adopt(namedItems).get());
+}
+
+// HTMLCollections are strange objects, they support both get and call,
+// so that document.forms.item(0) and document.forms(0) both work.
 static JSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec, JSObject* function, JSValue, const ArgList& args)
 {
-    return callHTMLCollectionGeneric<HTMLAllCollection, JSHTMLAllCollection>(exec, function, args);
+    if (args.size() < 1)
+        return jsUndefined();
+
+    // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
+    JSHTMLAllCollection* jsCollection = static_cast<JSHTMLAllCollection*>(function);
+    HTMLAllCollection* collection = jsCollection->impl();
+
+    // Also, do we need the TypeError test here ?
+
+    if (args.size() == 1) {
+        // Support for document.all(<index>) etc.
+        bool ok;
+        UString string = args.at(0).toString(exec);
+        unsigned index = string.toUInt32(&ok, false);
+        if (ok)
+            return toJS(exec, jsCollection->globalObject(), collection->item(index));
+
+        // Support for document.images('<name>') etc.
+        return getNamedItems(exec, jsCollection, Identifier(exec, string));
+    }
+
+    // The second arg, if set, is the index of the item we want
+    bool ok;
+    UString string = args.at(0).toString(exec);
+    unsigned index = args.at(1).toString(exec).toUInt32(&ok, false);
+    if (ok) {
+        String pstr = string;
+        Node* node = collection->namedItem(pstr);
+        while (node) {
+            if (!index)
+                return toJS(exec, jsCollection->globalObject(), node);
+            node = collection->nextNamedItem(pstr);
+            --index;
+        }
+    }
+
+    return jsUndefined();
 }
 
 CallType JSHTMLAllCollection::getCallData(CallData& callData)
@@ -60,17 +115,21 @@ bool JSHTMLAllCollection::canGetItemsForName(ExecState*, HTMLAllCollection* coll
 JSValue JSHTMLAllCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
 {
     JSHTMLAllCollection* thisObj = static_cast<JSHTMLAllCollection*>(asObject(slot.slotBase()));
-    return getCollectionNamedItems<JSHTMLAllCollection>(exec, thisObj, propertyName);
+    return getNamedItems(exec, thisObj, propertyName);
 }
 
 JSValue JSHTMLAllCollection::item(ExecState* exec, const ArgList& args)
 {
-    return getCollectionItems<JSHTMLAllCollection>(exec, this, args.at(0));
+    bool ok;
+    uint32_t index = args.at(0).toString(exec).toUInt32(&ok, false);
+    if (ok)
+        return toJS(exec, globalObject(), impl()->item(index));
+    return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
 }
 
 JSValue JSHTMLAllCollection::namedItem(ExecState* exec, const ArgList& args)
 {
-    return getCollectionNamedItems<JSHTMLAllCollection>(exec, this, Identifier(exec, args.at(0).toString(exec)));
+    return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
 }
 
 } // namespace WebCore
diff --git a/WebCore/bindings/js/JSHTMLCollectionCustom.cpp b/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
index e3464f6..dd4ceaa 100644
--- a/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
@@ -21,12 +21,11 @@
 #include "JSHTMLCollection.h"
 
 #include "AtomicString.h"
-#include "HTMLAllCollection.h"
 #include "HTMLCollection.h"
 #include "HTMLOptionsCollection.h"
+#include "HTMLAllCollection.h"
 #include "JSDOMBinding.h"
 #include "JSHTMLAllCollection.h"
-#include "JSHTMLCollectionFunctions.h"
 #include "JSHTMLOptionsCollection.h"
 #include "JSNode.h"
 #include "JSNodeList.h"
@@ -38,9 +37,63 @@ using namespace JSC;
 
 namespace WebCore {
 
+static JSValue getNamedItems(ExecState* exec, JSHTMLCollection* collection, const Identifier& propertyName)
+{
+    Vector<RefPtr<Node> > namedItems;
+    collection->impl()->namedItems(propertyName, namedItems);
+
+    if (namedItems.isEmpty())
+        return jsUndefined();
+    if (namedItems.size() == 1)
+        return toJS(exec, collection->globalObject(), namedItems[0].get());
+
+    // FIXME: HTML5 specifies that this should be a DynamicNodeList.
+    // FIXME: HTML5 specifies that non-HTMLOptionsCollection collections should return
+    // the first matching item instead of a NodeList.
+    return toJS(exec, collection->globalObject(), StaticNodeList::adopt(namedItems).get());
+}
+
+// HTMLCollections are strange objects, they support both get and call,
+// so that document.forms.item(0) and document.forms(0) both work.
 static JSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec, JSObject* function, JSValue, const ArgList& args)
 {
-    return callHTMLCollectionGeneric<HTMLCollection, JSHTMLCollection>(exec, function, args);
+    if (args.size() < 1)
+        return jsUndefined();
+
+    // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
+    JSHTMLCollection* jsCollection = static_cast<JSHTMLCollection*>(function);
+    HTMLCollection* collection = jsCollection->impl();
+
+    // Also, do we need the TypeError test here ?
+
+    if (args.size() == 1) {
+        // Support for document.all(<index>) etc.
+        bool ok;
+        UString string = args.at(0).toString(exec);
+        unsigned index = string.toUInt32(&ok, false);
+        if (ok)
+            return toJS(exec, jsCollection->globalObject(), collection->item(index));
+
+        // Support for document.images('<name>') etc.
+        return getNamedItems(exec, jsCollection, Identifier(exec, string));
+    }
+
+    // The second arg, if set, is the index of the item we want
+    bool ok;
+    UString string = args.at(0).toString(exec);
+    unsigned index = args.at(1).toString(exec).toUInt32(&ok, false);
+    if (ok) {
+        String pstr = string;
+        Node* node = collection->namedItem(pstr);
+        while (node) {
+            if (!index)
+                return toJS(exec, jsCollection->globalObject(), node);
+            node = collection->nextNamedItem(pstr);
+            --index;
+        }
+    }
+
+    return jsUndefined();
 }
 
 CallType JSHTMLCollection::getCallData(CallData& callData)
@@ -59,17 +112,46 @@ bool JSHTMLCollection::canGetItemsForName(ExecState*, HTMLCollection* collection
 JSValue JSHTMLCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
 {
     JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slot.slotBase()));
-    return getCollectionNamedItems<JSHTMLCollection>(exec, thisObj, propertyName);
+    return getNamedItems(exec, thisObj, propertyName);
 }
 
 JSValue JSHTMLCollection::item(ExecState* exec, const ArgList& args)
 {
-    return getCollectionItems<JSHTMLCollection>(exec, this, args.at(0));
+    bool ok;
+    uint32_t index = args.at(0).toString(exec).toUInt32(&ok, false);
+    if (ok)
+        return toJS(exec, globalObject(), impl()->item(index));
+    return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
 }
 
 JSValue JSHTMLCollection::namedItem(ExecState* exec, const ArgList& args)
 {
-    return getCollectionNamedItems<JSHTMLCollection>(exec, this, Identifier(exec, args.at(0).toString(exec)));
+    return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
+}
+
+JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, HTMLCollection* collection)
+{
+    if (!collection)
+        return jsNull();
+
+    DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), collection);
+
+    if (wrapper)
+        return wrapper;
+
+    switch (collection->type()) {
+        case SelectOptions:
+            wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLOptionsCollection, collection);
+            break;
+        case DocAll:
+            wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLAllCollection, collection);
+            break;
+        default:
+            wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLCollection, collection);
+            break;
+    }
+
+    return wrapper;
 }
 
 } // namespace WebCore
diff --git a/WebCore/bindings/js/JSHTMLCollectionFunctions.h b/WebCore/bindings/js/JSHTMLCollectionFunctions.h
deleted file mode 100644
index 406c50d..0000000
--- a/WebCore/bindings/js/JSHTMLCollectionFunctions.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#ifndef JSHTMLCollectionFunctions_h
-#define JSHTMLCollectionFunctions_h
-
-#include "JSNode.h"
-#include "JSNodeList.h"
-#include "Node.h"
-#include "PlatformString.h"
-#include "StaticNodeList.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-template<typename JSCollection>
-JSC::JSValue getCollectionNamedItems(JSC::ExecState* exec, JSCollection* jsCollection, const JSC::Identifier& propertyName)
-{
-    Vector<RefPtr<Node> > namedItems;
-    jsCollection->impl()->namedItems(propertyName, namedItems);
-
-    if (namedItems.isEmpty())
-        return JSC::jsUndefined();
-    if (namedItems.size() == 1)
-        return toJS(exec, jsCollection->globalObject(), namedItems[0].get());
-
-    // FIXME: HTML5 specifies that this should be a DynamicNodeList.
-    // FIXME: HTML5 specifies that non-HTMLOptionsCollection collections should return
-    // the first matching item instead of a NodeList.
-    return toJS(exec, jsCollection->globalObject(), StaticNodeList::adopt(namedItems).get());
-}
-
-template<typename JSCollection>
-JSC::JSValue getCollectionItems(JSC::ExecState* exec, JSCollection* jsCollection, JSC::JSValue value)
-{
-    bool ok;
-    JSC::UString string = value.toString(exec);
-    unsigned index = string.toUInt32(&ok, false);
-    if (ok)
-        return toJS(exec, jsCollection->globalObject(), jsCollection->impl()->item(index));
-    return getCollectionNamedItems<JSCollection>(exec, jsCollection, JSC::Identifier(exec, string));
-}
-
-template<typename Collection, typename JSCollection>
-JSC::JSValue callHTMLCollectionGeneric(JSC::ExecState* exec, JSC::JSObject* function, const JSC::ArgList& args)
-{
-    if (args.size() < 1)
-        return JSC::jsUndefined();
-
-    JSCollection* jsCollection = static_cast<JSCollection*>(function);
-    Collection* collection = jsCollection->impl();
-
-    // Do we need the TypeError test here?
-
-    if (args.size() == 1)
-        return getCollectionItems<JSCollection>(exec, jsCollection, args.at(0));
-
-    // The second arg, if set, is the index of the item we want
-    bool ok;
-    JSC::UString string = args.at(0).toString(exec);
-    unsigned index = args.at(1).toString(exec).toUInt32(&ok, false);
-    if (ok) {
-        String pstr = string;
-        Node* node = collection->namedItem(pstr);
-        while (node) {
-            if (!index)
-                return toJS(exec, jsCollection->globalObject(), node);
-            node = collection->nextNamedItem(pstr);
-            --index;
-        }
-    }
-
-    return JSC::jsUndefined();
-}
-
-} // namespace WebCore
-
-#endif // JSHTMLCollectionFunctions_h
diff --git a/WebCore/bindings/js/JSHTMLDocumentCustom.cpp b/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
index 820e096..a65ca7c 100644
--- a/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
@@ -38,7 +38,6 @@
 #include "JSDOMWindow.h"
 #include "JSDOMWindowCustom.h"
 #include "JSDOMWindowShell.h"
-#include "JSHTMLAllCollection.h"
 #include "JSHTMLCollection.h"
 #include "SegmentedString.h"
 #include "Tokenizer.h"
diff --git a/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp b/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
index 230e613..7bca2db 100644
--- a/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
@@ -25,56 +25,20 @@
 #include "HTMLOptionElement.h"
 #include "HTMLOptionsCollection.h"
 #include "HTMLSelectElement.h"
-#include "JSHTMLCollection.h"
-#include "JSHTMLCollectionFunctions.h"
 #include "JSHTMLOptionElement.h"
 #include "JSHTMLSelectElement.h"
 #include "JSHTMLSelectElementCustom.h"
+
 #include <wtf/MathExtras.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
-static JSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec, JSObject* function, JSValue, const ArgList& args)
-{
-    return callHTMLCollectionGeneric<HTMLOptionsCollection, JSHTMLOptionsCollection>(exec, function, args);
-}
-
-CallType JSHTMLOptionsCollection::getCallData(CallData& callData)
-{
-    callData.native.function = callHTMLCollection;
-    return CallTypeHost;
-}
-
-bool JSHTMLOptionsCollection::canGetItemsForName(ExecState*, HTMLOptionsCollection* collection, const Identifier& propertyName)
-{
-    Vector<RefPtr<Node> > namedItems;
-    collection->namedItems(propertyName, namedItems);
-    return !namedItems.isEmpty();
-}
-
-JSValue JSHTMLOptionsCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
-{
-    JSHTMLOptionsCollection* thisObj = static_cast<JSHTMLOptionsCollection*>(asObject(slot.slotBase()));
-    return getCollectionNamedItems<JSHTMLOptionsCollection>(exec, thisObj, propertyName);
-}
-
-void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue value)
+JSValue JSHTMLOptionsCollection::length(ExecState* exec) const
 {
     HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
-    HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
-    selectIndexSetter(base, exec, index, value);
-}
-
-JSValue JSHTMLOptionsCollection::item(ExecState* exec, const ArgList& args)
-{
-    return getCollectionItems<JSHTMLOptionsCollection>(exec, this, args.at(0));
-}
-
-JSValue JSHTMLOptionsCollection::namedItem(ExecState* exec, const ArgList& args)
-{
-    return getCollectionNamedItems<JSHTMLOptionsCollection>(exec, this, Identifier(exec, args.at(0).toString(exec)));
+    return jsNumber(exec, imp->length());
 }
 
 void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValue value)
@@ -96,6 +60,13 @@ void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValue value)
     setDOMException(exec, ec);
 }
 
+void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue value)
+{
+    HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
+    HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
+    selectIndexSetter(base, exec, index, value);
+}
+
 JSValue JSHTMLOptionsCollection::add(ExecState* exec, const ArgList& args)
 {
     HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
@@ -124,4 +95,4 @@ JSValue JSHTMLOptionsCollection::remove(ExecState* exec, const ArgList& args)
     return base->remove(exec, args);
 }
 
-} // namespace WebCore
+}
diff --git a/WebCore/bindings/objc/DOMHTML.mm b/WebCore/bindings/objc/DOMHTML.mm
index 2cc3d6c..1043d8e 100644
--- a/WebCore/bindings/objc/DOMHTML.mm
+++ b/WebCore/bindings/objc/DOMHTML.mm
@@ -28,6 +28,7 @@
 
 #import "DOMDocumentFragmentInternal.h"
 #import "DOMExtensions.h"
+#import "DOMHTMLCollectionInternal.h"
 #import "DOMHTMLDocumentInternal.h"
 #import "DOMHTMLInputElementInternal.h"
 #import "DOMHTMLSelectElementInternal.h"
@@ -36,6 +37,7 @@
 #import "DOMPrivate.h"
 #import "DocumentFragment.h"
 #import "FrameView.h"
+#import "HTMLCollection.h"
 #import "HTMLDocument.h"
 #import "HTMLInputElement.h"
 #import "HTMLSelectElement.h"
@@ -179,3 +181,10 @@
 }
 
 @end
+
+Class kitClass(WebCore::HTMLCollection* collection)
+{
+    if (collection->type() == WebCore::SelectOptions)
+        return [DOMHTMLOptionsCollection class];
+    return [DOMHTMLCollection class];
+}
diff --git a/WebCore/bindings/objc/DOMUtility.mm b/WebCore/bindings/objc/DOMUtility.mm
index fb16af6..2b8c474 100644
--- a/WebCore/bindings/objc/DOMUtility.mm
+++ b/WebCore/bindings/objc/DOMUtility.mm
@@ -34,7 +34,6 @@
 #import "DOMCounterInternal.h"
 #import "DOMEventInternal.h"
 #import "DOMHTMLCollectionInternal.h"
-#import "DOMHTMLOptionsCollectionInternal.h"
 #import "DOMImplementationFront.h"
 #import "DOMInternal.h"
 #import "DOMMediaListInternal.h"
@@ -106,7 +105,6 @@ static inline id createDOMWrapper(JSC::JSObject* object)
     WRAP(CSSValue)
     WRAP(Counter)
     WRAP(Event)
-    WRAP(HTMLCollection)
     WRAP(HTMLOptionsCollection)
     WRAP(MediaList)
     WRAP(NamedNodeMap)
@@ -119,14 +117,20 @@ static inline id createDOMWrapper(JSC::JSObject* object)
     WRAP(StyleSheet)
     WRAP(StyleSheetList)
     WRAP(TreeWalker)
-    WRAP(DOMWindowShell)
 #if ENABLE(XPATH)
     WRAP(XPathExpression)
     WRAP(XPathResult)
 #endif
 
+    // This must be after the HTMLOptionsCollection check, because it's a subclass in the JavaScript
+    // binding, but not a subclass in the ObjC binding.
+    WRAP(HTMLCollection)
+
     #undef WRAP
 
+    if (object->inherits(&WebCore::JSDOMWindowShell::s_info))
+        return kit(static_cast<WebCore::JSDOMWindowShell*>(object)->impl());
+
     if (object->inherits(&WebCore::JSDOMImplementation::s_info))
         return kit(implementationFront(static_cast<WebCore::JSDOMImplementation*>(object)));
 
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index e57227d..d8367ac 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -1708,7 +1708,7 @@ sub GenerateImplementation
             push(@implContent, "    return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n");
         }
         push(@implContent, "}\n");
-        if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection" or $interfaceName eq "HTMLOptionsCollection") {
+        if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
             $implIncludes{"JSNode.h"} = 1;
             $implIncludes{"Node.h"} = 1;
         }
@@ -1719,7 +1719,7 @@ sub GenerateImplementation
         push(@implContent, "{\n");
         push(@implContent, "    return jsNumber(exec, static_cast<$implClassName*>(impl())->item(index));\n");
         push(@implContent, "}\n");
-        if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection" or $interfaceName eq "HTMLOptionsCollection") {
+        if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
             $implIncludes{"JSNode.h"} = 1;
             $implIncludes{"Node.h"} = 1;
         }
diff --git a/WebCore/html/HTMLAllCollection.idl b/WebCore/html/HTMLAllCollection.idl
index d36f41e..1e13c09 100644
--- a/WebCore/html/HTMLAllCollection.idl
+++ b/WebCore/html/HTMLAllCollection.idl
@@ -30,6 +30,7 @@ module html {
         HasIndexGetter,
         HasNameGetter,
         CustomCall,
+        CustomToJS,
         MasqueradesAsUndefined
     ] HTMLAllCollection {
         readonly attribute unsigned long length;
diff --git a/WebCore/html/HTMLCollection.idl b/WebCore/html/HTMLCollection.idl
index e6ae4f5..45d1127 100644
--- a/WebCore/html/HTMLCollection.idl
+++ b/WebCore/html/HTMLCollection.idl
@@ -25,6 +25,8 @@ module html {
         HasIndexGetter,
         HasNameGetter,
         CustomCall,
+        CustomToJS,
+        Polymorphic,
         InterfaceUUID=b0d215ff-6f9c-4d1f-86c3-f200a65a5134,
         ImplementationUUID=8e81b17f-7f74-4121-8f2f-a339a7e66447
     ] HTMLCollection {
diff --git a/WebCore/html/HTMLOptionsCollection.idl b/WebCore/html/HTMLOptionsCollection.idl
index dbe2e6c..cd8f884 100644
--- a/WebCore/html/HTMLOptionsCollection.idl
+++ b/WebCore/html/HTMLOptionsCollection.idl
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Samuel Weinig <sam.weinig at gmail.com>
  *
  * This library is free software; you can redistribute it and/or
@@ -20,26 +20,25 @@
 
 module html {
 
+    // FIXME: The W3C spec says that HTMLOptionsCollection should not have a parent class.
     interface [
-        GenerateConstructor,
-        HasIndexGetter,
+        GenerateNativeConverter,
         HasCustomIndexSetter,
-        HasNameGetter,
-        CustomCall,
         InterfaceUUID=a03aaeac-e47d-4bb3-acb4-f1897ae74237,
         ImplementationUUID=99c11fde-6f9f-44a4-a041-49a894c52e70
-    ] HTMLOptionsCollection {
-                 attribute [CustomSetter] unsigned long length
+    ] HTMLOptionsCollection : HTMLCollection {
+                 attribute long selectedIndex;
+                 attribute [Custom] unsigned long length
                         setter raises (DOMException);
-        [Custom] Node item(in unsigned long index);
-        [Custom] Node namedItem(in DOMString name);
 
         [Custom] void add(in HTMLOptionElement option, in [Optional] unsigned long index)
              raises (DOMException);
         [Custom] void remove(in unsigned long index);
 
-        // Extension
-                 attribute long selectedIndex;
+#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT
+        Node item(in unsigned long index);
+        Node namedItem(in DOMString name);
+#endif
     };
 
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list