~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/generated/JSXMLHttpRequest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
*/
20
20
 
21
21
#include "config.h"
22
 
 
23
22
#include "JSXMLHttpRequest.h"
24
23
 
25
 
#include <wtf/GetPtr.h>
26
 
 
27
24
#include "Document.h"
28
25
#include "Event.h"
29
26
#include "EventListener.h"
34
31
#include "JSEventListener.h"
35
32
#include "JSXMLHttpRequestUpload.h"
36
33
#include "KURL.h"
 
34
#include "RegisteredEventListener.h"
37
35
#include "XMLHttpRequest.h"
38
36
#include "XMLHttpRequestUpload.h"
39
 
 
40
37
#include <runtime/Error.h>
41
38
#include <runtime/JSNumberCell.h>
42
39
#include <runtime/JSString.h>
 
40
#include <wtf/GetPtr.h>
43
41
 
44
42
using namespace JSC;
45
43
 
46
44
namespace WebCore {
47
45
 
48
 
ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequest)
 
46
ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequest);
49
47
 
50
48
/* Hash table */
51
49
 
52
 
static const HashTableValue JSXMLHttpRequestTableValues[13] =
 
50
static const HashTableValue JSXMLHttpRequestTableValues[14] =
53
51
{
54
52
    { "onabort", DontDelete, (intptr_t)jsXMLHttpRequestOnabort, (intptr_t)setJSXMLHttpRequestOnabort },
55
53
    { "onerror", DontDelete, (intptr_t)jsXMLHttpRequestOnerror, (intptr_t)setJSXMLHttpRequestOnerror },
58
56
    { "onprogress", DontDelete, (intptr_t)jsXMLHttpRequestOnprogress, (intptr_t)setJSXMLHttpRequestOnprogress },
59
57
    { "onreadystatechange", DontDelete, (intptr_t)jsXMLHttpRequestOnreadystatechange, (intptr_t)setJSXMLHttpRequestOnreadystatechange },
60
58
    { "readyState", DontDelete|ReadOnly, (intptr_t)jsXMLHttpRequestReadyState, (intptr_t)0 },
 
59
    { "withCredentials", DontDelete, (intptr_t)jsXMLHttpRequestWithCredentials, (intptr_t)setJSXMLHttpRequestWithCredentials },
61
60
    { "upload", DontDelete|ReadOnly, (intptr_t)jsXMLHttpRequestUpload, (intptr_t)0 },
62
61
    { "responseText", DontDelete|ReadOnly, (intptr_t)jsXMLHttpRequestResponseText, (intptr_t)0 },
63
62
    { "responseXML", DontDelete|ReadOnly, (intptr_t)jsXMLHttpRequestResponseXML, (intptr_t)0 },
66
65
    { 0, 0, 0, 0 }
67
66
};
68
67
 
69
 
static const HashTable JSXMLHttpRequestTable =
 
68
static JSC_CONST_HASHTABLE HashTable JSXMLHttpRequestTable =
70
69
#if ENABLE(PERFECT_HASH_SIZE)
71
70
    { 127, JSXMLHttpRequestTableValues, 0 };
72
71
#else
73
 
    { 34, 31, JSXMLHttpRequestTableValues, 0 };
 
72
    { 35, 31, JSXMLHttpRequestTableValues, 0 };
74
73
#endif
75
74
 
76
75
/* Hash table for prototype */
95
94
    { 0, 0, 0, 0 }
96
95
};
97
96
 
98
 
static const HashTable JSXMLHttpRequestPrototypeTable =
 
97
static JSC_CONST_HASHTABLE HashTable JSXMLHttpRequestPrototypeTable =
99
98
#if ENABLE(PERFECT_HASH_SIZE)
100
99
    { 1023, JSXMLHttpRequestPrototypeTableValues, 0 };
101
100
#else
102
101
    { 37, 31, JSXMLHttpRequestPrototypeTableValues, 0 };
103
102
#endif
104
103
 
105
 
const ClassInfo JSXMLHttpRequestPrototype::s_info = { "XMLHttpRequestPrototype", 0, &JSXMLHttpRequestPrototypeTable, 0 };
 
104
static const HashTable* getJSXMLHttpRequestPrototypeTable(ExecState* exec)
 
105
{
 
106
    return getHashTableForGlobalData(exec->globalData(), &JSXMLHttpRequestPrototypeTable);
 
107
}
 
108
const ClassInfo JSXMLHttpRequestPrototype::s_info = { "XMLHttpRequestPrototype", 0, 0, getJSXMLHttpRequestPrototypeTable };
106
109
 
107
110
JSObject* JSXMLHttpRequestPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
108
111
{
111
114
 
112
115
bool JSXMLHttpRequestPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
113
116
{
114
 
    return getStaticPropertySlot<JSXMLHttpRequestPrototype, JSObject>(exec, &JSXMLHttpRequestPrototypeTable, this, propertyName, slot);
115
 
}
116
 
 
117
 
const ClassInfo JSXMLHttpRequest::s_info = { "XMLHttpRequest", 0, &JSXMLHttpRequestTable, 0 };
118
 
 
119
 
JSXMLHttpRequest::JSXMLHttpRequest(PassRefPtr<Structure> structure, PassRefPtr<XMLHttpRequest> impl)
120
 
    : DOMObject(structure)
 
117
    return getStaticPropertySlot<JSXMLHttpRequestPrototype, JSObject>(exec, getJSXMLHttpRequestPrototypeTable(exec), this, propertyName, slot);
 
118
}
 
119
 
 
120
bool JSXMLHttpRequestPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
 
121
{
 
122
    return getStaticPropertyDescriptor<JSXMLHttpRequestPrototype, JSObject>(exec, getJSXMLHttpRequestPrototypeTable(exec), this, propertyName, descriptor);
 
123
}
 
124
 
 
125
static const HashTable* getJSXMLHttpRequestTable(ExecState* exec)
 
126
{
 
127
    return getHashTableForGlobalData(exec->globalData(), &JSXMLHttpRequestTable);
 
128
}
 
129
const ClassInfo JSXMLHttpRequest::s_info = { "XMLHttpRequest", 0, 0, getJSXMLHttpRequestTable };
 
130
 
 
131
JSXMLHttpRequest::JSXMLHttpRequest(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<XMLHttpRequest> impl)
 
132
    : DOMObjectWithGlobalPointer(structure, globalObject)
121
133
    , m_impl(impl)
122
134
{
123
135
}
124
136
 
125
137
JSXMLHttpRequest::~JSXMLHttpRequest()
126
138
{
127
 
    forgetDOMObject(*Heap::heap(this)->globalData(), m_impl.get());
128
 
 
 
139
    impl()->invalidateEventListeners();
 
140
    forgetDOMObject(*Heap::heap(this)->globalData(), impl());
129
141
}
130
142
 
131
143
JSObject* JSXMLHttpRequest::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
135
147
 
136
148
bool JSXMLHttpRequest::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
137
149
{
138
 
    return getStaticValueSlot<JSXMLHttpRequest, Base>(exec, &JSXMLHttpRequestTable, this, propertyName, slot);
139
 
}
140
 
 
141
 
JSValuePtr jsXMLHttpRequestOnabort(ExecState* exec, const Identifier&, const PropertySlot& slot)
142
 
{
143
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
144
 
    if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(imp->onabort())) {
145
 
        if (JSObject* listenerObj = listener->listenerObj())
146
 
            return listenerObj;
147
 
    }
148
 
    return jsNull();
149
 
}
150
 
 
151
 
JSValuePtr jsXMLHttpRequestOnerror(ExecState* exec, const Identifier&, const PropertySlot& slot)
152
 
{
153
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
154
 
    if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(imp->onerror())) {
155
 
        if (JSObject* listenerObj = listener->listenerObj())
156
 
            return listenerObj;
157
 
    }
158
 
    return jsNull();
159
 
}
160
 
 
161
 
JSValuePtr jsXMLHttpRequestOnload(ExecState* exec, const Identifier&, const PropertySlot& slot)
162
 
{
163
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
164
 
    if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(imp->onload())) {
165
 
        if (JSObject* listenerObj = listener->listenerObj())
166
 
            return listenerObj;
167
 
    }
168
 
    return jsNull();
169
 
}
170
 
 
171
 
JSValuePtr jsXMLHttpRequestOnloadstart(ExecState* exec, const Identifier&, const PropertySlot& slot)
172
 
{
173
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
174
 
    if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(imp->onloadstart())) {
175
 
        if (JSObject* listenerObj = listener->listenerObj())
176
 
            return listenerObj;
177
 
    }
178
 
    return jsNull();
179
 
}
180
 
 
181
 
JSValuePtr jsXMLHttpRequestOnprogress(ExecState* exec, const Identifier&, const PropertySlot& slot)
182
 
{
183
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
184
 
    if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(imp->onprogress())) {
185
 
        if (JSObject* listenerObj = listener->listenerObj())
186
 
            return listenerObj;
187
 
    }
188
 
    return jsNull();
189
 
}
190
 
 
191
 
JSValuePtr jsXMLHttpRequestOnreadystatechange(ExecState* exec, const Identifier&, const PropertySlot& slot)
192
 
{
193
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
194
 
    if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(imp->onreadystatechange())) {
195
 
        if (JSObject* listenerObj = listener->listenerObj())
196
 
            return listenerObj;
197
 
    }
198
 
    return jsNull();
199
 
}
200
 
 
201
 
JSValuePtr jsXMLHttpRequestReadyState(ExecState* exec, const Identifier&, const PropertySlot& slot)
202
 
{
203
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
 
150
    return getStaticValueSlot<JSXMLHttpRequest, Base>(exec, getJSXMLHttpRequestTable(exec), this, propertyName, slot);
 
151
}
 
152
 
 
153
bool JSXMLHttpRequest::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
 
154
{
 
155
    return getStaticValueDescriptor<JSXMLHttpRequest, Base>(exec, getJSXMLHttpRequestTable(exec), this, propertyName, descriptor);
 
156
}
 
157
 
 
158
JSValue jsXMLHttpRequestOnabort(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
159
{
 
160
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
161
    UNUSED_PARAM(exec);
 
162
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
163
    if (EventListener* listener = imp->onabort()) {
 
164
        if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext()))
 
165
            return jsFunction;
 
166
    }
 
167
    return jsNull();
 
168
}
 
169
 
 
170
JSValue jsXMLHttpRequestOnerror(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
171
{
 
172
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
173
    UNUSED_PARAM(exec);
 
174
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
175
    if (EventListener* listener = imp->onerror()) {
 
176
        if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext()))
 
177
            return jsFunction;
 
178
    }
 
179
    return jsNull();
 
180
}
 
181
 
 
182
JSValue jsXMLHttpRequestOnload(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
183
{
 
184
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
185
    UNUSED_PARAM(exec);
 
186
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
187
    if (EventListener* listener = imp->onload()) {
 
188
        if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext()))
 
189
            return jsFunction;
 
190
    }
 
191
    return jsNull();
 
192
}
 
193
 
 
194
JSValue jsXMLHttpRequestOnloadstart(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
195
{
 
196
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
197
    UNUSED_PARAM(exec);
 
198
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
199
    if (EventListener* listener = imp->onloadstart()) {
 
200
        if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext()))
 
201
            return jsFunction;
 
202
    }
 
203
    return jsNull();
 
204
}
 
205
 
 
206
JSValue jsXMLHttpRequestOnprogress(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
207
{
 
208
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
209
    UNUSED_PARAM(exec);
 
210
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
211
    if (EventListener* listener = imp->onprogress()) {
 
212
        if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext()))
 
213
            return jsFunction;
 
214
    }
 
215
    return jsNull();
 
216
}
 
217
 
 
218
JSValue jsXMLHttpRequestOnreadystatechange(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
219
{
 
220
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
221
    UNUSED_PARAM(exec);
 
222
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
223
    if (EventListener* listener = imp->onreadystatechange()) {
 
224
        if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext()))
 
225
            return jsFunction;
 
226
    }
 
227
    return jsNull();
 
228
}
 
229
 
 
230
JSValue jsXMLHttpRequestReadyState(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
231
{
 
232
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
233
    UNUSED_PARAM(exec);
 
234
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
204
235
    return jsNumber(exec, imp->readyState());
205
236
}
206
237
 
207
 
JSValuePtr jsXMLHttpRequestUpload(ExecState* exec, const Identifier&, const PropertySlot& slot)
208
 
{
209
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
210
 
    return toJS(exec, WTF::getPtr(imp->upload()));
211
 
}
212
 
 
213
 
JSValuePtr jsXMLHttpRequestResponseText(ExecState* exec, const Identifier&, const PropertySlot& slot)
214
 
{
215
 
    return static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->responseText(exec);
216
 
}
217
 
 
218
 
JSValuePtr jsXMLHttpRequestResponseXML(ExecState* exec, const Identifier&, const PropertySlot& slot)
219
 
{
220
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
221
 
    return toJS(exec, WTF::getPtr(imp->responseXML()));
222
 
}
223
 
 
224
 
JSValuePtr jsXMLHttpRequestStatus(ExecState* exec, const Identifier&, const PropertySlot& slot)
225
 
{
226
 
    ExceptionCode ec = 0;
227
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
228
 
    JSC::JSValuePtr result = jsNumber(exec, imp->status(ec));
229
 
    setDOMException(exec, ec);
230
 
    return result;
231
 
}
232
 
 
233
 
JSValuePtr jsXMLHttpRequestStatusText(ExecState* exec, const Identifier&, const PropertySlot& slot)
234
 
{
235
 
    ExceptionCode ec = 0;
236
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()))->impl());
237
 
    JSC::JSValuePtr result = jsString(exec, imp->statusText(ec));
238
 
    setDOMException(exec, ec);
239
 
    return result;
240
 
}
241
 
 
242
 
void JSXMLHttpRequest::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot)
243
 
{
244
 
    lookupPut<JSXMLHttpRequest, Base>(exec, propertyName, value, &JSXMLHttpRequestTable, this, slot);
245
 
}
246
 
 
247
 
void setJSXMLHttpRequestOnabort(ExecState* exec, JSObject* thisObject, JSValuePtr value)
248
 
{
249
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
250
 
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
251
 
    if (!globalObject)
252
 
        return;
253
 
    imp->setOnabort(globalObject->findOrCreateJSUnprotectedEventListener(exec, value, true));
254
 
}
255
 
 
256
 
void setJSXMLHttpRequestOnerror(ExecState* exec, JSObject* thisObject, JSValuePtr value)
257
 
{
258
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
259
 
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
260
 
    if (!globalObject)
261
 
        return;
262
 
    imp->setOnerror(globalObject->findOrCreateJSUnprotectedEventListener(exec, value, true));
263
 
}
264
 
 
265
 
void setJSXMLHttpRequestOnload(ExecState* exec, JSObject* thisObject, JSValuePtr value)
266
 
{
267
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
268
 
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
269
 
    if (!globalObject)
270
 
        return;
271
 
    imp->setOnload(globalObject->findOrCreateJSUnprotectedEventListener(exec, value, true));
272
 
}
273
 
 
274
 
void setJSXMLHttpRequestOnloadstart(ExecState* exec, JSObject* thisObject, JSValuePtr value)
275
 
{
276
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
277
 
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
278
 
    if (!globalObject)
279
 
        return;
280
 
    imp->setOnloadstart(globalObject->findOrCreateJSUnprotectedEventListener(exec, value, true));
281
 
}
282
 
 
283
 
void setJSXMLHttpRequestOnprogress(ExecState* exec, JSObject* thisObject, JSValuePtr value)
284
 
{
285
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
286
 
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
287
 
    if (!globalObject)
288
 
        return;
289
 
    imp->setOnprogress(globalObject->findOrCreateJSUnprotectedEventListener(exec, value, true));
290
 
}
291
 
 
292
 
void setJSXMLHttpRequestOnreadystatechange(ExecState* exec, JSObject* thisObject, JSValuePtr value)
293
 
{
294
 
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
295
 
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
296
 
    if (!globalObject)
297
 
        return;
298
 
    imp->setOnreadystatechange(globalObject->findOrCreateJSUnprotectedEventListener(exec, value, true));
299
 
}
300
 
 
301
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionOpen(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
302
 
{
303
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
238
JSValue jsXMLHttpRequestWithCredentials(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
239
{
 
240
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
241
    UNUSED_PARAM(exec);
 
242
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
243
    return jsBoolean(imp->withCredentials());
 
244
}
 
245
 
 
246
JSValue jsXMLHttpRequestUpload(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
247
{
 
248
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
249
    UNUSED_PARAM(exec);
 
250
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
251
    return toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->upload()));
 
252
}
 
253
 
 
254
JSValue jsXMLHttpRequestResponseText(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
255
{
 
256
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
257
    return castedThis->responseText(exec);
 
258
}
 
259
 
 
260
JSValue jsXMLHttpRequestResponseXML(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
261
{
 
262
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
263
    UNUSED_PARAM(exec);
 
264
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
265
    return toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->responseXML()));
 
266
}
 
267
 
 
268
JSValue jsXMLHttpRequestStatus(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
269
{
 
270
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
271
    ExceptionCode ec = 0;
 
272
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
273
    JSC::JSValue result = jsNumber(exec, imp->status(ec));
 
274
    setDOMException(exec, ec);
 
275
    return result;
 
276
}
 
277
 
 
278
JSValue jsXMLHttpRequestStatusText(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
279
{
 
280
    JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slot.slotBase()));
 
281
    ExceptionCode ec = 0;
 
282
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
 
283
    JSC::JSValue result = jsString(exec, imp->statusText(ec));
 
284
    setDOMException(exec, ec);
 
285
    return result;
 
286
}
 
287
 
 
288
void JSXMLHttpRequest::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
 
289
{
 
290
    lookupPut<JSXMLHttpRequest, Base>(exec, propertyName, value, getJSXMLHttpRequestTable(exec), this, slot);
 
291
}
 
292
 
 
293
void setJSXMLHttpRequestOnabort(ExecState* exec, JSObject* thisObject, JSValue value)
 
294
{
 
295
    UNUSED_PARAM(exec);
 
296
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
 
297
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
 
298
    if (!globalObject)
 
299
        return;
 
300
    imp->setOnabort(globalObject->createJSAttributeEventListener(value));
 
301
}
 
302
 
 
303
void setJSXMLHttpRequestOnerror(ExecState* exec, JSObject* thisObject, JSValue value)
 
304
{
 
305
    UNUSED_PARAM(exec);
 
306
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
 
307
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
 
308
    if (!globalObject)
 
309
        return;
 
310
    imp->setOnerror(globalObject->createJSAttributeEventListener(value));
 
311
}
 
312
 
 
313
void setJSXMLHttpRequestOnload(ExecState* exec, JSObject* thisObject, JSValue value)
 
314
{
 
315
    UNUSED_PARAM(exec);
 
316
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
 
317
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
 
318
    if (!globalObject)
 
319
        return;
 
320
    imp->setOnload(globalObject->createJSAttributeEventListener(value));
 
321
}
 
322
 
 
323
void setJSXMLHttpRequestOnloadstart(ExecState* exec, JSObject* thisObject, JSValue value)
 
324
{
 
325
    UNUSED_PARAM(exec);
 
326
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
 
327
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
 
328
    if (!globalObject)
 
329
        return;
 
330
    imp->setOnloadstart(globalObject->createJSAttributeEventListener(value));
 
331
}
 
332
 
 
333
void setJSXMLHttpRequestOnprogress(ExecState* exec, JSObject* thisObject, JSValue value)
 
334
{
 
335
    UNUSED_PARAM(exec);
 
336
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
 
337
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
 
338
    if (!globalObject)
 
339
        return;
 
340
    imp->setOnprogress(globalObject->createJSAttributeEventListener(value));
 
341
}
 
342
 
 
343
void setJSXMLHttpRequestOnreadystatechange(ExecState* exec, JSObject* thisObject, JSValue value)
 
344
{
 
345
    UNUSED_PARAM(exec);
 
346
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
 
347
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());
 
348
    if (!globalObject)
 
349
        return;
 
350
    imp->setOnreadystatechange(globalObject->createJSAttributeEventListener(value));
 
351
}
 
352
 
 
353
void setJSXMLHttpRequestWithCredentials(ExecState* exec, JSObject* thisObject, JSValue value)
 
354
{
 
355
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
 
356
    ExceptionCode ec = 0;
 
357
    imp->setWithCredentials(value.toBoolean(exec), ec);
 
358
    setDOMException(exec, ec);
 
359
}
 
360
 
 
361
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionOpen(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
 
362
{
 
363
    UNUSED_PARAM(args);
 
364
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
304
365
        return throwError(exec, TypeError);
305
366
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
306
367
    return castedThisObj->open(exec, args);
307
368
}
308
369
 
309
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionSetRequestHeader(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
370
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionSetRequestHeader(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
310
371
{
311
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
372
    UNUSED_PARAM(args);
 
373
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
312
374
        return throwError(exec, TypeError);
313
375
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
314
376
    return castedThisObj->setRequestHeader(exec, args);
315
377
}
316
378
 
317
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionSend(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
379
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionSend(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
318
380
{
319
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
381
    UNUSED_PARAM(args);
 
382
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
320
383
        return throwError(exec, TypeError);
321
384
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
322
385
    return castedThisObj->send(exec, args);
323
386
}
324
387
 
325
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionAbort(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
388
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionAbort(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
326
389
{
327
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
390
    UNUSED_PARAM(args);
 
391
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
328
392
        return throwError(exec, TypeError);
329
393
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
330
394
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThisObj->impl());
333
397
    return jsUndefined();
334
398
}
335
399
 
336
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
400
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
337
401
{
338
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
402
    UNUSED_PARAM(args);
 
403
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
339
404
        return throwError(exec, TypeError);
340
405
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
341
406
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThisObj->impl());
342
407
    ExceptionCode ec = 0;
343
408
 
344
409
 
345
 
    JSC::JSValuePtr result = jsStringOrUndefined(exec, imp->getAllResponseHeaders(ec));
 
410
    JSC::JSValue result = jsStringOrUndefined(exec, imp->getAllResponseHeaders(ec));
346
411
    setDOMException(exec, ec);
347
412
    return result;
348
413
}
349
414
 
350
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionGetResponseHeader(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
415
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionGetResponseHeader(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
351
416
{
352
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
417
    UNUSED_PARAM(args);
 
418
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
353
419
        return throwError(exec, TypeError);
354
420
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
355
421
    return castedThisObj->getResponseHeader(exec, args);
356
422
}
357
423
 
358
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionOverrideMimeType(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
424
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionOverrideMimeType(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
359
425
{
360
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
426
    UNUSED_PARAM(args);
 
427
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
361
428
        return throwError(exec, TypeError);
362
429
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
363
430
    return castedThisObj->overrideMimeType(exec, args);
364
431
}
365
432
 
366
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionAddEventListener(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
433
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionAddEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
367
434
{
368
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
435
    UNUSED_PARAM(args);
 
436
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
369
437
        return throwError(exec, TypeError);
370
438
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
371
439
    return castedThisObj->addEventListener(exec, args);
372
440
}
373
441
 
374
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
442
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
375
443
{
376
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
444
    UNUSED_PARAM(args);
 
445
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
377
446
        return throwError(exec, TypeError);
378
447
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
379
448
    return castedThisObj->removeEventListener(exec, args);
380
449
}
381
450
 
382
 
JSValuePtr jsXMLHttpRequestPrototypeFunctionDispatchEvent(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
451
JSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionDispatchEvent(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
383
452
{
384
 
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
 
453
    UNUSED_PARAM(args);
 
454
    if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
385
455
        return throwError(exec, TypeError);
386
456
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
387
457
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThisObj->impl());
388
458
    ExceptionCode ec = 0;
389
 
    Event* evt = toEvent(args.at(exec, 0));
390
 
 
391
 
 
392
 
    JSC::JSValuePtr result = jsBoolean(imp->dispatchEvent(evt, ec));
 
459
    Event* evt = toEvent(args.at(0));
 
460
 
 
461
 
 
462
    JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec));
393
463
    setDOMException(exec, ec);
394
464
    return result;
395
465
}
396
466
 
397
467
// Constant getters
398
468
 
399
 
JSValuePtr jsXMLHttpRequestUNSENT(ExecState* exec, const Identifier&, const PropertySlot&)
 
469
JSValue jsXMLHttpRequestUNSENT(ExecState* exec, const Identifier&, const PropertySlot&)
400
470
{
401
471
    return jsNumber(exec, static_cast<int>(0));
402
472
}
403
473
 
404
 
JSValuePtr jsXMLHttpRequestOPENED(ExecState* exec, const Identifier&, const PropertySlot&)
 
474
JSValue jsXMLHttpRequestOPENED(ExecState* exec, const Identifier&, const PropertySlot&)
405
475
{
406
476
    return jsNumber(exec, static_cast<int>(1));
407
477
}
408
478
 
409
 
JSValuePtr jsXMLHttpRequestHEADERS_RECEIVED(ExecState* exec, const Identifier&, const PropertySlot&)
 
479
JSValue jsXMLHttpRequestHEADERS_RECEIVED(ExecState* exec, const Identifier&, const PropertySlot&)
410
480
{
411
481
    return jsNumber(exec, static_cast<int>(2));
412
482
}
413
483
 
414
 
JSValuePtr jsXMLHttpRequestLOADING(ExecState* exec, const Identifier&, const PropertySlot&)
 
484
JSValue jsXMLHttpRequestLOADING(ExecState* exec, const Identifier&, const PropertySlot&)
415
485
{
416
486
    return jsNumber(exec, static_cast<int>(3));
417
487
}
418
488
 
419
 
JSValuePtr jsXMLHttpRequestDONE(ExecState* exec, const Identifier&, const PropertySlot&)
 
489
JSValue jsXMLHttpRequestDONE(ExecState* exec, const Identifier&, const PropertySlot&)
420
490
{
421
491
    return jsNumber(exec, static_cast<int>(4));
422
492
}
423
493
 
424
 
JSC::JSValuePtr toJS(JSC::ExecState* exec, XMLHttpRequest* object)
 
494
JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, XMLHttpRequest* object)
425
495
{
426
 
    return getDOMObjectWrapper<JSXMLHttpRequest>(exec, object);
 
496
    return getDOMObjectWrapper<JSXMLHttpRequest>(exec, globalObject, object);
427
497
}
428
 
XMLHttpRequest* toXMLHttpRequest(JSC::JSValuePtr value)
 
498
XMLHttpRequest* toXMLHttpRequest(JSC::JSValue value)
429
499
{
430
 
    return value->isObject(&JSXMLHttpRequest::s_info) ? static_cast<JSXMLHttpRequest*>(asObject(value))->impl() : 0;
 
500
    return value.inherits(&JSXMLHttpRequest::s_info) ? static_cast<JSXMLHttpRequest*>(asObject(value))->impl() : 0;
431
501
}
432
502
 
433
503
}