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

Unified Diff: Source/WebCore/bindings/v8/NPV8Object.cpp

Issue 9250027: Merge 103979 - v8 binding: npCreateV8ScriptObject() should not returned an existing V8NPObject if... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 11 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 | « LayoutTests/http/tests/plugins/resources/create-v8-script-objects-iframe.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/bindings/v8/NPV8Object.cpp
===================================================================
--- Source/WebCore/bindings/v8/NPV8Object.cpp (revision 105350)
+++ Source/WebCore/bindings/v8/NPV8Object.cpp (working copy)
@@ -57,7 +57,8 @@
return &typeInfo;
}
-typedef HashMap<int, V8NPObject*> V8NPObjectMap;
+typedef Vector<V8NPObject*> V8NPObjectVector;
+typedef HashMap<int, V8NPObjectVector> V8NPObjectMap;
static V8NPObjectMap* staticV8NPObjectMap()
{
@@ -75,8 +76,19 @@
{
V8NPObject* v8NpObject = reinterpret_cast<V8NPObject*>(npObject);
if (int v8ObjectHash = v8NpObject->v8Object->GetIdentityHash()) {
- ASSERT(staticV8NPObjectMap()->contains(v8ObjectHash));
- staticV8NPObjectMap()->remove(v8ObjectHash);
+ V8NPObjectMap::iterator iter = staticV8NPObjectMap()->find(v8ObjectHash);
+ if (iter != staticV8NPObjectMap()->end()) {
+ V8NPObjectVector& objects = iter->second;
+ for (size_t index = 0; index < objects.size(); ++index) {
+ if (objects.at(index) == v8NpObject) {
+ objects.remove(index);
+ break;
+ }
+ }
+ if (objects.isEmpty())
+ staticV8NPObjectMap()->remove(v8ObjectHash);
+ } else
+ ASSERT_NOT_REACHED();
} else {
ASSERT(!v8::Context::InContext());
staticV8NPObjectMap()->clear();
@@ -139,11 +151,19 @@
int v8ObjectHash = object->GetIdentityHash();
ASSERT(v8ObjectHash);
- if (staticV8NPObjectMap()->contains(v8ObjectHash)) {
- V8NPObject* v8npObject = staticV8NPObjectMap()->get(v8ObjectHash);
- ASSERT(v8npObject->v8Object == object);
- _NPN_RetainObject(&v8npObject->object);
- return reinterpret_cast<NPObject*>(v8npObject);
+ V8NPObjectMap::iterator iter = staticV8NPObjectMap()->find(v8ObjectHash);
+ if (iter != staticV8NPObjectMap()->end()) {
+ V8NPObjectVector& objects = iter->second;
+ for (size_t index = 0; index < objects.size(); ++index) {
+ V8NPObject* v8npObject = objects.at(index);
+ if (v8npObject->rootObject == root) {
+ ASSERT(v8npObject->v8Object == object);
+ _NPN_RetainObject(&v8npObject->object);
+ return reinterpret_cast<NPObject*>(v8npObject);
+ }
+ }
+ } else {
+ iter = staticV8NPObjectMap()->set(v8ObjectHash, V8NPObjectVector()).first;
}
V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp, &V8NPObjectClass));
@@ -153,7 +173,7 @@
#endif
v8npObject->rootObject = root;
- staticV8NPObjectMap()->set(v8ObjectHash, v8npObject);
+ iter->second.append(v8npObject);
return reinterpret_cast<NPObject*>(v8npObject);
}
« no previous file with comments | « LayoutTests/http/tests/plugins/resources/create-v8-script-objects-iframe.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698