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

Unified Diff: Source/bindings/v8/custom/V8CustomEventCustom.cpp

Issue 17063016: Remove leak of objects between isolated worlds on custom events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reverted to version that expects GetHiddenValue to not return an empty Handle for undefined Created 7 years, 6 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
Index: Source/bindings/v8/custom/V8CustomEventCustom.cpp
diff --git a/Source/bindings/v8/custom/V8CustomEventCustom.cpp b/Source/bindings/v8/custom/V8CustomEventCustom.cpp
index ff0f9b355c75a404d34f7125047a40ec5070b14d..57c2d8dd46bf66c6e5886362f58e57211feafa67 100644
--- a/Source/bindings/v8/custom/V8CustomEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8CustomEventCustom.cpp
@@ -45,20 +45,45 @@
namespace WebCore {
+static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> customEvent, v8::Handle<v8::Value> detail)
+{
+ customEvent->SetHiddenValue(V8HiddenPropertyName::detail(), detail);
+ return detail;
+}
+
+
void V8CustomEvent::detailAttrGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
haraken 2013/06/27 04:50:27 Why does this method need to be custom? I guess th
jww 2013/06/27 17:44:42 This function has always been custom (in fact, it
haraken 2013/06/28 00:08:01 I'd guess it's worth auto-generating this method,
{
- CustomEvent* imp = V8CustomEvent::toNative(info.Holder());
- RefPtr<SerializedScriptValue> serialized = imp->serializedScriptValue();
+ CustomEvent* event = V8CustomEvent::toNative(info.Holder());
+ ASSERT(!event->serializedScriptValue().get());
+
+ v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::detail());
+
+ if (!result.IsEmpty()) {
+ v8SetReturnValue(info, result);
+ return;
+ }
+
+ RefPtr<SerializedScriptValue> serialized = event->serializedScriptValue();
if (serialized) {
- v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(V8HiddenPropertyName::detail());
- if (value.IsEmpty()) {
- value = serialized->deserialize();
- info.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), value);
- }
- v8SetReturnValue(info, value);
+ result = serialized->deserialize();
+ v8SetReturnValue(info, cacheState(info.Holder(), result));
return;
}
- v8SetReturnValue(info, imp->detail().v8Value());
+
+ v8SetReturnValue(info, cacheState(info.Holder(), v8Null(info.GetIsolate())));
+}
+
+void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ CustomEvent* event = V8CustomEvent::toNative(args.Holder());
+ String typeArg = toWebCoreString(args[0]);
haraken 2013/06/27 04:50:27 You should use V8TRYCATCH_FOR_V8STRINGRESOURCE_VOI
jww 2013/06/27 17:44:42 Done.
+ bool canBubbleArg = args[1]->BooleanValue();
haraken 2013/06/27 04:50:27 You should use V8TRYCATCH_VOID().
jww 2013/06/27 17:44:42 Done.
+ bool cancelableArg = args[2]->BooleanValue();
haraken 2013/06/27 04:50:27 Ditto.
jww 2013/06/27 17:44:42 Done.
+ v8::Handle<v8::Value> detailsArg = args[3];
+
+ args.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), detailsArg);
+ event->initEvent(typeArg, canBubbleArg, cancelableArg);
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698