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, 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 * | 5 * |
5 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
7 * are met: | 8 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
11 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
13 * | 14 * |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 char buffer[32]; | 108 char buffer[32]; |
108 snprintf(buffer, sizeof(buffer), "%d", identifier->value.number); | 109 snprintf(buffer, sizeof(buffer), "%d", identifier->value.number); |
109 return v8AtomicString(isolate, buffer); | 110 return v8AtomicString(isolate, buffer); |
110 } | 111 } |
111 | 112 |
112 NPObject* v8ObjectToNPObject(v8::Handle<v8::Object> object) | 113 NPObject* v8ObjectToNPObject(v8::Handle<v8::Object> object) |
113 { | 114 { |
114 return reinterpret_cast<NPObject*>(object->GetAlignedPointerFromInternalFiel
d(v8DOMWrapperObjectIndex)); | 115 return reinterpret_cast<NPObject*>(object->GetAlignedPointerFromInternalFiel
d(v8DOMWrapperObjectIndex)); |
115 } | 116 } |
116 | 117 |
| 118 bool isWrappedNPObject(v8::Handle<v8::Object> object) |
| 119 { |
| 120 if (object->InternalFieldCount() == npObjectInternalFieldCount) { |
| 121 const WrapperTypeInfo* typeInfo = static_cast<const WrapperTypeInfo*>(ob
ject->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex)); |
| 122 return typeInfo == npObjectTypeInfo(); |
| 123 } |
| 124 return false; |
| 125 } |
| 126 |
117 NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, LocalDO
MWindow* root, v8::Isolate* isolate) | 127 NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, LocalDO
MWindow* root, v8::Isolate* isolate) |
118 { | 128 { |
119 // Check to see if this object is already wrapped. | 129 // Check to see if this object is already wrapped. |
120 if (object->InternalFieldCount() == npObjectInternalFieldCount) { | 130 if (isWrappedNPObject(object)) { |
121 const WrapperTypeInfo* typeInfo = static_cast<const WrapperTypeInfo*>(ob
ject->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex)); | 131 NPObject* returnValue = v8ObjectToNPObject(object); |
122 if (typeInfo == npObjectTypeInfo()) { | 132 _NPN_RetainObject(returnValue); |
123 NPObject* returnValue = v8ObjectToNPObject(object); | 133 return returnValue; |
124 _NPN_RetainObject(returnValue); | |
125 return returnValue; | |
126 } | |
127 } | 134 } |
128 | 135 |
129 V8NPObjectVector* objectVector = 0; | 136 V8NPObjectVector* objectVector = 0; |
130 if (V8PerContextData* perContextData = V8PerContextData::from(object->Creati
onContext())) { | 137 if (V8PerContextData* perContextData = V8PerContextData::from(object->Creati
onContext())) { |
131 int v8ObjectHash = object->GetIdentityHash(); | 138 int v8ObjectHash = object->GetIdentityHash(); |
132 ASSERT(v8ObjectHash); | 139 ASSERT(v8ObjectHash); |
133 V8NPObjectMap* v8NPObjectMap = perContextData->v8NPObjectMap(); | 140 V8NPObjectMap* v8NPObjectMap = perContextData->v8NPObjectMap(); |
134 V8NPObjectMap::iterator iter = v8NPObjectMap->find(v8ObjectHash); | 141 V8NPObjectMap::iterator iter = v8NPObjectMap->find(v8ObjectHash); |
135 if (iter != v8NPObjectMap->end()) { | 142 if (iter != v8NPObjectMap->end()) { |
136 V8NPObjectVector& objects = iter->value; | 143 V8NPObjectVector& objects = iter->value; |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 607 |
601 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); | 608 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); |
602 return true; | 609 return true; |
603 } | 610 } |
604 | 611 |
605 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) | 612 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) |
606 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); | 613 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); |
607 | 614 |
608 return false; | 615 return false; |
609 } | 616 } |
OLD | NEW |