Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: Source/bindings/core/v8/NPV8Object.cpp

Issue 1097273002: Refactor core/v8/* methods to take isolate as first parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Initializer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved. 3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved.
4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 ASSERT(npObject->_class == &V8NPObjectClass); 90 ASSERT(npObject->_class == &V8NPObjectClass);
91 V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject); 91 V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject);
92 LocalDOMWindow* window = object->rootObject; 92 LocalDOMWindow* window = object->rootObject;
93 if (!window || !window->isCurrentlyDisplayedInFrame()) 93 if (!window || !window->isCurrentlyDisplayedInFrame())
94 return 0; 94 return 0;
95 v8::HandleScope handleScope(isolate); 95 v8::HandleScope handleScope(isolate);
96 v8::Local<v8::Context> context = toV8Context(object->rootObject->frame(), DO MWrapperWorld::mainWorld()); 96 v8::Local<v8::Context> context = toV8Context(object->rootObject->frame(), DO MWrapperWorld::mainWorld());
97 return ScriptState::from(context); 97 return ScriptState::from(context);
98 } 98 }
99 99
100 static PassOwnPtr<v8::Local<v8::Value>[]> createValueListFromVariantArgs(const N PVariant* arguments, uint32_t argumentCount, NPObject* owner, v8::Isolate* isola te) 100 static PassOwnPtr<v8::Local<v8::Value>[]> createValueListFromVariantArgs(v8::Iso late* isolate, const NPVariant* arguments, uint32_t argumentCount, NPObject* own er)
101 { 101 {
102 OwnPtr<v8::Local<v8::Value>[]> argv = adoptArrayPtr(new v8::Local<v8::Value> [argumentCount]); 102 OwnPtr<v8::Local<v8::Value>[]> argv = adoptArrayPtr(new v8::Local<v8::Value> [argumentCount]);
103 for (uint32_t index = 0; index < argumentCount; index++) { 103 for (uint32_t index = 0; index < argumentCount; index++) {
104 const NPVariant* arg = &arguments[index]; 104 const NPVariant* arg = &arguments[index];
105 argv[index] = convertNPVariantToV8Object(isolate, arg, owner); 105 argv[index] = convertNPVariantToV8Object(isolate, arg, owner);
106 } 106 }
107 return argv.release(); 107 return argv.release();
108 } 108 }
109 109
110 // Create an identifier (null terminated utf8 char*) from the NPIdentifier. 110 // Create an identifier (null terminated utf8 char*) from the NPIdentifier.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 if (functionObject->IsUndefined()) { 265 if (functionObject->IsUndefined()) {
266 VOID_TO_NPVARIANT(*result); 266 VOID_TO_NPVARIANT(*result);
267 return false; 267 return false;
268 } 268 }
269 269
270 LocalFrame* frame = v8NpObject->rootObject->frame(); 270 LocalFrame* frame = v8NpObject->rootObject->frame();
271 ASSERT(frame); 271 ASSERT(frame);
272 272
273 // Call the function object. 273 // Call the function object.
274 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionObj ect); 274 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionObj ect);
275 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(argumen ts, argumentCount, npObject, isolate); 275 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(isolate , arguments, argumentCount, npObject);
276 v8::Local<v8::Value> resultObject = frame->script().callFunction(function, v 8Object, argumentCount, argv.get()); 276 v8::Local<v8::Value> resultObject = frame->script().callFunction(function, v 8Object, argumentCount, argv.get());
277 277
278 // If we had an error, return false. The spec is a little unclear here, but says "Returns true if the method was 278 // If we had an error, return false. The spec is a little unclear here, but says "Returns true if the method was
279 // successfully invoked". If we get an error return value, was that success fully invoked? 279 // successfully invoked". If we get an error return value, was that success fully invoked?
280 if (resultObject.IsEmpty()) 280 if (resultObject.IsEmpty())
281 return false; 281 return false;
282 282
283 convertV8ObjectToNPVariant(isolate, resultObject, npObject, result); 283 convertV8ObjectToNPVariant(isolate, resultObject, npObject, result);
284 return true; 284 return true;
285 } 285 }
(...skipping 28 matching lines...) Expand all
314 v8::Local<v8::Object> functionObject = v8::Local<v8::Object>::New(isolate, v 8NpObject->v8Object); 314 v8::Local<v8::Object> functionObject = v8::Local<v8::Object>::New(isolate, v 8NpObject->v8Object);
315 if (!functionObject->IsFunction()) 315 if (!functionObject->IsFunction())
316 return false; 316 return false;
317 317
318 v8::Local<v8::Value> resultObject; 318 v8::Local<v8::Value> resultObject;
319 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionObj ect); 319 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(functionObj ect);
320 if (!function->IsNull()) { 320 if (!function->IsNull()) {
321 LocalFrame* frame = v8NpObject->rootObject->frame(); 321 LocalFrame* frame = v8NpObject->rootObject->frame();
322 ASSERT(frame); 322 ASSERT(frame);
323 323
324 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(arg uments, argumentCount, npObject, isolate); 324 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(iso late, arguments, argumentCount, npObject);
325 resultObject = frame->script().callFunction(function, functionObject, ar gumentCount, argv.get()); 325 resultObject = frame->script().callFunction(function, functionObject, ar gumentCount, argv.get());
326 } 326 }
327 // If we had an error, return false. The spec is a little unclear here, but says "Returns true if the method was 327 // If we had an error, return false. The spec is a little unclear here, but says "Returns true if the method was
328 // successfully invoked". If we get an error return value, was that success fully invoked? 328 // successfully invoked". If we get an error return value, was that success fully invoked?
329 if (resultObject.IsEmpty()) 329 if (resultObject.IsEmpty())
330 return false; 330 return false;
331 331
332 convertV8ObjectToNPVariant(isolate, resultObject, npObject, result); 332 convertV8ObjectToNPVariant(isolate, resultObject, npObject, result);
333 return true; 333 return true;
334 } 334 }
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 return false; 602 return false;
603 603
604 // Call the constructor. 604 // Call the constructor.
605 v8::Local<v8::Value> resultObject; 605 v8::Local<v8::Value> resultObject;
606 v8::Local<v8::Function> ctor = v8::Local<v8::Function>::Cast(ctorObj); 606 v8::Local<v8::Function> ctor = v8::Local<v8::Function>::Cast(ctorObj);
607 if (ctor->IsNull()) 607 if (ctor->IsNull())
608 return false; 608 return false;
609 609
610 LocalFrame* frame = object->rootObject->frame(); 610 LocalFrame* frame = object->rootObject->frame();
611 ASSERT(frame); 611 ASSERT(frame);
612 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(arg uments, argumentCount, npObject, scriptState->isolate()); 612 OwnPtr<v8::Local<v8::Value>[]> argv = createValueListFromVariantArgs(scr iptState->isolate(), arguments, argumentCount, npObject);
613 if (!V8ObjectConstructor::newInstanceInDocument(scriptState->isolate(), ctor, argumentCount, argv.get(), frame ? frame->document() : 0).ToLocal(&resultO bject)) 613 if (!V8ObjectConstructor::newInstanceInDocument(scriptState->isolate(), ctor, argumentCount, argv.get(), frame ? frame->document() : 0).ToLocal(&resultO bject))
614 return false; 614 return false;
615 615
616 convertV8ObjectToNPVariant(scriptState->isolate(), resultObject, npObjec t, result); 616 convertV8ObjectToNPVariant(scriptState->isolate(), resultObject, npObjec t, result);
617 return true; 617 return true;
618 } 618 }
619 619
620 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class-> construct) 620 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class-> construct)
621 return npObject->_class->construct(npObject, arguments, argumentCount, r esult); 621 return npObject->_class->construct(npObject, arguments, argumentCount, r esult);
622 622
623 return false; 623 return false;
624 } 624 }
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Initializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698