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

Side by Side Diff: webkit/port/bindings/v8/v8_npobject.cpp

Issue 14031: Fix for http://code.google.com/p/chromium/issues/detail?id=5409.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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 | Annotate | Revision Log
« no previous file with comments | « webkit/port/bindings/v8/v8_helpers.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // 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 11 matching lines...) Expand all
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 #include "config.h" 30 #include "config.h"
31 31
32 #include "v8_custom.h"
32 #include "v8_helpers.h" 33 #include "v8_helpers.h"
33 #include "v8_npobject.h" 34 #include "v8_npobject.h"
34 #include "v8_np_utils.h" 35 #include "v8_np_utils.h"
35 #include "np_v8object.h" 36 #include "np_v8object.h"
36 #include "npruntime_priv.h" 37 #include "npruntime_priv.h"
37 #include "v8_proxy.h" 38 #include "v8_proxy.h"
38 #include "dom_wrapper_map.h" 39 #include "dom_wrapper_map.h"
39 #include "HTMLPlugInElement.h" 40 #include "HTMLPlugInElement.h"
40 #include "V8HTMLAppletElement.h" 41 #include "V8HTMLAppletElement.h"
41 #include "V8HTMLEmbedElement.h" 42 #include "V8HTMLEmbedElement.h"
(...skipping 23 matching lines...) Expand all
65 if (script_instance) { 66 if (script_instance) {
66 npobject = V8Proxy::ToNativeObject<NPObject>( 67 npobject = V8Proxy::ToNativeObject<NPObject>(
67 V8ClassIndex::NPOBJECT, script_instance->instance()); 68 V8ClassIndex::NPOBJECT, script_instance->instance());
68 } else { 69 } else {
69 npobject = NULL; 70 npobject = NULL;
70 } 71 }
71 72
72 } else { 73 } else {
73 // The holder object is not a subtype of HTMLPlugInElement, it 74 // The holder object is not a subtype of HTMLPlugInElement, it
74 // must be an NPObject which has three internal fields. 75 // must be an NPObject which has three internal fields.
75 if (args.Holder()->InternalFieldCount() != 3) { 76 if (args.Holder()->InternalFieldCount() !=
77 V8Custom::kNPObjectInternalFieldCount) {
76 V8Proxy::ThrowError(V8Proxy::REFERENCE_ERROR, 78 V8Proxy::ThrowError(V8Proxy::REFERENCE_ERROR,
77 "NPMethod called on non-NPObject"); 79 "NPMethod called on non-NPObject");
78 return v8::Undefined(); 80 return v8::Undefined();
79 } 81 }
80 npobject = V8Proxy::ToNativeObject<NPObject>( 82 npobject = V8Proxy::ToNativeObject<NPObject>(
81 V8ClassIndex::NPOBJECT, args.Holder()); 83 V8ClassIndex::NPOBJECT, args.Holder());
82 } 84 }
83 85
84 // Verify that our wrapper wasn't using a NPObject which 86 // Verify that our wrapper wasn't using a NPObject which
85 // has already been deleted. 87 // has already been deleted.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return v8::Local<v8::Object>::New(static_npobject_map.get(object)); 324 return v8::Local<v8::Object>::New(static_npobject_map.get(object));
323 325
324 // TODO: we should create a Wrapper type as a subclass of JSObject. 326 // TODO: we should create a Wrapper type as a subclass of JSObject.
325 // It has two internal fields, field 0 is the wrapped pointer, 327 // It has two internal fields, field 0 is the wrapped pointer,
326 // and field 1 is the type. There should be an api function that 328 // and field 1 is the type. There should be an api function that
327 // returns unused type id. 329 // returns unused type id.
328 // The same Wrapper type can be used by DOM bindings. 330 // The same Wrapper type can be used by DOM bindings.
329 if (np_object_desc.IsEmpty()) { 331 if (np_object_desc.IsEmpty()) {
330 np_object_desc = 332 np_object_desc =
331 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New()); 333 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New());
332 np_object_desc->InstanceTemplate()->SetInternalFieldCount(3); 334 np_object_desc->InstanceTemplate()->SetInternalFieldCount(
335 V8Custom::kNPObjectInternalFieldCount);
333 np_object_desc->InstanceTemplate()->SetNamedPropertyHandler( 336 np_object_desc->InstanceTemplate()->SetNamedPropertyHandler(
334 NPObjectNamedPropertyGetter, NPObjectNamedPropertySetter); 337 NPObjectNamedPropertyGetter, NPObjectNamedPropertySetter);
335 np_object_desc->InstanceTemplate()->SetIndexedPropertyHandler( 338 np_object_desc->InstanceTemplate()->SetIndexedPropertyHandler(
336 NPObjectIndexedPropertyGetter, NPObjectIndexedPropertySetter); 339 NPObjectIndexedPropertyGetter, NPObjectIndexedPropertySetter);
337 np_object_desc->InstanceTemplate()->SetCallAsFunctionHandler( 340 np_object_desc->InstanceTemplate()->SetCallAsFunctionHandler(
338 NPObjectInvokeDefaultHandler); 341 NPObjectInvokeDefaultHandler);
339 } 342 }
340 343
341 v8::Handle<v8::Function> func = np_object_desc->GetFunction(); 344 v8::Handle<v8::Function> func = np_object_desc->GetFunction();
342 v8::Local<v8::Object> value = SafeAllocation::NewInstance(func); 345 v8::Local<v8::Object> value = SafeAllocation::NewInstance(func);
(...skipping 20 matching lines...) Expand all
363 void ForgetV8ObjectForNPObject(NPObject* object) { 366 void ForgetV8ObjectForNPObject(NPObject* object) {
364 if (static_npobject_map.contains(object)) { 367 if (static_npobject_map.contains(object)) {
365 v8::HandleScope scope; 368 v8::HandleScope scope;
366 v8::Persistent<v8::Object> handle(static_npobject_map.get(object)); 369 v8::Persistent<v8::Object> handle(static_npobject_map.get(object));
367 WebCore::V8Proxy::SetDOMWrapper(handle, 370 WebCore::V8Proxy::SetDOMWrapper(handle,
368 WebCore::V8ClassIndex::NPOBJECT, NULL); 371 WebCore::V8ClassIndex::NPOBJECT, NULL);
369 static_npobject_map.forget(object); 372 static_npobject_map.forget(object);
370 NPN_ReleaseObject(object); 373 NPN_ReleaseObject(object);
371 } 374 }
372 } 375 }
OLDNEW
« no previous file with comments | « webkit/port/bindings/v8/v8_helpers.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698