OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 }; | 66 }; |
67 | 67 |
68 // FIXME: need comments. | 68 // FIXME: need comments. |
69 // Params: holder could be HTMLEmbedElement or NPObject | 69 // Params: holder could be HTMLEmbedElement or NPObject |
70 static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
InvokeFunctionType functionId) | 70 static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
InvokeFunctionType functionId) |
71 { | 71 { |
72 NPObject* npObject; | 72 NPObject* npObject; |
73 v8::Isolate* isolate = info.GetIsolate(); | 73 v8::Isolate* isolate = info.GetIsolate(); |
74 | 74 |
75 // These three types are subtypes of HTMLPlugInElement. | 75 // These three types are subtypes of HTMLPlugInElement. |
76 HTMLPlugInElement* element = V8HTMLAppletElement::toNativeWithTypeCheck(isol
ate, info.Holder()); | 76 HTMLPlugInElement* element = V8HTMLAppletElement::toImplWithTypeCheck(isolat
e, info.Holder()); |
77 if (!element) { | 77 if (!element) { |
78 element = V8HTMLEmbedElement::toNativeWithTypeCheck(isolate, info.Holder
()); | 78 element = V8HTMLEmbedElement::toImplWithTypeCheck(isolate, info.Holder()
); |
79 if (!element) { | 79 if (!element) { |
80 element = V8HTMLObjectElement::toNativeWithTypeCheck(isolate, info.H
older()); | 80 element = V8HTMLObjectElement::toImplWithTypeCheck(isolate, info.Hol
der()); |
81 } | 81 } |
82 } | 82 } |
83 if (element) { | 83 if (element) { |
84 if (RefPtr<SharedPersistent<v8::Object> > wrapper = element->pluginWrapp
er()) { | 84 if (RefPtr<SharedPersistent<v8::Object> > wrapper = element->pluginWrapp
er()) { |
85 v8::HandleScope handleScope(isolate); | 85 v8::HandleScope handleScope(isolate); |
86 npObject = v8ObjectToNPObject(wrapper->newLocal(isolate)); | 86 npObject = v8ObjectToNPObject(wrapper->newLocal(isolate)); |
87 } else { | 87 } else { |
88 npObject = 0; | 88 npObject = 0; |
89 } | 89 } |
90 } else { | 90 } else { |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 // FIXME: Move staticNPObjectMap() to DOMDataStore. | 464 // FIXME: Move staticNPObjectMap() to DOMDataStore. |
465 // Use V8DOMWrapper::createWrapper() and | 465 // Use V8DOMWrapper::createWrapper() and |
466 // V8DOMWrapper::associateObjectWithWrapper() | 466 // V8DOMWrapper::associateObjectWithWrapper() |
467 // to create a wrapper object. | 467 // to create a wrapper object. |
468 v8::Handle<v8::Function> v8Function = npObjectDesc.Get(isolate)->GetFunction
(); | 468 v8::Handle<v8::Function> v8Function = npObjectDesc.Get(isolate)->GetFunction
(); |
469 v8::Local<v8::Object> value = V8ObjectConstructor::newInstance(isolate, v8Fu
nction); | 469 v8::Local<v8::Object> value = V8ObjectConstructor::newInstance(isolate, v8Fu
nction); |
470 if (value.IsEmpty()) | 470 if (value.IsEmpty()) |
471 return value; | 471 return value; |
472 | 472 |
473 V8DOMWrapper::setNativeInfo(value, npObjectTypeInfo(), npObjectToInternalPoi
nter(object)); | 473 V8DOMWrapper::setNativeInfo(value, npObjectTypeInfo(), npObjectToScriptWrapp
ableBase(object)); |
474 | 474 |
475 // KJS retains the object as part of its wrapper (see Bindings::CInstance). | 475 // KJS retains the object as part of its wrapper (see Bindings::CInstance). |
476 _NPN_RetainObject(object); | 476 _NPN_RetainObject(object); |
477 _NPN_RegisterObject(object, root); | 477 _NPN_RegisterObject(object, root); |
478 | 478 |
479 staticNPObjectMap().set(object, value, npObjectTypeInfo()); | 479 staticNPObjectMap().set(object, value, npObjectTypeInfo()); |
480 ASSERT(V8DOMWrapper::isDOMWrapper(value)); | 480 ASSERT(V8DOMWrapper::isDOMWrapper(value)); |
481 return value; | 481 return value; |
482 } | 482 } |
483 | 483 |
484 void forgetV8ObjectForNPObject(NPObject* object) | 484 void forgetV8ObjectForNPObject(NPObject* object) |
485 { | 485 { |
486 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 486 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
487 v8::HandleScope scope(isolate); | 487 v8::HandleScope scope(isolate); |
488 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat
e); | 488 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat
e); |
489 if (!wrapper.IsEmpty()) { | 489 if (!wrapper.IsEmpty()) { |
490 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); | 490 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); |
491 staticNPObjectMap().removeAndDispose(object); | 491 staticNPObjectMap().removeAndDispose(object); |
492 _NPN_ReleaseObject(object); | 492 _NPN_ReleaseObject(object); |
493 } | 493 } |
494 } | 494 } |
495 | 495 |
496 } // namespace blink | 496 } // namespace blink |
OLD | NEW |