LayoutTests:
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jun 2007 06:00:26 +0000 (06:00 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jun 2007 06:00:26 +0000 (06:00 +0000)
        Reviewed by Oliver.

        Update test for http://bugs.webkit.org/show_bug.cgi?id=14044
        Autogenerate the JS bindings for HTMLCollection.

        * tables/mozilla/bugs/bug53690-1-expected.txt: Now throws Undefined Error instead of Null Error

WebCore:

        Reviewed by Oliver.

        Patch for http://bugs.webkit.org/show_bug.cgi?id=14044
        Autogenerate the JS bindings for HTMLCollection

        - also moves JSHTMLAllCollection into it's own file.

        * DerivedSources.make:
        * WebCore.pro:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSHTMLAllCollection.h: Added.
        (WebCore::JSHTMLAllCollection::JSHTMLAllCollection):
        (WebCore::JSHTMLAllCollection::toBoolean):
        (WebCore::JSHTMLAllCollection::masqueradeAsUndefined):
        * bindings/js/JSHTMLCollectionCustom.cpp: Added.
        (WebCore::getNamedItems):
        (WebCore::JSHTMLCollection::callAsFunction):
        (WebCore::JSHTMLCollection::implementsCall):
        (WebCore::JSHTMLCollection::canGetItemsForName):
        (WebCore::JSHTMLCollection::nameGetter):
        (WebCore::JSHTMLCollection::item):
        (WebCore::JSHTMLCollection::namedItem):
        (WebCore::toJS):
        * bindings/js/JSHTMLDocumentCustom.cpp:
        (WebCore::JSHTMLDocument::nameGetter):
        (WebCore::JSHTMLDocument::all):
        * bindings/js/JSXMLHttpRequest.cpp:
        * bindings/js/kjs_html.cpp:
        (WebCore::ImageConstructorImp::ImageConstructorImp):
        (WebCore::ImageConstructorImp::construct):
        * bindings/js/kjs_html.h:
        (WebCore::ImageConstructorImp::implementsConstruct):
        * bindings/js/kjs_window.cpp:
        (KJS::Window::namedItemGetter):
        * bindings/objc/DOMUtility.mm:
        (KJS::createDOMWrapper):
        * bindings/scripts/CodeGeneratorJS.pm:
        * html/HTMLCollection.cpp:
        (WebCore::HTMLCollection::tags):
        * html/HTMLCollection.h:
        (WebCore::HTMLCollection::collectionType):
        * html/HTMLCollection.idl:
        * html/HTMLOptionsCollection.idl:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@22080 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/tables/mozilla/bugs/bug53690-1-expected.txt
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/WebCore.pro
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSHTMLAllCollection.h [new file with mode: 0644]
WebCore/bindings/js/JSHTMLCollectionCustom.cpp [new file with mode: 0644]
WebCore/bindings/js/JSHTMLDocumentCustom.cpp
WebCore/bindings/js/JSXMLHttpRequest.cpp
WebCore/bindings/js/kjs_html.cpp
WebCore/bindings/js/kjs_html.h
WebCore/bindings/js/kjs_window.cpp
WebCore/bindings/objc/DOMUtility.mm
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/html/HTMLCollection.cpp
WebCore/html/HTMLCollection.h
WebCore/html/HTMLCollection.idl
WebCore/html/HTMLOptionsCollection.idl

index dbcf8b5..7a31aba 100644 (file)
@@ -1,3 +1,12 @@
+2007-06-08  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Oliver.
+
+        Update test for http://bugs.webkit.org/show_bug.cgi?id=14044
+        Autogenerate the JS bindings for HTMLCollection.
+
+        * tables/mozilla/bugs/bug53690-1-expected.txt: Now throws Undefined Error instead of Null Error
+
 2007-06-08  dethbakin  <bdakin@apple.com>
 
         Reviewed by Brady.
index fe6f6e3..b4dcf10 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 4: TypeError: Null value
+CONSOLE MESSAGE: line 4: TypeError: Undefined value
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
index ee7079c..9e6fd46 100644 (file)
@@ -1,3 +1,49 @@
+2007-06-08  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Oliver.
+
+        Patch for http://bugs.webkit.org/show_bug.cgi?id=14044
+        Autogenerate the JS bindings for HTMLCollection
+
+        - also moves JSHTMLAllCollection into it's own file.
+
+        * DerivedSources.make:
+        * WebCore.pro:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSHTMLAllCollection.h: Added.
+        (WebCore::JSHTMLAllCollection::JSHTMLAllCollection):
+        (WebCore::JSHTMLAllCollection::toBoolean):
+        (WebCore::JSHTMLAllCollection::masqueradeAsUndefined):
+        * bindings/js/JSHTMLCollectionCustom.cpp: Added.
+        (WebCore::getNamedItems):
+        (WebCore::JSHTMLCollection::callAsFunction):
+        (WebCore::JSHTMLCollection::implementsCall):
+        (WebCore::JSHTMLCollection::canGetItemsForName):
+        (WebCore::JSHTMLCollection::nameGetter):
+        (WebCore::JSHTMLCollection::item):
+        (WebCore::JSHTMLCollection::namedItem):
+        (WebCore::toJS):
+        * bindings/js/JSHTMLDocumentCustom.cpp:
+        (WebCore::JSHTMLDocument::nameGetter):
+        (WebCore::JSHTMLDocument::all):
+        * bindings/js/JSXMLHttpRequest.cpp:
+        * bindings/js/kjs_html.cpp:
+        (WebCore::ImageConstructorImp::ImageConstructorImp):
+        (WebCore::ImageConstructorImp::construct):
+        * bindings/js/kjs_html.h:
+        (WebCore::ImageConstructorImp::implementsConstruct):
+        * bindings/js/kjs_window.cpp:
+        (KJS::Window::namedItemGetter):
+        * bindings/objc/DOMUtility.mm:
+        (KJS::createDOMWrapper):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * html/HTMLCollection.cpp:
+        (WebCore::HTMLCollection::tags):
+        * html/HTMLCollection.h:
+        (WebCore::HTMLCollection::collectionType):
+        * html/HTMLCollection.idl:
+        * html/HTMLOptionsCollection.idl:
+
 2007-06-08  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by John.
index 5c4e53e..e4751cd 100644 (file)
@@ -341,6 +341,7 @@ all : \
     JSHTMLBRElement.h \
     JSHTMLButtonElement.h \
     JSHTMLCanvasElement.h \
+    JSHTMLCollection.h \
     JSHTMLDListElement.h \
     JSHTMLDirectoryElement.h \
     JSHTMLDivElement.h \
@@ -550,7 +551,6 @@ all : \
     XPathGrammar.cpp \
     kjs_css.lut.h \
     kjs_events.lut.h \
-    kjs_html.lut.h \
     kjs_navigator.lut.h \
     kjs_window.lut.h \
     ksvgcssproperties.h \
index 353e163..9a539d9 100644 (file)
@@ -142,7 +142,6 @@ LUT_FILES += \
     bindings/js/JSXSLTProcessor.cpp \
     bindings/js/kjs_css.cpp \
     bindings/js/kjs_events.cpp \
-    bindings/js/kjs_html.cpp \
     bindings/js/kjs_navigator.cpp \
     bindings/js/kjs_window.cpp
 
@@ -211,6 +210,7 @@ IDL_BINDINGS += \
     html/HTMLBRElement.idl \
     html/HTMLButtonElement.idl \
     html/HTMLCanvasElement.idl \
+    html/HTMLCollection.idl \
     html/HTMLDirectoryElement.idl \
     html/HTMLDivElement.idl \
     html/HTMLDListElement.idl \
@@ -276,6 +276,7 @@ SOURCES += \
     bindings/js/JSDOMWindowCustom.cpp \
     bindings/js/JSEventTargetNode.cpp \
     bindings/js/JSHTMLAppletElementCustom.cpp \
+    bindings/js/JSHTMLCollectionCustom.cpp \
     bindings/js/JSHTMLDocumentCustom.cpp \
     bindings/js/JSHTMLElementCustom.cpp \
     bindings/js/JSHTMLElementWrapperFactory.cpp \
index cdc5b67..12cf86f 100644 (file)
                656581F009D1508D000E61D7 /* JSXSLTProcessor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581D909D1508D000E61D7 /* JSXSLTProcessor.lut.h */; };
                656581F109D1508D000E61D7 /* kjs_css.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581DA09D1508D000E61D7 /* kjs_css.lut.h */; };
                656581F309D1508D000E61D7 /* kjs_events.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581DC09D1508D000E61D7 /* kjs_events.lut.h */; };
-               656581F409D1508D000E61D7 /* kjs_html.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581DD09D1508D000E61D7 /* kjs_html.lut.h */; };
                656581F509D1508D000E61D7 /* kjs_navigator.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581DE09D1508D000E61D7 /* kjs_navigator.lut.h */; };
                656581F809D1508D000E61D7 /* kjs_window.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581E109D1508D000E61D7 /* kjs_window.lut.h */; };
                656581FB09D1508D000E61D7 /* ksvgcssproperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581E409D1508D000E61D7 /* ksvgcssproperties.h */; };
                BC6DB3690A1A7CB700E5CD14 /* GlyphPageTreeNode.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6DB3680A1A7CB700E5CD14 /* GlyphPageTreeNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC6DB4740A1A90FB00E5CD14 /* GlyphPageTreeNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6DB4730A1A90FB00E5CD14 /* GlyphPageTreeNode.cpp */; };
                BC6DB4D40A1AFEEF00E5CD14 /* GlyphPageTreeNodeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6DB4D30A1AFEEF00E5CD14 /* GlyphPageTreeNodeMac.cpp */; };
+               BC6DC7A10C1A4BFA004E2017 /* JSHTMLAllCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6DC7A00C1A4BFA004E2017 /* JSHTMLAllCollection.h */; };
                BC6E2B1A0C04B93600444EF8 /* DOMHTMLDocumentPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */; };
                BC6E2B290C04B95400444EF8 /* DOMHTMLDocumentPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */; };
                BC7F44A80B9E324E00A9D081 /* ImageObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7F44A70B9E324E00A9D081 /* ImageObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BCC5BE000C0E93110011C2DB /* JSCSSStyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC5BDFE0C0E93110011C2DB /* JSCSSStyleSheet.cpp */; };
                BCC5BE010C0E93110011C2DB /* JSCSSStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */; };
                BCC71A130A0FF94D0014EE6E /* GlyphBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC71A120A0FF94D0014EE6E /* GlyphBuffer.h */; };
+               BCCBAD3B0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */; };
+               BCCBAD400C18C14200CE890F /* JSHTMLCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCBAD3E0C18C14200CE890F /* JSHTMLCollection.cpp */; };
+               BCCBAD410C18C14200CE890F /* JSHTMLCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCBAD3F0C18C14200CE890F /* JSHTMLCollection.h */; };
                BCCD74DC0A4C8D35005FDA6D /* HTMLViewSourceDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCD74DB0A4C8D35005FDA6D /* HTMLViewSourceDocument.h */; };
                BCCD74E50A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCD74E40A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp */; };
                BCCFBAE80B5152ED0001F1D7 /* Tokenizer.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCFBAE70B5152ED0001F1D7 /* Tokenizer.h */; };
                656581D909D1508D000E61D7 /* JSXSLTProcessor.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXSLTProcessor.lut.h; sourceTree = "<group>"; };
                656581DA09D1508D000E61D7 /* kjs_css.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_css.lut.h; sourceTree = "<group>"; };
                656581DC09D1508D000E61D7 /* kjs_events.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_events.lut.h; sourceTree = "<group>"; };
-               656581DD09D1508D000E61D7 /* kjs_html.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_html.lut.h; sourceTree = "<group>"; };
                656581DE09D1508D000E61D7 /* kjs_navigator.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_navigator.lut.h; sourceTree = "<group>"; };
                656581E109D1508D000E61D7 /* kjs_window.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_window.lut.h; sourceTree = "<group>"; };
                656581E209D1508D000E61D7 /* ksvgcssproperties.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = ksvgcssproperties.c; sourceTree = "<group>"; };
                BC6DB3680A1A7CB700E5CD14 /* GlyphPageTreeNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GlyphPageTreeNode.h; sourceTree = "<group>"; };
                BC6DB4730A1A90FB00E5CD14 /* GlyphPageTreeNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphPageTreeNode.cpp; sourceTree = "<group>"; };
                BC6DB4D30A1AFEEF00E5CD14 /* GlyphPageTreeNodeMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphPageTreeNodeMac.cpp; sourceTree = "<group>"; };
+               BC6DC7A00C1A4BFA004E2017 /* JSHTMLAllCollection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLAllCollection.h; sourceTree = "<group>"; };
                BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLDocumentPrivate.h; sourceTree = "<group>"; };
                BC7B2AF80450824100A8000F /* ScrollBar.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBar.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BC7B2AF90450824100A8000F /* PlatformScrollBarMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformScrollBarMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCSSStyleSheet.h; sourceTree = "<group>"; };
                BCC71A120A0FF94D0014EE6E /* GlyphBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GlyphBuffer.h; sourceTree = "<group>"; };
                BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ColorData.gperf; sourceTree = "<group>"; };
+               BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLCollectionCustom.cpp; sourceTree = "<group>"; };
+               BCCBAD3E0C18C14200CE890F /* JSHTMLCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLCollection.cpp; sourceTree = "<group>"; };
+               BCCBAD3F0C18C14200CE890F /* JSHTMLCollection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLCollection.h; sourceTree = "<group>"; };
                BCCD74DB0A4C8D35005FDA6D /* HTMLViewSourceDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLViewSourceDocument.h; sourceTree = "<group>"; };
                BCCD74E40A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLViewSourceDocument.cpp; sourceTree = "<group>"; };
                BCCFBAE70B5152ED0001F1D7 /* Tokenizer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Tokenizer.h; sourceTree = "<group>"; };
                14DFB33F0A7DF7630018F769 /* Derived Sources */ = {
                        isa = PBXGroup;
                        children = (
+                               BCCBAD3E0C18C14200CE890F /* JSHTMLCollection.cpp */,
+                               BCCBAD3F0C18C14200CE890F /* JSHTMLCollection.h */,
                                65DF31D809D1C122000BE325 /* JSAttr.cpp */,
                                65DF31D909D1C123000BE325 /* JSAttr.h */,
                                65DF323309D1DE65000BE325 /* JSCanvasGradient.cpp */,
                                BCD9C2C50C17B6EC005C90A2 /* JSEventTargetNode.lut.h */,
                                656581DA09D1508D000E61D7 /* kjs_css.lut.h */,
                                656581DC09D1508D000E61D7 /* kjs_events.lut.h */,
-                               656581DD09D1508D000E61D7 /* kjs_html.lut.h */,
                                656581DE09D1508D000E61D7 /* kjs_navigator.lut.h */,
                                656581E109D1508D000E61D7 /* kjs_window.lut.h */,
                                656581E209D1508D000E61D7 /* ksvgcssproperties.c */,
                854F12AC0A8EBC18000940B5 /* Core */ = {
                        isa = PBXGroup;
                        children = (
+                               858C39510AA9024C00B187A4 /* CSS */,
                                856C8AE20A912649005C687B /* DOMObject.h */,
                                856C8AE30A912649005C687B /* DOMObject.mm */,
                                93C841FE09CE858300DFF5E5 /* DOMImplementationFront.cpp */,
                                BCD9C2690C17AA81005C90A2 /* JSDOMExceptionConstructor.h */,
                                BCD9C26A0C17AA81005C90A2 /* JSEventTargetNode.cpp */,
                                BCD9C26B0C17AA81005C90A2 /* JSEventTargetNode.h */,
+                               BC6DC7A00C1A4BFA004E2017 /* JSHTMLAllCollection.h */,
                                938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */,
                                938E65F009F09840008A48EC /* JSHTMLElementWrapperFactory.h */,
                                A80E7E640A1A82EC007FB8C5 /* JSHTMLInputElementBase.cpp */,
                        children = (
                                85B232260A8BF3A100FDF47B /* Derived Sources */,
                                854F12AC0A8EBC18000940B5 /* Core */,
-                               858C39510AA9024C00B187A4 /* CSS */,
                                8549492D0AC85A0A008AB035 /* SVG */,
                                854075420AD6C73E00620C57 /* DOMExceptions */,
                                859B7FB90A8D288800A5F1EA /* CodeGeneratorObjC.pm */,
                                929264760B61FC7200B41D34 /* JSDocumentCustom.cpp */,
                                BCD9C25E0C17AA67005C90A2 /* JSDOMWindowCustom.cpp */,
                                BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */,
+                               BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */,
                                BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */,
                                BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */,
                                BC6D44BD0C07EFB60072D2C9 /* JSHTMLEmbedElementCustom.cpp */,
                                656581F009D1508D000E61D7 /* JSXSLTProcessor.lut.h in Headers */,
                                656581F109D1508D000E61D7 /* kjs_css.lut.h in Headers */,
                                656581F309D1508D000E61D7 /* kjs_events.lut.h in Headers */,
-                               656581F409D1508D000E61D7 /* kjs_html.lut.h in Headers */,
                                656581F509D1508D000E61D7 /* kjs_navigator.lut.h in Headers */,
                                656581F809D1508D000E61D7 /* kjs_window.lut.h in Headers */,
                                656581FB09D1508D000E61D7 /* ksvgcssproperties.h in Headers */,
                                BCD9C2C30C17B69E005C90A2 /* JSNodeList.h in Headers */,
                                BCD9C2C60C17B6EC005C90A2 /* JSDOMExceptionConstructor.lut.h in Headers */,
                                BCD9C2C70C17B6EC005C90A2 /* JSEventTargetNode.lut.h in Headers */,
+                               BCCBAD410C18C14200CE890F /* JSHTMLCollection.h in Headers */,
+                               BC6DC7A10C1A4BFA004E2017 /* JSHTMLAllCollection.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCD9C2720C17AA81005C90A2 /* JSNamedNodesCollection.cpp in Sources */,
                                BCD9C2C00C17B69E005C90A2 /* JSNamedNodeMap.cpp in Sources */,
                                BCD9C2C20C17B69E005C90A2 /* JSNodeList.cpp in Sources */,
+                               BCCBAD3B0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp in Sources */,
+                               BCCBAD400C18C14200CE890F /* JSHTMLCollection.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebCore/bindings/js/JSHTMLAllCollection.h b/WebCore/bindings/js/JSHTMLAllCollection.h
new file mode 100644 (file)
index 0000000..ed0a27c
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2007 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 COMPUTER, 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 COMPUTER, 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 JSHTMLAllCollection_h
+#define JSHTMLAllCollection_h
+
+#include "JSHTMLCollection.h"
+
+namespace WebCore {
+
+    class HTMLCollection;
+
+    class JSHTMLAllCollection : public JSHTMLCollection {
+    public:
+        JSHTMLAllCollection(KJS::ExecState* exec, HTMLCollection* collection)
+            : JSHTMLCollection(exec, collection)
+        {
+        }
+
+        virtual bool toBoolean(KJS::ExecState*) const { return false; }
+        virtual bool masqueradeAsUndefined() const { return true; }
+    };
+
+} // namespace WebCore
+
+#endif // JSHTMLAllCollection_h
diff --git a/WebCore/bindings/js/JSHTMLCollectionCustom.cpp b/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
new file mode 100644 (file)
index 0000000..6a7b1a8
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "JSHTMLCollection.h"
+
+#include "AtomicString.h"
+#include "HTMLCollection.h"
+#include "HTMLOptionsCollection.h"
+#include "JSHTMLAllCollection.h"
+#include "JSHTMLOptionsCollection.h"
+#include "JSNamedNodesCollection.h"
+#include "JSNode.h"
+#include "Node.h"
+#include "kjs_binding.h"
+#include "kjs_html.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+static KJS::JSValue* getNamedItems(KJS::ExecState* exec, HTMLCollection* impl, const KJS::Identifier& propertyName)
+{
+    Vector<RefPtr<Node> > namedItems;
+    impl->namedItems(propertyName, namedItems);
+
+    if (namedItems.isEmpty())
+        return KJS::jsUndefined();
+
+    if (namedItems.size() == 1)
+        return toJS(exec, namedItems[0].get());
+
+    return new JSNamedNodesCollection(exec, namedItems);
+}
+
+// HTMLCollections are strange objects, they support both get and call,
+// so that document.forms.item(0) and document.forms(0) both work.
+KJS::JSValue* JSHTMLCollection::callAsFunction(KJS::ExecState* exec, KJS::JSObject*, const KJS::List& args)
+{
+    if (args.size() < 1)
+        return KJS::jsUndefined();
+
+    // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
+    HTMLCollection* collection = impl();
+
+    // Also, do we need the TypeError test here ?
+
+    if (args.size() == 1) {
+        // Support for document.all(<index>) etc.
+        bool ok;
+        KJS::UString string = args[0]->toString(exec);
+        unsigned index = string.toUInt32(&ok, false);
+        if (ok)
+            return toJS(exec, collection->item(index));
+
+        // Support for document.images('<name>') etc.
+        return getNamedItems(exec, collection, KJS::Identifier(string));
+    }
+
+    // The second arg, if set, is the index of the item we want
+    bool ok;
+    KJS::UString string = args[0]->toString(exec);
+    unsigned index = args[1]->toString(exec).toUInt32(&ok, false);
+    if (ok) {
+        String pstr = string;
+        Node* node = collection->namedItem(pstr);
+        while (node) {
+            if (!index)
+                return toJS(exec, node);
+            node = collection->nextNamedItem(pstr);
+            --index;
+        }
+    }
+
+    return KJS::jsUndefined();
+}
+
+bool JSHTMLCollection::implementsCall() const
+{
+    return true;
+}
+
+bool JSHTMLCollection::canGetItemsForName(KJS::ExecState* exec, HTMLCollection* thisObj, const KJS::Identifier& propertyName)
+{
+    return !getNamedItems(exec, thisObj, propertyName)->isUndefined();
+}
+
+KJS::JSValue* JSHTMLCollection::nameGetter(KJS::ExecState* exec, KJS::JSObject* originalObject, const KJS::Identifier& propertyName, const KJS::PropertySlot& slot)
+{
+    JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(slot.slotBase());
+    return getNamedItems(exec, thisObj->impl(), propertyName);
+}
+
+KJS::JSValue* JSHTMLCollection::item(KJS::ExecState* exec, const KJS::List& args)
+{
+    bool ok;
+    uint32_t index = args[0]->toString(exec).toUInt32(&ok, false);
+    if (ok)
+        return toJS(exec, impl()->item(index));
+    return getNamedItems(exec, impl(), KJS::Identifier(args[0]->toString(exec)));
+}
+
+KJS::JSValue* JSHTMLCollection::namedItem(KJS::ExecState* exec, const KJS::List& args)
+{
+    return getNamedItems(exec, impl(), KJS::Identifier(args[0]->toString(exec)));
+}
+
+KJS::JSValue* toJS(KJS::ExecState* exec, HTMLCollection* collection)
+{
+    if (!collection)
+        return KJS::jsNull();
+
+    KJS::ScriptInterpreter* interp = static_cast<KJS::ScriptInterpreter*>(exec->dynamicInterpreter());
+    KJS::DOMObject* ret = interp->getDOMObject(collection);
+
+    if (ret)
+        return ret;
+
+    switch (collection->collectionType()) {
+        case HTMLCollection::SelectOptions:
+            ret = new JSHTMLOptionsCollection(exec, static_cast<HTMLOptionsCollection*>(collection));
+            break;
+        case HTMLCollection::DocAll:
+            ret = new JSHTMLAllCollection(exec, static_cast<HTMLCollection*>(collection));
+            break;
+        default:
+            ret = new JSHTMLCollection(exec, static_cast<HTMLCollection*>(collection));
+            break;
+    }
+
+    interp->putDOMObject(collection, ret);
+    return ret;
+}
+
+} // namespace WebCore
index 9db557f..b8ddda9 100644 (file)
@@ -34,6 +34,7 @@
 #include "HTMLElement.h"
 #include "HTMLIFrameElement.h"
 #include "HTMLNames.h"
+#include "JSHTMLCollection.h"
 #include "kjs_html.h"
 #include "kjs_window.h"
 
@@ -69,7 +70,7 @@ JSValue* JSHTMLDocument::nameGetter(ExecState* exec, JSObject* originalObject, c
         return toJS(exec, node);
     } 
 
-    return getHTMLCollection(exec, collection.get());
+    return toJS(exec, collection.get());
 }
 
 // Custom attributes
@@ -80,7 +81,7 @@ JSValue* JSHTMLDocument::all(ExecState* exec) const
     if (JSValue* v = getDirect("all"))
         return v;
 
-    return getAllHTMLCollection(exec, static_cast<HTMLDocument*>(impl())->all().get());
+    return toJS(exec, static_cast<HTMLDocument*>(impl())->all().get());
 }
 
 void JSHTMLDocument::setAll(ExecState*, JSValue* value)
index 2ad959d..488a0e8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  This file is part of the KDE libraries
- *  Copyright (C) 2004 Apple Computer, Inc.
+ *  Copyright (C) 2004, 2007 Apple Inc. All rights reserved.
  *  Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@nypop.com>
  *
  *  This library is free software; you can redistribute it and/or
@@ -25,6 +25,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "HTMLDocument.h"
+#include "JSDocument.h"
 #include "kjs_events.h"
 #include "kjs_window.h"
 #include "xmlhttprequest.h"
index ae4f248..bab6b05 100644 (file)
 #include "config.h"
 #include "kjs_html.h"
 
-#include "DocLoader.h"
-#include "EventNames.h"
 #include "Frame.h"
 #include "FrameLoader.h"
-#include "FrameView.h"
+#include "JSHTMLElement.h"
 #include "HTMLDocument.h"
 #include "HTMLImageElement.h"
-#include "HTMLNames.h"
-#include "HTMLOptionElement.h"
-#include "HTMLOptionsCollection.h"
-#include "JSHTMLOptionsCollection.h"
-#include "JSNamedNodesCollection.h"
-#include "JSNodeList.h"
-#include "NameNodeList.h"
-#include "RenderLayer.h"
-#include "Text.h"
-#include "kjs_css.h"
-#include "kjs_events.h"
 #include "kjs_proxy.h"
-#include "kjs_window.h"
-#include <math.h>
 
-#if ENABLE(SVG)
-#include "SVGDocument.h"
-#endif
+namespace WebCore {
 
-#include "kjs_html.lut.h"
+using namespace KJS;
 
-using namespace WebCore;
-using namespace HTMLNames;
-using namespace EventNames;
-
-namespace KJS {
-
-/*
-@begin JSHTMLCollectionPrototypeTable 3
-  item          JSHTMLCollection::Item            DontDelete|Function 1
-  namedItem     JSHTMLCollection::NamedItem       DontDelete|Function 1
-  tags          JSHTMLCollection::Tags            DontDelete|Function 1
-@end
-*/
-KJS_IMPLEMENT_PROTOTYPE_FUNCTION(JSHTMLCollectionPrototypeFunction)
-KJS_IMPLEMENT_PROTOTYPE("HTMLCollection",JSHTMLCollectionPrototype,JSHTMLCollectionPrototypeFunction)
-
-const ClassInfo JSHTMLCollection::info = { "HTMLCollection", 0, 0, 0 };
-
-JSHTMLCollection::JSHTMLCollection(ExecState* exec, HTMLCollection* c)
-  : m_impl(c) 
-{
-  setPrototype(JSHTMLCollectionPrototype::self(exec));
-}
-
-JSHTMLCollection::~JSHTMLCollection()
-{
-  ScriptInterpreter::forgetDOMObject(m_impl.get());
-}
-
-JSValue *JSHTMLCollection::lengthGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
-{
-    JSHTMLCollection *thisObj = static_cast<JSHTMLCollection*>(slot.slotBase());
-    return jsNumber(thisObj->m_impl->length());
-}
-
-JSValue *JSHTMLCollection::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
-{
-    JSHTMLCollection *thisObj = static_cast<JSHTMLCollection*>(slot.slotBase());
-    return toJS(exec, thisObj->m_impl->item(slot.index()));
-}
-
-JSValue *JSHTMLCollection::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
-{
-    JSHTMLCollection *thisObj = static_cast<JSHTMLCollection*>(slot.slotBase());
-    return thisObj->getNamedItems(exec, propertyName);
-}
-
-bool JSHTMLCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
-{
-  if (propertyName == exec->propertyNames().length) {
-      slot.setCustom(this, lengthGetter);
-      return true;
-  } else {
-    // Look in the prototype (for functions) before assuming it's an item's name
-    JSValue *proto = prototype();
-    if (proto->isObject() && static_cast<JSObject*>(proto)->hasProperty(exec, propertyName))
-      return false;
-
-    // name or index ?
-    bool ok;
-    unsigned int u = propertyName.toUInt32(&ok, false);
-    if (ok) {
-      slot.setCustomIndex(this, u, indexGetter);
-      return true;
-    }
-
-    if (!getNamedItems(exec, propertyName)->isUndefined()) {
-      slot.setCustom(this, nameGetter);
-      return true;
-    }
-  }
-
-  return DOMObject::getOwnPropertySlot(exec, propertyName, slot);
-}
-
-// HTMLCollections are strange objects, they support both get and call,
-// so that document.forms.item(0) and document.forms(0) both work.
-JSValue *JSHTMLCollection::callAsFunction(ExecState* exec, JSObject* , const List &args)
-{
-  // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
-  HTMLCollection &collection = *m_impl;
-
-  // Also, do we need the TypeError test here ?
-
-  if (args.size() == 1) {
-    // support for document.all(<index>) etc.
-    bool ok;
-    UString s = args[0]->toString(exec);
-    unsigned int u = s.toUInt32(&ok, false);
-    if (ok)
-      return toJS(exec, collection.item(u));
-    // support for document.images('<name>') etc.
-    return getNamedItems(exec, Identifier(s));
-  }
-  else if (args.size() >= 1) // the second arg, if set, is the index of the item we want
-  {
-    bool ok;
-    UString s = args[0]->toString(exec);
-    unsigned int u = args[1]->toString(exec).toUInt32(&ok, false);
-    if (ok)
-    {
-      WebCore::String pstr = s;
-      WebCore::Node *node = collection.namedItem(pstr);
-      while (node) {
-        if (!u)
-          return toJS(exec,node);
-        node = collection.nextNamedItem(pstr);
-        --u;
-      }
-    }
-  }
-  return jsUndefined();
-}
-
-JSValue *JSHTMLCollection::getNamedItems(ExecState* exec, const Identifier &propertyName) const
-{
-    Vector<RefPtr<Node> > namedItems;
-    
-    m_impl->namedItems(propertyName, namedItems);
-
-    if (namedItems.isEmpty())
-        return jsUndefined();
-
-    if (namedItems.size() == 1)
-        return toJS(exec, namedItems[0].get());
-
-    return new JSNamedNodesCollection(exec, namedItems);
-}
-
-JSValue* JSHTMLCollectionPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
-{
-  if (!thisObj->inherits(&JSHTMLCollection::info))
-    return throwError(exec, TypeError);
-  HTMLCollection &coll = *static_cast<JSHTMLCollection*>(thisObj)->impl();
-
-  switch (id) {
-  case JSHTMLCollection::Tags:
-    return toJS(exec, coll.base()->getElementsByTagName(args[0]->toString(exec)).get());
-  case JSHTMLCollection::Item:
-    {
-        bool ok;
-        uint32_t index = args[0]->toString(exec).toUInt32(&ok, false);
-        if (ok)
-            return toJS(exec, coll.item(index));
-    }
-    // Fall through
-  case JSHTMLCollection::NamedItem:
-    return static_cast<JSHTMLCollection*>(thisObj)->getNamedItems(exec, Identifier(args[0]->toString(exec)));
-  default:
-    return jsUndefined();
-  }
-}
-
-////////////////////// Image Object ////////////////////////
-
-ImageConstructorImp::ImageConstructorImp(ExecState* exec, Document* d)
-    : m_doc(d)
+ImageConstructorImp::ImageConstructorImp(ExecState* exec, Document* doc)
+    : m_doc(doc)
 {
     setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
 }
 
-bool ImageConstructorImp::implementsConstruct() const
+JSObject* ImageConstructorImp::construct(ExecState*  exec, const List& list)
 {
-  return true;
-}
+    bool widthSet = false;
+    bool heightSet = false;
+    int width = 0;
+    int height = 0;
 
-JSObject* ImageConstructorImp::construct(ExecState*  exec, const List & list)
-{
-    bool widthSet = false, heightSet = false;
-    int width = 0, height = 0;
     if (list.size() > 0) {
         widthSet = true;
-        JSValue *w = list.at(0);
+        JSValuew = list.at(0);
         width = w->toInt32(exec);
     }
+
     if (list.size() > 1) {
         heightSet = true;
-        JSValue *h = list.at(1);
+        JSValueh = list.at(1);
         height = h->toInt32(exec);
     }
-        
+
     HTMLImageElement* image = new HTMLImageElement(m_doc.get());
     JSObject* result = static_cast<JSObject*>(toJS(exec, image));
-    
+
     if (widthSet)
         image->setWidth(width);
     if (heightSet)
         image->setHeight(height);
-    
-    return result;
-}
 
-////////////////////////////////////////////////////////////////
-                     
-JSValue* getAllHTMLCollection(ExecState* exec, HTMLCollection* c)
-{
-    return cacheDOMObject<HTMLCollection, HTMLAllCollection>(exec, c);
-}
-
-JSValue* getHTMLCollection(ExecState* exec, HTMLCollection* c)
-{
-    return cacheDOMObject<HTMLCollection, JSHTMLCollection>(exec, c);
-}
-
-JSValue* toJS(ExecState* exec, HTMLOptionsCollection* c)
-{
-    return cacheDOMObject<HTMLOptionsCollection, JSHTMLOptionsCollection>(exec, c);
+    return result;
 }
 
 // -------------------------------------------------------------------------
 
 // Runtime object support code for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
 
-
 JSValue* runtimeObjectGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
     JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
@@ -329,4 +138,4 @@ JSValue* runtimeObjectCallAsFunction(ExecState* exec, JSObject* thisObj, const L
     return jsUndefined();
 }
 
-} // namespace KJS
+} // namespace WebCore
index 41ba70f..f92ef2c 100644 (file)
 #ifndef kjs_html_h
 #define kjs_html_h
 
-#include "JSDocument.h"
-#include "JSElement.h"
-#include "JSHTMLElement.h"
 #include "kjs_dom.h"
 
 namespace WebCore {
+
+    class Document;
     class HTMLCollection;
-    class HTMLDocument;
     class HTMLElement;
-    class HTMLOptionsCollection;
-}
-
-namespace KJS {
-
-  class JSAbstractEventListener;
+    class JSHTMLElement;
 
-  KJS_DEFINE_PROTOTYPE(JSHTMLCollectionPrototype)
+    class ImageConstructorImp : public KJS::DOMObject {
+    public:
+        ImageConstructorImp(KJS::ExecState*, Document*);
 
-  class JSHTMLCollection : public DOMObject {
-  public:
-    JSHTMLCollection(ExecState*, WebCore::HTMLCollection*);
-    ~JSHTMLCollection();
-    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
-    virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List&args);
-    virtual bool implementsCall() const { return true; }
-    virtual bool toBoolean(ExecState*) const { return true; }
-    enum { Item, NamedItem, Tags };
-    JSValue* getNamedItems(ExecState*, const Identifier& propertyName) const;
-    virtual const ClassInfo* classInfo() const { return &info; }
-    static const ClassInfo info;
-    WebCore::HTMLCollection* impl() const { return m_impl.get(); }
-  protected:
-    RefPtr<WebCore::HTMLCollection> m_impl;
-  private:
-    static JSValue* lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
-    static JSValue* indexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
-    static JSValue* nameGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
-  };
+        virtual bool implementsConstruct() const { return true; }
+        virtual KJS::JSObject* construct(KJS::ExecState*, const KJS::List&);
 
-  class HTMLAllCollection : public JSHTMLCollection {
-  public:
-    HTMLAllCollection(ExecState* exec, WebCore::HTMLCollection* c) :
-      JSHTMLCollection(exec, c) { }
-    virtual bool toBoolean(ExecState*) const { return false; }
-    virtual bool masqueradeAsUndefined() const { return true; }
-  };
-  
-  ////////////////////// Image Object ////////////////////////
+    private:
+        RefPtr<Document> m_doc;
+    };
 
-  class ImageConstructorImp : public DOMObject {
-  public:
-    ImageConstructorImp(ExecState*, WebCore::Document*);
-    virtual bool implementsConstruct() const;
-    virtual JSObject* construct(ExecState*, const List& args);
-  private:
-    RefPtr<WebCore::Document> m_doc;
-  };
 
-  JSValue* toJS(ExecState*, WebCore::HTMLOptionsCollection*);
-  JSValue* getHTMLCollection(ExecState*, WebCore::HTMLCollection*);
-  JSValue* getAllHTMLCollection(ExecState*, WebCore::HTMLCollection*);
+    // Runtime object support code for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
+    // FIXME: Move these to a more appropriate place.
 
-  JSValue* runtimeObjectGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
-  JSValue* runtimeObjectPropertyGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
-  bool runtimeObjectCustomGetOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&, WebCore::JSHTMLElement*, WebCore::HTMLElement*);
-  bool runtimeObjectCustomPut(ExecState*, const Identifier&, JSValue*, int attr, WebCore::HTMLElement*);
-  bool runtimeObjectImplementsCall(WebCore::HTMLElement*);
-  JSValue* runtimeObjectCallAsFunction(ExecState*, JSObject*, const List&, WebCore::HTMLElement*);
+    KJS::JSValue* runtimeObjectGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&);
+    KJS::JSValue* runtimeObjectPropertyGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&);
+    bool runtimeObjectCustomGetOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&, JSHTMLElement*, HTMLElement*);
+    bool runtimeObjectCustomPut(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr, HTMLElement*);
+    bool runtimeObjectImplementsCall(HTMLElement*);
+    KJS::JSValue* runtimeObjectCallAsFunction(KJS::ExecState*, KJS::JSObject*, const KJS::List&, HTMLElement*);
 
-} // namespace KJS
+} // namespace WebCore
 
 #endif // kjs_html_h
index 8aa6f0d..a87ec61 100644 (file)
@@ -24,8 +24,8 @@
 #include "kjs_window.h"
 
 #include "Base64.h"
-#include "Chrome.h"
 #include "CString.h"
+#include "Chrome.h"
 #include "DOMWindow.h"
 #include "Element.h"
 #include "EventListener.h"
@@ -43,6 +43,7 @@
 #include "JSDOMExceptionConstructor.h"
 #include "JSDOMWindow.h"
 #include "JSEvent.h"
+#include "JSHTMLCollection.h"
 #include "JSHTMLOptionElementConstructor.h"
 #include "JSMutationEvent.h"
 #include "JSNode.h"
@@ -939,8 +940,7 @@ JSValue *Window::namedItemGetter(ExecState *exec, JSObject *originalObject, cons
   RefPtr<WebCore::HTMLCollection> collection = doc->windowNamedItems(name);
   if (collection->length() == 1)
     return toJS(exec, collection->firstItem());
-  else 
-    return getHTMLCollection(exec, collection.get());
+  return toJS(exec, collection.get());
 }
 
 bool Window::getOverridePropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
index dfdcae7..c5a847f 100644 (file)
@@ -35,6 +35,7 @@
 #import "JSCounter.h"
 #import "JSDOMImplementation.h"
 #import "JSEvent.h"
+#import "JSHTMLCollection.h"
 #import "JSHTMLOptionsCollection.h"
 #import "JSMediaList.h"
 #import "JSNamedNodeMap.h"
@@ -86,6 +87,10 @@ static inline id createDOMWrapper(KJS::JSObject* object)
     WRAP(XPathExpression)
     WRAP(XPathResult)
 
+    // 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
 
     #define WRAP(className) \
@@ -108,11 +113,6 @@ static inline id createDOMWrapper(KJS::JSObject* object)
     if (object->inherits(&WebCore::JSTreeWalker::info))
         return [DOMTreeWalker _wrapTreeWalker:static_cast<WebCore::JSTreeWalker*>(object)->impl() filter:nil];
 
-    // This must be after the HTMLOptionsCollection check, because it's a subclass in the JavaScript
-    // binding, but not a subclass in the ObjC binding.
-    if (object->inherits(&JSHTMLCollection::info))
-        return [DOMHTMLCollection _wrapHTMLCollection:static_cast<JSHTMLCollection*>(object)->impl()];
-
     return nil;
 }
 
index aed51c1..85473ae 100644 (file)
@@ -21,7 +21,6 @@
 # aint with this library; see the file COPYING.LIB.  If not, write to
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
-#
 
 package CodeGeneratorJS;
 
@@ -159,7 +158,7 @@ sub UsesManualToJSImplementation
 {
     my $type = shift;
 
-    return 1 if $type eq "Node" or $type eq "Document" or $type eq "SVGPathSeg" or $type eq "StyleSheet" or $type eq "CSSRule" or $type eq "CSSValue";
+    return 1 if $type eq "Node" or $type eq "Document" or $type eq "HTMLCollection" or $type eq "SVGPathSeg" or $type eq "StyleSheet" or $type eq "CSSRule" or $type eq "CSSValue";
     return 0;
 }
 
@@ -793,10 +792,10 @@ sub GenerateImplementation
         push(@implContent, "bool ${className}::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n");
         push(@implContent, "{\n");
 
-        if ($interfaceName eq "NamedNodeMap") {
+        if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection") {
             push(@implContent, "    JSValue* proto = prototype();\n");
             push(@implContent, "    if (proto->isObject() && static_cast<JSObject*>(proto)->hasProperty(exec, propertyName))\n");
-            push(@implContent, "        return false;\n");
+            push(@implContent, "        return false;\n\n");
         }
 
         my $hasNameGetterGeneration = sub {
@@ -822,9 +821,9 @@ sub GenerateImplementation
 
         if ($dataNode->extendedAttributes->{"HasIndexGetter"}) {
             push(@implContent, "    bool ok;\n");
-            push(@implContent, "    unsigned u = propertyName.toUInt32(&ok);\n");
-            push(@implContent, "    if (ok && u < static_cast<$implClassName*>(impl())->length()) {\n");
-            push(@implContent, "        slot.setCustomIndex(this, u, indexGetter);\n");
+            push(@implContent, "    unsigned index = propertyName.toUInt32(&ok, false);\n");
+            push(@implContent, "    if (ok && index < static_cast<$implClassName*>(impl())->length()) {\n");
+            push(@implContent, "        slot.setCustomIndex(this, index, indexGetter);\n");
             push(@implContent, "        return true;\n");
             push(@implContent, "    }\n");
         }
@@ -941,7 +940,7 @@ sub GenerateImplementation
             push(@implContent, "{\n");
             if ($dataNode->extendedAttributes->{"HasCustomIndexSetter"}) {
                 push(@implContent, "    bool ok;\n");
-                push(@implContent, "    unsigned index = propertyName.toUInt32(&ok);\n");
+                push(@implContent, "    unsigned index = propertyName.toUInt32(&ok, false);\n");
                 push(@implContent, "    if (ok) {\n");
                 push(@implContent, "        indexSetter(exec, index, value, attr);\n");
                 push(@implContent, "        return;\n");
@@ -1148,6 +1147,10 @@ sub GenerateImplementation
             push(@implContent, "    return toJS(exec, static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n");
         }
         push(@implContent, "}\n");
+        if ($interfaceName eq "HTMLCollection") {
+            $implIncludes{"JSNode.h"} = 1;
+            $implIncludes{"Node.h"} = 1;
+        }
     }
 
     if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateToJS"}) and !UsesManualToJSImplementation($implClassName)) {
@@ -1404,12 +1407,6 @@ sub NativeToJSValue
         }
     }
 
-    if ($type eq "HTMLCollection") {
-        $implIncludes{"kjs_html.h"} = 1;
-        $implIncludes{"HTMLCollection.h"} = 1;
-        return "getHTMLCollection(exec, WTF::getPtr($value))";
-    }
-
     if ($type eq "StyleSheetList") {
         $implIncludes{"StyleSheetList.h"} = 1;
         $implIncludes{"kjs_css.h"} = 1;
index 99db7d0..0e5359d 100644 (file)
@@ -29,6 +29,7 @@
 #include "HTMLElement.h"
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
+#include "NodeList.h"
 
 namespace WebCore {
 
@@ -416,4 +417,9 @@ Node *HTMLCollection::nextNamedItem(const String &name) const
     return 0;
 }
 
+PassRefPtr<NodeList> HTMLCollection::tags(const String& name)
+{
+    return base()->getElementsByTagName(name);
 }
+
+} // namespace WebCore
index f7f1844..5dc112b 100644 (file)
@@ -35,10 +35,10 @@ namespace WebCore {
 class AtomicString;
 class AtomicStringImpl;
 class Node;
+class NodeList;
 class String;
 
-class HTMLCollection : public Shared<HTMLCollection>
-{
+class HTMLCollection : public Shared<HTMLCollection> {
 public:
     enum Type {
         // from JSHTMLDocument
@@ -83,6 +83,9 @@ public:
     // In case of multiple items named the same way
     virtual Node *nextNamedItem(const String &name) const;
 
+    // Extension
+    PassRefPtr<NodeList> tags(const String&);
+
     void namedItems(const AtomicString &name, Vector<RefPtr<Node> >&) const;
 
     Node *base() { return m_base.get(); }
@@ -100,7 +103,9 @@ public:
         HashMap<AtomicStringImpl*, Vector<Node*>*> nameCache;
         bool haslength;
         bool hasNameCache;
-     };
+    };
+
+    Type collectionType() const { return type; }
 
 protected:
     virtual void updateNameCache() const;
index 3a20874..0078511 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
 
 module html {
 
-    interface HTMLCollection {
+    interface [GenerateConstructor, HasIndexGetter, HasNameGetter, CustomCall, CustomToJS] HTMLCollection {
         readonly attribute unsigned long length;
-        Node item(in unsigned long index);
-        Node namedItem(in DOMString name);
+        [Custom] Node item(in unsigned long index);
+        [Custom] Node namedItem(in DOMString name);
+
+        // Extensions
+        NodeList tags(in DOMString name);
     };
 
 }
index 07214a0..b182ddb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
@@ -22,7 +22,7 @@ module html {
 
     // FIXME: The W3C spec says that HTMLOptionsCollection should not have a parent class.
 
-    interface [LegacyParent=KJS::JSHTMLCollection, GenerateNativeConverter, HasCustomIndexSetter] HTMLOptionsCollection : HTMLCollection {
+    interface [GenerateNativeConverter, HasCustomIndexSetter] HTMLOptionsCollection : HTMLCollection {
                  attribute long selectedIndex;
                  attribute [Custom] unsigned long length
                         setter raises (DOMException);
@@ -35,4 +35,5 @@ module html {
         Node namedItem(in DOMString name);
 #endif
     };
+
 }