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

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/bridge/NP_jsobject.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:
32
32
#include "PlatformString.h"
33
33
#include "StringSourceProvider.h"
34
34
#include "c_utility.h"
 
35
#include "c_instance.h"
 
36
#include "IdentifierRep.h"
35
37
#include "npruntime_impl.h"
36
38
#include "npruntime_priv.h"
37
39
#include "runtime_root.h"
43
45
#include <runtime/Completion.h>
44
46
#include <runtime/Completion.h>
45
47
 
46
 
using WebCore::String;
47
 
using WebCore::StringSourceProvider;
48
48
using namespace JSC;
49
49
using namespace JSC::Bindings;
 
50
using namespace WebCore;
50
51
 
51
 
static void getListFromVariantArgs(ExecState* exec, const NPVariant* args, unsigned argCount, RootObject* rootObject, ArgList& aList)
 
52
static void getListFromVariantArgs(ExecState* exec, const NPVariant* args, unsigned argCount, RootObject* rootObject, MarkedArgumentBuffer& aList)
52
53
{
53
54
    for (unsigned i = 0; i < argCount; ++i)
54
55
        aList.append(convertNPVariantToValue(exec, &args[i], rootObject));
109
110
            return false;
110
111
        
111
112
        ExecState* exec = rootObject->globalObject()->globalExec();
112
 
        JSLock lock(false);
 
113
        JSLock lock(SilenceAssertionsOnly);
113
114
        
114
115
        // Call the function object.
115
 
        JSValuePtr function = obj->imp;
 
116
        JSValue function = obj->imp;
116
117
        CallData callData;
117
 
        CallType callType = function->getCallData(callData);
 
118
        CallType callType = function.getCallData(callData);
118
119
        if (callType == CallTypeNone)
119
120
            return false;
120
121
        
121
 
        ArgList argList;
 
122
        MarkedArgumentBuffer argList;
122
123
        getListFromVariantArgs(exec, args, argCount, rootObject, argList);
123
124
        ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
124
 
        globalObject->startTimeoutCheck();
125
 
        JSValuePtr resultV = call(exec, function, callType, callData, function, argList);
126
 
        globalObject->stopTimeoutCheck();
 
125
        globalObject->globalData()->timeoutChecker.start();
 
126
        JSValue resultV = call(exec, function, callType, callData, function, argList);
 
127
        globalObject->globalData()->timeoutChecker.stop();
127
128
 
128
129
        // Convert and return the result of the function call.
129
130
        convertValueToNPVariant(exec, resultV, result);
142
143
    if (o->_class == NPScriptObjectClass) {
143
144
        JavaScriptObject* obj = reinterpret_cast<JavaScriptObject*>(o); 
144
145
 
145
 
        PrivateIdentifier* i = static_cast<PrivateIdentifier*>(methodName);
146
 
        if (!i->isString)
 
146
        IdentifierRep* i = static_cast<IdentifierRep*>(methodName);
 
147
        if (!i->isString())
147
148
            return false;
148
149
 
149
150
        // Special case the "eval" method.
160
161
        if (!rootObject || !rootObject->isValid())
161
162
            return false;
162
163
        ExecState* exec = rootObject->globalObject()->globalExec();
163
 
        JSLock lock(false);
164
 
        JSValuePtr function = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
 
164
        JSLock lock(SilenceAssertionsOnly);
 
165
        JSValue function = obj->imp->get(exec, identifierFromNPIdentifier(i->string()));
165
166
        CallData callData;
166
 
        CallType callType = function->getCallData(callData);
 
167
        CallType callType = function.getCallData(callData);
167
168
        if (callType == CallTypeNone)
168
169
            return false;
169
170
 
170
171
        // Call the function object.
171
 
        ArgList argList;
 
172
        MarkedArgumentBuffer argList;
172
173
        getListFromVariantArgs(exec, args, argCount, rootObject, argList);
173
174
        ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
174
 
        globalObject->startTimeoutCheck();
175
 
        JSValuePtr resultV = call(exec, function, callType, callData, obj->imp, argList);
176
 
        globalObject->stopTimeoutCheck();
 
175
        globalObject->globalData()->timeoutChecker.start();
 
176
        JSValue resultV = call(exec, function, callType, callData, obj->imp, argList);
 
177
        globalObject->globalData()->timeoutChecker.stop();
177
178
 
178
179
        // Convert and return the result of the function call.
179
180
        convertValueToNPVariant(exec, resultV, result);
198
199
            return false;
199
200
 
200
201
        ExecState* exec = rootObject->globalObject()->globalExec();
201
 
        JSLock lock(false);
 
202
        JSLock lock(SilenceAssertionsOnly);
202
203
        String scriptString = convertNPStringToUTF16(s);
203
204
        ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
204
 
        globalObject->startTimeoutCheck();
 
205
        globalObject->globalData()->timeoutChecker.start();
205
206
        Completion completion = JSC::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(scriptString));
206
 
        globalObject->stopTimeoutCheck();
 
207
        globalObject->globalData()->timeoutChecker.stop();
207
208
        ComplType type = completion.complType();
208
209
        
209
 
        JSValuePtr result;
 
210
        JSValue result;
210
211
        if (type == Normal) {
211
212
            result = completion.value();
212
213
            if (!result)
233
234
            return false;
234
235
 
235
236
        ExecState* exec = rootObject->globalObject()->globalExec();
236
 
        PrivateIdentifier* i = static_cast<PrivateIdentifier*>(propertyName);
 
237
        IdentifierRep* i = static_cast<IdentifierRep*>(propertyName);
237
238
        
238
 
        JSLock lock(false);
239
 
        JSValuePtr result;
240
 
        if (i->isString)
241
 
            result = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
 
239
        JSLock lock(SilenceAssertionsOnly);
 
240
        JSValue result;
 
241
        if (i->isString())
 
242
            result = obj->imp->get(exec, identifierFromNPIdentifier(i->string()));
242
243
        else
243
 
            result = obj->imp->get(exec, i->value.number);
 
244
            result = obj->imp->get(exec, i->number());
244
245
 
245
246
        convertValueToNPVariant(exec, result, variant);
246
247
        exec->clearException();
267
268
            return false;
268
269
 
269
270
        ExecState* exec = rootObject->globalObject()->globalExec();
270
 
        JSLock lock(false);
271
 
        PrivateIdentifier* i = static_cast<PrivateIdentifier*>(propertyName);
 
271
        JSLock lock(SilenceAssertionsOnly);
 
272
        IdentifierRep* i = static_cast<IdentifierRep*>(propertyName);
272
273
 
273
 
        if (i->isString) {
 
274
        if (i->isString()) {
274
275
            PutPropertySlot slot;
275
 
            obj->imp->put(exec, identifierFromNPIdentifier(i->value.string), convertNPVariantToValue(exec, variant, rootObject), slot);
 
276
            obj->imp->put(exec, identifierFromNPIdentifier(i->string()), convertNPVariantToValue(exec, variant, rootObject), slot);
276
277
        } else
277
 
            obj->imp->put(exec, i->value.number, convertNPVariantToValue(exec, variant, rootObject));
 
278
            obj->imp->put(exec, i->number(), convertNPVariantToValue(exec, variant, rootObject));
278
279
        exec->clearException();
279
280
        return true;
280
281
    }
295
296
            return false;
296
297
 
297
298
        ExecState* exec = rootObject->globalObject()->globalExec();
298
 
        PrivateIdentifier* i = static_cast<PrivateIdentifier*>(propertyName);
299
 
        if (i->isString) {
300
 
            if (!obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->value.string))) {
 
299
        IdentifierRep* i = static_cast<IdentifierRep*>(propertyName);
 
300
        if (i->isString()) {
 
301
            if (!obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->string()))) {
301
302
                exec->clearException();
302
303
                return false;
303
304
            }
304
305
        } else {
305
 
            if (!obj->imp->hasProperty(exec, i->value.number)) {
 
306
            if (!obj->imp->hasProperty(exec, i->number())) {
306
307
                exec->clearException();
307
308
                return false;
308
309
            }
309
310
        }
310
311
 
311
 
        JSLock lock(false);
312
 
        if (i->isString)
313
 
            obj->imp->deleteProperty(exec, identifierFromNPIdentifier(i->value.string));
 
312
        JSLock lock(SilenceAssertionsOnly);
 
313
        if (i->isString())
 
314
            obj->imp->deleteProperty(exec, identifierFromNPIdentifier(i->string()));
314
315
        else
315
 
            obj->imp->deleteProperty(exec, i->value.number);
 
316
            obj->imp->deleteProperty(exec, i->number());
316
317
 
317
318
        exec->clearException();
318
319
        return true;
330
331
            return false;
331
332
 
332
333
        ExecState* exec = rootObject->globalObject()->globalExec();
333
 
        PrivateIdentifier* i = static_cast<PrivateIdentifier*>(propertyName);
334
 
        JSLock lock(false);
335
 
        if (i->isString) {
336
 
            bool result = obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->value.string));
 
334
        IdentifierRep* i = static_cast<IdentifierRep*>(propertyName);
 
335
        JSLock lock(SilenceAssertionsOnly);
 
336
        if (i->isString()) {
 
337
            bool result = obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->string()));
337
338
            exec->clearException();
338
339
            return result;
339
340
        }
340
341
 
341
 
        bool result = obj->imp->hasProperty(exec, i->value.number);
 
342
        bool result = obj->imp->hasProperty(exec, i->number());
342
343
        exec->clearException();
343
344
        return result;
344
345
    }
354
355
    if (o->_class == NPScriptObjectClass) {
355
356
        JavaScriptObject* obj = reinterpret_cast<JavaScriptObject*>(o); 
356
357
 
357
 
        PrivateIdentifier* i = static_cast<PrivateIdentifier*>(methodName);
358
 
        if (!i->isString)
 
358
        IdentifierRep* i = static_cast<IdentifierRep*>(methodName);
 
359
        if (!i->isString())
359
360
            return false;
360
361
 
361
362
        RootObject* rootObject = obj->rootObject;
363
364
            return false;
364
365
 
365
366
        ExecState* exec = rootObject->globalObject()->globalExec();
366
 
        JSLock lock(false);
367
 
        JSValuePtr func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
 
367
        JSLock lock(SilenceAssertionsOnly);
 
368
        JSValue func = obj->imp->get(exec, identifierFromNPIdentifier(i->string()));
368
369
        exec->clearException();
369
 
        return !func->isUndefined();
 
370
        return !func.isUndefined();
370
371
    }
371
372
    
372
373
    if (o->_class->hasMethod)
375
376
    return false;
376
377
}
377
378
 
378
 
void _NPN_SetException(NPObject*, const NPUTF8*)
 
379
void _NPN_SetException(NPObject*, const NPUTF8* message)
379
380
{
380
 
    // FIXME:
381
 
    // Bug 19888: Implement _NPN_SetException() correctly
382
 
    // <https://bugs.webkit.org/show_bug.cgi?id=19888>
 
381
    // Ignorning the NPObject param is consistent with the Mozilla implementation.
 
382
    UString exception(message);
 
383
    CInstance::setGlobalException(exception);
383
384
}
384
385
 
385
386
bool _NPN_Enumerate(NPP, NPObject* o, NPIdentifier** identifier, uint32_t* count)
392
393
            return false;
393
394
        
394
395
        ExecState* exec = rootObject->globalObject()->globalExec();
395
 
        JSLock lock(false);
 
396
        JSLock lock(SilenceAssertionsOnly);
396
397
        PropertyNameArray propertyNames(exec);
397
398
 
398
399
        obj->imp->getPropertyNames(exec, propertyNames);
429
430
            return false;
430
431
        
431
432
        ExecState* exec = rootObject->globalObject()->globalExec();
432
 
        JSLock lock(false);
 
433
        JSLock lock(SilenceAssertionsOnly);
433
434
        
434
435
        // Call the constructor object.
435
 
        JSValuePtr constructor = obj->imp;
 
436
        JSValue constructor = obj->imp;
436
437
        ConstructData constructData;
437
 
        ConstructType constructType = constructor->getConstructData(constructData);
 
438
        ConstructType constructType = constructor.getConstructData(constructData);
438
439
        if (constructType == ConstructTypeNone)
439
440
            return false;
440
441
        
441
 
        ArgList argList;
 
442
        MarkedArgumentBuffer argList;
442
443
        getListFromVariantArgs(exec, args, argCount, rootObject, argList);
443
444
        ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
444
 
        globalObject->startTimeoutCheck();
445
 
        JSValuePtr resultV = construct(exec, constructor, constructType, constructData, argList);
446
 
        globalObject->stopTimeoutCheck();
 
445
        globalObject->globalData()->timeoutChecker.start();
 
446
        JSValue resultV = construct(exec, constructor, constructType, constructData, argList);
 
447
        globalObject->globalData()->timeoutChecker.stop();
447
448
        
448
449
        // Convert and return the result.
449
450
        convertValueToNPVariant(exec, resultV, result);