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

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: 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..44d3daea5d5a6d7a41c68478544cd4408db7da59 100644
--- a/Source/bindings/v8/custom/V8CustomEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8CustomEventCustom.cpp
@@ -45,6 +45,32 @@
namespace WebCore {
+void V8CustomEvent::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
haraken 2013/06/22 13:16:46 We don't want to increase custom bindings, which a
jww 2013/06/25 01:50:29 Good idea. I'v generalized the constructor to take
+{
+ if (args.Length() < 1) {
+ throwNotEnoughArgumentsError(args.GetIsolate());
+ return;
+ }
+
+ String type = toWebCoreString(args[0]);
+ CustomEventInit eventInit;
+
+ if (args.Length() >= 2) {
+ Dictionary options = Dictionary(args[1], args.GetIsolate());
adamk 2013/06/22 01:00:04 This syntax looks odd to me, can you get rid of th
jww 2013/06/25 01:50:29 Done.
+ if (!fillEventInit(eventInit, options))
+ return;
+ v8::Local<v8::Value> detail;
+ options.getKey("detail", detail);
+ args.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), detail);
adamk 2013/06/22 01:00:04 Guard this with an if() check on the above? Or at
jww 2013/06/25 01:50:29 I wrapped the "SetHiddenValue" with an "if" check
+ }
+
+ RefPtr<CustomEvent> event = CustomEvent::create(type, eventInit);
+
+ v8::Handle<v8::Object> wrapper = args.Holder();
+ V8DOMWrapper::associateObjectWithWrapper(event.release(), &V8CustomEvent::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
+ args.GetReturnValue().Set(wrapper);
haraken 2013/06/22 13:16:46 Nit: You can use v8SetRuturnValue().
jww 2013/06/25 01:50:29 Done.
+}
+
void V8CustomEvent::detailAttrGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
CustomEvent* imp = V8CustomEvent::toNative(info.Holder());
@@ -58,7 +84,19 @@ void V8CustomEvent::detailAttrGetterCustom(v8::Local<v8::String> name, const v8:
v8SetReturnValue(info, value);
return;
}
- v8SetReturnValue(info, imp->detail().v8Value());
+ v8SetReturnValue(info, info.Holder()->GetHiddenValue(V8HiddenPropertyName::detail()));
+}
+
+void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
haraken 2013/06/22 13:16:46 Ditto. I hope you can improve the code generator a
jww 2013/06/25 01:50:29 adamk@ and I discussed this, and while we agree th
haraken 2013/06/25 02:06:58 Hmm, I'm neutral about this. I agree that the gene
adamk 2013/06/25 19:10:04 My argument is that we'd have to special case even
haraken 2013/06/25 23:55:30 Good point. It makes sense to keep the code in cus
+{
+ CustomEvent* event = V8CustomEvent::toNative(args.Holder());
adamk 2013/06/22 01:00:04 Can you add an ASSERT() that this event doesn't ha
jww 2013/06/25 01:50:29 Done.
+ String typeArg = toWebCoreString(args[0]);
+ bool canBubbleArg = args[1]->BooleanValue();
+ bool cancelableArg = args[2]->BooleanValue();
+ v8::Handle<v8::Value> detailsArg = args[3];
+
+ args.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), detailsArg);
haraken 2013/06/22 13:16:46 SetHiddenValue affects the lifetime of 'detail'. I
jww 2013/06/25 01:50:29 I think the answer is 'no,' but honestly, I'm not
haraken 2013/06/25 02:06:58 I expect a test that fails if we miss SetHiddenVal
adamk 2013/06/25 19:10:04 The trouble with the old code was that it was leak
haraken 2013/06/25 23:55:30 Regarding GC issues, ideally we should have the fo
+ event->initCustomEvent(typeArg, canBubbleArg, cancelableArg);
adamk 2013/06/22 01:00:04 Can you just call initEvent() here and get rid of
jww 2013/06/25 01:50:29 Done.
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698