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

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: Minor rebase nits. Created 7 years, 5 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 | « Source/bindings/v8/V8HiddenPropertyName.h ('k') | Source/bindings/v8/custom/V8MessageEventCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a2d581635ba5c27287f115a4d3f94073b173b1af 100644
--- a/Source/bindings/v8/custom/V8CustomEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8CustomEventCustom.cpp
@@ -45,20 +45,46 @@
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)
{
- 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(), v8::Null(info.GetIsolate())));
+}
+
+void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ CustomEvent* event = V8CustomEvent::toNative(args.Holder());
+
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, typeArg, args[0]);
+ V8TRYCATCH_VOID(bool, canBubbleArg, args[1]->BooleanValue());
+ V8TRYCATCH_VOID(bool, cancelableArg, args[2]->BooleanValue());
+ v8::Handle<v8::Value> detailsArg = args[3];
+
+ args.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), detailsArg);
+ event->initEvent(typeArg, canBubbleArg, cancelableArg);
}
} // namespace WebCore
« no previous file with comments | « Source/bindings/v8/V8HiddenPropertyName.h ('k') | Source/bindings/v8/custom/V8MessageEventCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698