OLD | NEW |
---|---|
1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} | 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} |
2 | 2 |
3 {##############################################################################} | 3 {##############################################################################} |
4 {% macro attribute_getter(attribute, world_suffix) %} | 4 {% macro attribute_getter(attribute, world_suffix) %} |
5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( | 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( |
6 {%- if attribute.is_data_type_property %} | 6 {%- if attribute.is_data_type_property %} |
7 const v8::PropertyCallbackInfo<v8::Value>& info | 7 const v8::PropertyCallbackInfo<v8::Value>& info |
8 {%- else %} | 8 {%- else %} |
9 const v8::FunctionCallbackInfo<v8::Value>& info | 9 const v8::FunctionCallbackInfo<v8::Value>& info |
10 {%- endif %}) { | 10 {%- endif %}) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext , "{{interface_name}}", "{{attribute.name}}"); | 286 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext , "{{interface_name}}", "{{attribute.name}}"); |
287 {%- endset %} | 287 {%- endset %} |
288 | 288 |
289 {% if attribute.is_lenient_this %} | 289 {% if attribute.is_lenient_this %} |
290 // [LenientThis] | 290 // [LenientThis] |
291 // Make sure that info.Holder() really points to an instance if [LenientThis]. | 291 // Make sure that info.Holder() really points to an instance if [LenientThis]. |
292 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) | 292 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) |
293 return; // Return silently because of [LenientThis]. | 293 return; // Return silently because of [LenientThis]. |
294 {% endif %} | 294 {% endif %} |
295 | 295 |
296 {% if not attribute.is_static and not attribute.is_replaceable %} | 296 {% set check_security_for_receiver = attribute.is_check_security_for_receiver and not attribute.is_data_type_property %} |
Jens Widell
2017/03/06 14:05:28
The reason I changed things a bit around the secur
haraken
2017/03/06 18:57:28
Just to confirm: This CL is not changing the condi
| |
297 | |
298 {% if not attribute.is_static and not attribute.is_replaceable and | |
299 (not attribute.is_put_forwards or check_security_for_receiver) %} | |
297 v8::Local<v8::Object> holder = info.Holder(); | 300 v8::Local<v8::Object> holder = info.Holder(); |
298 {% if attribute.is_put_forwards %} | |
299 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); | |
300 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); | |
301 if (!impl) | |
302 return; | |
303 {% else %} | |
304 {% set local_dom_window_only = interface_name == 'Window' and not attribute.ha s_cross_origin_setter %} | 301 {% set local_dom_window_only = interface_name == 'Window' and not attribute.ha s_cross_origin_setter %} |
305 {% if local_dom_window_only %} | 302 {% if local_dom_window_only %} |
306 {% if attribute.is_check_security_for_receiver %} | 303 {% if attribute.is_check_security_for_receiver %} |
307 {{cpp_class}}* uncheckedImpl = {{v8_class}}::toImpl(holder); | 304 {{cpp_class}}* uncheckedImpl = {{v8_class}}::toImpl(holder); |
308 {% else %} | 305 {% else %} |
309 // Same-origin attributes setters are never exposed via the cross-origin | 306 // Same-origin attributes setters are never exposed via the cross-origin |
310 // interceptors. Since same-origin access requires a LocalDOMWindow, it is | 307 // interceptors. Since same-origin access requires a LocalDOMWindow, it is |
311 // safe to downcast here. | 308 // safe to downcast here. |
312 LocalDOMWindow* impl = toLocalDOMWindow({{v8_class}}::toImpl(holder)); | 309 LocalDOMWindow* impl = toLocalDOMWindow({{v8_class}}::toImpl(holder)); |
313 {% endif %}{# attribute.is_check_security_for_receiver #} | 310 {% endif %}{# attribute.is_check_security_for_receiver #} |
314 {% else %} | 311 {% else %} |
315 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 312 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
316 {% endif %}{# local_dom_window_only #} | 313 {% endif %}{# local_dom_window_only #} |
317 {% endif %} | 314 {% endif %} |
318 {% endif %} | |
319 | 315 |
320 {% if attribute.is_check_security_for_receiver and not attribute.is_data_type_ property %} | 316 {% if check_security_for_receiver %} |
321 // Perform a security check for the receiver object. | 317 // Perform a security check for the receiver object. |
322 {{define_exception_state}} | 318 {{define_exception_state}} |
323 {% if local_dom_window_only %} | 319 {% if local_dom_window_only %} |
324 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), uncheckedImpl, exceptionState)) { | 320 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), uncheckedImpl, exceptionState)) { |
325 {% else %} | 321 {% else %} |
326 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) { | 322 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) { |
327 {% endif %}{# local_dom_window_only #} | 323 {% endif %}{# local_dom_window_only #} |
328 v8SetReturnValue(info, v8Value); | 324 v8SetReturnValue(info, v8Value); |
329 return; | 325 return; |
330 } | 326 } |
331 {% if local_dom_window_only %} | 327 {% if local_dom_window_only %} |
332 LocalDOMWindow* impl = toLocalDOMWindow(uncheckedImpl); | 328 LocalDOMWindow* impl = toLocalDOMWindow(uncheckedImpl); |
333 {% endif %}{# local_dom_window_only #} | 329 {% endif %}{# local_dom_window_only #} |
334 {% endif %} | 330 {% endif %} |
335 | 331 |
336 {% if attribute.is_check_security_for_return_value %} | 332 {% if attribute.is_check_security_for_return_value %} |
337 #error Attribute setter with the security check for the return value is not supp orted. Since the return value is the given value to be set, it\'s meaningless t o perform the security check for the return value. | 333 #error Attribute setter with the security check for the return value is not supp orted. Since the return value is the given value to be set, it\'s meaningless t o perform the security check for the return value. |
338 {% endif %} | 334 {% endif %} |
339 | 335 |
336 {% if attribute.is_put_forwards %} | |
337 {{define_exception_state}} | |
338 v8::Local<v8::Value> target; | |
339 if (!info.Holder()->Get(info.GetIsolate()->GetEnteredContext(), v8String(info. GetIsolate(), "{{attribute.name}}")).ToLocal(&target)) | |
340 return; | |
341 if (!target->IsObject()) { | |
342 exceptionState.throwTypeError("The attribute value is not an object"); | |
343 return; | |
344 } | |
345 target.As<v8::Object>()->Set(info.GetIsolate()->GetEnteredContext(), v8String( info.GetIsolate(), "{{attribute.target_attribute_name}}"), v8Value).IsNothing(); | |
Jens Widell
2017/03/06 14:05:28
Note on use of `GetEnteredContext()` here: using `
haraken
2017/03/06 18:57:28
Yeah, I think this is because Chromium has not yet
jochen (gone - plz use gerrit)
2017/03/07 11:45:06
GetEnteredContext is also wrong during microtask e
haraken
2017/03/07 12:15:22
Jens: I'm confused. The context parameter in Get()
| |
346 {% else %} | |
340 {% if attribute.is_custom_element_callbacks or | 347 {% if attribute.is_custom_element_callbacks or |
341 (attribute.is_reflect and not (attribute.idl_type == 'DOMString' and is_ node)) %} | 348 (attribute.is_reflect and not (attribute.idl_type == 'DOMString' and is_ node)) %} |
342 // Skip on compact node DOMString getters. | 349 // Skip on compact node DOMString getters. |
343 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; | 350 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; |
344 {% endif %} | 351 {% endif %} |
345 | 352 |
346 {% if attribute.has_setter_exception_state %} | 353 {% if attribute.has_setter_exception_state %} |
347 {{define_exception_state}} | 354 {{define_exception_state}} |
348 {% endif %} | 355 {% endif %} |
349 | 356 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 {% if attribute.is_replaceable %} | 397 {% if attribute.is_replaceable %} |
391 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attr ibute.name}}"); | 398 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attr ibute.name}}"); |
392 {% endif %} | 399 {% endif %} |
393 {{attribute.cpp_setter}}; | 400 {{attribute.cpp_setter}}; |
394 | 401 |
395 {% if attribute.cached_attribute_validation_method %} | 402 {% if attribute.cached_attribute_validation_method %} |
396 // [CachedAttribute] | 403 // [CachedAttribute] |
397 // Invalidate the cached value. | 404 // Invalidate the cached value. |
398 V8HiddenValue::deleteHiddenValue(ScriptState::forFunctionObject(info), holder, v8AtomicString(info.GetIsolate(), "{{attribute.name}}")); | 405 V8HiddenValue::deleteHiddenValue(ScriptState::forFunctionObject(info), holder, v8AtomicString(info.GetIsolate(), "{{attribute.name}}")); |
399 {% endif %} | 406 {% endif %} |
407 {% endif %}{# is_put_forwards #} | |
400 } | 408 } |
401 {% endfilter %}{# format_remove_duplicates #} | 409 {% endfilter %}{# format_remove_duplicates #} |
402 {% endmacro %} | 410 {% endmacro %} |
403 | 411 |
404 | 412 |
405 {##############################################################################} | 413 {##############################################################################} |
406 {% macro attribute_setter_callback(attribute, world_suffix) %} | 414 {% macro attribute_setter_callback(attribute, world_suffix) %} |
407 void {{v8_class_or_partial}}::{{attribute.name}}AttributeSetterCallback{{world_s uffix}}( | 415 void {{v8_class_or_partial}}::{{attribute.name}}AttributeSetterCallback{{world_s uffix}}( |
408 {%- if attribute.is_data_type_property %} | 416 {%- if attribute.is_data_type_property %} |
409 v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInf o<void>& info | 417 v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInf o<void>& info |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 {% filter exposed(attribute.exposed_test) %} | 519 {% filter exposed(attribute.exposed_test) %} |
512 {% filter secure_context(attribute.secure_context_test) %} | 520 {% filter secure_context(attribute.secure_context_test) %} |
513 {% filter runtime_enabled(attribute.runtime_enabled_feature_name) %} | 521 {% filter runtime_enabled(attribute.runtime_enabled_feature_name) %} |
514 const V8DOMConfiguration::AccessorConfiguration accessorConfiguration = {{attrib ute_configuration(attribute)}}; | 522 const V8DOMConfiguration::AccessorConfiguration accessorConfiguration = {{attrib ute_configuration(attribute)}}; |
515 V8DOMConfiguration::installAccessor(isolate, world, v8::Local<v8::Object>(), pro totypeObject, interfaceObject, signature, accessorConfiguration); | 523 V8DOMConfiguration::installAccessor(isolate, world, v8::Local<v8::Object>(), pro totypeObject, interfaceObject, signature, accessorConfiguration); |
516 {% endfilter %}{# runtime_enabled #} | 524 {% endfilter %}{# runtime_enabled #} |
517 {% endfilter %}{# secure_context #} | 525 {% endfilter %}{# secure_context #} |
518 {% endfilter %}{# exposed #} | 526 {% endfilter %}{# exposed #} |
519 {% endfor %} | 527 {% endfor %} |
520 {% endmacro %} | 528 {% endmacro %} |
OLD | NEW |