Commit 661a37fc authored by weinig's avatar weinig
Browse files

LayoutTests:

        Reviewed by Darin.

        Update tests for http://bugs.webkit.org/show_bug.cgi?id=13830
        Auto-generate JS DOM bindings for HTMLDocument and most of 
        the rest of HTMLElement

        - Corrects prototype chain for JSHTMLDocument and adds test
          for HTMLFormElement.

        * fast/dom/prototype-chain-expected.txt:
        * fast/dom/prototype-chain.html:

WebCore:

        Reviewed by Darin.

        Part two of patch for http://bugs.webkit.org/show_bug.cgi?id=13830
        Auto-generate JS DOM bindings for HTMLDocument and most of the rest
        of HTMLElement

        - Just the HTMLDocument part.

        * WebCore.pro:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSHTMLDocumentCustom.cpp: Added.
        (WebCore::JSHTMLDocument::canGetItemsForName):
        (WebCore::JSHTMLDocument::nameGetter):
        (WebCore::JSHTMLDocument::all):
        (WebCore::JSHTMLDocument::setAll):
        (WebCore::JSHTMLDocument::location):
        (WebCore::JSHTMLDocument::setLocation):
        (WebCore::JSHTMLDocument::open):
        (WebCore::writeHelper):
        (WebCore::JSHTMLDocument::write):
        (WebCore::JSHTMLDocument::writeln):
        (WebCore::JSHTMLDocument::clear):
        * bindings/js/kjs_dom.cpp:
        (KJS::toJS):
        * bindings/js/kjs_dom.h:
        * bindings/js/kjs_html.cpp:
        * bindings/js/kjs_html.h:
        * bindings/objc/DOMPrivate.h:
        * bindings/scripts/CodeGeneratorJS.pm: Add [Deletable] property
        for Document.all and fix HasOverridingNameGetter to allow correct
        prototype chain
        * dom/Document.cpp:
        (WebCore::Document::plugins): adds alias to embeds() for bindings
        * dom/Document.h:
        * html/HTMLDocument.cpp:
        (WebCore::HTMLDocument::width):
        (WebCore::HTMLDocument::height):
        (WebCore::HTMLDocument::dir):
        (WebCore::HTMLDocument::setDir):
        (WebCore::HTMLDocument::designMode):
        (WebCore::HTMLDocument::setDesignMode):
        (WebCore::HTMLDocument::bgColor):
        (WebCore::HTMLDocument::setBgColor):
        (WebCore::HTMLDocument::fgColor):
        (WebCore::HTMLDocument::setFgColor):
        (WebCore::HTMLDocument::alinkColor):
        (WebCore::HTMLDocument::setAlinkColor):
        (WebCore::HTMLDocument::linkColor):
        (WebCore::HTMLDocument::setLinkColor):
        (WebCore::HTMLDocument::vlinkColor):
        (WebCore::HTMLDocument::setVlinkColor):
        (WebCore::HTMLDocument::captureEvents):
        (WebCore::HTMLDocument::releaseEvents):
        * html/HTMLDocument.h:
        * html/HTMLDocument.idl:

WebKit:

        Reviewed by Darin.

        Patch for http://bugs.webkit.org/show_bug.cgi?id=13830
        Auto-generate JS DOM bindings for HTMLDocument and most of the rest
        of HTMLElement

        * MigrateHeaders.make: add DOMHTMLDocumentPrivate.h
        * WebKit.xcodeproj/project.pbxproj:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21681 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dff3c4d7
2007-05-23 Sam Weinig <sam@webkit.org>
Reviewed by Darin.
Update tests for http://bugs.webkit.org/show_bug.cgi?id=13830
Auto-generate JS DOM bindings for HTMLDocument and most of
the rest of HTMLElement
- Corrects prototype chain for JSHTMLDocument and adds test
for HTMLFormElement.
* fast/dom/prototype-chain-expected.txt:
* fast/dom/prototype-chain.html:
2007-05-23 Kevin McCullough <kmccullough@apple.com>
 
Reviewed by.
......@@ -2,7 +2,7 @@ This page prints out the prototype chains of select DOM objects. Older versions
NOTE: This test will start failing if you change the layout of a related prototype chain in WebCore. That does not necessarily mean that you have done something wrong; you may just need to check in new results.
----- [object HTMLDocument] (7 prototypes) -----
----- [object HTMLDocument] (6 prototypes) -----
[object Object]
......@@ -14,8 +14,6 @@ NOTE: This test will start failing if you change the layout of a related prototy
[object DocumentPrototype]
[object DOMHTMLDocumentPrototype]
[object HTMLDocumentPrototype]
----- [object HTMLDivElement] (8 prototypes) -----
......@@ -36,6 +34,24 @@ NOTE: This test will start failing if you change the layout of a related prototy
[object HTMLDivElementPrototype]
----- [object HTMLFormElement] (8 prototypes) -----
[object Object]
[object DOMNodePrototype]
[object NodePrototype]
[object DOMEventTargetNodePrototype]
[object ElementPrototype]
[object HTMLElementPrototype]
[object HTMLElementPrototype]
[object HTMLFormElementPrototype]
----- [object UIEvent] (4 prototypes) -----
[object Object]
......
......@@ -36,6 +36,9 @@ function test()
e = document.getElementById("div");
printPrototypes(e);
e = document.createElement("form");
printPrototypes(e);
e = document.createEvent("UIEvents");
printPrototypes(e);
......
2007-05-23 Sam Weinig <sam@webkit.org>
Reviewed by Darin.
Part two of patch for http://bugs.webkit.org/show_bug.cgi?id=13830
Auto-generate JS DOM bindings for HTMLDocument and most of the rest
of HTMLElement
- Just the HTMLDocument part.
* WebCore.pro:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSHTMLDocumentCustom.cpp: Added.
(WebCore::JSHTMLDocument::canGetItemsForName):
(WebCore::JSHTMLDocument::nameGetter):
(WebCore::JSHTMLDocument::all):
(WebCore::JSHTMLDocument::setAll):
(WebCore::JSHTMLDocument::location):
(WebCore::JSHTMLDocument::setLocation):
(WebCore::JSHTMLDocument::open):
(WebCore::writeHelper):
(WebCore::JSHTMLDocument::write):
(WebCore::JSHTMLDocument::writeln):
(WebCore::JSHTMLDocument::clear):
* bindings/js/kjs_dom.cpp:
(KJS::toJS):
* bindings/js/kjs_dom.h:
* bindings/js/kjs_html.cpp:
* bindings/js/kjs_html.h:
* bindings/objc/DOMPrivate.h:
* bindings/scripts/CodeGeneratorJS.pm: Add [Deletable] property
for Document.all and fix HasOverridingNameGetter to allow correct
prototype chain
* dom/Document.cpp:
(WebCore::Document::plugins): adds alias to embeds() for bindings
* dom/Document.h:
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::width):
(WebCore::HTMLDocument::height):
(WebCore::HTMLDocument::dir):
(WebCore::HTMLDocument::setDir):
(WebCore::HTMLDocument::designMode):
(WebCore::HTMLDocument::setDesignMode):
(WebCore::HTMLDocument::bgColor):
(WebCore::HTMLDocument::setBgColor):
(WebCore::HTMLDocument::fgColor):
(WebCore::HTMLDocument::setFgColor):
(WebCore::HTMLDocument::alinkColor):
(WebCore::HTMLDocument::setAlinkColor):
(WebCore::HTMLDocument::linkColor):
(WebCore::HTMLDocument::setLinkColor):
(WebCore::HTMLDocument::vlinkColor):
(WebCore::HTMLDocument::setVlinkColor):
(WebCore::HTMLDocument::captureEvents):
(WebCore::HTMLDocument::releaseEvents):
* html/HTMLDocument.h:
* html/HTMLDocument.idl:
2007-05-23 David Hyatt <hyatt@apple.com>
 
Fix for <rdar://problem/5221838> REGRESSION (r21581): no content in idisk
......@@ -267,6 +267,7 @@ SOURCES += \
bindings/js/JSCustomXPathNSResolver.cpp \
bindings/js/JSDocumentCustom.cpp \
bindings/js/JSHTMLAnchorElementCustom.cpp \
bindings/js/JSHTMLDocumentCustom.cpp \
bindings/js/JSHTMLElementWrapperFactory.cpp \
bindings/js/JSHTMLFormElementCustom.cpp \
bindings/js/JSHTMLInputElementBase.cpp \
......
......@@ -2774,6 +2774,7 @@
BC5156F40C03B7DC008BB0EE /* DOMHTMLFrameElementPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = BC5156F30C03B7DC008BB0EE /* DOMHTMLFrameElementPrivate.h */; };
BC51579F0C03BBD3008BB0EE /* DOMHTMLMarqueeElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5156E50C03B741008BB0EE /* DOMHTMLMarqueeElement.h */; };
BC5157DD0C03BC22008BB0EE /* DOMHTMLFrameElementPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5156F30C03B7DC008BB0EE /* DOMHTMLFrameElementPrivate.h */; };
BC51580B0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */; };
BC588AF00BFA6CF900EE679E /* HTMLParserErrorCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */; };
BC588B4B0BFA723C00EE679E /* HTMLParserErrorCodes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC588B4A0BFA723C00EE679E /* HTMLParserErrorCodes.cpp */; };
BC6D6DD209AF906600F59759 /* Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6D6DD009AF906600F59759 /* Font.cpp */; };
......@@ -2785,6 +2786,8 @@
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 */; };
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, ); }; };
BCA169A20BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCA169A00BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp */; };
BCA169A30BFD55B40019CA76 /* JSHTMLTableCaptionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA169A10BFD55B40019CA76 /* JSHTMLTableCaptionElement.h */; };
......@@ -2981,6 +2984,7 @@
dstPath = Versions/A/PrivateHeaders;
dstSubfolderSpec = 1;
files = (
BC6E2B290C04B95400444EF8 /* DOMHTMLDocumentPrivate.h in Copy Generated Headers */,
BC5156E80C03B741008BB0EE /* DOMHTMLMarqueeElement.h in Copy Generated Headers */,
BC5156F40C03B7DC008BB0EE /* DOMHTMLFrameElementPrivate.h in Copy Generated Headers */,
93F9B6560BA0F35E00854064 /* DOMHTMLCanvasElement.h in Copy Generated Headers */,
......@@ -6010,6 +6014,7 @@
BC5156E60C03B741008BB0EE /* DOMHTMLMarqueeElement.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLMarqueeElement.mm; sourceTree = "<group>"; };
BC5156E70C03B741008BB0EE /* DOMHTMLMarqueeElementInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLMarqueeElementInternal.h; sourceTree = "<group>"; };
BC5156F30C03B7DC008BB0EE /* DOMHTMLFrameElementPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLFrameElementPrivate.h; sourceTree = "<group>"; };
BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLDocumentCustom.cpp; sourceTree = "<group>"; };
BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLParserErrorCodes.h; sourceTree = "<group>"; };
BC588B4A0BFA723C00EE679E /* HTMLParserErrorCodes.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLParserErrorCodes.cpp; sourceTree = "<group>"; };
BC5EC1760A507E3E006007F5 /* view-source.css */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "view-source.css"; sourceTree = "<group>"; };
......@@ -6022,6 +6027,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>"; };
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; };
BC7F44A70B9E324E00A9D081 /* ImageObserver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ImageObserver.h; sourceTree = "<group>"; };
......@@ -7635,6 +7641,7 @@
85BA4D020AA688680088052D /* DOMHTMLDListElement.mm */,
85BCBC110ABBA87D00381160 /* DOMHTMLDocument.h */,
85BCBC120ABBA87D00381160 /* DOMHTMLDocument.mm */,
BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */,
85DF2EEB0AA387CB00AD64C5 /* DOMHTMLElement.h */,
85DF2EEC0AA387CB00AD64C5 /* DOMHTMLElement.mm */,
854075650AD6CBF900620C57 /* DOMHTMLEmbedElement.h */,
......@@ -9063,6 +9070,7 @@
E10B937B0B73C00A003ED890 /* JSCustomXPathNSResolver.h */,
929264760B61FC7200B41D34 /* JSDocumentCustom.cpp */,
BCF411770BFCC76A00125622 /* JSHTMLAnchorElementCustom.cpp */,
BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */,
938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */,
938E65F009F09840008A48EC /* JSHTMLElementWrapperFactory.h */,
A8D065AD0A2446CD005E7203 /* JSHTMLFormElementCustom.cpp */,
......@@ -11369,6 +11377,7 @@
BC5156EA0C03B741008BB0EE /* DOMHTMLMarqueeElementInternal.h in Headers */,
BC51579F0C03BBD3008BB0EE /* DOMHTMLMarqueeElement.h in Headers */,
BC5157DD0C03BC22008BB0EE /* DOMHTMLFrameElementPrivate.h in Headers */,
BC6E2B1A0C04B93600444EF8 /* DOMHTMLDocumentPrivate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -12757,6 +12766,7 @@
BC491B780C023EFD009D6316 /* JSHTMLMarqueeElement.cpp in Sources */,
BC5156E90C03B741008BB0EE /* DOMHTMLMarqueeElement.mm in Sources */,
ABAF22080C03B1C700B0BCF0 /* ChromeMac.mm in Sources */,
BC51580B0C03D404008BB0EE /* JSHTMLDocumentCustom.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.
*/
#include "config.h"
#include "JSHTMLDocument.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "HTMLBodyElement.h"
#include "HTMLCollection.h"
#include "HTMLDocument.h"
#include "HTMLElement.h"
#include "HTMLIFrameElement.h"
#include "HTMLNames.h"
#include "kjs_html.h"
#include "kjs_window.h"
namespace WebCore {
using namespace KJS;
using namespace HTMLNames;
bool JSHTMLDocument::canGetItemsForName(ExecState*, HTMLDocument* doc, const AtomicString& propertyName)
{
return doc->hasNamedItem(propertyName) || doc->hasDocExtraNamedItem(propertyName);
}
JSValue* JSHTMLDocument::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
JSHTMLDocument* thisObj = static_cast<JSHTMLDocument*>(slot.slotBase());
HTMLDocument* doc = static_cast<HTMLDocument*>(thisObj->impl());
String name = propertyName;
RefPtr<HTMLCollection> collection = doc->documentNamedItems(name);
unsigned length = collection->length();
if (!length)
return jsUndefined();
if (length == 1) {
Node* node = collection->firstItem();
Frame* frame;
if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
return Window::retrieve(frame);
return toJS(exec, node);
}
return getHTMLCollection(exec, collection.get());
}
// Custom attributes
JSValue* JSHTMLDocument::all(ExecState* exec) const
{
// If "all" has been overwritten, return the overwritten value
if (JSValue* v = getDirect("all"))
return v;
return getAllHTMLCollection(exec, static_cast<HTMLDocument*>(impl())->all().get());
}
void JSHTMLDocument::setAll(ExecState*, JSValue* value)
{
// Add "all" to the property map.
putDirect("all", value);
}
JSValue* JSHTMLDocument::location(ExecState* exec) const
{
Frame* frame = static_cast<HTMLDocument*>(impl())->frame();
if (!frame)
return jsNull();
Window* win = Window::retrieveWindow(frame);
ASSERT(win);
return win->location();
}
void JSHTMLDocument::setLocation(ExecState* exec, JSValue* value)
{
Frame* frame = static_cast<HTMLDocument*>(impl())->frame();
if (!frame)
return;
String str = value->toString(exec);
// When assigning location, IE and Mozilla both resolve the URL
// relative not the target frame.
Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame();
if (activeFrame)
str = activeFrame->document()->completeURL(str);
// We want a new history item if this JS was called via a user gesture
bool userGesture = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->wasRunByUserGesture();
frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !userGesture);
}
// Custom functions
JSValue* JSHTMLDocument::open(ExecState* exec, const List& args)
{
// For compatibility with other browsers, pass open calls with more than 2 parameters to the window.
if (args.size() > 2) {
Frame* frame = static_cast<HTMLDocument*>(impl())->frame();
if (frame) {
Window* window = Window::retrieveWindow(frame);
if (window) {
JSObject* functionObject = window->get(exec, "open")->getObject();
if (!functionObject || !functionObject->implementsCall())
return throwError(exec, TypeError);
return functionObject->call(exec, window, args);
}
}
return jsUndefined();
}
// In the case of two parameters or fewer, do a normal document open.
static_cast<HTMLDocument*>(impl())->open();
return jsUndefined();
}
static String writeHelper(ExecState* exec, const List& args)
{
// DOM only specifies single string argument, but NS & IE allow multiple
// or no arguments.
String str = "";
for (int i = 0; i < args.size(); ++i)
str += args[i]->toString(exec);
return str;
}
JSValue* JSHTMLDocument::write(ExecState* exec, const List& args)
{
static_cast<HTMLDocument*>(impl())->write(writeHelper(exec, args));
return jsUndefined();
}
JSValue* JSHTMLDocument::writeln(ExecState* exec, const List& args)
{
static_cast<HTMLDocument*>(impl())->write(writeHelper(exec, args) + "\n");
return jsUndefined();
}
JSValue* JSHTMLDocument::clear(ExecState*, const List&)
{
// even IE doesn't support this one...
// static_cast<HTMLDocument*>(impl())->clear();
return jsUndefined();
}
} // namespace WebCore
......@@ -1071,9 +1071,9 @@ JSValue* getRuntimeObject(ExecState* exec, Node* n)
return 0;
}
JSValue* toJS(ExecState* exec, PassRefPtr<NodeList> l)
JSValue* toJS(ExecState* exec, NodeList* l)
{
return cacheDOMObject<NodeList, DOMNodeList>(exec, l.get());
return cacheDOMObject<NodeList, DOMNodeList>(exec, l);
}
// -------------------------------------------------------------------------
......
......@@ -137,7 +137,7 @@ namespace KJS {
JSValue* getRuntimeObject(ExecState*, WebCore::Node*);
JSValue* toJS(ExecState*, PassRefPtr<WebCore::Node>);
JSValue* toJS(ExecState*, WebCore::NamedNodeMap*);
JSValue* toJS(ExecState*, PassRefPtr<WebCore::NodeList>);
JSValue* toJS(ExecState*, WebCore::NodeList*);
JSValue* toJS(ExecState*, WebCore::EventTarget*);
JSObject* getNodeConstructor(ExecState*);
JSObject* getDOMExceptionConstructor(ExecState*);
......
......@@ -71,345 +71,6 @@ private:
int id;
};
/*
@begin JSHTMLDocumentPrototypeTable 8
clear JSHTMLDocument::Clear DontDelete|Function 0
open JSHTMLDocument::Open DontDelete|Function 0
close JSHTMLDocument::Close DontDelete|Function 0
write JSHTMLDocument::Write DontDelete|Function 1
writeln JSHTMLDocument::WriteLn DontDelete|Function 1
getElementsByName JSHTMLDocument::GetElementsByName DontDelete|Function 1
captureEvents JSHTMLDocument::CaptureEvents DontDelete|Function 0
releaseEvents JSHTMLDocument::ReleaseEvents DontDelete|Function 0
@end
*/
KJS_IMPLEMENT_PROTOTYPE_FUNCTION(JSHTMLDocumentPrototypeFunction)
KJS_IMPLEMENT_PROTOTYPE("DOMHTMLDocument", JSHTMLDocumentPrototype, JSHTMLDocumentPrototypeFunction)
JSValue *JSHTMLDocumentPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
{
if (!thisObj->inherits(&JSHTMLDocument::info))
return throwError(exec, TypeError);
HTMLDocument &doc = *static_cast<HTMLDocument*>(static_cast<JSHTMLDocument*>(thisObj)->impl());
switch (id) {
case JSHTMLDocument::Clear: // even IE doesn't support that one...
//doc.clear(); // TODO
return jsUndefined();
case JSHTMLDocument::Open:
// For compatibility with other browsers, pass open calls with more than 2 parameters to the window.
if (args.size() > 2) {
Frame *frame = doc.frame();
if (frame) {
Window *window = Window::retrieveWindow(frame);
if (window) {
JSObject* functionObject = window->get(exec, "open")->getObject();
if (!functionObject || !functionObject->implementsCall())
return throwError(exec, TypeError);
return functionObject->call(exec, window, args);
}
}
return jsUndefined();
}
// In the case of two parameters or fewer, do a normal document open.
doc.open();
return jsUndefined();
case JSHTMLDocument::Close:
doc.close();
return jsUndefined();
case JSHTMLDocument::Write:
case JSHTMLDocument::WriteLn: {
// DOM only specifies single string argument, but NS & IE allow multiple
// or no arguments
String str = "";
for (int i = 0; i < args.size(); i++)
str += args[i]->toString(exec);
if (id == JSHTMLDocument::WriteLn)
str += "\n";
doc.write(str);
return jsUndefined();
}
case JSHTMLDocument::GetElementsByName:
return toJS(exec, doc.getElementsByName(args[0]->toString(exec)).get());
case JSHTMLDocument::CaptureEvents:
case JSHTMLDocument::ReleaseEvents:
// Do nothing for now. These are NS-specific legacy calls.
break;
}
return jsUndefined();
}
// FIXME: functions should be in the prototype
const ClassInfo JSHTMLDocument::info =
{ "DOMHTMLDocument", &JSDocument::info, &HTMLDocumentTable, 0 };
/* Source for HTMLDocumentTable. Use "make hashtables" to regenerate.
@begin HTMLDocumentTable 30
title JSHTMLDocument::Title DontDelete
referrer JSHTMLDocument::Referrer DontDelete|ReadOnly
domain JSHTMLDocument::Domain DontDelete
body JSHTMLDocument::Body DontDelete
location JSHTMLDocument::Location DontDelete
cookie JSHTMLDocument::Cookie DontDelete
images JSHTMLDocument::Images DontDelete|ReadOnly
embeds JSHTMLDocument::Embeds DontDelete|ReadOnly
plugins JSHTMLDocument::Embeds DontDelete|ReadOnly
applets JSHTMLDocument::Applets DontDelete|ReadOnly
links JSHTMLDocument::Links DontDelete|ReadOnly
forms JSHTMLDocument::Forms DontDelete|ReadOnly
anchors JSHTMLDocument::Anchors DontDelete|ReadOnly
scripts JSHTMLDocument::Scripts DontDelete|ReadOnly
all JSHTMLDocument::All
bgColor JSHTMLDocument::BgColor DontDelete
fgColor JSHTMLDocument::FgColor DontDelete
alinkColor JSHTMLDocument::AlinkColor DontDelete
linkColor JSHTMLDocument::LinkColor DontDelete
vlinkColor JSHTMLDocument::VlinkColor DontDelete
lastModified JSHTMLDocument::LastModified DontDelete|ReadOnly
height JSHTMLDocument::Height DontDelete|ReadOnly
width JSHTMLDocument::Width DontDelete|ReadOnly
dir JSHTMLDocument::Dir DontDelete
designMode JSHTMLDocument::DesignMode DontDelete
#potentially obsolete array properties
# layers
# plugins
# tags
#potentially obsolete properties
# embeds
# ids
@end
*/
JSHTMLDocument::JSHTMLDocument(ExecState* exec, HTMLDocument *d)
: JSDocument(exec, d)
{
setPrototype(JSHTMLDocumentPrototype::self(exec));
}
JSValue *JSHTMLDocument::namedItemGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
JSHTMLDocument *thisObj = static_cast<JSHTMLDocument*>(slot.slotBase());
HTMLDocument &doc = *static_cast<HTMLDocument*>(thisObj->impl());
String name = propertyName;
RefPtr<HTMLCollection> collection = doc.documentNamedItems(name);
if (collection->length() == 1) {
Node* node = collection->firstItem();
Frame *frame;
if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
return Window::retrieve(frame);
return toJS(exec, node);
} else if (collection->length() == 0)
return jsUndefined();
return getHTMLCollection(exec, collection.get());
}
JSValue *JSHTMLDocument::getValueProperty(ExecState* exec, int token) const
{
HTMLDocument& doc = *static_cast<HTMLDocument*>(impl());
FrameView* view = doc.view();
Frame* frame = doc.frame();
HTMLElement* body = doc.body();
HTMLBodyElement* bodyElement = (body && body->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(body) : 0;
switch (token) {
case Title:
return jsString(doc.title());
case Referrer:
return jsString(doc.referrer());
case Domain:
return jsString(doc.domain());
case Body:
return toJS(exec, body);
case Location:
if (!frame)
return jsNull();
if (Window* win = Window::retrieveWindow(frame))
return win->location();
return jsUndefined();
case Cookie:
return jsString(doc.cookie());
case Images:
return getHTMLCollection(exec, doc.images().get());
case Embeds:
return getHTMLCollection(exec, doc.embeds().get());
case Applets:
return getHTMLCollection(exec, doc.applets().get());
case Links:
return getHTMLCollection(exec, doc.links().get());
case Forms:
return getHTMLCollection(exec, doc.forms().get());
case Anchors:
return getHTMLCollection(exec, doc.anchors().get());
case Scripts:
return getHTMLCollection(exec, doc.scripts().get());
case All:
// If "all" has been overwritten, return the overwritten value
if (JSValue *v = getDirect("all"))
return v;
else
return getAllHTMLCollection(exec, doc.all().get());
case BgColor:
if (!bodyElement)
return jsUndefined();
return jsString(bodyElement->bgColor());
case FgColor:
if (!bodyElement)
return jsUndefined();