| OLD | NEW |
| 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 Google, Inc. All rights reserved. | 3 * Copyright (C) 2007 Google, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include <string> | 31 #include <string> |
| 32 #include <sstream> | 32 #include <sstream> |
| 33 #include <v8.h> | 33 #include <v8.h> |
| 34 #include "np_v8object.h" | 34 #include "np_v8object.h" |
| 35 #include "ChromiumBridge.h" | 35 #include "ChromiumBridge.h" |
| 36 #include "Frame.h" | 36 #include "Frame.h" |
| 37 #include "bindings/npruntime.h" | 37 #include "bindings/npruntime.h" |
| 38 #include "npruntime_priv.h" | 38 #include "npruntime_priv.h" |
| 39 #include "PlatformString.h" | 39 #include "PlatformString.h" |
| 40 #include "ScriptController.h" | 40 #include "ScriptController.h" |
| 41 #include "v8_custom.h" |
| 41 #include "v8_helpers.h" | 42 #include "v8_helpers.h" |
| 42 #include "v8_np_utils.h" | 43 #include "v8_np_utils.h" |
| 43 #include "v8_proxy.h" | 44 #include "v8_proxy.h" |
| 44 #include "DOMWindow.h" | 45 #include "DOMWindow.h" |
| 45 | 46 |
| 46 using WebCore::V8ClassIndex; | 47 using WebCore::V8ClassIndex; |
| 48 using WebCore::V8Custom; |
| 47 using WebCore::V8Proxy; | 49 using WebCore::V8Proxy; |
| 48 | 50 |
| 49 namespace { | 51 namespace { |
| 50 | 52 |
| 51 // TODO(mbelshe): comments on why use malloc and free. | 53 // TODO(mbelshe): comments on why use malloc and free. |
| 52 static NPObject* AllocV8NPObject(NPP, NPClass*) { | 54 static NPObject* AllocV8NPObject(NPP, NPClass*) { |
| 53 return static_cast<NPObject*>(malloc(sizeof(V8NPObject))); | 55 return static_cast<NPObject*>(malloc(sizeof(V8NPObject))); |
| 54 } | 56 } |
| 55 | 57 |
| 56 static void FreeV8NPObject(NPObject* npobj) { | 58 static void FreeV8NPObject(NPObject* npobj) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } // namespace | 95 } // namespace |
| 94 | 96 |
| 95 // | 97 // |
| 96 // NPAPI's npruntime functions | 98 // NPAPI's npruntime functions |
| 97 // | 99 // |
| 98 NPClass* NPScriptObjectClass = &V8NPObjectClass; | 100 NPClass* NPScriptObjectClass = &V8NPObjectClass; |
| 99 | 101 |
| 100 NPObject* NPN_CreateScriptObject(NPP npp, v8::Handle<v8::Object> object, | 102 NPObject* NPN_CreateScriptObject(NPP npp, v8::Handle<v8::Object> object, |
| 101 WebCore::DOMWindow* root) { | 103 WebCore::DOMWindow* root) { |
| 102 // Check to see if this object is already wrapped. | 104 // Check to see if this object is already wrapped. |
| 103 if (object->InternalFieldCount() == 3 && | 105 if (object->InternalFieldCount() == V8Custom::kNPObjectInternalFieldCount && |
| 104 object->GetInternalField(1)->IsNumber() && | 106 object->GetInternalField(V8Custom::kDOMWrapperTypeIndex)->IsNumber() && |
| 105 object->GetInternalField(1)->Uint32Value() == V8ClassIndex::NPOBJECT) { | 107 object->GetInternalField(V8Custom::kDOMWrapperTypeIndex)->Uint32Value() == |
| 108 V8ClassIndex::NPOBJECT) { |
| 106 NPObject* rv = V8Proxy::ToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, | 109 NPObject* rv = V8Proxy::ToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, |
| 107 object); | 110 object); |
| 108 NPN_RetainObject(rv); | 111 NPN_RetainObject(rv); |
| 109 return rv; | 112 return rv; |
| 110 } | 113 } |
| 111 | 114 |
| 112 V8NPObject* obj = | 115 V8NPObject* obj = |
| 113 reinterpret_cast<V8NPObject*>(NPN_CreateObject(npp, &V8NPObjectClass)); | 116 reinterpret_cast<V8NPObject*>(NPN_CreateObject(npp, &V8NPObjectClass)); |
| 114 obj->v8_object = v8::Persistent<v8::Object>::New(object); | 117 obj->v8_object = v8::Persistent<v8::Object>::New(object); |
| 115 #ifndef NDEBUG | 118 #ifndef NDEBUG |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 return true; | 484 return true; |
| 482 } | 485 } |
| 483 | 486 |
| 484 if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(npobj->_class) && | 487 if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(npobj->_class) && |
| 485 npobj->_class->enumerate) { | 488 npobj->_class->enumerate) { |
| 486 return npobj->_class->enumerate(npobj, identifier, count); | 489 return npobj->_class->enumerate(npobj, identifier, count); |
| 487 } | 490 } |
| 488 | 491 |
| 489 return false; | 492 return false; |
| 490 } | 493 } |
| OLD | NEW |