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

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

Issue 1130763006: IDL: Add any support to IDL dictionary and use it in CustomEventInit (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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/core/v8/ScriptValue.cpp ('k') | Source/bindings/scripts/v8_dictionary.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/custom/V8CustomEventCustom.cpp
diff --git a/Source/bindings/core/v8/custom/V8CustomEventCustom.cpp b/Source/bindings/core/v8/custom/V8CustomEventCustom.cpp
index 29f8d8e26a8d1a0f09c99721ac89f69890f91410..6582206313410403d41cb3a0d143f19a0223234e 100644
--- a/Source/bindings/core/v8/custom/V8CustomEventCustom.cpp
+++ b/Source/bindings/core/v8/custom/V8CustomEventCustom.cpp
@@ -61,27 +61,21 @@ void V8CustomEvent::detailAttributeGetterCustom(const v8::PropertyCallbackInfo<v
return;
}
- if (!event->serializedDetail()) {
- // If we're in an isolated world and the event was created in the main world,
- // we need to find the 'detail' property on the main world wrapper and clone it.
- v8::Local<v8::Value> mainWorldDetail = V8HiddenValue::getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenValue::detail(info.GetIsolate()));
- if (!mainWorldDetail.IsEmpty())
- event->setSerializedDetail(SerializedScriptValueFactory::instance().createAndSwallowExceptions(info.GetIsolate(), mainWorldDetail));
- }
-
- if (event->serializedDetail()) {
- result = event->serializedDetail()->deserialize();
- v8SetReturnValue(info, cacheState(info.GetIsolate(), info.Holder(), result));
- return;
- }
-
- v8SetReturnValue(info, cacheState(info.GetIsolate(), info.Holder(), v8::Null(info.GetIsolate())));
+ // Be careful not to return a V8 value which is created in different world.
+ v8::Local<v8::Value> detail;
+ if (SerializedScriptValue* serializedValue = event->serializedDetail())
+ detail = serializedValue->deserialize();
+ else
+ detail = event->detail().v8ValueFor(ScriptState::current(info.GetIsolate()));
+ // |detail| should be null when it is an empty handle because its default value is null.
+ if (detail.IsEmpty())
+ detail = v8::Null(info.GetIsolate());
+ v8SetReturnValue(info, cacheState(info.GetIsolate(), info.Holder(), detail));
}
void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
CustomEvent* event = V8CustomEvent::toImpl(info.Holder());
- ASSERT(!event->serializedDetail());
TOSTRING_VOID(V8StringResource<>, typeArg, info[0]);
bool canBubbleArg;
@@ -92,12 +86,7 @@ void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v
v8::Local<v8::Value> detailsArg = info[3];
event->initEvent(typeArg, canBubbleArg, cancelableArg);
-
- if (!detailsArg.IsEmpty()) {
- V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::detail(info.GetIsolate()), detailsArg);
- if (DOMWrapperWorld::current(info.GetIsolate()).isIsolatedWorld())
- event->setSerializedDetail(SerializedScriptValueFactory::instance().createAndSwallowExceptions(info.GetIsolate(), detailsArg));
- }
+ event->setDetail(ScriptValue(ScriptState::current(info.GetIsolate()), detailsArg));
}
} // namespace blink
« no previous file with comments | « Source/bindings/core/v8/ScriptValue.cpp ('k') | Source/bindings/scripts/v8_dictionary.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698