Diff
Modified: trunk/Source/WebCore/ChangeLog (136167 => 136168)
--- trunk/Source/WebCore/ChangeLog 2012-11-29 22:34:18 UTC (rev 136167)
+++ trunk/Source/WebCore/ChangeLog 2012-11-29 22:59:14 UTC (rev 136168)
@@ -1,3 +1,21 @@
+2012-11-29 Adam Barth <[email protected]>
+
+ [V8] DOM callbacks shouldn't reimplement ScopedPersistent they should use it
+ https://bugs.webkit.org/show_bug.cgi?id=103662
+
+ Reviewed by Eric Seidel.
+
+ This patch replaces yet another instance of the ScopedPersistent
+ pattern with ScopedPersistent.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateCallbackHeader):
+ (GenerateCallbackImplementation):
+ * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp:
+ (WebCore::V8SQLStatementErrorCallback::handleEvent):
+ * bindings/v8/custom/V8MutationCallbackCustom.cpp:
+ (WebCore::V8MutationCallback::handleEvent):
+
2012-11-29 Min Qin <[email protected]>
Make LazyDecodingPixelRef inherit from skia::LazyPixelRef so that cc thread can access it
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (136167 => 136168)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-11-29 22:34:18 UTC (rev 136167)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-11-29 22:59:14 UTC (rev 136168)
@@ -3263,6 +3263,7 @@
my @unsortedIncludes = ();
push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\"");
push(@unsortedIncludes, "#include \"$interfaceName.h\"");
+ push(@unsortedIncludes, "#include \"ScopedPersistent.h\"");
push(@unsortedIncludes, "#include \"WorldContextHandle.h\"");
push(@unsortedIncludes, "#include <v8.h>");
push(@unsortedIncludes, "#include <wtf/Forward.h>");
@@ -3315,12 +3316,10 @@
static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter)
{
${v8InterfaceName}* object = static_cast<${v8InterfaceName}*>(parameter);
- object->m_callback.Dispose();
- object->m_callback.Clear();
+ object->m_callback.clear();
}
- // FIXME: m_callback should be a ScopedPersistent.
- v8::Persistent<v8::Object> m_callback;
+ ScopedPersistent<v8::Object> m_callback;
WorldContextHandle m_worldContext;
};
@@ -3352,19 +3351,17 @@
push(@implContent, <<END);
${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
: ActiveDOMCallback(context)
- , m_callback(v8::Persistent<v8::Object>::New(callback))
+ , m_callback(callback)
, m_worldContext(UseCurrentWorld)
{
- if (!owner.IsEmpty()) {
- owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
- m_callback.MakeWeak(this, &${v8InterfaceName}::weakCallback);
- }
+ if (owner.IsEmpty())
+ return;
+ owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
+ m_callback.get().MakeWeak(this, &${v8InterfaceName}::weakCallback);
}
${v8InterfaceName}::~${v8InterfaceName}()
{
- if (!m_callback.IsEmpty())
- m_callback.Dispose();
}
END
@@ -3434,11 +3431,11 @@
foreach my $param (@params) {
next if $param->type ne $thisType;
my $paramName = $param->name;
- push(@implContent, " return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(${paramName}Handle), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
+ push(@implContent, " return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(${paramName}Handle), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
last;
}
} else {
- push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
+ push(@implContent, " return !invokeCallback(m_callback.get(), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
}
push(@implContent, "}\n");
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp (136167 => 136168)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp 2012-11-29 22:34:18 UTC (rev 136167)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp 2012-11-29 22:59:14 UTC (rev 136168)
@@ -41,19 +41,17 @@
V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
: ActiveDOMCallback(context)
- , m_callback(v8::Persistent<v8::Object>::New(callback))
+ , m_callback(callback)
, m_worldContext(UseCurrentWorld)
{
- if (!owner.IsEmpty()) {
- owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
- m_callback.MakeWeak(this, &V8TestCallback::weakCallback);
- }
+ if (owner.IsEmpty())
+ return;
+ owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
+ m_callback.get().MakeWeak(this, &V8TestCallback::weakCallback);
}
V8TestCallback::~V8TestCallback()
{
- if (!m_callback.IsEmpty())
- m_callback.Dispose();
}
// Functions
@@ -75,7 +73,7 @@
v8::Handle<v8::Value> *argv = 0;
bool callbackReturnValue = false;
- return !invokeCallback(m_callback, 0, argv, callbackReturnValue, scriptExecutionContext());
+ return !invokeCallback(m_callback.get(), 0, argv, callbackReturnValue, scriptExecutionContext());
}
bool V8TestCallback::callbackWithClass1Param(Class1* class1Param)
@@ -103,7 +101,7 @@
};
bool callbackReturnValue = false;
- return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
+ return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
}
bool V8TestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg)
@@ -138,7 +136,7 @@
};
bool callbackReturnValue = false;
- return !invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext());
+ return !invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext());
}
bool V8TestCallback::callbackWithStringList(RefPtr<DOMStringList> listParam)
@@ -166,7 +164,7 @@
};
bool callbackReturnValue = false;
- return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
+ return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
}
bool V8TestCallback::callbackWithBoolean(bool boolParam)
@@ -194,7 +192,7 @@
};
bool callbackReturnValue = false;
- return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
+ return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
}
bool V8TestCallback::callbackRequiresThisToPass(Class8* class8Param, ThisClass* thisClassParam)
@@ -231,7 +229,7 @@
};
bool callbackReturnValue = false;
- return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(thisClassParamHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
+ return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(thisClassParamHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h (136167 => 136168)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h 2012-11-29 22:34:18 UTC (rev 136167)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h 2012-11-29 22:59:14 UTC (rev 136168)
@@ -24,6 +24,7 @@
#define V8TestCallback_h
#include "ActiveDOMCallback.h"
+#include "ScopedPersistent.h"
#include "TestCallback.h"
#include "WorldContextHandle.h"
#include <v8.h>
@@ -60,12 +61,10 @@
static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter)
{
V8TestCallback* object = static_cast<V8TestCallback*>(parameter);
- object->m_callback.Dispose();
- object->m_callback.Clear();
+ object->m_callback.clear();
}
- // FIXME: m_callback should be a ScopedPersistent.
- v8::Persistent<v8::Object> m_callback;
+ ScopedPersistent<v8::Object> m_callback;
WorldContextHandle m_worldContext;
};
Modified: trunk/Source/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp (136167 => 136168)
--- trunk/Source/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp 2012-11-29 22:34:18 UTC (rev 136167)
+++ trunk/Source/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp 2012-11-29 22:59:14 UTC (rev 136168)
@@ -73,7 +73,7 @@
// statement, if any, or onto the next overall step otherwise. Otherwise,
// the error callback did not return false, or there was no error callback.
// Jump to the last step in the overall steps.
- return invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext()) || callbackReturnValue;
+ return invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext()) || callbackReturnValue;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp (136167 => 136168)
--- trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp 2012-11-29 22:34:18 UTC (rev 136167)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp 2012-11-29 22:59:14 UTC (rev 136168)
@@ -83,7 +83,7 @@
};
bool callbackReturnValue = false;
- return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
+ return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
}
} // namespace WebCore