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

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: Add FIXMEs 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 104
105 {##############################################################################} 105 {##############################################################################}
106 {% macro attribute_setter(attribute, world_suffix) %} 106 {% macro attribute_setter(attribute, world_suffix) %}
107 {% filter conditional(attribute.conditional_string) %} 107 {% filter conditional(attribute.conditional_string) %}
108 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 static void {{attribute.name}}AttributeSetter{{world_suffix}}(v8::Local<v8::Stri ng> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& in fo)
109 { 109 {
110 {% if not attribute.is_static %} 110 {% if not attribute.is_static %}
111 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); 111 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder());
112 {% endif %} 112 {% endif %}
113 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %}
114 if (!imp->document())
115 return;
116 {% endif %}
117 {% if attribute.idl_type != 'EventHandler' %}
113 {{attribute.v8_value_to_local_cpp_value}}; 118 {{attribute.v8_value_to_local_cpp_value}};
119 {% else %}{# EventHandler hack #}
120 {# Non-callable input should be treated as null #}
121 if (!jsValue->IsNull() && !jsValue->IsFunction())
122 jsValue = v8::Null(info.GetIsolate());
123 transferHiddenDependency(info.Holder(), {{attribute.event_handler_getter_exp ression}}, jsValue, {{v8_class_name}}::eventListenerCacheIndex, info.GetIsolate( ));
124 {% endif %}
114 {% if attribute.enum_validation_expression %} 125 {% if attribute.enum_validation_expression %}
115 {# Setter ignores invalid enum values #} 126 {# Setter ignores invalid enum values #}
116 String string = cppValue; 127 String string = cppValue;
117 if (!({{attribute.enum_validation_expression}})) 128 if (!({{attribute.enum_validation_expression}}))
118 return; 129 return;
119 {% endif %} 130 {% endif %}
120 {% if attribute.is_call_with_script_execution_context %} 131 {% if attribute.is_call_with_script_execution_context %}
121 ExecutionContext* scriptContext = getExecutionContext(); 132 ExecutionContext* scriptContext = getExecutionContext();
122 {% endif %} 133 {% endif %}
123 {{attribute.cpp_setter}}; 134 {{attribute.cpp_setter}};
(...skipping 13 matching lines...) Expand all
137 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 148 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
138 {% if attribute.has_custom_setter %} 149 {% if attribute.has_custom_setter %}
139 {{v8_class_name}}::{{attribute.name}}AttributeSetterCustom(name, jsValue, in fo); 150 {{v8_class_name}}::{{attribute.name}}AttributeSetterCustom(name, jsValue, in fo);
140 {% else %} 151 {% else %}
141 {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffi x}}(name, jsValue, info); 152 {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffi x}}(name, jsValue, info);
142 {% endif %} 153 {% endif %}
143 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 154 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
144 } 155 }
145 {% endfilter %} 156 {% endfilter %}
146 {% endmacro %} 157 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698