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

Unified Diff: Source/bindings/v8/V8NPObject.cpp

Issue 171533006: V8 Binding: Introduce toNativeWithTypeCheck (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/IDBBindingUtilities.cpp ('k') | Source/bindings/v8/custom/V8ArrayBufferCustom.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/V8NPObject.cpp
diff --git a/Source/bindings/v8/V8NPObject.cpp b/Source/bindings/v8/V8NPObject.cpp
index 3899c672670d64a6e4c4366656fea1adb6f7f7e9..a3f8ab7566c8219ff8ac88292599c05ee6b53164 100644
--- a/Source/bindings/v8/V8NPObject.cpp
+++ b/Source/bindings/v8/V8NPObject.cpp
@@ -69,20 +69,18 @@ struct IdentifierRep {
static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& info, InvokeFunctionType functionId)
{
NPObject* npObject;
+ v8::Isolate* isolate = info.GetIsolate();
// These three types are subtypes of HTMLPlugInElement.
- if (V8HTMLAppletElement::hasInstance(info.Holder(), info.GetIsolate()) || V8HTMLEmbedElement::hasInstance(info.Holder(), info.GetIsolate())
- || V8HTMLObjectElement::hasInstance(info.Holder(), info.GetIsolate())) {
- // The holder object is a subtype of HTMLPlugInElement.
- HTMLPlugInElement* element;
- if (V8HTMLAppletElement::hasInstance(info.Holder(), info.GetIsolate()))
- element = V8HTMLAppletElement::toNative(info.Holder());
- else if (V8HTMLEmbedElement::hasInstance(info.Holder(), info.GetIsolate()))
- element = V8HTMLEmbedElement::toNative(info.Holder());
- else
- element = V8HTMLObjectElement::toNative(info.Holder());
+ HTMLPlugInElement* element = V8HTMLAppletElement::toNativeWithTypeCheck(isolate, info.Holder());
+ if (!element) {
+ element = V8HTMLEmbedElement::toNativeWithTypeCheck(isolate, info.Holder());
+ if (!element) {
+ element = V8HTMLObjectElement::toNativeWithTypeCheck(isolate, info.Holder());
+ }
+ }
+ if (element) {
if (RefPtr<SharedPersistent<v8::Object> > wrapper = element->pluginWrapper()) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
npObject = v8ObjectToNPObject(wrapper->newLocal(isolate));
} else
@@ -100,7 +98,7 @@ static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
// Verify that our wrapper wasn't using a NPObject which has already been deleted.
if (!npObject || !_NPN_IsAlive(npObject)) {
- throwError(v8ReferenceError, "NPObject deleted", info.GetIsolate());
+ throwError(v8ReferenceError, "NPObject deleted", isolate);
return;
}
@@ -109,7 +107,7 @@ static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
OwnPtr<NPVariant[]> npArgs = adoptArrayPtr(new NPVariant[numArgs]);
for (int i = 0; i < numArgs; i++)
- convertV8ObjectToNPVariant(info[i], npObject, &npArgs[i], info.GetIsolate());
+ convertV8ObjectToNPVariant(info[i], npObject, &npArgs[i], isolate);
NPVariant result;
VOID_TO_NPVARIANT(result);
@@ -136,7 +134,7 @@ static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
}
if (!retval)
- throwError(v8GeneralError, "Error calling method on NPObject.", info.GetIsolate());
+ throwError(v8GeneralError, "Error calling method on NPObject.", isolate);
for (int i = 0; i < numArgs; i++)
_NPN_ReleaseVariantValue(&npArgs[i]);
@@ -144,7 +142,7 @@ static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
// Unwrap return values.
v8::Handle<v8::Value> returnValue;
if (_NPN_IsAlive(npObject))
- returnValue = convertNPVariantToV8Object(&result, npObject, info.GetIsolate());
+ returnValue = convertNPVariantToV8Object(&result, npObject, isolate);
_NPN_ReleaseVariantValue(&result);
v8SetReturnValue(info, returnValue);
« no previous file with comments | « Source/bindings/v8/IDBBindingUtilities.cpp ('k') | Source/bindings/v8/custom/V8ArrayBufferCustom.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698