| 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 {# imp #} | 15 {# impl #} |
| 16 {# FIXME: use a local variable for holder more often and simplify below #} | 16 {# FIXME: use a local variable for holder more often and simplify below #} |
| 17 {% if attribute.is_unforgeable or | 17 {% if attribute.is_unforgeable or |
| 18 interface_name == 'Window' and attribute.idl_type == 'EventHandler' %} | 18 interface_name == 'Window' and attribute.idl_type == 'EventHandler' %} |
| 19 {% if interface_name == 'Window' %} | 19 {% if interface_name == 'Window' %} |
| 20 v8::Handle<v8::Object> holder = info.Holder(); | 20 v8::Handle<v8::Object> holder = info.Holder(); |
| 21 {% else %}{# perform lookup first #} | 21 {% else %}{# perform lookup first #} |
| 22 {# FIXME: can we remove this lookup? #} | 22 {# FIXME: can we remove this lookup? #} |
| 23 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i
nfo.This(), info.GetIsolate()); | 23 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i
nfo.This(), info.GetIsolate()); |
| 24 if (holder.IsEmpty()) | 24 if (holder.IsEmpty()) |
| 25 return; | 25 return; |
| 26 {% endif %}{# Window #} | 26 {% endif %}{# Window #} |
| 27 {{cpp_class}}* imp = {{v8_class}}::toNative(holder); | 27 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); |
| 28 {% elif attribute.cached_attribute_validation_method %} | 28 {% elif attribute.cached_attribute_validation_method %} |
| 29 v8::Handle<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{a
ttribute.name}}"); | 29 v8::Handle<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{a
ttribute.name}}"); |
| 30 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); | 30 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); |
| 31 if (!imp->{{attribute.cached_attribute_validation_method}}()) { | 31 if (!impl->{{attribute.cached_attribute_validation_method}}()) { |
| 32 v8::Handle<v8::Value> jsValue = V8HiddenValue::getHiddenValue(info.GetIs
olate(), info.Holder(), propertyName); | 32 v8::Handle<v8::Value> jsValue = V8HiddenValue::getHiddenValue(info.GetIs
olate(), info.Holder(), propertyName); |
| 33 if (!jsValue.IsEmpty()) { | 33 if (!jsValue.IsEmpty()) { |
| 34 v8SetReturnValue(info, jsValue); | 34 v8SetReturnValue(info, jsValue); |
| 35 return; | 35 return; |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 {% elif not (attribute.is_static or attribute.is_unforgeable) %} | 38 {% elif not (attribute.is_static or attribute.is_unforgeable) %} |
| 39 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); | 39 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); |
| 40 {% endif %} | 40 {% endif %} |
| 41 {% if attribute.is_implemented_by and not attribute.is_static %} | 41 {% if attribute.is_implemented_by and not attribute.is_static %} |
| 42 ASSERT(imp); | 42 ASSERT(impl); |
| 43 {% endif %} | 43 {% endif %} |
| 44 {% if interface_name == 'Window' and attribute.idl_type == 'EventHandler' %} | 44 {% if interface_name == 'Window' and attribute.idl_type == 'EventHandler' %} |
| 45 if (!imp->document()) | 45 if (!impl->document()) |
| 46 return; | 46 return; |
| 47 {% endif %} | 47 {% endif %} |
| 48 {# Local variables #} | 48 {# Local variables #} |
| 49 {% if attribute.is_call_with_execution_context %} | 49 {% if attribute.is_call_with_execution_context %} |
| 50 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate())
; | 50 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate())
; |
| 51 {% endif %} | 51 {% endif %} |
| 52 {% if attribute.is_check_security_for_node or | 52 {% if attribute.is_check_security_for_node or |
| 53 attribute.is_getter_raises_exception %} | 53 attribute.is_getter_raises_exception %} |
| 54 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 54 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 55 {% endif %} | 55 {% endif %} |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 {% endif %} | 217 {% endif %} |
| 218 {% if attribute.has_strict_type_checking %} | 218 {% if attribute.has_strict_type_checking %} |
| 219 {# Type checking for interface types (if interface not implemented, throw | 219 {# Type checking for interface types (if interface not implemented, throw |
| 220 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 220 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 221 if (!isUndefinedOrNull(jsValue) && !V8{{attribute.idl_type}}::hasInstance(js
Value, info.GetIsolate())) { | 221 if (!isUndefinedOrNull(jsValue) && !V8{{attribute.idl_type}}::hasInstance(js
Value, info.GetIsolate())) { |
| 222 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); | 222 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); |
| 223 exceptionState.throwIfNeeded(); | 223 exceptionState.throwIfNeeded(); |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 {% endif %} | 226 {% endif %} |
| 227 {# imp #} | 227 {# impl #} |
| 228 {% if attribute.put_forwards %} | 228 {% if attribute.put_forwards %} |
| 229 {{cpp_class}}* proxyImp = {{v8_class}}::toNative(info.Holder()); | 229 {{cpp_class}}* proxyImpl = {{v8_class}}::toNative(info.Holder()); |
| 230 RefPtr<{{attribute.idl_type}}> imp = WTF::getPtr(proxyImp->{{attribute.name}
}()); | 230 RefPtr<{{attribute.idl_type}}> impl = WTF::getPtr(proxyImpl->{{attribute.nam
e}}()); |
| 231 if (!imp) | 231 if (!impl) |
| 232 return; | 232 return; |
| 233 {% elif not attribute.is_static %} | 233 {% elif not attribute.is_static %} |
| 234 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); | 234 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); |
| 235 {% endif %} | 235 {% endif %} |
| 236 {% if attribute.is_implemented_by and not attribute.is_static %} | 236 {% if attribute.is_implemented_by and not attribute.is_static %} |
| 237 ASSERT(imp); | 237 ASSERT(impl); |
| 238 {% endif %} | 238 {% endif %} |
| 239 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} | 239 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} |
| 240 if (!imp->document()) | 240 if (!impl->document()) |
| 241 return; | 241 return; |
| 242 {% endif %} | 242 {% endif %} |
| 243 {# Convert JS value to C++ value #} | 243 {# Convert JS value to C++ value #} |
| 244 {% if attribute.idl_type != 'EventHandler' %} | 244 {% if attribute.idl_type != 'EventHandler' %} |
| 245 {{attribute.v8_value_to_local_cpp_value}}; | 245 {{attribute.v8_value_to_local_cpp_value}}; |
| 246 {% elif not is_node %}{# EventHandler hack #} | 246 {% elif not is_node %}{# EventHandler hack #} |
| 247 moveEventListenerToNewWrapper(info.Holder(), {{attribute.event_handler_gette
r_expression}}, jsValue, {{v8_class}}::eventListenerCacheIndex, info.GetIsolate(
)); | 247 moveEventListenerToNewWrapper(info.Holder(), {{attribute.event_handler_gette
r_expression}}, jsValue, {{v8_class}}::eventListenerCacheIndex, info.GetIsolate(
)); |
| 248 {% endif %} | 248 {% endif %} |
| 249 {% if attribute.enum_validation_expression %} | 249 {% if attribute.enum_validation_expression %} |
| 250 {# Setter ignores invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enum
s #} | 250 {# Setter ignores invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enum
s #} |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 {% endif %} | 309 {% endif %} |
| 310 {% if attribute.has_custom_setter %} | 310 {% if attribute.has_custom_setter %} |
| 311 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(jsValue, info); | 311 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(jsValue, info); |
| 312 {% else %} | 312 {% else %} |
| 313 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(j
sValue, info); | 313 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(j
sValue, info); |
| 314 {% endif %} | 314 {% endif %} |
| 315 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 315 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 316 } | 316 } |
| 317 {% endfilter %} | 317 {% endfilter %} |
| 318 {% endmacro %} | 318 {% endmacro %} |
| OLD | NEW |