Commit 0794fbb6 authored by zimmermann@webkit.org's avatar zimmermann@webkit.org

2009-12-23 Nikolas Zimmermann <nzimmermann@rim.com>

        Reviewed by Eric Seidel.

        Reverse JS GenerateConstructor logic
        https://bugs.webkit.org/show_bug.cgi?id=32910

        Make 'GenerateConstructor' the default setting for all classes, defined in IDL files. The flag is now obsolete and
        can be removed from all IDL files in a follow-up patch. Add new 'OmitConstructor' flag, that allows to restore the
        old default behaviour: do not generate JSFoobarConstructor class.

        No change in functionality, despite the fact that we're generating a lot more constructors now, as they have to
        be exposed through DOMWindow.idl -- this can be done per affected class in follow-up patches. Especially the SVG
        classes have to be exposed, most of them are missing JS constructors so far.

        As side effect HTMLOptionsCollection is now correctly exposing its constructor, thus fixing a test in fast/dom/wrapper-classes.html


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52534 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9e5547d1
2009-12-23 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Eric Seidel.
Reverse JS GenerateConstructor logic
https://bugs.webkit.org/show_bug.cgi?id=32910
HTMLOptionsCollection correctly exposes its JS constructor now, thus fixing its test in fast/dom/wrapper-classes.html
* fast/dom/wrapper-classes-expected.txt:
2009-12-23 Brian Weinstein <bweinstein@apple.com>
Rubber-stamped by Eric Seidel.
......@@ -142,7 +142,7 @@ PASS jsWrapperClass(document.__proto__) is 'HTMLDocumentPrototype'
PASS jsWrapperClass(document.constructor) is 'HTMLDocumentConstructor'
PASS jsWrapperClass(document.createElement('select').options) is 'HTMLOptionsCollection'
FAIL jsWrapperClass(document.createElement('select').options.__proto__) should be HTMLOptionsCollectionPrototype. Was HTMLCollectionPrototype.
FAIL jsWrapperClass(document.createElement('select').options.constructor) should be HTMLOptionsCollectionConstructor. Was Function.
PASS jsWrapperClass(document.createElement('select').options.constructor) is 'HTMLOptionsCollectionConstructor'
HTML Elements
......
2009-12-23 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Eric Seidel.
Reverse JS GenerateConstructor logic
https://bugs.webkit.org/show_bug.cgi?id=32910
Make 'GenerateConstructor' the default setting for all classes, defined in IDL files. The flag is now obsolete and
can be removed from all IDL files in a follow-up patch. Add new 'OmitConstructor' flag, that allows to restore the
old default behaviour: do not generate JSFoobarConstructor class.
No change in functionality, despite the fact that we're generating a lot more constructors now, as they have to
be exposed through DOMWindow.idl -- this can be done per affected class in follow-up patches. Especially the SVG
classes have to be exposed, most of them are missing JS constructors so far.
As side effect HTMLOptionsCollection is now correctly exposing its constructor, thus fixing a test in fast/dom/wrapper-classes.html
* bindings/scripts/CodeGeneratorJS.pm:
* css/CSSUnknownRule.idl:
* css/WebKitCSSMatrix.idl:
* dom/EventListener.idl:
* dom/EventTarget.idl:
* dom/MessageChannel.idl:
* html/TimeRanges.idl:
* html/ValidityState.idl:
* html/VoidCallback.idl:
* html/canvas/CanvasGradient.idl:
* html/canvas/CanvasPattern.idl:
* html/canvas/CanvasPixelArray.idl:
* html/canvas/WebGLActiveInfo.idl:
* html/canvas/WebGLArray.idl:
* html/canvas/WebGLArrayBuffer.idl:
* html/canvas/WebGLBuffer.idl:
* html/canvas/WebGLByteArray.idl:
* html/canvas/WebGLFloatArray.idl:
* html/canvas/WebGLFramebuffer.idl:
* html/canvas/WebGLIntArray.idl:
* html/canvas/WebGLProgram.idl:
* html/canvas/WebGLRenderbuffer.idl:
* html/canvas/WebGLShader.idl:
* html/canvas/WebGLShortArray.idl:
* html/canvas/WebGLTexture.idl:
* html/canvas/WebGLUniformLocation.idl:
* html/canvas/WebGLUnsignedByteArray.idl:
* html/canvas/WebGLUnsignedIntArray.idl:
* html/canvas/WebGLUnsignedShortArray.idl:
* inspector/JavaScriptCallFrame.idl:
* loader/appcache/DOMApplicationCache.idl:
* notifications/Notification.idl:
* notifications/NotificationCenter.idl:
* page/AbstractView.idl:
* page/BarInfo.idl:
* page/Console.idl:
* page/Coordinates.idl:
* page/DOMSelection.idl:
* page/DOMWindow.idl:
* page/EventSource.idl:
* page/Geolocation.idl:
* page/Geoposition.idl:
* page/History.idl:
* page/Location.idl:
* page/Navigator.idl:
* page/Screen.idl:
* page/WebKitPoint.idl:
* page/WorkerNavigator.idl:
* storage/Database.idl:
* storage/SQLError.idl:
* storage/SQLResultSet.idl:
* storage/SQLResultSetRowList.idl:
* storage/SQLTransaction.idl:
* websockets/WebSocket.idl:
* workers/DedicatedWorkerContext.idl:
* workers/SharedWorker.idl:
* workers/SharedWorkerContext.idl:
* workers/Worker.idl:
* workers/WorkerContext.idl:
* xml/XMLHttpRequest.idl:
* xml/XPathNSResolver.idl:
* xml/XSLTProcessor.idl:
2009-12-23 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
......@@ -576,7 +576,7 @@ sub GenerateHeader
$implIncludes{"${className}Custom.h"} = 1 if $dataNode->extendedAttributes->{"CustomHeader"} || $dataNode->extendedAttributes->{"CustomPutFunction"} || $dataNode->extendedAttributes->{"DelegatingPutFunction"};
my $hasGetter = $numAttributes > 0
|| $dataNode->extendedAttributes->{"GenerateConstructor"}
|| !$dataNode->extendedAttributes->{"OmitConstructor"}
|| $dataNode->extendedAttributes->{"HasIndexGetter"}
|| $dataNode->extendedAttributes->{"HasCustomIndexGetter"}
|| $dataNode->extendedAttributes->{"HasNumericIndexGetter"}
......@@ -679,7 +679,7 @@ sub GenerateHeader
}
# Constructor object getter
push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if $dataNode->extendedAttributes->{"GenerateConstructor"};
push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if !$dataNode->extendedAttributes->{"OmitConstructor"};
my $numCustomFunctions = 0;
my $numCustomAttributes = 0;
......@@ -862,7 +862,7 @@ sub GenerateHeader
}
}
if ($numAttributes > 0 || $dataNode->extendedAttributes->{"GenerateConstructor"}) {
if ($numAttributes > 0 || !$dataNode->extendedAttributes->{"OmitConstructor"}) {
push(@headerContent,"// Attributes\n\n");
foreach my $attribute (@{$dataNode->attributes}) {
my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
......@@ -873,7 +873,7 @@ sub GenerateHeader
}
}
if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
my $getter = "js" . $interfaceName . "Constructor";
push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&);\n");
}
......@@ -942,7 +942,7 @@ sub GenerateImplementation
# - Add all attributes in a hashtable definition
my $numAttributes = @{$dataNode->attributes};
$numAttributes++ if $dataNode->extendedAttributes->{"GenerateConstructor"};
$numAttributes++ if !$dataNode->extendedAttributes->{"OmitConstructor"};
if ($numAttributes > 0) {
my $hashSize = $numAttributes;
......@@ -983,7 +983,7 @@ sub GenerateImplementation
}
}
if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
push(@hashKeys, "constructor");
my $getter = "js" . $interfaceName . "Constructor";
push(@hashValue1, $getter);
......@@ -1001,7 +1001,7 @@ sub GenerateImplementation
my $numFunctions = @{$dataNode->functions};
# - Add all constants
if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
$hashSize = $numConstants;
$hashName = $className . "ConstructorTable";
......@@ -1239,7 +1239,7 @@ sub GenerateImplementation
}
my $hasGetter = $numAttributes > 0
|| $dataNode->extendedAttributes->{"GenerateConstructor"}
|| !$dataNode->extendedAttributes->{"OmitConstructor"}
|| $dataNode->extendedAttributes->{"HasIndexGetter"}
|| $dataNode->extendedAttributes->{"HasCustomIndexGetter"}
|| $dataNode->extendedAttributes->{"HasNumericIndexGetter"}
......@@ -1390,7 +1390,7 @@ sub GenerateImplementation
push(@implContent, "\n");
}
if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
my $constructorFunctionName = "js" . $interfaceName . "Constructor";
push(@implContent, "JSValue ${constructorFunctionName}(ExecState* exec, const Identifier&, const PropertySlot& slot)\n");
......@@ -1548,7 +1548,7 @@ sub GenerateImplementation
push(@implContent, "}\n\n");
}
if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
if (!$dataNode->extendedAttributes->{"OmitConstructor"}) {
push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec, JSGlobalObject* globalObject)\n{\n");
push(@implContent, " return getDOMConstructor<${className}Constructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));\n");
push(@implContent, "}\n\n");
......
......@@ -23,7 +23,8 @@ module css {
// Introduced in DOM Level 2:
interface [
InterfaceUUID=35670098-b732-419c-b7cd-dc0d5e26d5e3,
ImplementationUUID=4b755f87-2509-4b98-a953-8ecb88fe4b21
ImplementationUUID=4b755f87-2509-4b98-a953-8ecb88fe4b21,
OmitConstructor
] CSSUnknownRule : CSSRule {
};
......
......@@ -26,7 +26,7 @@
module css {
// Introduced in DOM Level ?:
interface WebKitCSSMatrix {
interface [OmitConstructor] WebKitCSSMatrix {
// These attributes are simple aliases for certain elements of the 4x4 matrix
attribute double a; // alias for m11
......
......@@ -25,6 +25,7 @@ module events {
NoStaticTables,
ObjCProtocol,
PureInterface,
OmitConstructor,
InterfaceUUID=B04F2AE3-71E2-4ebe-ABFE-EF4938354082,
] EventListener {
void handleEvent(in Event evt);
......
......@@ -24,6 +24,7 @@ module events {
interface [
ObjCProtocol,
PureInterface,
OmitConstructor
InterfaceUUID=1D71C7EC-0BA0-4044-BDFD-56B3E8F5F9D4
] EventTarget {
[OldStyleObjC] void addEventListener(in DOMString type,
......
......@@ -26,7 +26,7 @@
module events {
interface [CustomMarkFunction, NoStaticTables] MessageChannel {
interface [CustomMarkFunction, NoStaticTables, OmitConstructor] MessageChannel {
readonly attribute MessagePort port1;
readonly attribute MessagePort port2;
......
......@@ -25,7 +25,7 @@
module html {
interface [Conditional=VIDEO] TimeRanges {
interface [Conditional=VIDEO, OmitConstructor] TimeRanges {
readonly attribute unsigned long length;
float start(in unsigned long index)
raises (DOMException);
......
......@@ -22,7 +22,7 @@
module html {
interface ValidityState {
interface [OmitConstructor] ValidityState {
readonly attribute boolean valueMissing;
readonly attribute boolean typeMismatch;
readonly attribute boolean patternMismatch;
......
......@@ -24,7 +24,7 @@
*/
module html {
interface [CustomNativeConverter] VoidCallback {
interface [CustomNativeConverter, OmitConstructor] VoidCallback {
void handleEvent();
};
}
......@@ -27,7 +27,8 @@ module html {
interface [
InterfaceUUID=bb1108ea-6b8c-4a08-894a-218628630cdb,
ImplementationUUID=a2942ae6-2731-4286-98cc-9d5e79e20de1
ImplementationUUID=a2942ae6-2731-4286-98cc-9d5e79e20de1,
OmitConstructor
] CanvasGradient {
void addColorStop(in float offset, in DOMString color)
......
......@@ -27,7 +27,8 @@ module html {
interface [
InterfaceUUID=c2131348-6d8c-47b5-86cc-d41aff34ce15,
ImplementationUUID=82f5d713-3d17-44dd-aa4a-7766fe345940
ImplementationUUID=82f5d713-3d17-44dd-aa4a-7766fe345940,
OmitConstructor
] CanvasPattern {
};
......
......@@ -29,6 +29,7 @@
module html {
#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT || defined(V8_BINDING) && V8_BINDING
interface [
OmitConstructor,
CustomHeader,
HasNumericIndexGetter,
HasCustomIndexSetter
......
......@@ -27,6 +27,7 @@ module html {
interface [
Conditional=3D_CANVAS,
OmitConstructor
] WebGLActiveInfo {
readonly attribute int size;
readonly attribute unsigned int type;
......
......@@ -24,7 +24,7 @@
*/
module html {
interface [Conditional=3D_CANVAS, CustomToJS] WebGLArray {
interface [Conditional=3D_CANVAS, CustomToJS, OmitConstructor] WebGLArray {
readonly attribute WebGLArrayBuffer buffer;
readonly attribute unsigned long byteOffset;
readonly attribute unsigned long byteLength;
......
......@@ -24,7 +24,7 @@
*/
module html {
interface [Conditional=3D_CANVAS] WebGLArrayBuffer {
interface [Conditional=3D_CANVAS, OmitConstructor] WebGLArrayBuffer {
readonly attribute int byteLength;
};
}
......@@ -24,6 +24,6 @@
*/
module html {
interface [Conditional=3D_CANVAS] WebGLBuffer {
interface [Conditional=3D_CANVAS, OmitConstructor] WebGLBuffer {
};
}
......@@ -30,7 +30,7 @@ module html {
HasNumericIndexGetter,
HasCustomIndexSetter,
GenerateNativeConverter,
GenerateCustomConstructor,
OmitConstructor,
CustomToJS
] WebGLByteArray : WebGLArray {
long get(in unsigned long index);
......
......@@ -30,7 +30,7 @@ module html {
HasNumericIndexGetter,
HasCustomIndexSetter,
GenerateNativeConverter,
GenerateCustomConstructor,
OmitConstructor,
CustomToJS
] WebGLFloatArray : WebGLArray {
float get(in unsigned long index);
......
......@@ -24,6 +24,6 @@
*/
module html {
interface [Conditional=3D_CANVAS] WebGLFramebuffer {
interface [Conditional=3D_CANVAS, OmitConstructor] WebGLFramebuffer {
};
}
......@@ -30,7 +30,7 @@ module html {
HasNumericIndexGetter,
HasCustomIndexSetter,
GenerateNativeConverter,
GenerateCustomConstructor,
OmitConstructor,
CustomToJS
] WebGLIntArray : WebGLArray {
long get(in unsigned long index);
......
......@@ -24,6 +24,6 @@
*/
module html {
interface [Conditional=3D_CANVAS] WebGLProgram {
interface [Conditional=3D_CANVAS, OmitConstructor] WebGLProgram {
};
}
......@@ -24,6 +24,6 @@
*/
module html {
interface [Conditional=3D_CANVAS] WebGLRenderbuffer {
interface [Conditional=3D_CANVAS, OmitConstructor] WebGLRenderbuffer {
};
}
......@@ -24,6 +24,6 @@
*/
module html {
interface [Conditional=3D_CANVAS] WebGLShader {
interface [Conditional=3D_CANVAS, OmitConstructor] WebGLShader {
};
}
......@@ -29,7 +29,7 @@ module html {
HasNumericIndexGetter,
HasCustomIndexSetter,
GenerateNativeConverter,
GenerateCustomConstructor,
OmitConstructor,
CustomToJS
] WebGLShortArray : WebGLArray {
long get(in unsigned long index);
......
......@@ -24,6 +24,6 @@
*/
module html {
interface [Conditional=3D_CANVAS] WebGLTexture {
interface [Conditional=3D_CANVAS, OmitConstructor] WebGLTexture {
};
}
......@@ -25,6 +25,6 @@
*/
module html {
interface [Conditional=3D_CANVAS] WebGLUniformLocation {
interface [Conditional=3D_CANVAS, OmitConstructor] WebGLUniformLocation {
};
}
......@@ -30,7 +30,7 @@ module html {
HasNumericIndexGetter,
HasCustomIndexSetter,
GenerateNativeConverter,
GenerateCustomConstructor,
OmitConstructor,
CustomToJS
] WebGLUnsignedByteArray : WebGLArray {
long get(in unsigned long index);
......
......@@ -30,7 +30,7 @@ module html {
HasNumericIndexGetter,
HasCustomIndexSetter,
GenerateNativeConverter,
GenerateCustomConstructor,
OmitConstructor,
CustomToJS
] WebGLUnsignedIntArray : WebGLArray {
unsigned long get(in unsigned long index);
......
......@@ -30,7 +30,7 @@ module html {
HasNumericIndexGetter,
HasCustomIndexSetter,
GenerateNativeConverter,
GenerateCustomConstructor,
OmitConstructor,
CustomToJS
] WebGLUnsignedShortArray : WebGLArray {
long get(in unsigned long index);
......
......@@ -25,7 +25,7 @@
module inspector {
interface [Conditional=JAVASCRIPT_DEBUGGER] JavaScriptCallFrame {
interface [Conditional=JAVASCRIPT_DEBUGGER, OmitConstructor] JavaScriptCallFrame {
[Custom] void evaluate(in DOMString script);
readonly attribute JavaScriptCallFrame caller;
......
......@@ -27,7 +27,8 @@ module offline {
interface [
Conditional=OFFLINE_WEB_APPLICATIONS,
EventTarget
EventTarget,
OmitConstructor
] DOMApplicationCache {
// update status
const unsigned short UNCACHED = 0;
......
......@@ -32,7 +32,8 @@ module threads {
interface [
Conditional=NOTIFICATIONS,
EventTarget
EventTarget,
OmitConstructor
] Notification {
void show();
void cancel();
......
......@@ -31,7 +31,8 @@
module threads {
interface [
Conditional=NOTIFICATIONS
Conditional=NOTIFICATIONS,
OmitConstructor
] NotificationCenter {
[V8Custom] Notification createHTMLNotification(in DOMString url) raises(Exception);
[V8Custom] Notification createNotification(in DOMString iconUrl, in DOMString title, in DOMString body) raises(Exception);
......
......@@ -28,7 +28,8 @@ module views {
// Introduced in DOM Level 2:
interface [
ObjCCustomImplementation
ObjCCustomImplementation,
OmitConstructor
] AbstractView {
readonly attribute Document document;
readonly attribute Media media;
......
......@@ -28,7 +28,7 @@
module window {
interface BarInfo {
interface [OmitConstructor] BarInfo {
readonly attribute boolean visible;
};
......
......@@ -28,7 +28,7 @@
module window {
interface Console {
interface [OmitConstructor] Console {
#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
readonly attribute [CustomGetter] Array profiles;
......
......@@ -25,7 +25,7 @@
module core {
interface Coordinates {
interface [OmitConstructor] Coordinates {
readonly attribute double latitude;
readonly attribute double longitude;
readonly attribute [Custom] double altitude;
......
......@@ -31,7 +31,7 @@ module window {
// This is based off of Mozilla's Selection interface
// https://developer.mozilla.org/En/DOM/Selection
interface DOMSelection {
interface [OmitConstructor] DOMSelection {
readonly attribute Node anchorNode;
readonly attribute long anchorOffset;
readonly attribute Node focusNode;
......
......@@ -38,6 +38,7 @@ module window {
CustomNativeConverter,
CustomPutFunction,
EventTarget,
OmitConstructor,
ExtendsDOMGlobalObject,
GenerateNativeConverter,
LegacyParent=JSDOMWindowBase
......
......@@ -34,6 +34,7 @@ module window {
interface [
Conditional=EVENTSOURCE,
EventTarget,
OmitConstructor,
NoStaticTables
] EventSource {
......
......@@ -25,7 +25,7 @@
module core {
interface Geolocation {
interface [OmitConstructor] Geolocation {
readonly attribute Geoposition lastPosition;
[Custom] void getCurrentPosition(in PositionCallback successCallback, in PositionErrorCallback errorCallback, in PositionOptions options);
......
......@@ -25,7 +25,7 @@
module core {
interface Geoposition {
interface [OmitConstructor] Geoposition {
readonly attribute Coordinates coords;
readonly attribute DOMTimeStamp timestamp;
};
......
......@@ -32,7 +32,8 @@ module window {
DelegatingGetOwnPropertySlot,
DelegatingPutFunction,
CustomDeleteProperty,
CustomGetPropertyNames
CustomGetPropertyNames,
OmitConstructor
] History {
readonly attribute unsigned long length;
......
......@@ -38,7 +38,8 @@ module window {
CustomGetPropertyNames,
CustomDefineGetter,
DelegatingPrototypePutFunction,
CustomPrototypeDefineGetter
CustomPrototypeDefineGetter,
OmitConstructor
] Location {
attribute [DoNotCheckDomainSecurityOnSet, CustomSetter, V8DisallowShadowing] DOMString href;
......
......@@ -20,7 +20,8 @@
module window {
interface [
CustomMarkFunction
CustomMarkFunction,
OmitConstructor
] Navigator {
readonly attribute DOMString appCodeName;
readonly attribute DOMString appName;
......
......@@ -29,7 +29,7 @@
module window {
interface Screen {
interface [OmitConstructor] Screen {
readonly attribute unsigned long height;
readonly attribute unsigned long width;
readonly attribute unsigned long colorDepth;
......
......@@ -25,7 +25,7 @@
module window {
interface WebKitPoint {
interface [OmitConstructor] WebKitPoint {
attribute float x;
attribute float y;
};
......
......@@ -30,7 +30,8 @@ module threads {
interface [
Conditional=WORKERS,
NoStaticTables
NoStaticTables,
OmitConstructor