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

Unified Diff: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl

Issue 2626183003: Switch RemoteWindowProxy to use v8::Context::NewRemoteContext. (Closed)
Patch Set: EventTarget as well Created 3 years, 10 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: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
index a036d5839d10565c153094f907d8123dcc7e408e..36ef5371e085168e050982a1af6f369fc2166bb6 100644
--- a/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
+++ b/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
@@ -13,7 +13,7 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
{% set function_call = func_call_with_prep_of_args(method, world_suffix) %}
{% if 'exceptionState' in function_call or
- (method.returns_promise and not method.is_static) %}
+ ((method.returns_promise or interface_name == 'Window' or interface_name == 'EventTarget') and not method.is_static) %}
dcheng 2017/02/16 10:48:36 I had to add EventTarget to this list as well...
Yuki 2017/02/16 12:47:39 Could you help me understand the situation? You'r
dcheng 2017/02/16 19:50:23 Correct. Due to the way we create the proxy templa
Yuki 2017/02/17 06:49:31 Thanks for the explanation. Overall, I'm okay wit
dcheng 2017/02/17 07:16:52 I was getting pretty unhappy with how the code loo
{{define_exception_state}}
{% if method.returns_promise %}
ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState);
@@ -21,7 +21,7 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
{% endif %}
{% if not method.is_static %}
- {% if method.returns_promise %}
+ {% if method.returns_promise or interface_name == 'Window' or interface_name == 'EventTarget' %}
// V8DOMConfiguration::DoNotCheckHolder
// Make sure that info.Holder() really points to an instance of the type.
if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) {
@@ -547,8 +547,17 @@ static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop
static int domTemplateKey; // This address is used for a key to look up the dom template.
V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCurrentContext());
+{% if interface_name == 'Window' %}
+ // Note: signature is intentionally omitted for functions that use Window as
+ // the receiver object. A remote context's global proxy does not have the
+ // standard prototype chain set up, so v8 won't be able to find the receiver
+ // type in the prototype chain. Instead, the method implementation must do
+ // the check manually.
+ v8::Local<v8::Signature> signature;
+{% else %}
v8::Local<v8::FunctionTemplate> interfaceTemplate = data->findInterfaceTemplate(world, &{{v8_class}}::wrapperTypeInfo);
v8::Local<v8::Signature> signature = v8::Signature::New(info.GetIsolate(), interfaceTemplate);
+{% endif %}
v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTemplate(world, &domTemplateKey, {{v8_class_or_partial}}::{{method.name}}MethodCallback{{world_suffix}}, v8Undefined(), signature, {{method.length}});
// Return the function by default, unless the user script has overwritten it.
@@ -628,7 +637,7 @@ v8SetReturnValue(info, wrapper);
'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attributes)
if method.property_attributes else 'v8::None' %}
{% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder'
- if method.returns_promise else 'V8DOMConfiguration::CheckHolder' %}
+ if method.returns_promise or interface_name == 'Window' or interface_name == 'EventTarget' else 'V8DOMConfiguration::CheckHolder' %}
{"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, {{property_attribute}}, {{property_location(method)}}, {{holder_check}}}
{%- endmacro %}

Powered by Google App Engine
This is Rietveld 408576698