File: JSEvent.cpp

package info (click to toggle)
qtwebkit 2.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 143,644 kB
  • sloc: cpp: 913,445; python: 19,625; ansic: 16,252; perl: 11,604; yacc: 3,615; asm: 992; lex: 555; sh: 379; makefile: 375; objc: 347; ruby: 23; xml: 5
file content (570 lines) | stat: -rw-r--r-- 25,636 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
/*
    This file is part of the WebKit open source project.
    This file has been generated by generate-bindings.pl. DO NOT MODIFY!

    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., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#include "config.h"
#include "JSEvent.h"

#include "Event.h"
#include "EventTarget.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSEventTarget.h"
#include "KURL.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

ASSERT_CLASS_FITS_IN_CELL(JSEvent);

/* Hash table */
#if ENABLE(JIT)
#define THUNK_GENERATOR(generator) , generator
#else
#define THUNK_GENERATOR(generator)
#endif

static const HashTableValue JSEventTableValues[14] =
{
    { "type", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventType), (intptr_t)0 THUNK_GENERATOR(0) },
    { "target", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventTarget), (intptr_t)0 THUNK_GENERATOR(0) },
    { "currentTarget", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventCurrentTarget), (intptr_t)0 THUNK_GENERATOR(0) },
    { "eventPhase", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventEventPhase), (intptr_t)0 THUNK_GENERATOR(0) },
    { "bubbles", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventBubbles), (intptr_t)0 THUNK_GENERATOR(0) },
    { "cancelable", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventCancelable), (intptr_t)0 THUNK_GENERATOR(0) },
    { "timeStamp", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventTimeStamp), (intptr_t)0 THUNK_GENERATOR(0) },
    { "defaultPrevented", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventDefaultPrevented), (intptr_t)0 THUNK_GENERATOR(0) },
    { "srcElement", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventSrcElement), (intptr_t)0 THUNK_GENERATOR(0) },
    { "returnValue", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventReturnValue), (intptr_t)setJSEventReturnValue THUNK_GENERATOR(0) },
    { "cancelBubble", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventCancelBubble), (intptr_t)setJSEventCancelBubble THUNK_GENERATOR(0) },
    { "clipboardData", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventClipboardData), (intptr_t)0 THUNK_GENERATOR(0) },
    { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
};

#undef THUNK_GENERATOR
static JSC_CONST_HASHTABLE HashTable JSEventTable = { 35, 31, JSEventTableValues, 0 };
/* Hash table for constructor */
#if ENABLE(JIT)
#define THUNK_GENERATOR(generator) , generator
#else
#define THUNK_GENERATOR(generator)
#endif

static const HashTableValue JSEventConstructorTableValues[20] =
{
    { "CAPTURING_PHASE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventCAPTURING_PHASE), (intptr_t)0 THUNK_GENERATOR(0) },
    { "AT_TARGET", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventAT_TARGET), (intptr_t)0 THUNK_GENERATOR(0) },
    { "BUBBLING_PHASE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventBUBBLING_PHASE), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEDOWN", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEDOWN), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEUP", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEUP), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEOVER", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEOVER), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEOUT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEOUT), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEMOVE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEMOVE), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEDRAG", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEDRAG), (intptr_t)0 THUNK_GENERATOR(0) },
    { "CLICK", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventCLICK), (intptr_t)0 THUNK_GENERATOR(0) },
    { "DBLCLICK", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventDBLCLICK), (intptr_t)0 THUNK_GENERATOR(0) },
    { "KEYDOWN", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventKEYDOWN), (intptr_t)0 THUNK_GENERATOR(0) },
    { "KEYUP", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventKEYUP), (intptr_t)0 THUNK_GENERATOR(0) },
    { "KEYPRESS", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventKEYPRESS), (intptr_t)0 THUNK_GENERATOR(0) },
    { "DRAGDROP", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventDRAGDROP), (intptr_t)0 THUNK_GENERATOR(0) },
    { "FOCUS", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventFOCUS), (intptr_t)0 THUNK_GENERATOR(0) },
    { "BLUR", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventBLUR), (intptr_t)0 THUNK_GENERATOR(0) },
    { "SELECT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventSELECT), (intptr_t)0 THUNK_GENERATOR(0) },
    { "CHANGE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventCHANGE), (intptr_t)0 THUNK_GENERATOR(0) },
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
};

#undef THUNK_GENERATOR
static JSC_CONST_HASHTABLE HashTable JSEventConstructorTable = { 68, 63, JSEventConstructorTableValues, 0 };

COMPILE_ASSERT(1 == Event::CAPTURING_PHASE, EventEnumCAPTURING_PHASEIsWrongUseDontCheckEnums);
COMPILE_ASSERT(2 == Event::AT_TARGET, EventEnumAT_TARGETIsWrongUseDontCheckEnums);
COMPILE_ASSERT(3 == Event::BUBBLING_PHASE, EventEnumBUBBLING_PHASEIsWrongUseDontCheckEnums);
COMPILE_ASSERT(1 == Event::MOUSEDOWN, EventEnumMOUSEDOWNIsWrongUseDontCheckEnums);
COMPILE_ASSERT(2 == Event::MOUSEUP, EventEnumMOUSEUPIsWrongUseDontCheckEnums);
COMPILE_ASSERT(4 == Event::MOUSEOVER, EventEnumMOUSEOVERIsWrongUseDontCheckEnums);
COMPILE_ASSERT(8 == Event::MOUSEOUT, EventEnumMOUSEOUTIsWrongUseDontCheckEnums);
COMPILE_ASSERT(16 == Event::MOUSEMOVE, EventEnumMOUSEMOVEIsWrongUseDontCheckEnums);
COMPILE_ASSERT(32 == Event::MOUSEDRAG, EventEnumMOUSEDRAGIsWrongUseDontCheckEnums);
COMPILE_ASSERT(64 == Event::CLICK, EventEnumCLICKIsWrongUseDontCheckEnums);
COMPILE_ASSERT(128 == Event::DBLCLICK, EventEnumDBLCLICKIsWrongUseDontCheckEnums);
COMPILE_ASSERT(256 == Event::KEYDOWN, EventEnumKEYDOWNIsWrongUseDontCheckEnums);
COMPILE_ASSERT(512 == Event::KEYUP, EventEnumKEYUPIsWrongUseDontCheckEnums);
COMPILE_ASSERT(1024 == Event::KEYPRESS, EventEnumKEYPRESSIsWrongUseDontCheckEnums);
COMPILE_ASSERT(2048 == Event::DRAGDROP, EventEnumDRAGDROPIsWrongUseDontCheckEnums);
COMPILE_ASSERT(4096 == Event::FOCUS, EventEnumFOCUSIsWrongUseDontCheckEnums);
COMPILE_ASSERT(8192 == Event::BLUR, EventEnumBLURIsWrongUseDontCheckEnums);
COMPILE_ASSERT(16384 == Event::SELECT, EventEnumSELECTIsWrongUseDontCheckEnums);
COMPILE_ASSERT(32768 == Event::CHANGE, EventEnumCHANGEIsWrongUseDontCheckEnums);

class JSEventConstructor : public DOMConstructorObject {
public:
    JSEventConstructor(JSC::ExecState*, JSC::Structure*, JSDOMGlobalObject*);

    virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
    virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
    static const JSC::ClassInfo s_info;
    static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
    {
        return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
    }
protected:
    static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
};

const ClassInfo JSEventConstructor::s_info = { "EventConstructor", &DOMConstructorObject::s_info, &JSEventConstructorTable, 0 };

JSEventConstructor::JSEventConstructor(ExecState* exec, Structure* structure, JSDOMGlobalObject* globalObject)
    : DOMConstructorObject(structure, globalObject)
{
    ASSERT(inherits(&s_info));
    putDirect(exec->globalData(), exec->propertyNames().prototype, JSEventPrototype::self(exec, globalObject), DontDelete | ReadOnly);
}

bool JSEventConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSEventConstructor, JSDOMWrapper>(exec, &JSEventConstructorTable, this, propertyName, slot);
}

bool JSEventConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticValueDescriptor<JSEventConstructor, JSDOMWrapper>(exec, &JSEventConstructorTable, this, propertyName, descriptor);
}

/* Hash table for prototype */
#if ENABLE(JIT)
#define THUNK_GENERATOR(generator) , generator
#else
#define THUNK_GENERATOR(generator)
#endif

static const HashTableValue JSEventPrototypeTableValues[24] =
{
    { "CAPTURING_PHASE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventCAPTURING_PHASE), (intptr_t)0 THUNK_GENERATOR(0) },
    { "AT_TARGET", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventAT_TARGET), (intptr_t)0 THUNK_GENERATOR(0) },
    { "BUBBLING_PHASE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventBUBBLING_PHASE), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEDOWN", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEDOWN), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEUP", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEUP), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEOVER", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEOVER), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEOUT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEOUT), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEMOVE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEMOVE), (intptr_t)0 THUNK_GENERATOR(0) },
    { "MOUSEDRAG", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventMOUSEDRAG), (intptr_t)0 THUNK_GENERATOR(0) },
    { "CLICK", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventCLICK), (intptr_t)0 THUNK_GENERATOR(0) },
    { "DBLCLICK", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventDBLCLICK), (intptr_t)0 THUNK_GENERATOR(0) },
    { "KEYDOWN", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventKEYDOWN), (intptr_t)0 THUNK_GENERATOR(0) },
    { "KEYUP", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventKEYUP), (intptr_t)0 THUNK_GENERATOR(0) },
    { "KEYPRESS", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventKEYPRESS), (intptr_t)0 THUNK_GENERATOR(0) },
    { "DRAGDROP", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventDRAGDROP), (intptr_t)0 THUNK_GENERATOR(0) },
    { "FOCUS", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventFOCUS), (intptr_t)0 THUNK_GENERATOR(0) },
    { "BLUR", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventBLUR), (intptr_t)0 THUNK_GENERATOR(0) },
    { "SELECT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventSELECT), (intptr_t)0 THUNK_GENERATOR(0) },
    { "CHANGE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsEventCHANGE), (intptr_t)0 THUNK_GENERATOR(0) },
    { "stopPropagation", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsEventPrototypeFunctionStopPropagation), (intptr_t)0 THUNK_GENERATOR(0) },
    { "preventDefault", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsEventPrototypeFunctionPreventDefault), (intptr_t)0 THUNK_GENERATOR(0) },
    { "initEvent", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsEventPrototypeFunctionInitEvent), (intptr_t)3 THUNK_GENERATOR(0) },
    { "stopImmediatePropagation", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsEventPrototypeFunctionStopImmediatePropagation), (intptr_t)0 THUNK_GENERATOR(0) },
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
};

#undef THUNK_GENERATOR
static JSC_CONST_HASHTABLE HashTable JSEventPrototypeTable = { 69, 63, JSEventPrototypeTableValues, 0 };
static const HashTable* getJSEventPrototypeTable(ExecState* exec)
{
    return getHashTableForGlobalData(exec->globalData(), &JSEventPrototypeTable);
}

const ClassInfo JSEventPrototype::s_info = { "EventPrototype", &JSC::JSObjectWithGlobalObject::s_info, 0, getJSEventPrototypeTable };

JSObject* JSEventPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
{
    return getDOMPrototype<JSEvent>(exec, globalObject);
}

bool JSEventPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticPropertySlot<JSEventPrototype, JSObject>(exec, getJSEventPrototypeTable(exec), this, propertyName, slot);
}

bool JSEventPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticPropertyDescriptor<JSEventPrototype, JSObject>(exec, getJSEventPrototypeTable(exec), this, propertyName, descriptor);
}

static const HashTable* getJSEventTable(ExecState* exec)
{
    return getHashTableForGlobalData(exec->globalData(), &JSEventTable);
}

const ClassInfo JSEvent::s_info = { "Event", &JSDOMWrapper::s_info, 0, getJSEventTable };

JSEvent::JSEvent(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Event> impl)
    : JSDOMWrapper(structure, globalObject)
    , m_impl(impl)
{
    ASSERT(inherits(&s_info));
}

JSObject* JSEvent::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
{
    return new (exec) JSEventPrototype(exec->globalData(), globalObject, JSEventPrototype::createStructure(globalObject->globalData(), globalObject->objectPrototype()));
}

bool JSEvent::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSEvent, Base>(exec, getJSEventTable(exec), this, propertyName, slot);
}

bool JSEvent::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticValueDescriptor<JSEvent, Base>(exec, getJSEventTable(exec), this, propertyName, descriptor);
}

JSValue jsEventType(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = jsString(exec, imp->type());
    return result;
}


JSValue jsEventTarget(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->target()));
    return result;
}


JSValue jsEventCurrentTarget(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->currentTarget()));
    return result;
}


JSValue jsEventEventPhase(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = jsNumber(imp->eventPhase());
    return result;
}


JSValue jsEventBubbles(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = jsBoolean(imp->bubbles());
    return result;
}


JSValue jsEventCancelable(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = jsBoolean(imp->cancelable());
    return result;
}


JSValue jsEventTimeStamp(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = jsNumber(imp->timeStamp());
    return result;
}


JSValue jsEventDefaultPrevented(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = jsBoolean(imp->defaultPrevented());
    return result;
}


JSValue jsEventSrcElement(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->srcElement()));
    return result;
}


JSValue jsEventReturnValue(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = jsBoolean(imp->returnValue());
    return result;
}


JSValue jsEventCancelBubble(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Event* imp = static_cast<Event*>(castedThis->impl());
    JSValue result = jsBoolean(imp->cancelBubble());
    return result;
}


JSValue jsEventClipboardData(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(slotBase));
    return castedThis->clipboardData(exec);
}


JSValue jsEventConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSEvent* domObject = static_cast<JSEvent*>(asObject(slotBase));
    return JSEvent::getConstructor(exec, domObject->globalObject());
}

void JSEvent::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
    lookupPut<JSEvent, Base>(exec, propertyName, value, getJSEventTable(exec), this, slot);
}

void setJSEventReturnValue(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSEvent* castedThis = static_cast<JSEvent*>(thisObject);
    Event* imp = static_cast<Event*>(castedThis->impl());
    imp->setReturnValue(value.toBoolean(exec));
}


void setJSEventCancelBubble(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSEvent* castedThis = static_cast<JSEvent*>(thisObject);
    Event* imp = static_cast<Event*>(castedThis->impl());
    imp->setCancelBubble(value.toBoolean(exec));
}


JSValue JSEvent::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
{
    return getDOMConstructor<JSEventConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
}

EncodedJSValue JSC_HOST_CALL jsEventPrototypeFunctionStopPropagation(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSEvent::s_info))
        return throwVMTypeError(exec);
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(thisValue));
    Event* imp = static_cast<Event*>(castedThis->impl());

    imp->stopPropagation();
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsEventPrototypeFunctionPreventDefault(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSEvent::s_info))
        return throwVMTypeError(exec);
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(thisValue));
    Event* imp = static_cast<Event*>(castedThis->impl());

    imp->preventDefault();
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsEventPrototypeFunctionInitEvent(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSEvent::s_info))
        return throwVMTypeError(exec);
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(thisValue));
    Event* imp = static_cast<Event*>(castedThis->impl());
    const String& eventTypeArg(ustringToString(exec->argument(0).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    bool canBubbleArg(exec->argument(1).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    bool cancelableArg(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    imp->initEvent(eventTypeArg, canBubbleArg, cancelableArg);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsEventPrototypeFunctionStopImmediatePropagation(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSEvent::s_info))
        return throwVMTypeError(exec);
    JSEvent* castedThis = static_cast<JSEvent*>(asObject(thisValue));
    Event* imp = static_cast<Event*>(castedThis->impl());

    imp->stopImmediatePropagation();
    return JSValue::encode(jsUndefined());
}

// Constant getters

JSValue jsEventCAPTURING_PHASE(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(1));
}

JSValue jsEventAT_TARGET(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(2));
}

JSValue jsEventBUBBLING_PHASE(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(3));
}

JSValue jsEventMOUSEDOWN(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(1));
}

JSValue jsEventMOUSEUP(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(2));
}

JSValue jsEventMOUSEOVER(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(4));
}

JSValue jsEventMOUSEOUT(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(8));
}

JSValue jsEventMOUSEMOVE(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(16));
}

JSValue jsEventMOUSEDRAG(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(32));
}

JSValue jsEventCLICK(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(64));
}

JSValue jsEventDBLCLICK(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(128));
}

JSValue jsEventKEYDOWN(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(256));
}

JSValue jsEventKEYUP(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(512));
}

JSValue jsEventKEYPRESS(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(1024));
}

JSValue jsEventDRAGDROP(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(2048));
}

JSValue jsEventFOCUS(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(4096));
}

JSValue jsEventBLUR(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(8192));
}

JSValue jsEventSELECT(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(16384));
}

JSValue jsEventCHANGE(ExecState* exec, JSValue, const Identifier&)
{
    UNUSED_PARAM(exec);
    return jsNumber(static_cast<int>(32768));
}

Event* toEvent(JSC::JSValue value)
{
    return value.inherits(&JSEvent::s_info) ? static_cast<JSEvent*>(asObject(value))->impl() : 0;
}

}