Don't leak Documents when using MutationObserver from extensions
[WebKit-https.git] / Source / WebCore / bindings / v8 / V8MutationCallback.cpp
index 7ed3961cab1358c310a349bd951ec2aa6fae5d43..ad99a6b871e51fd5624c5e1a66c14f321a539527 100644 (file)
 
 namespace WebCore {
 
-V8MutationCallback::V8MutationCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
+V8MutationCallback::V8MutationCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
     : ActiveDOMCallback(context)
     , m_callback(callback)
-    , m_worldContext(UseCurrentWorld)
+    , m_world(DOMWrapperWorld::getWorld(v8::Context::GetCurrent()))
 {
     owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
-    m_callback.get().MakeWeak(this, &V8MutationCallback::weakCallback);
+    m_callback.get().MakeWeak(isolate, this, &V8MutationCallback::weakCallback);
 }
 
 bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, MutationObserver* observer)
@@ -55,7 +55,7 @@ bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, MutationObs
 
     v8::HandleScope handleScope;
 
-    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
+    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
     if (v8Context.IsEmpty())
         return true;