| 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_unforgeable %} | 11 {% if attribute.is_unforgeable %} |
| 12 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{
v8_class_name}}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); | 12 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{
v8_class}}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); |
| 13 if (holder.IsEmpty()) | 13 if (holder.IsEmpty()) |
| 14 return; | 14 return; |
| 15 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder); | 15 {{cpp_class}}* imp = {{v8_class}}::toNative(holder); |
| 16 {% endif %} | 16 {% endif %} |
| 17 {% if attribute.cached_attribute_validation_method %} | 17 {% if attribute.cached_attribute_validation_method %} |
| 18 v8::Handle<v8::String> propertyName = v8::String::NewFromUtf8(info.GetIsolat
e(), "{{attribute.name}}", v8::String::kInternalizedString); | 18 v8::Handle<v8::String> propertyName = v8::String::NewFromUtf8(info.GetIsolat
e(), "{{attribute.name}}", v8::String::kInternalizedString); |
| 19 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | 19 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); |
| 20 if (!imp->{{attribute.cached_attribute_validation_method}}()) { | 20 if (!imp->{{attribute.cached_attribute_validation_method}}()) { |
| 21 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa
me); | 21 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa
me); |
| 22 if (!jsValue.IsEmpty()) { | 22 if (!jsValue.IsEmpty()) { |
| 23 v8SetReturnValue(info, jsValue); | 23 v8SetReturnValue(info, jsValue); |
| 24 return; | 24 return; |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 {% elif not (attribute.is_static or attribute.is_unforgeable) %} | 27 {% elif not (attribute.is_static or attribute.is_unforgeable) %} |
| 28 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | 28 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); |
| 29 {% endif %} | 29 {% endif %} |
| 30 {% if attribute.is_call_with_execution_context %} | 30 {% if attribute.is_call_with_execution_context %} |
| 31 ExecutionContext* scriptContext = getExecutionContext(); | 31 ExecutionContext* scriptContext = getExecutionContext(); |
| 32 {% endif %} | 32 {% endif %} |
| 33 {# Special cases #} | 33 {# Special cases #} |
| 34 {% if attribute.is_check_security_for_node %} | 34 {% if attribute.is_check_security_for_node %} |
| 35 {# FIXME: consider using a local variable to not call getter twice #} | 35 {# FIXME: consider using a local variable to not call getter twice #} |
| 36 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 36 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 37 if (!BindingSecurity::shouldAllowAccessToNode({{attribute.cpp_value}}, excep
tionState)) { | 37 if (!BindingSecurity::shouldAllowAccessToNode({{attribute.cpp_value}}, excep
tionState)) { |
| 38 v8SetReturnValueNull(info); | 38 v8SetReturnValueNull(info); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 {% endif %} | 95 {% endif %} |
| 96 {% if attribute.measure_as %} | 96 {% if attribute.measure_as %} |
| 97 UseCounter::count(activeDOMWindow(), UseCounter::{{attribute.measure_as}}); | 97 UseCounter::count(activeDOMWindow(), UseCounter::{{attribute.measure_as}}); |
| 98 {% endif %} | 98 {% endif %} |
| 99 {% if world_suffix in attribute.activity_logging_world_list_for_getter %} | 99 {% if world_suffix in attribute.activity_logging_world_list_for_getter %} |
| 100 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); | 100 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
| 101 if (contextData && contextData->activityLogger()) | 101 if (contextData && contextData->activityLogger()) |
| 102 contextData->activityLogger()->log("{{interface_name}}.{{attribute.name}
}", 0, 0, "Getter"); | 102 contextData->activityLogger()->log("{{interface_name}}.{{attribute.name}
}", 0, 0, "Getter"); |
| 103 {% endif %} | 103 {% endif %} |
| 104 {% if attribute.has_custom_getter %} | 104 {% if attribute.has_custom_getter %} |
| 105 {{v8_class_name}}::{{attribute.name}}AttributeGetterCustom(info); | 105 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info); |
| 106 {% else %} | 106 {% else %} |
| 107 {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeGetter{{world_suffi
x}}(info); | 107 {{cpp_class}}V8Internal::{{attribute.name}}AttributeGetter{{world_suffix}}(i
nfo); |
| 108 {% endif %} | 108 {% endif %} |
| 109 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 109 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 110 } | 110 } |
| 111 {% endfilter %} | 111 {% endfilter %} |
| 112 {% endmacro %} | 112 {% endmacro %} |
| 113 | 113 |
| 114 | 114 |
| 115 {##############################################################################} | 115 {##############################################################################} |
| 116 {% macro attribute_setter(attribute, world_suffix) %} | 116 {% macro attribute_setter(attribute, world_suffix) %} |
| 117 {% filter conditional(attribute.conditional_string) %} | 117 {% filter conditional(attribute.conditional_string) %} |
| 118 static void {{attribute.name}}AttributeSetter{{world_suffix}}( | 118 static void {{attribute.name}}AttributeSetter{{world_suffix}}( |
| 119 {%- if attribute.is_expose_js_accessors %} | 119 {%- if attribute.is_expose_js_accessors %} |
| 120 v8::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info | 120 v8::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info |
| 121 {%- else %} | 121 {%- else %} |
| 122 v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info | 122 v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info |
| 123 {%- endif %}) | 123 {%- endif %}) |
| 124 { | 124 { |
| 125 {% if attribute.has_strict_type_checking %} | 125 {% if attribute.has_strict_type_checking %} |
| 126 {# Type checking for interface types (if interface not implemented, throw | 126 {# Type checking for interface types (if interface not implemented, throw |
| 127 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 127 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 128 if (!isUndefinedOrNull(jsValue) && !V8{{attribute.idl_type}}::hasInstance(js
Value, info.GetIsolate(), worldType(info.GetIsolate()))) { | 128 if (!isUndefinedOrNull(jsValue) && !V8{{attribute.idl_type}}::hasInstance(js
Value, info.GetIsolate(), worldType(info.GetIsolate()))) { |
| 129 throwTypeError(ExceptionMessages::failedToSet("{{attribute.name}}", "{{i
nterface_name}}", "The provided value is not of type '{{attribute.idl_type}}'.")
, info.GetIsolate()); | 129 throwTypeError(ExceptionMessages::failedToSet("{{attribute.name}}", "{{i
nterface_name}}", "The provided value is not of type '{{attribute.idl_type}}'.")
, info.GetIsolate()); |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 {% endif %} | 132 {% endif %} |
| 133 {% if not attribute.is_static %} | 133 {% if not attribute.is_static %} |
| 134 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | 134 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); |
| 135 {% endif %} | 135 {% endif %} |
| 136 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} | 136 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} |
| 137 if (!imp->document()) | 137 if (!imp->document()) |
| 138 return; | 138 return; |
| 139 {% endif %} | 139 {% endif %} |
| 140 {% if attribute.idl_type != 'EventHandler' %} | 140 {% if attribute.idl_type != 'EventHandler' %} |
| 141 {{attribute.v8_value_to_local_cpp_value}}; | 141 {{attribute.v8_value_to_local_cpp_value}}; |
| 142 {% else %}{# EventHandler hack #} | 142 {% else %}{# EventHandler hack #} |
| 143 transferHiddenDependency(info.Holder(), {{attribute.event_handler_getter_exp
ression}}, jsValue, {{v8_class_name}}::eventListenerCacheIndex, info.GetIsolate(
)); | 143 transferHiddenDependency(info.Holder(), {{attribute.event_handler_getter_exp
ression}}, jsValue, {{v8_class}}::eventListenerCacheIndex, info.GetIsolate()); |
| 144 {% endif %} | 144 {% endif %} |
| 145 {% if attribute.enum_validation_expression %} | 145 {% if attribute.enum_validation_expression %} |
| 146 {# Setter ignores invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enum
s #} | 146 {# Setter ignores invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enum
s #} |
| 147 String string = cppValue; | 147 String string = cppValue; |
| 148 if (!({{attribute.enum_validation_expression}})) | 148 if (!({{attribute.enum_validation_expression}})) |
| 149 return; | 149 return; |
| 150 {% endif %} | 150 {% endif %} |
| 151 {% if attribute.is_reflect %} | 151 {% if attribute.is_reflect %} |
| 152 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 152 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 153 {% endif %} | 153 {% endif %} |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); | 193 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
| 194 if (contextData && contextData->activityLogger()) { | 194 if (contextData && contextData->activityLogger()) { |
| 195 v8::Handle<v8::Value> loggerArg[] = { jsValue }; | 195 v8::Handle<v8::Value> loggerArg[] = { jsValue }; |
| 196 contextData->activityLogger()->log("{{interface_name}}.{{attribute.name}
}", 1, &loggerArg[0], "Setter"); | 196 contextData->activityLogger()->log("{{interface_name}}.{{attribute.name}
}", 1, &loggerArg[0], "Setter"); |
| 197 } | 197 } |
| 198 {% endif %} | 198 {% endif %} |
| 199 {% if attribute.is_reflect %} | 199 {% if attribute.is_reflect %} |
| 200 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 200 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 201 {% endif %} | 201 {% endif %} |
| 202 {% if attribute.has_custom_setter %} | 202 {% if attribute.has_custom_setter %} |
| 203 {{v8_class_name}}::{{attribute.name}}AttributeSetterCustom(jsValue, info); | 203 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(jsValue, info); |
| 204 {% else %} | 204 {% else %} |
| 205 {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffi
x}}(jsValue, info); | 205 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(j
sValue, info); |
| 206 {% endif %} | 206 {% endif %} |
| 207 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 207 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 208 } | 208 } |
| 209 {% endfilter %} | 209 {% endfilter %} |
| 210 {% endmacro %} | 210 {% endmacro %} |
| OLD | NEW |