+2006-05-11 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Darin.
+
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=7838
+ Add support for mozilla-style node constructors as properties of the window object
+
+ * fast/dom/prototype-chain-expected.txt:
+ Update prototype chains.
+
+ * fast/dom/global-constructors-expected.txt:
+ * fast/dom/global-constructors.html:
+ Test new constructor objects.
+
2006-05-10 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
This page tests global constructor objects like window.HTMLDocument. If it passes, you'll see a series of 'PASS' messages below.
PASS: window.Document.prototype.isPrototypeOf(document) should be true and is.
+PASS: window.HTMLDocument.prototype.isPrototypeOf(document) should be true and is.
PASS: window.Node.prototype.isPrototypeOf(element) should be true and is.
PASS: window.Element.prototype.isPrototypeOf(element) should be true and is.
+PASS: window.HTMLElement.prototype.isPrototypeOf(element) should be true and is.
PASS: window.Range.prototype.isPrototypeOf(range) should be true and is.
PASS: window.CSSRule.prototype.isPrototypeOf(cssRule) should be true and is.
PASS: window.CSSValue.prototype.isPrototypeOf(cssPrimitiveValue) should be true and is.
PASS: window.CSSStyleDeclaration.prototype.isPrototypeOf(cssStyleDeclaration) should be true and is.
PASS: window.Event.prototype.isPrototypeOf(event) should be true and is.
PASS: window.MutationEvent.prototype.isPrototypeOf(event) should be true and is.
+PASS: window.XMLDocument.prototype.isPrototypeOf(xmldoc) should be true and is.
+PASS: window.DocumentFragment.prototype.isPrototypeOf(fragment) should be true and is.
+PASS: window.XPathEvaluator.prototype.isPrototypeOf(xpathevaluator) should be true and is.
+PASS: window.XPathResult.prototype.isPrototypeOf(xpathresult) should be true and is.
PASS: window.NodeFilter.prototype.isPrototypeOf(nodeFilter) should be true and is.
[Deleted window.Node.prototype]
PASS: window.Node.prototype should be undefined and is.
layoutTestController.dumpAsText();
shouldBe("window.Document.prototype.isPrototypeOf(document)", true);
-
+ shouldBe("window.HTMLDocument.prototype.isPrototypeOf(document)", true);
+
element = document.body;
shouldBe("window.Node.prototype.isPrototypeOf(element)", true);
shouldBe("window.Element.prototype.isPrototypeOf(element)", true);
+ shouldBe("window.HTMLElement.prototype.isPrototypeOf(element)", true);
range = document.createRange();
shouldBe("window.Range.prototype.isPrototypeOf(range)", true);
shouldBe("window.Event.prototype.isPrototypeOf(event)", true);
shouldBe("window.MutationEvent.prototype.isPrototypeOf(event)", true);
+ xmldoc = document.implementation.createDocument(null, null, null);
+ shouldBe("window.XMLDocument.prototype.isPrototypeOf(xmldoc)", true);
+
+ fragment = document.createDocumentFragment();
+ shouldBe("window.DocumentFragment.prototype.isPrototypeOf(fragment)", true);
+
+ xpathevaluator = new XPathEvaluator();
+ shouldBe("window.XPathEvaluator.prototype.isPrototypeOf(xpathevaluator)", true);
+
+ xpathresult = xpathevaluator.evaluate('/', document, null, 0, null);
+ shouldBe("window.XPathResult.prototype.isPrototypeOf(xpathresult)", true);
+
try {
nodeFilter = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, function () {}, false).filter;
} catch(e) {}
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] (5 prototypes) -----
+----- [object HTMLDocument] (7 prototypes) -----
[object Object]
[object Document]
------ [object DIV] (5 prototypes) -----
+[object HTMLDocument]
+
+[object HTMLDocument]
+
+----- [object DIV] (7 prototypes) -----
[object Object]
[object Element]
+[object HTMLElement]
+
+[object HTMLElement]
+
----- [object UIEvent] (4 prototypes) -----
[object Object]
+2006-05-11 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Darin.
+
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=7838
+ Add support for mozilla-style node constructors as properties of the window object
+
+ * DerivedSources.make:
+ * WebCore.xcodeproj/project.pbxproj:
+ Add new generated files.
+
+ * bindings/js/JSCanvasRenderingContext2DBase.cpp:
+ (WebCore::JSCanvasRenderingContext2DBaseProtoFunc::callAsFunction):
+ * bindings/js/JSHTMLElementWrapperFactory.cpp:
+ (WebCore::createJSWrapper):
+ Specify the KJS namespace for JSHTMLElmement.
+
+ * bindings/js/kjs_dom.cpp:
+ (KJS::toJS):
+ Create a WebCore::JSHTMLDocument for document nodes. Also, create
+ JSDocumentFragments for document fragments (instead of plain node objects).
+
+ * bindings/js/kjs_html.cpp:
+ (KJS::JSHTMLDocumentProtoFunc::callAsFunction):
+ (KJS::JSHTMLDocument::JSHTMLDocument):
+ (KJS::JSHTMLDocument::getOwnPropertySlot):
+ Add a prototype for JSHTMLDocument and move all functions there.
+
+ (KJS::JSHTMLElement::JSHTMLElement):
+ (KJS::JSHTMLElement::getOwnPropertySlot):
+ Update since JSHTMLElement now inherits from WebCore::JSHTMLElement.
+
+ (KJS::JSHTMLElement::getValueProperty):
+ (KJS::JSHTMLElement::putValueProperty):
+ Remove title setter and getter. Those are autogenerated now.
+
+ * bindings/js/kjs_html.h:
+ (KJS::JSHTMLElement::):
+ Inherit from WebCore::JSHTMLElement. Clarify the inheritance chain.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ Always generate a prototype object, regardless of whether the object has any functions or
+ constants.
+
+ Use the type of generator attributes to determine what constructor to use. This is useful for
+ the XMLDocument property in DOMWindow.idl, since that's just an alias for the Document constructor.
+
+ * dom/DocumentFragment.idl: Added.
+ * html/HTMLDocument.idl: Added.
+ * html/HTMLElement.idl: Added.
+
+ * page/DOMWindow.idl:
+ Add constructors for DocumentFragment, HTMLElement, HTMLDocument and XMLDocument. XMLDocument is just
+ an alias for the Document constructor.
+
2006-05-11 David Hyatt <hyatt@apple.com>
Bug 8845. Define a TextRun (similar to the old WebCoreTextRun) and
* WebCore: Removed an extra WebCore subtree that somehow got checked in.
+>>>>>>> .r14297
2006-05-10 David Carson <dacarson@gmail.com>
- Fix for bug 8833. Removed inline keyword from functions declared
JSDOMParser.lut.h \
JSDOMWindow.h \
JSDocument.h \
+ JSDocumentFragment.h \
JSDocumentType.h \
JSElement.h \
JSEvent.h \
JSEntity.h \
+ JSHTMLDocument.h \
JSHTMLCanvasElement.h \
+ JSHTMLElement.h \
JSKeyboardEvent.h \
JSMouseEvent.h \
JSMutationEvent.h \
14E8378E09F85D4F00B85AE4 /* JSEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 14E8378D09F85D4F00B85AE4 /* JSEvent.h */; };
14EC267F09CA07E000E1EEEC /* EventTargetNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 14EC267D09CA07E000E1EEEC /* EventTargetNode.h */; };
14EC268009CA07E000E1EEEC /* EventTargetNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14EC267E09CA07E000E1EEEC /* EventTargetNode.cpp */; };
+ 1A494BBC0A122DCD00FDAFC1 /* HTMLElement.idl in Resources */ = {isa = PBXBuildFile; fileRef = 1A494BBB0A122DCD00FDAFC1 /* HTMLElement.idl */; };
+ 1A494BFA0A122F4400FDAFC1 /* JSHTMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */; };
+ 1A494BFB0A122F4400FDAFC1 /* JSHTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */; };
+ 1A494E2A0A12354300FDAFC1 /* HTMLDocument.idl in Resources */ = {isa = PBXBuildFile; fileRef = 1A494E290A12354300FDAFC1 /* HTMLDocument.idl */; };
+ 1A494E340A12358B00FDAFC1 /* JSHTMLDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494E320A12358A00FDAFC1 /* JSHTMLDocument.cpp */; };
+ 1A494E350A12358B00FDAFC1 /* JSHTMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A494E330A12358B00FDAFC1 /* JSHTMLDocument.h */; };
+ 1A494ED60A123F1A00FDAFC1 /* DocumentFragment.idl in Resources */ = {isa = PBXBuildFile; fileRef = 1A494ED50A123F1A00FDAFC1 /* DocumentFragment.idl */; };
+ 1A494EDE0A123F4C00FDAFC1 /* JSDocumentFragment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494EDC0A123F4C00FDAFC1 /* JSDocumentFragment.cpp */; };
+ 1A494EDF0A123F4C00FDAFC1 /* JSDocumentFragment.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A494EDD0A123F4C00FDAFC1 /* JSDocumentFragment.h */; };
1A5D938E0A0B9ACC00B1121F /* XPathParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5D938C0A0B9ACC00B1121F /* XPathParser.cpp */; };
1A5D938F0A0B9ACC00B1121F /* XPathParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5D938D0A0B9ACC00B1121F /* XPathParser.h */; };
1A6931760A0CD4FA00C127FE /* XPathValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6931740A0CD4FA00C127FE /* XPathValue.h */; };
14E8378D09F85D4F00B85AE4 /* JSEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSEvent.h; sourceTree = "<group>"; };
14EC267D09CA07E000E1EEEC /* EventTargetNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventTargetNode.h; sourceTree = "<group>"; };
14EC267E09CA07E000E1EEEC /* EventTargetNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventTargetNode.cpp; sourceTree = "<group>"; };
+ 1A494BBB0A122DCD00FDAFC1 /* HTMLElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLElement.idl; sourceTree = "<group>"; };
+ 1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLElement.cpp; sourceTree = "<group>"; };
+ 1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLElement.h; sourceTree = "<group>"; };
+ 1A494E290A12354300FDAFC1 /* HTMLDocument.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLDocument.idl; sourceTree = "<group>"; };
+ 1A494E320A12358A00FDAFC1 /* JSHTMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLDocument.cpp; sourceTree = "<group>"; };
+ 1A494E330A12358B00FDAFC1 /* JSHTMLDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLDocument.h; sourceTree = "<group>"; };
+ 1A494ED50A123F1A00FDAFC1 /* DocumentFragment.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DocumentFragment.idl; sourceTree = "<group>"; };
+ 1A494EDC0A123F4C00FDAFC1 /* JSDocumentFragment.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentFragment.cpp; sourceTree = "<group>"; };
+ 1A494EDD0A123F4C00FDAFC1 /* JSDocumentFragment.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSDocumentFragment.h; sourceTree = "<group>"; };
1A5D938C0A0B9ACC00B1121F /* XPathParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = XPathParser.cpp; sourceTree = "<group>"; };
1A5D938D0A0B9ACC00B1121F /* XPathParser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = XPathParser.h; sourceTree = "<group>"; };
1A6931740A0CD4FA00C127FE /* XPathValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathValue.h; sourceTree = "<group>"; };
14CF78A509F58CD800EB3665 /* JSCSSValue.h */,
659DDC8009E198BA001BF3C6 /* JSDocument.cpp */,
659DDC8109E198BA001BF3C6 /* JSDocument.h */,
+ 1A494EDC0A123F4C00FDAFC1 /* JSDocumentFragment.cpp */,
+ 1A494EDD0A123F4C00FDAFC1 /* JSDocumentFragment.h */,
65DF31E109D1CC60000BE325 /* JSDocumentType.cpp */,
65DF31E209D1CC60000BE325 /* JSDocumentType.h */,
65DF31E309D1CC60000BE325 /* JSDOMImplementation.cpp */,
14E8378D09F85D4F00B85AE4 /* JSEvent.h */,
938E665F09F09B81008A48EC /* JSHTMLCanvasElement.cpp */,
938E666109F09B87008A48EC /* JSHTMLCanvasElement.h */,
+ 1A494E320A12358A00FDAFC1 /* JSHTMLDocument.cpp */,
+ 1A494E330A12358B00FDAFC1 /* JSHTMLDocument.h */,
+ 1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */,
+ 1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */,
A86629CE09DA2B47009633A5 /* JSKeyboardEvent.cpp */,
A86629CD09DA2B47009633A5 /* JSKeyboardEvent.h */,
A86629CC09DA2B47009633A5 /* JSMouseEvent.cpp */,
F523D23C02DE4396018635CA /* HTMLDocument.h */,
F523D23E02DE4396018635CA /* HTMLElement.cpp */,
F523D23F02DE4396018635CA /* HTMLElement.h */,
+ 1A494BBB0A122DCD00FDAFC1 /* HTMLElement.idl */,
BCEF3432087B563E00BBF833 /* HTMLElementFactory.cpp */,
BCEF3433087B563E00BBF833 /* HTMLElementFactory.h */,
A81369B9097374F500D74463 /* HTMLFieldSetElement.cpp */,
AB23A31109BBA7760067CC53 /* HTMLTextFieldInnerElement.h */,
F523D25202DE4396018635CA /* HTMLTokenizer.cpp */,
F523D25302DE4396018635CA /* HTMLTokenizer.h */,
+ 1A494E290A12354300FDAFC1 /* HTMLDocument.idl */,
);
path = html;
sourceTree = "<group>";
F523D30A02DE4476018635CA /* xml_tokenizer.h */,
14E836D209F8512000B85AE4 /* Event.idl */,
14DC0D0B09FECFA4007B0235 /* Node.idl */,
+ 1A494ED50A123F1A00FDAFC1 /* DocumentFragment.idl */,
);
path = dom;
sourceTree = "<group>";
1A5D938F0A0B9ACC00B1121F /* XPathParser.h in Headers */,
1A6931760A0CD4FA00C127FE /* XPathValue.h in Headers */,
1A6938020A11100A00C127FE /* TextDocument.h in Headers */,
+ 1A494BFB0A122F4400FDAFC1 /* JSHTMLElement.h in Headers */,
+ 1A494E350A12358B00FDAFC1 /* JSHTMLDocument.h in Headers */,
+ 1A494EDF0A123F4C00FDAFC1 /* JSDocumentFragment.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
14E836D309F8512000B85AE4 /* Event.idl in Resources */,
14DC0D0C09FECFA4007B0235 /* Node.idl in Resources */,
142011AF0A003117008303F9 /* CSSStyleDeclaration.idl in Resources */,
+ 1A494BBC0A122DCD00FDAFC1 /* HTMLElement.idl in Resources */,
+ 1A494E2A0A12354300FDAFC1 /* HTMLDocument.idl in Resources */,
+ 1A494ED60A123F1A00FDAFC1 /* DocumentFragment.idl in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
BCCD13200A0C0030001AFA8B /* FontData.mm in Sources */,
1A6931770A0CD4FA00C127FE /* XPathValue.cpp in Sources */,
1A6938010A11100A00C127FE /* TextDocument.cpp in Sources */,
+ 1A494BFA0A122F4400FDAFC1 /* JSHTMLElement.cpp in Sources */,
+ 1A494E340A12358B00FDAFC1 /* JSHTMLDocument.cpp in Sources */,
+ 1A494EDE0A123F4C00FDAFC1 /* JSDocumentFragment.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include "JSCanvasRenderingContext2D.h"
#include "JSHTMLCanvasElement.h"
+#include "kjs_html.h"
+
#include "JSCanvasRenderingContext2DBaseTable.cpp"
using namespace KJS;
if (!o->isObject())
return throwError(exec, TypeError);
ExceptionCode ec;
- if (o->inherits(&JSHTMLElement::img_info)) {
+ if (o->inherits(&KJS::JSHTMLElement::img_info)) {
HTMLImageElement* imgElt = static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args[0])->impl());
switch (args.size()) {
case 3:
JSObject* o = static_cast<JSObject*>(args[0]);
if (!o->isObject())
return throwError(exec, TypeError);
- if (!o->inherits(&JSHTMLElement::img_info))
+ if (!o->inherits(&KJS::JSHTMLElement::img_info))
return throwError(exec, TypeError);
context->drawImageFromRect(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args[0])->impl()),
args[1]->toNumber(exec), args[2]->toNumber(exec),
JSObject* o = static_cast<JSObject*>(args[0]);
if (!o->isObject())
return throwError(exec, TypeError);
- if (o->inherits(&JSHTMLElement::img_info)) {
+ if (o->inherits(&KJS::JSHTMLElement::img_info)) {
ExceptionCode ec;
JSValue* pattern = toJS(exec,
context->createPattern(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args[0])->impl()),
#include "HTMLCanvasElement.h"
#include "HTMLNames.h"
#include "JSHTMLCanvasElement.h"
+#include "JSHTMLElement.h"
#include "kjs_html.h"
using namespace KJS;
CreateHTMLElementWrapperFunction f = map.get(element->localName().impl());
if (f)
return f(exec, element);
- return new JSHTMLElement(exec, element.get());
+ return new KJS::JSHTMLElement(exec, element.get());
}
}
#include "JSElement.h"
#include "JSCharacterData.h"
#include "JSDOMImplementation.h"
+#include "JSDocumentFragment.h"
#include "JSDocumentType.h"
#include "JSEntity.h"
+#include "JSHTMLDocument.h"
#include "JSNode.h"
#include "JSNotation.h"
#include "JSProcessingInstruction.h"
return ret;
if (n->isHTMLDocument())
- ret = new JSHTMLDocument(exec, static_cast<HTMLDocument *>(n));
+ ret = new WebCore::JSHTMLDocument(exec, static_cast<HTMLDocument *>(n));
else
ret = new JSDocument(exec, n);
ret = new JSNotation(exec, static_cast<Notation *>(n));
break;
case WebCore::Node::DOCUMENT_FRAGMENT_NODE:
+ ret = new JSDocumentFragment(exec, static_cast<DocumentFragment*>(n));
+ break;
case WebCore::Node::ENTITY_REFERENCE_NODE:
default:
ret = new JSNode(exec, n);
int id;
};
-KJS_IMPLEMENT_PROTOFUNC(HTMLDocFunction)
+/*
+@begin JSHTMLDocumentProtoTable 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_PROTOFUNC(JSHTMLDocumentProtoFunc)
+KJS_IMPLEMENT_PROTOTYPE("HTMLDocument", JSHTMLDocumentProto, JSHTMLDocumentProtoFunc)
-JSValue *HTMLDocFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue *JSHTMLDocumentProtoFunc::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);
+ 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();
}
- }
- 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;
}
- // 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 =
{ "HTMLDocument", &JSDocument::info, &HTMLDocumentTable, 0 };
anchors JSHTMLDocument::Anchors DontDelete|ReadOnly
scripts JSHTMLDocument::Scripts DontDelete|ReadOnly
all JSHTMLDocument::All
- 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
bgColor JSHTMLDocument::BgColor DontDelete
fgColor JSHTMLDocument::FgColor DontDelete
alinkColor JSHTMLDocument::AlinkColor DontDelete
JSHTMLDocument::JSHTMLDocument(ExecState *exec, HTMLDocument *d)
: JSDocument(exec, d)
{
+ setPrototype(JSHTMLDocumentProto::self(exec));
}
JSValue *JSHTMLDocument::namedItemGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
return true;
}
+ return getStaticValueSlot<JSHTMLDocument, JSDocument>(exec, &HTMLDocumentTable, this, propertyName, slot);
+
const HashEntry* entry = Lookup::findEntry(&HTMLDocumentTable, propertyName);
if (entry) {
- if (entry->attr & Function)
- slot.setStaticEntry(this, entry, staticFunctionGetter<HTMLDocFunction>);
- else
- slot.setStaticEntry(this, entry, staticValueGetter<JSHTMLDocument>);
+ slot.setStaticEntry(this, entry, staticValueGetter<JSHTMLDocument>);
return true;
}
@begin HTMLElementTable 14
id KJS::JSHTMLElement::ElementId DontDelete
- title KJS::JSHTMLElement::ElementTitle DontDelete
lang KJS::JSHTMLElement::ElementLang DontDelete
dir KJS::JSHTMLElement::ElementDir DontDelete
### isn't this "class" in the HTML spec?
}
JSHTMLElement::JSHTMLElement(ExecState *exec, HTMLElement *e)
- : JSElement(exec, e)
+ : WebCore::JSHTMLElement(exec, e)
{
+ setPrototype(JSHTMLElementProto::self(exec));
}
JSValue *JSHTMLElement::formIndexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
}
// Base JSHTMLElement stuff or parent class forward, as usual
- return getStaticPropertySlot<HTMLElementFunction, JSHTMLElement, JSElement>(exec, &HTMLElementTable, this, propertyName, slot);
+ return getStaticPropertySlot<HTMLElementFunction, JSHTMLElement, WebCore::JSHTMLElement>(exec, &HTMLElementTable, this, propertyName, slot);
}
bool JSHTMLElement::implementsCall() const
// iht.com relies on this value being "" when no id is present. Other browsers do this as well.
// So we use jsString() instead of jsStringOrNull() here.
return jsString(element.id());
- case ElementTitle:
- return jsString(element.title());
case ElementLang:
return jsString(element.lang());
case ElementDir:
case ElementId:
element.setId(str);
return;
- case ElementTitle:
- element.setTitle(str);
- return;
case ElementLang:
element.setLang(str);
return;
#include "JSDocument.h"
#include "JSElement.h"
+#include "JSHTMLElement.h"
namespace WebCore {
class HTMLCollection;
class JSAbstractEventListener;
+ KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(JSHTMLDocumentProto, WebCore::JSDocumentProto)
+
class JSHTMLDocument : public WebCore::JSDocument {
public:
JSHTMLDocument(ExecState *exec, WebCore::HTMLDocument *d);
static JSValue *namedItemGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
};
- KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(JSHTMLElementProto, WebCore::JSElementProto)
+ // The inheritance chain for JSHTMLElement is a bit different from other
+ // classes that are "half-autogenerated". Because we return different ClassInfo structs
+ // depending on the type of element, we inherit JSHTMLElement from WebCore::JSHTMLElement
+ // instead of the other way around.
+ KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(JSHTMLElementProto, WebCore::JSHTMLElementProto)
- class JSHTMLElement : public WebCore::JSElement {
+ class JSHTMLElement : public WebCore::JSHTMLElement {
public:
JSHTMLElement(ExecState *exec, WebCore::HTMLElement *e);
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
IFrameMarginHeight, IFrameMarginWidth, IFrameScrolling, IFrameWidth, IFrameContentDocument, IFrameContentWindow,
MarqueeStart, MarqueeStop,
GetContext,
- ElementInnerHTML, ElementTitle, ElementId, ElementDir, ElementLang,
+ ElementInnerHTML, ElementId, ElementDir, ElementLang,
ElementClassName, ElementInnerText, ElementDocument, ElementChildren, ElementContentEditable,
ElementIsContentEditable, ElementOuterHTML, ElementOuterText};
private:
$type eq "DocumentType" or
$type eq "Element" or
$type eq "HTMLCanvasElement" or
+ $type eq "HTMLElement" or
$type eq "Node" or
$type eq "NodeList" or
$type eq "Range" or
}
# Add prototype declaration -- code adopted from the KJS_DEFINE_PROTOTYPE and KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE macros
+ push(@headerContent, "class ${className}Proto : public KJS::JSObject {\n");
+ if (!$dataNode->extendedAttributes->{"DoNotCache"}) {
+ push(@headerContent, " friend KJS::JSObject* KJS_GCC_ROOT_NS_HACK cacheGlobalObject<${className}Proto>(KJS::ExecState*, const KJS::Identifier& propertyName);\n");
+ }
+ push(@headerContent, "public:\n");
+ if ($dataNode->extendedAttributes->{"DoNotCache"}) {
+ push(@headerContent, " static KJS::JSObject* self();\n");
+ } else {
+ push(@headerContent, " static KJS::JSObject* self(KJS::ExecState* exec);\n");
+ }
+ push(@headerContent, " virtual const KJS::ClassInfo* classInfo() const { return &info; }\n");
+ push(@headerContent, " static const KJS::ClassInfo info;\n");
if ($numFunctions > 0 || $numConstants > 0) {
- push(@headerContent, "class ${className}Proto : public KJS::JSObject {\n");
- if (!$dataNode->extendedAttributes->{"DoNotCache"}) {
- push(@headerContent, " friend KJS::JSObject* KJS_GCC_ROOT_NS_HACK cacheGlobalObject<${className}Proto>(KJS::ExecState*, const KJS::Identifier& propertyName);\n");
- }
- push(@headerContent, "public:\n");
- if ($dataNode->extendedAttributes->{"DoNotCache"}) {
- push(@headerContent, " static KJS::JSObject* self();\n");
- } else {
- push(@headerContent, " static KJS::JSObject* self(KJS::ExecState* exec);\n");
- }
- push(@headerContent, " virtual const KJS::ClassInfo* classInfo() const { return &info; }\n");
- push(@headerContent, " static const KJS::ClassInfo info;\n");
push(@headerContent, " bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);\n");
- if ($numConstants ne 0) {
- push(@headerContent, " KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;\n");
- }
- push(@headerContent, "protected:\n");
- if ($dataNode->extendedAttributes->{"DoNotCache"}) {
- push(@headerContent, " ${className}Proto() { }\n");
+ }
+ if ($numConstants ne 0) {
+ push(@headerContent, " KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;\n");
+ }
+ push(@headerContent, "protected:\n");
+ if ($dataNode->extendedAttributes->{"DoNotCache"}) {
+ push(@headerContent, " ${className}Proto() { }\n");
+ } else {
+ push(@headerContent, " ${className}Proto(KJS::ExecState* exec)\n");
+ if ($hasParent && $parentClassName ne "KJS::DOMCSSRule" && $parentClassName ne "KJS::DOMNodeFilter") {
+ push(@headerContent, " : KJS::JSObject(${parentClassName}Proto::self(exec)) { }\n");
} else {
- push(@headerContent, " ${className}Proto(KJS::ExecState* exec)\n");
- if ($hasParent && $parentClassName ne "KJS::DOMCSSRule" && $parentClassName ne "KJS::DOMNodeFilter") {
- push(@headerContent, " : KJS::JSObject(${parentClassName}Proto::self(exec)) { }\n");
- } else {
- push(@headerContent, " : KJS::JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()) { }\n");
- }
+ push(@headerContent, " : KJS::JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()) { }\n");
}
- push(@headerContent, "};\n\n");
}
+ push(@headerContent, "};\n\n");
push(@headerContent, "}\n\n#endif\n");
}
\@hashSpecials, \@hashParameters);
my $protoClassName;
- if ($numFunctions ne 0 || $numConstants ne 0) {
- $protoClassName = "${className}Proto";
- } else {
- # Since we have no functions or constants, we won't have generated
- # our own prototype -- use our parent's instead
- $protoClassName = "${parentClassName}Proto";
- }
+ $protoClassName = "${className}Proto";
push(@implContent, constructorFor($className, $protoClassName, $interfaceName, $dataNode->extendedAttributes->{"CanBeConstructed"}));
}
# - Add functions and constants to a hashtable definition
- if ($numFunctions > 0 || $numConstants > 0) {
- $hashSize = $numFunctions + $numConstants;
- $hashName = $className . "ProtoTable";
+ $hashSize = $numFunctions + $numConstants;
+ $hashName = $className . "ProtoTable";
- @hashKeys = ();
- @hashValues = ();
- @hashSpecials = ();
- @hashParameters = ();
+ @hashKeys = ();
+ @hashValues = ();
+ @hashSpecials = ();
+ @hashParameters = ();
- foreach my $constant (@{$dataNode->constants}) {
- my $name = $constant->name;
- push(@hashKeys, $name);
+ foreach my $constant (@{$dataNode->constants}) {
+ my $name = $constant->name;
+ push(@hashKeys, $name);
- my $value = "${implClassName}::$name";
- push(@hashValues, $value);
+ my $value = "${implClassName}::$name";
+ push(@hashValues, $value);
- my $special = "DontDelete|ReadOnly";
- push(@hashSpecials, $special);
+ my $special = "DontDelete|ReadOnly";
+ push(@hashSpecials, $special);
- my $numParameters = 0;
- push(@hashParameters, $numParameters);
- }
+ my $numParameters = 0;
+ push(@hashParameters, $numParameters);
+ }
- foreach my $function (@{$dataNode->functions}) {
- my $name = $function->signature->name;
- push(@hashKeys, $name);
+ foreach my $function (@{$dataNode->functions}) {
+ my $name = $function->signature->name;
+ push(@hashKeys, $name);
- my $value = $className . "::" . ucfirst($name) . "FuncNum";
- push(@hashValues, $value);
+ my $value = $className . "::" . ucfirst($name) . "FuncNum";
+ push(@hashValues, $value);
- my $special = "DontDelete|Function";
- push(@hashSpecials, $special);
+ my $special = "DontDelete|Function";
+ push(@hashSpecials, $special);
- my $numParameters = @{$function->parameters};
- push(@hashParameters, $numParameters);
- }
+ my $numParameters = @{$function->parameters};
+ push(@hashParameters, $numParameters);
+ }
- $object->GenerateHashTable($hashName, $hashSize,
- \@hashKeys, \@hashValues,
- \@hashSpecials, \@hashParameters);
+ $object->GenerateHashTable($hashName, $hashSize,
+ \@hashKeys, \@hashValues,
+ \@hashSpecials, \@hashParameters);
- if($numFunctions > 0) {
- push(@implContent, protoFuncFor($className));
- }
+ if($numFunctions > 0) {
+ push(@implContent, protoFuncFor($className));
+ }
- push(@implContent, "const ClassInfo ${className}Proto::info = { \"$interfaceName\", 0, &${className}ProtoTable, 0 };\n\n");
- if ($dataNode->extendedAttributes->{"DoNotCache"}) {
- push(@implContent, "JSObject* ${className}Proto::self()\n");
- push(@implContent, "{\n");
- push(@implContent, " return new ${className}Proto();\n");
- push(@implContent, "}\n\n");
- } else {
- push(@implContent, "JSObject* ${className}Proto::self(ExecState* exec)\n");
- push(@implContent, "{\n");
- push(@implContent, " return ::cacheGlobalObject<${className}Proto>(exec, \"[[${className}.prototype]]\");\n");
- push(@implContent, "}\n\n");
- }
- push(@implContent, "bool ${className}Proto::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n");
- push(@implContent, "{\n");
- if ($numConstants eq 0) {
- push(@implContent, " return getStaticFunctionSlot<${className}ProtoFunc, JSObject>(exec, &${className}ProtoTable, this, propertyName, slot);\n");
- } elsif ($numFunctions eq 0) {
- push(@implContent, " return getStaticValueSlot<${className}Proto, JSObject>(exec, &${className}ProtoTable, this, propertyName, slot);\n");
- } else {
- push(@implContent, " return getStaticPropertySlot<${className}ProtoFunc, ${className}Proto, JSObject>(exec, &${className}ProtoTable, this, propertyName, slot);\n");
- }
- push(@implContent, "}\n\n");
- if ($numConstants ne 0) {
- push(@implContent, "JSValue* ${className}Proto::getValueProperty(ExecState*, int token) const\n{\n");
- push(@implContent, " // The token is the numeric value of its associated constant\n");
- push(@implContent, " return jsNumber(token);\n}\n\n");
- }
+ push(@implContent, "const ClassInfo ${className}Proto::info = { \"$interfaceName\", 0, &${className}ProtoTable, 0 };\n\n");
+ if ($dataNode->extendedAttributes->{"DoNotCache"}) {
+ push(@implContent, "JSObject* ${className}Proto::self()\n");
+ push(@implContent, "{\n");
+ push(@implContent, " return new ${className}Proto();\n");
+ push(@implContent, "}\n\n");
+ } else {
+ push(@implContent, "JSObject* ${className}Proto::self(ExecState* exec)\n");
+ push(@implContent, "{\n");
+ push(@implContent, " return ::cacheGlobalObject<${className}Proto>(exec, \"[[${className}.prototype]]\");\n");
+ push(@implContent, "}\n\n");
+ }
+ if ($numConstants > 0 || $numFunctions > 0) {
+ push(@implContent, "bool ${className}Proto::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n");
+ push(@implContent, "{\n");
+ if ($numConstants eq 0) {
+ push(@implContent, " return getStaticFunctionSlot<${className}ProtoFunc, JSObject>(exec, &${className}ProtoTable, this, propertyName, slot);\n");
+ } elsif ($numFunctions eq 0) {
+ push(@implContent, " return getStaticValueSlot<${className}Proto, JSObject>(exec, &${className}ProtoTable, this, propertyName, slot);\n");
+ } else {
+ push(@implContent, " return getStaticPropertySlot<${className}ProtoFunc, ${className}Proto, JSObject>(exec, &${className}ProtoTable, this, propertyName, slot);\n");
+ }
+ push(@implContent, "}\n\n");
+ }
+ if ($numConstants ne 0) {
+ push(@implContent, "JSValue* ${className}Proto::getValueProperty(ExecState*, int token) const\n{\n");
+ push(@implContent, " // The token is the numeric value of its associated constant\n");
+ push(@implContent, " return jsNumber(token);\n}\n\n");
}
# - Initialize static ClassInfo object
if ($dataNode->extendedAttributes->{"DoNotCache"}) {
push(@implContent, "{\n setPrototype(${className}Proto::self());\n}\n\n");
- } elsif ($numFunctions ne 0 || $numConstants ne 0) {
- push(@implContent, "{\n setPrototype(${className}Proto::self(exec));\n}\n\n");
} else {
- push(@implContent, "{\n}\n\n");
+ push(@implContent, "{\n setPrototype(${className}Proto::self(exec));\n}\n\n");
}
# Destructor
foreach my $attribute (@{$dataNode->attributes}) {
my $name = $attribute->signature->name;
-
+
if ($attribute->signature->type =~ /Constructor$/) {
+ my $constructorType = $attribute->signature->type;
+ $constructorType =~ s/Constructor$//;
+
push(@implContent, " case " . $name . "ConstructorAttrNum:\n");
- push(@implContent, " return JS" . $name . "::getConstructor(exec);\n");
+ push(@implContent, " return JS" . $constructorType . "::getConstructor(exec);\n");
} elsif (!@{$attribute->getterExceptions}) {
push(@implContent, " case " . ucfirst($name) . "AttrNum:\n");
push(@implContent, " return " . NativeToJSValue($attribute->signature, "impl->$name()") . ";\n");
if ($attribute->type !~ /^readonly/) {
my $name = $attribute->signature->name;
if ($attribute->signature->type =~ /Constructor$/) {
- $implIncludes{"JS" . $attribute->signature->name . ".h"} = 1;
+ my $constructorType = $attribute->signature->type;
+ $constructorType =~ s/Constructor$//;
+
+ $implIncludes{"JS" . $constructorType . ".h"} = 1;
push(@implContent, " case " . $name ."ConstructorAttrNum: {\n");
push(@implContent, " // Shadowing a built-in constructor\n");
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * 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.
+ */
+
+module core {
+
+ interface [LegacyParent=KJS::DOMEventTargetNode, GenerateConstructor] DocumentFragment : EventTargetNode {
+ };
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * 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.
+ */
+
+module html {
+
+ interface [LegacyParent=KJS::JSHTMLDocument, GenerateConstructor] HTMLDocument : Document {
+ };
+
+}
+
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * 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.
+ */
+
+module html {
+
+ interface [GenerateConstructor] HTMLElement : Element {
+ attribute DOMString title;
+ };
+
+}
attribute CSSStyleDeclarationConstructor CSSStyleDeclaration;
attribute CSSValueConstructor CSSValue;
attribute DocumentConstructor Document;
+ attribute DocumentFragmentConstructor DocumentFragment;
attribute ElementConstructor Element;
attribute EventConstructor Event;
+ attribute HTMLElementConstructor HTMLElement;
+ attribute HTMLDocumentConstructor HTMLDocument;
attribute MutationEventConstructor MutationEvent;
attribute NodeConstructor Node;
attribute NodeFilterConstructor NodeFilter;
attribute RangeConstructor Range;
+
+ // Mozilla has a separate XMLDocument object for XML documents.
+ // We just use Document for this.
+ attribute DocumentConstructor XMLDocument;
+
attribute XPathEvaluatorConstructor XPathEvaluator;
attribute XPathResultConstructor XPathResult;
};