OLD | NEW |
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}}( | 4 static void {{attribute.name}}AttributeGetter{{world_suffix}}( |
5 {%- if attribute.is_expose_js_accessors %} | 5 {%- if attribute.is_expose_js_accessors %} |
6 const v8::FunctionCallbackInfo<v8::Value>& info | 6 const v8::FunctionCallbackInfo<v8::Value>& info |
7 {%- else %} | 7 {%- else %} |
8 const v8::PropertyCallbackInfo<v8::Value>& info | 8 const v8::PropertyCallbackInfo<v8::Value>& info |
9 {%- endif %}) | 9 {%- endif %}) |
10 { | 10 { |
11 {% if attribute.is_reflect and not attribute.is_url and | 11 {% if attribute.is_reflect and not attribute.is_url and |
12 attribute.idl_type == 'DOMString' and is_node %} | 12 attribute.idl_type == 'DOMString' and is_node %} |
13 {% set cpp_class, v8_class = 'Element', 'V8Element' %} | 13 {% set cpp_class, v8_class = 'Element', 'V8Element' %} |
14 {% endif %} | 14 {% endif %} |
15 {# holder #} | 15 {# holder #} |
16 {% if attribute.is_unforgeable and interface_name != 'Window' %} | 16 {% if attribute.is_unforgeable and interface_name != 'Window' %} |
17 {# perform lookup first #} | 17 {# perform lookup first #} |
18 {# FIXME: can we remove this lookup? #} | 18 {# FIXME: can we remove this lookup? #} |
19 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i
nfo.This(), info.GetIsolate()); | 19 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i
nfo.This(), info.GetIsolate()); |
20 if (holder.IsEmpty()) | 20 if (holder.IsEmpty()) |
21 return; | 21 return; |
22 {% elif not attribute.is_static %} | 22 {% elif not attribute.is_static %} |
23 v8::Handle<v8::Object> holder = info.Holder(); | 23 v8::Handle<v8::Object> holder = info.Holder(); |
24 {% endif %} | 24 {% endif %} |
25 {# impl #} | 25 {# impl #} |
26 {% if attribute.cached_attribute_validation_method %} | 26 {% if attribute.cached_attribute_validation_method %} |
27 v8::Handle<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{a
ttribute.name}}"); | 27 v8::Handle<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{a
ttribute.name}}"); |
28 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); | 28 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); |
29 if (!impl->{{attribute.cached_attribute_validation_method}}()) { | 29 if (!impl->{{attribute.cached_attribute_validation_method}}()) { |
30 v8::Handle<v8::Value> jsValue = V8HiddenValue::getHiddenValue(info.GetIs
olate(), holder, propertyName); | 30 v8::Handle<v8::Value> v8Value = V8HiddenValue::getHiddenValue(info.GetIs
olate(), holder, propertyName); |
31 if (!jsValue.IsEmpty()) { | 31 if (!v8Value.IsEmpty()) { |
32 v8SetReturnValue(info, jsValue); | 32 v8SetReturnValue(info, v8Value); |
33 return; | 33 return; |
34 } | 34 } |
35 } | 35 } |
36 {% elif not attribute.is_static %} | 36 {% elif not attribute.is_static %} |
37 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); | 37 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); |
38 {% endif %} | 38 {% endif %} |
39 {% if attribute.is_implemented_by and not attribute.is_static %} | 39 {% if attribute.is_implemented_by and not attribute.is_static %} |
40 ASSERT(impl); | 40 ASSERT(impl); |
41 {% endif %} | 41 {% endif %} |
42 {% if interface_name == 'Window' and attribute.idl_type == 'EventHandler' %} | 42 {% if interface_name == 'Window' and attribute.idl_type == 'EventHandler' %} |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 {% endfilter %} | 109 {% endfilter %} |
110 {% endmacro %} | 110 {% endmacro %} |
111 | 111 |
112 {######################################} | 112 {######################################} |
113 {% macro release_only_check(reflect_only_values, reflect_missing, | 113 {% macro release_only_check(reflect_only_values, reflect_missing, |
114 reflect_invalid, reflect_empty) %} | 114 reflect_invalid, reflect_empty) %} |
115 {# Attribute is limited to only known values: check that the attribute value is | 115 {# Attribute is limited to only known values: check that the attribute value is |
116 one of those. If not, set it to the empty string. | 116 one of those. If not, set it to the empty string. |
117 http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-valu
es #} | 117 http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-valu
es #} |
118 {% if reflect_empty %} | 118 {% if reflect_empty %} |
119 if (jsValue.isNull()) { | 119 if (v8Value.isNull()) { |
120 {% if reflect_missing %} | 120 {% if reflect_missing %} |
121 jsValue = "{{reflect_missing}}"; | 121 v8Value = "{{reflect_missing}}"; |
122 {% else %} | 122 {% else %} |
123 ; | 123 ; |
124 {% endif %} | 124 {% endif %} |
125 } else if (jsValue.isEmpty()) { | 125 } else if (v8Value.isEmpty()) { |
126 jsValue = "{{reflect_empty}}"; | 126 v8Value = "{{reflect_empty}}"; |
127 {% else %} | 127 {% else %} |
128 if (jsValue.isEmpty()) { | 128 if (v8Value.isEmpty()) { |
129 {# FIXME: should use [ReflectEmpty] instead; need to change IDL files #} | 129 {# FIXME: should use [ReflectEmpty] instead; need to change IDL files #} |
130 {% if reflect_missing %} | 130 {% if reflect_missing %} |
131 jsValue = "{{reflect_missing}}"; | 131 v8Value = "{{reflect_missing}}"; |
132 {% else %} | 132 {% else %} |
133 ; | 133 ; |
134 {% endif %} | 134 {% endif %} |
135 {% endif %} | 135 {% endif %} |
136 {% for value in reflect_only_values %} | 136 {% for value in reflect_only_values %} |
137 } else if (equalIgnoringCase(jsValue, "{{value}}")) { | 137 } else if (equalIgnoringCase(v8Value, "{{value}}")) { |
138 jsValue = "{{value}}"; | 138 v8Value = "{{value}}"; |
139 {% endfor %} | 139 {% endfor %} |
140 } else { | 140 } else { |
141 jsValue = "{{reflect_invalid}}"; | 141 v8Value = "{{reflect_invalid}}"; |
142 } | 142 } |
143 {% endmacro %} | 143 {% endmacro %} |
144 | 144 |
145 | 145 |
146 {##############################################################################} | 146 {##############################################################################} |
147 {% macro attribute_getter_callback(attribute, world_suffix) %} | 147 {% macro attribute_getter_callback(attribute, world_suffix) %} |
148 {% filter conditional(attribute.conditional_string) %} | 148 {% filter conditional(attribute.conditional_string) %} |
149 static void {{attribute.name}}AttributeGetterCallback{{world_suffix}}( | 149 static void {{attribute.name}}AttributeGetterCallback{{world_suffix}}( |
150 {%- if attribute.is_expose_js_accessors %} | 150 {%- if attribute.is_expose_js_accessors %} |
151 const v8::FunctionCallbackInfo<v8::Value>& info | 151 const v8::FunctionCallbackInfo<v8::Value>& info |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 193 } |
194 {% endfilter %} | 194 {% endfilter %} |
195 {% endmacro %} | 195 {% endmacro %} |
196 | 196 |
197 | 197 |
198 {##############################################################################} | 198 {##############################################################################} |
199 {% macro attribute_setter(attribute, world_suffix) %} | 199 {% macro attribute_setter(attribute, world_suffix) %} |
200 {% filter conditional(attribute.conditional_string) %} | 200 {% filter conditional(attribute.conditional_string) %} |
201 static void {{attribute.name}}AttributeSetter{{world_suffix}}( | 201 static void {{attribute.name}}AttributeSetter{{world_suffix}}( |
202 {%- if attribute.is_expose_js_accessors %} | 202 {%- if attribute.is_expose_js_accessors %} |
203 v8::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info | 203 v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info |
204 {%- else %} | 204 {%- else %} |
205 v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info | 205 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info |
206 {%- endif %}) | 206 {%- endif %}) |
207 { | 207 { |
208 {% if attribute.is_reflect and attribute.idl_type == 'DOMString' and | 208 {% if attribute.is_reflect and attribute.idl_type == 'DOMString' and |
209 is_node %} | 209 is_node %} |
210 {% set cpp_class, v8_class = 'Element', 'V8Element' %} | 210 {% set cpp_class, v8_class = 'Element', 'V8Element' %} |
211 {% endif %} | 211 {% endif %} |
212 {# Local variables #} | 212 {# Local variables #} |
213 {% if not attribute.is_static %} | 213 {% if not attribute.is_static %} |
214 v8::Handle<v8::Object> holder = info.Holder(); | 214 v8::Handle<v8::Object> holder = info.Holder(); |
215 {% endif %} | 215 {% endif %} |
216 {% if attribute.has_setter_exception_state %} | 216 {% if attribute.has_setter_exception_state %} |
217 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); | 217 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); |
218 {% endif %} | 218 {% endif %} |
219 {# Type checking #} | 219 {# Type checking #} |
220 {% if attribute.has_strict_type_checking %} | 220 {% if attribute.has_strict_type_checking %} |
221 {# Type checking for interface types (if interface not implemented, throw | 221 {# Type checking for interface types (if interface not implemented, throw |
222 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 222 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
223 if (!isUndefinedOrNull(jsValue) && !V8{{attribute.idl_type}}::hasInstance(js
Value, info.GetIsolate())) { | 223 if (!isUndefinedOrNull(v8Value) && !V8{{attribute.idl_type}}::hasInstance(v8
Value, info.GetIsolate())) { |
224 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); | 224 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); |
225 exceptionState.throwIfNeeded(); | 225 exceptionState.throwIfNeeded(); |
226 return; | 226 return; |
227 } | 227 } |
228 {% endif %} | 228 {% endif %} |
229 {# impl #} | 229 {# impl #} |
230 {% if attribute.put_forwards %} | 230 {% if attribute.put_forwards %} |
231 {{cpp_class}}* proxyImpl = {{v8_class}}::toNative(holder); | 231 {{cpp_class}}* proxyImpl = {{v8_class}}::toNative(holder); |
232 {{attribute.ref_ptr}}<{{attribute.idl_type}}> impl = WTF::getPtr(proxyImpl->
{{attribute.name}}()); | 232 {{attribute.ref_ptr}}<{{attribute.idl_type}}> impl = WTF::getPtr(proxyImpl->
{{attribute.name}}()); |
233 if (!impl) | 233 if (!impl) |
234 return; | 234 return; |
235 {% elif not attribute.is_static %} | 235 {% elif not attribute.is_static %} |
236 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); | 236 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); |
237 {% endif %} | 237 {% endif %} |
238 {% if attribute.is_implemented_by and not attribute.is_static %} | 238 {% if attribute.is_implemented_by and not attribute.is_static %} |
239 ASSERT(impl); | 239 ASSERT(impl); |
240 {% endif %} | 240 {% endif %} |
241 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} | 241 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} |
242 if (!impl->document()) | 242 if (!impl->document()) |
243 return; | 243 return; |
244 {% endif %} | 244 {% endif %} |
245 {# Convert JS value to C++ value #} | 245 {# Convert JS value to C++ value #} |
246 {% if attribute.idl_type != 'EventHandler' %} | 246 {% if attribute.idl_type != 'EventHandler' %} |
247 {{attribute.v8_value_to_local_cpp_value}}; | 247 {{attribute.v8_value_to_local_cpp_value}}; |
248 {% elif not is_node %}{# EventHandler hack #} | 248 {% elif not is_node %}{# EventHandler hack #} |
249 moveEventListenerToNewWrapper(holder, {{attribute.event_handler_getter_expre
ssion}}, jsValue, {{v8_class}}::eventListenerCacheIndex, info.GetIsolate()); | 249 moveEventListenerToNewWrapper(holder, {{attribute.event_handler_getter_expre
ssion}}, v8Value, {{v8_class}}::eventListenerCacheIndex, info.GetIsolate()); |
250 {% endif %} | 250 {% endif %} |
251 {% if attribute.enum_validation_expression %} | 251 {% if attribute.enum_validation_expression %} |
252 {# Setter ignores invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enum
s #} | 252 {# Setter ignores invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enum
s #} |
253 String string = cppValue; | 253 String string = cppValue; |
254 if (!({{attribute.enum_validation_expression}})) | 254 if (!({{attribute.enum_validation_expression}})) |
255 return; | 255 return; |
256 {% endif %} | 256 {% endif %} |
257 {# Pre-set context #} | 257 {# Pre-set context #} |
258 {% if attribute.is_custom_element_callbacks or | 258 {% if attribute.is_custom_element_callbacks or |
259 (attribute.is_reflect and | 259 (attribute.is_reflect and |
(...skipping 19 matching lines...) Expand all Loading... |
279 {% endmacro %} | 279 {% endmacro %} |
280 | 280 |
281 | 281 |
282 {##############################################################################} | 282 {##############################################################################} |
283 {% macro attribute_setter_callback(attribute, world_suffix) %} | 283 {% macro attribute_setter_callback(attribute, world_suffix) %} |
284 {% filter conditional(attribute.conditional_string) %} | 284 {% filter conditional(attribute.conditional_string) %} |
285 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}( | 285 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}( |
286 {%- if attribute.is_expose_js_accessors %} | 286 {%- if attribute.is_expose_js_accessors %} |
287 const v8::FunctionCallbackInfo<v8::Value>& info | 287 const v8::FunctionCallbackInfo<v8::Value>& info |
288 {%- else %} | 288 {%- else %} |
289 v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackI
nfo<void>& info | 289 v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackI
nfo<void>& info |
290 {%- endif %}) | 290 {%- endif %}) |
291 { | 291 { |
292 {% if attribute.is_expose_js_accessors %} | 292 {% if attribute.is_expose_js_accessors %} |
293 v8::Local<v8::Value> jsValue = info[0]; | 293 v8::Local<v8::Value> v8Value = info[0]; |
294 {% endif %} | 294 {% endif %} |
295 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | 295 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); |
296 {% if attribute.deprecate_as %} | 296 {% if attribute.deprecate_as %} |
297 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), Use
Counter::{{attribute.deprecate_as}}); | 297 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), Use
Counter::{{attribute.deprecate_as}}); |
298 {% endif %} | 298 {% endif %} |
299 {% if attribute.measure_as %} | 299 {% if attribute.measure_as %} |
300 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCounter::{{
attribute.measure_as}}); | 300 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCounter::{{
attribute.measure_as}}); |
301 {% endif %} | 301 {% endif %} |
302 {% if world_suffix in attribute.activity_logging_world_list_for_setter %} | 302 {% if world_suffix in attribute.activity_logging_world_list_for_setter %} |
303 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); | 303 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
304 if (contextData && contextData->activityLogger()) { | 304 if (contextData && contextData->activityLogger()) { |
305 v8::Handle<v8::Value> loggerArg[] = { jsValue }; | 305 v8::Handle<v8::Value> loggerArg[] = { v8Value }; |
306 contextData->activityLogger()->log("{{interface_name}}.{{attribute.name}
}", 1, &loggerArg[0], "Setter"); | 306 contextData->activityLogger()->log("{{interface_name}}.{{attribute.name}
}", 1, &loggerArg[0], "Setter"); |
307 } | 307 } |
308 {% endif %} | 308 {% endif %} |
309 {% if attribute.is_custom_element_callbacks or attribute.is_reflect %} | 309 {% if attribute.is_custom_element_callbacks or attribute.is_reflect %} |
310 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 310 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
311 {% endif %} | 311 {% endif %} |
312 {% if attribute.has_custom_setter %} | 312 {% if attribute.has_custom_setter %} |
313 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(jsValue, info); | 313 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info); |
314 {% else %} | 314 {% else %} |
315 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(j
sValue, info); | 315 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v
8Value, info); |
316 {% endif %} | 316 {% endif %} |
317 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 317 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
318 } | 318 } |
319 {% endfilter %} | 319 {% endfilter %} |
320 {% endmacro %} | 320 {% endmacro %} |
OLD | NEW |