[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
weinig at apple.com
weinig at apple.com
Thu Oct 29 20:51:40 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 871bd27b30567cc1ce86ffd7c69070e821631e97
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Oct 25 07:52:10 2009 +0000
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:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50041 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f00cbdf..e1de708 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,12 @@
+2009-10-25 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 f3f0080..8af56c4 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'
-FAIL jsWrapperClass(document.createElement('select').options.__proto__) should be HTMLOptionsCollectionPrototype. Was HTMLCollectionPrototype.
-FAIL jsWrapperClass(document.createElement('select').options.constructor) should be HTMLOptionsCollectionConstructor. Was Function.
+PASS jsWrapperClass(document.createElement('select').options.__proto__) is 'HTMLOptionsCollectionPrototype'
+PASS jsWrapperClass(document.createElement('select').options.constructor) is 'HTMLOptionsCollectionConstructor'
HTML Elements
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ddb0a5c..84eb863 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,58 @@
+2009-10-25 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 Keishi Hattori <casey.hattori at gmail.com>
Reviewed by Timothy Hatcher.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 6e8d6d8..e36fd32 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -376,6 +376,7 @@ 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 3c282f3..21bca02 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -496,6 +496,7 @@
'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 f60cf61..662130c 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -709,6 +709,7 @@ 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 3ecf7d9..aea7401 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -33938,6 +33938,10 @@
>
</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 0a4bd0a..5054afc 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4328,6 +4328,7 @@
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 */; };
@@ -9461,6 +9462,7 @@
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>"; };
@@ -14270,6 +14272,7 @@
BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */,
3314ACE910892086000F0E56 /* JSExceptionBase.cpp */,
3314ACEA10892086000F0E56 /* JSExceptionBase.h */,
+ BC97E53E10926C870010D361 /* JSHTMLCollectionFunctions.h */,
C09158840DB4209200E55AF4 /* JSInspectedObjectWrapper.cpp */,
C09158850DB4209200E55AF4 /* JSInspectedObjectWrapper.h */,
C09158860DB4209200E55AF4 /* JSInspectorCallbackWrapper.cpp */,
@@ -18068,6 +18071,7 @@
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 636a751..f3ec30d 100644
--- a/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
@@ -30,73 +30,18 @@
#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)
{
- 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();
+ return callHTMLCollectionGeneric<HTMLAllCollection, JSHTMLAllCollection>(exec, function, args);
}
CallType JSHTMLAllCollection::getCallData(CallData& callData)
@@ -115,21 +60,17 @@ 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 getNamedItems(exec, thisObj, propertyName);
+ return getCollectionNamedItems<JSHTMLAllCollection>(exec, thisObj, propertyName);
}
JSValue JSHTMLAllCollection::item(ExecState* exec, const ArgList& args)
{
- 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)));
+ return getCollectionItems<JSHTMLAllCollection>(exec, this, args.at(0));
}
JSValue JSHTMLAllCollection::namedItem(ExecState* exec, const ArgList& args)
{
- return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
+ return getCollectionNamedItems<JSHTMLAllCollection>(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 dd4ceaa..e3464f6 100644
--- a/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
@@ -21,11 +21,12 @@
#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"
@@ -37,63 +38,9 @@ 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)
{
- 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();
+ return callHTMLCollectionGeneric<HTMLCollection, JSHTMLCollection>(exec, function, args);
}
CallType JSHTMLCollection::getCallData(CallData& callData)
@@ -112,46 +59,17 @@ 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 getNamedItems(exec, thisObj, propertyName);
+ return getCollectionNamedItems<JSHTMLCollection>(exec, thisObj, propertyName);
}
JSValue JSHTMLCollection::item(ExecState* exec, const ArgList& args)
{
- 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)));
+ return getCollectionItems<JSHTMLCollection>(exec, this, args.at(0));
}
JSValue JSHTMLCollection::namedItem(ExecState* exec, const ArgList& args)
{
- 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;
+ return getCollectionNamedItems<JSHTMLCollection>(exec, this, Identifier(exec, args.at(0).toString(exec)));
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSHTMLCollectionFunctions.h b/WebCore/bindings/js/JSHTMLCollectionFunctions.h
new file mode 100644
index 0000000..406c50d
--- /dev/null
+++ b/WebCore/bindings/js/JSHTMLCollectionFunctions.h
@@ -0,0 +1,100 @@
+/*
+ * 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 a65ca7c..820e096 100644
--- a/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
@@ -38,6 +38,7 @@
#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 7bca2db..230e613 100644
--- a/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
@@ -25,20 +25,56 @@
#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 {
-JSValue JSHTMLOptionsCollection::length(ExecState* exec) const
+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)
{
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
- return jsNumber(exec, imp->length());
+ 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)));
}
void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValue value)
@@ -60,13 +96,6 @@ 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());
@@ -95,4 +124,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 1043d8e..2cc3d6c 100644
--- a/WebCore/bindings/objc/DOMHTML.mm
+++ b/WebCore/bindings/objc/DOMHTML.mm
@@ -28,7 +28,6 @@
#import "DOMDocumentFragmentInternal.h"
#import "DOMExtensions.h"
-#import "DOMHTMLCollectionInternal.h"
#import "DOMHTMLDocumentInternal.h"
#import "DOMHTMLInputElementInternal.h"
#import "DOMHTMLSelectElementInternal.h"
@@ -37,7 +36,6 @@
#import "DOMPrivate.h"
#import "DocumentFragment.h"
#import "FrameView.h"
-#import "HTMLCollection.h"
#import "HTMLDocument.h"
#import "HTMLInputElement.h"
#import "HTMLSelectElement.h"
@@ -181,10 +179,3 @@
}
@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 2b8c474..fb16af6 100644
--- a/WebCore/bindings/objc/DOMUtility.mm
+++ b/WebCore/bindings/objc/DOMUtility.mm
@@ -34,6 +34,7 @@
#import "DOMCounterInternal.h"
#import "DOMEventInternal.h"
#import "DOMHTMLCollectionInternal.h"
+#import "DOMHTMLOptionsCollectionInternal.h"
#import "DOMImplementationFront.h"
#import "DOMInternal.h"
#import "DOMMediaListInternal.h"
@@ -105,6 +106,7 @@ static inline id createDOMWrapper(JSC::JSObject* object)
WRAP(CSSValue)
WRAP(Counter)
WRAP(Event)
+ WRAP(HTMLCollection)
WRAP(HTMLOptionsCollection)
WRAP(MediaList)
WRAP(NamedNodeMap)
@@ -117,20 +119,14 @@ 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 d8367ac..e57227d 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") {
+ if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection" or $interfaceName eq "HTMLOptionsCollection") {
$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") {
+ if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection" or $interfaceName eq "HTMLOptionsCollection") {
$implIncludes{"JSNode.h"} = 1;
$implIncludes{"Node.h"} = 1;
}
diff --git a/WebCore/html/HTMLAllCollection.idl b/WebCore/html/HTMLAllCollection.idl
index 1e13c09..d36f41e 100644
--- a/WebCore/html/HTMLAllCollection.idl
+++ b/WebCore/html/HTMLAllCollection.idl
@@ -30,7 +30,6 @@ 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 45d1127..e6ae4f5 100644
--- a/WebCore/html/HTMLCollection.idl
+++ b/WebCore/html/HTMLCollection.idl
@@ -25,8 +25,6 @@ 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 cd8f884..dbe2e6c 100644
--- a/WebCore/html/HTMLOptionsCollection.idl
+++ b/WebCore/html/HTMLOptionsCollection.idl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2009 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,25 +20,26 @@
module html {
- // FIXME: The W3C spec says that HTMLOptionsCollection should not have a parent class.
interface [
- GenerateNativeConverter,
+ GenerateConstructor,
+ HasIndexGetter,
HasCustomIndexSetter,
+ HasNameGetter,
+ CustomCall,
InterfaceUUID=a03aaeac-e47d-4bb3-acb4-f1897ae74237,
ImplementationUUID=99c11fde-6f9f-44a4-a041-49a894c52e70
- ] HTMLOptionsCollection : HTMLCollection {
- attribute long selectedIndex;
- attribute [Custom] unsigned long length
+ ] HTMLOptionsCollection {
+ attribute [CustomSetter] 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);
-#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT
- Node item(in unsigned long index);
- Node namedItem(in DOMString name);
-#endif
+ // Extension
+ attribute long selectedIndex;
};
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list