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

Side by Side Diff: Source/bindings/templates/attributes.cpp

Issue 30493002: IDL compiler: EventHandler for setters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Briefer Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro attribute_getter(attribute, world_suffix) %} 2 {% macro attribute_getter(attribute, world_suffix) %}
3 {% filter conditional(attribute.conditional_string) %} 3 {% filter conditional(attribute.conditional_string) %}
4 static void {{attribute.name}}AttributeGetter{{world_suffix}}(v8::Local<v8::Stri ng> name, const v8::PropertyCallbackInfo<v8::Value>& info) 4 static void {{attribute.name}}AttributeGetter{{world_suffix}}(v8::Local<v8::Stri ng> name, const v8::PropertyCallbackInfo<v8::Value>& info)
5 { 5 {
6 {% if attribute.is_unforgeable %} 6 {% if attribute.is_unforgeable %}
7 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class_name}}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 7 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class_name}}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
8 if (holder.IsEmpty()) 8 if (holder.IsEmpty())
9 return; 9 return;
10 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder); 10 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 {% endfilter %} 101 {% endfilter %}
102 {% endmacro %} 102 {% endmacro %}
103 103
104 104
105 {##############################################################################} 105 {##############################################################################}
106 {% macro attribute_setter(attribute, world_suffix) %} 106 {% macro attribute_setter(attribute, world_suffix) %}
107 static void {{attribute.name}}AttributeSetter{{world_suffix}}(v8::Local<v8::Stri ng> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& in fo) 107 static void {{attribute.name}}AttributeSetter{{world_suffix}}(v8::Local<v8::Stri ng> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& in fo)
108 { 108 {
109 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); 109 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder());
110 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %}
111 if (!imp->document())
haraken 2013/10/19 12:41:29 I think this check should be moved to core/ if the
Nils Barth (inactive) 2013/10/21 02:41:38 28 attribute setters.
haraken 2013/10/21 03:43:52 OK, then it would make sense to keep the check in
Nils Barth (inactive) 2013/10/21 03:58:34 Got it, n/p!
112 return;
113 {% endif %}
114 {% if attribute.idl_type != 'EventHandler' %}
110 {{attribute.v8_value_to_local_cpp_value}}; 115 {{attribute.v8_value_to_local_cpp_value}};
116 {% else %}{# EventHandler hack #}
117 {# Non-callable input should be treated as null #}
118 if (!jsValue->IsNull() && !jsValue->IsFunction())
119 jsValue = v8::Null(info.GetIsolate());
120 transferHiddenDependency(info.Holder(), {{attribute.event_handler_getter_exp ression}}, jsValue, {{v8_class_name}}::eventListenerCacheIndex, info.GetIsolate( ));
121 {% endif %}
111 {% if attribute.is_call_with_script_execution_context %} 122 {% if attribute.is_call_with_script_execution_context %}
112 ExecutionContext* scriptContext = getExecutionContext(); 123 ExecutionContext* scriptContext = getExecutionContext();
113 {% endif %} 124 {% endif %}
114 {{attribute.cpp_setter}}; 125 {{attribute.cpp_setter}};
115 {% if attribute.cached_attribute_validation_method %} 126 {% if attribute.cached_attribute_validation_method %}
116 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("{{attribute.name}}") ); // Invalidate the cached value. 127 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("{{attribute.name}}") ); // Invalidate the cached value.
117 {% endif %} 128 {% endif %}
118 } 129 }
119 {% endmacro %} 130 {% endmacro %}
120 131
121 132
122 {##############################################################################} 133 {##############################################################################}
123 {% macro attribute_setter_callback(attribute, world_suffix) %} 134 {% macro attribute_setter_callback(attribute, world_suffix) %}
124 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}(v8::Local< v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v oid>& info) 135 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}(v8::Local< v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v oid>& info)
125 { 136 {
126 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 137 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
127 {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffi x}}(name, jsValue, info); 138 {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffi x}}(name, jsValue, info);
128 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 139 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
129 } 140 }
130 {% endmacro %} 141 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698