Chromium Code Reviews| 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 { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info | 204 v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info |
| 205 {%- else %} | 205 {%- else %} |
| 206 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info | 206 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info |
| 207 {%- endif %}) | 207 {%- endif %}) |
| 208 { | 208 { |
| 209 {% if attribute.is_reflect and attribute.idl_type == 'DOMString' | 209 {% if attribute.is_reflect and attribute.idl_type == 'DOMString' |
| 210 and is_node and not attribute.is_implemented_in_private_script %} | 210 and is_node and not attribute.is_implemented_in_private_script %} |
| 211 {% set cpp_class, v8_class = 'Element', 'V8Element' %} | 211 {% set cpp_class, v8_class = 'Element', 'V8Element' %} |
| 212 {% endif %} | 212 {% endif %} |
| 213 {# Local variables #} | 213 {# Local variables #} |
| 214 {% if not attribute.is_static %} | 214 {% if not attribute.is_static and not attribute.is_replaceable %} |
|
haraken
2015/02/23 14:48:52
For readability, it seems better to remove this br
Yuki
2015/02/23 15:18:42
Most of attributes need |holder|. Only static att
| |
| 215 v8::Local<v8::Object> holder = info.Holder(); | 215 v8::Local<v8::Object> holder = info.Holder(); |
| 216 {% endif %} | 216 {% endif %} |
| 217 {% if attribute.has_setter_exception_state %} | 217 {% if attribute.has_setter_exception_state %} |
| 218 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate()); | 218 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate()); |
| 219 {% endif %} | 219 {% endif %} |
| 220 {% if attribute.use_output_parameter_for_result %} | 220 {% if attribute.use_output_parameter_for_result %} |
| 221 {{attribute.cpp_type}} cppValue; | 221 {{attribute.cpp_type}} cppValue; |
| 222 {% endif %} | 222 {% endif %} |
| 223 {# impl #} | 223 {# impl #} |
| 224 {% if attribute.put_forwards %} | 224 {% if attribute.put_forwards %} |
| 225 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); | 225 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); |
| 226 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); | 226 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); |
| 227 if (!impl) | 227 if (!impl) |
| 228 return; | 228 return; |
| 229 {% elif attribute.is_replaceable %} | |
| 230 {% if is_check_security %} | |
|
haraken
2015/02/23 14:48:52
Why do we have the is_check_security clause only i
Yuki
2015/02/23 15:18:42
The code was copied from
https://code.google.com/p
| |
| 231 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | |
| 232 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | |
| 233 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) { | |
| 234 exceptionState.throwIfNeeded(); | |
| 235 return; | |
| 236 } | |
| 237 {% endif %} | |
| 238 if (info.This()->IsObject()) { | |
| 239 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), " {{attribute.name}}"); | |
| 240 v8::Local<v8::Object>::Cast(info.This())->ForceSet(propertyName, v8Value ); | |
| 241 } | |
| 229 {% elif not attribute.is_static %} | 242 {% elif not attribute.is_static %} |
| 230 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 243 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
| 231 {% endif %} | 244 {% endif %} |
| 232 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} | 245 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} |
| 233 if (!impl->document()) | 246 if (!impl->document()) |
| 234 return; | 247 return; |
| 235 {% endif %} | 248 {% endif %} |
| 236 {# Convert JS value to C++ value #} | 249 {# Convert JS value to C++ value #} |
| 237 {% if attribute.idl_type != 'EventHandler' %} | 250 {% if attribute.idl_type != 'EventHandler' %} |
| 251 {% if attribute.v8_value_to_local_cpp_value %} | |
| 238 {{attribute.v8_value_to_local_cpp_value}}; | 252 {{attribute.v8_value_to_local_cpp_value}}; |
| 253 {% endif %} | |
| 239 {% elif not is_node %}{# EventHandler hack #} | 254 {% elif not is_node %}{# EventHandler hack #} |
| 240 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); | 255 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); |
| 241 {% endif %} | 256 {% endif %} |
| 242 {# Type checking, possibly throw a TypeError, per: | 257 {# Type checking, possibly throw a TypeError, per: |
| 243 http://www.w3.org/TR/WebIDL/#es-type-mapping #} | 258 http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
| 244 {% if attribute.has_type_checking_interface %} | 259 {% if attribute.has_type_checking_interface %} |
| 245 {# Type checking for interface types (if interface not implemented, throw | 260 {# Type checking for interface types (if interface not implemented, throw |
| 246 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 261 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 247 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) { | 262 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) { |
| 248 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'."); | 263 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'."); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 261 (attribute.is_reflect and | 276 (attribute.is_reflect and |
| 262 not(attribute.idl_type == 'DOMString' and is_node)) %} | 277 not(attribute.idl_type == 'DOMString' and is_node)) %} |
| 263 {# Skip on compact node DOMString getters #} | 278 {# Skip on compact node DOMString getters #} |
| 264 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; | 279 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; |
| 265 {% endif %} | 280 {% endif %} |
| 266 {% if attribute.is_call_with_execution_context or | 281 {% if attribute.is_call_with_execution_context or |
| 267 attribute.is_setter_call_with_execution_context %} | 282 attribute.is_setter_call_with_execution_context %} |
| 268 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ()); | 283 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ()); |
| 269 {% endif %} | 284 {% endif %} |
| 270 {# Set #} | 285 {# Set #} |
| 286 {% if attribute.cpp_setter %} | |
| 271 {{attribute.cpp_setter}}; | 287 {{attribute.cpp_setter}}; |
| 288 {% endif %} | |
| 272 {# Post-set #} | 289 {# Post-set #} |
| 273 {% if attribute.is_setter_raises_exception %} | 290 {% if attribute.is_setter_raises_exception %} |
| 274 exceptionState.throwIfNeeded(); | 291 exceptionState.throwIfNeeded(); |
| 275 {% endif %} | 292 {% endif %} |
| 276 {% if attribute.cached_attribute_validation_method %} | 293 {% if attribute.cached_attribute_validation_method %} |
| 277 V8HiddenValue::deleteHiddenValue(info.GetIsolate(), holder, v8AtomicString(i nfo.GetIsolate(), "{{attribute.name}}")); // Invalidate the cached value. | 294 V8HiddenValue::deleteHiddenValue(info.GetIsolate(), holder, v8AtomicString(i nfo.GetIsolate(), "{{attribute.name}}")); // Invalidate the cached value. |
| 278 {% endif %} | 295 {% endif %} |
| 279 } | 296 } |
| 280 {% endfilter %} | 297 {% endfilter %} |
| 281 {% endmacro %} | 298 {% endmacro %} |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 access_control, | 440 access_control, |
| 424 property_attribute, | 441 property_attribute, |
| 425 only_exposed_to_private_script, | 442 only_exposed_to_private_script, |
| 426 ] %} | 443 ] %} |
| 427 {% if not attribute.is_expose_js_accessors %} | 444 {% if not attribute.is_expose_js_accessors %} |
| 428 {% set attribute_configuration_list = attribute_configuration_list | 445 {% set attribute_configuration_list = attribute_configuration_list |
| 429 + [on_prototype] %} | 446 + [on_prototype] %} |
| 430 {% endif %} | 447 {% endif %} |
| 431 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} | 448 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} |
| 432 {%- endmacro %} | 449 {%- endmacro %} |
| OLD | NEW |