Commit 0d78994a authored by weinig's avatar weinig
Browse files

LayoutTests:

        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: http://svn.webkit.org/repository/webkit/trunk@22080 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cbcb9e25
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.
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
......
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.
......@@ -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 \
......
......@@ -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 \
......
......@@ -372,7 +372,6 @@
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 */; };
......@@ -2807,6 +2806,7 @@
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, ); }; };
......@@ -2854,6 +2854,9 @@
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 */; };
......@@ -3595,7 +3598,6 @@
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>"; };
......@@ -6095,6 +6097,7 @@
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; };
......@@ -6144,6 +6147,9 @@
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>"; };
......@@ -6460,6 +6466,8 @@
14DFB33F0A7DF7630018F769 /* Derived Sources */ = {
isa = PBXGroup;
children = (
BCCBAD3E0C18C14200CE890F /* JSHTMLCollection.cpp */,
BCCBAD3F0C18C14200CE890F /* JSHTMLCollection.h */,
65DF31D809D1C122000BE325 /* JSAttr.cpp */,
65DF31D909D1C123000BE325 /* JSAttr.h */,
65DF323309D1DE65000BE325 /* JSCanvasGradient.cpp */,
......@@ -7029,7 +7037,6 @@
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 */,
......@@ -7308,6 +7315,7 @@
854F12AC0A8EBC18000940B5 /* Core */ = {
isa = PBXGroup;
children = (
858C39510AA9024C00B187A4 /* CSS */,
856C8AE20A912649005C687B /* DOMObject.h */,
856C8AE30A912649005C687B /* DOMObject.mm */,
93C841FE09CE858300DFF5E5 /* DOMImplementationFront.cpp */,
......@@ -9196,6 +9204,7 @@
BCD9C2690C17AA81005C90A2 /* JSDOMExceptionConstructor.h */,
BCD9C26A0C17AA81005C90A2 /* JSEventTargetNode.cpp */,
BCD9C26B0C17AA81005C90A2 /* JSEventTargetNode.h */,
BC6DC7A00C1A4BFA004E2017 /* JSHTMLAllCollection.h */,
938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */,
938E65F009F09840008A48EC /* JSHTMLElementWrapperFactory.h */,
A80E7E640A1A82EC007FB8C5 /* JSHTMLInputElementBase.cpp */,
......@@ -9238,7 +9247,6 @@
children = (
85B232260A8BF3A100FDF47B /* Derived Sources */,
854F12AC0A8EBC18000940B5 /* Core */,
858C39510AA9024C00B187A4 /* CSS */,
8549492D0AC85A0A008AB035 /* SVG */,
854075420AD6C73E00620C57 /* DOMExceptions */,
859B7FB90A8D288800A5F1EA /* CodeGeneratorObjC.pm */,
......@@ -9285,6 +9293,7 @@
929264760B61FC7200B41D34 /* JSDocumentCustom.cpp */,
BCD9C25E0C17AA67005C90A2 /* JSDOMWindowCustom.cpp */,
BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */,
BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */,
BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */,
BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */,
BC6D44BD0C07EFB60072D2C9 /* JSHTMLEmbedElementCustom.cpp */,
......@@ -10391,7 +10400,6 @@
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 */,
......@@ -11542,6 +11550,8 @@
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;
};
......@@ -12963,6 +12973,8 @@
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;
};
/*
* 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
/*
* 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
......@@ -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)
......
/*
* 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"
......
......@@ -22,248 +22,57 @@
#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) {