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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 v8::Local<v8::Value> v8Value, const V8CrossOriginSetterInfo& info | 281 v8::Local<v8::Value> v8Value, const V8CrossOriginSetterInfo& info |
282 {%- elif attribute.is_data_type_property %} | 282 {%- elif attribute.is_data_type_property %} |
283 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info | 283 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info |
284 {%- else %} | 284 {%- else %} |
285 v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info | 285 v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info |
286 {%- endif %}) { | 286 {%- endif %}) { |
287 {% filter format_remove_duplicates(['ExceptionState exceptionState']) %} | 287 {% filter format_remove_duplicates(['ExceptionState exceptionState']) %} |
288 v8::Isolate* isolate = info.GetIsolate(); | 288 v8::Isolate* isolate = info.GetIsolate(); |
289 ALLOW_UNUSED_LOCAL(isolate); | 289 ALLOW_UNUSED_LOCAL(isolate); |
290 | 290 |
291 v8::Local<v8::Object> holder = info.Holder(); | |
292 ALLOW_UNUSED_LOCAL(holder); | |
293 | |
291 {% set define_exception_state -%} | 294 {% set define_exception_state -%} |
292 ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "{{inte rface_name}}", "{{attribute.name}}"); | 295 ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "{{inte rface_name}}", "{{attribute.name}}"); |
293 {%- endset %} | 296 {%- endset %} |
294 | 297 |
295 {% if attribute.is_lenient_this %} | 298 {% if attribute.is_lenient_this %} |
296 // [LenientThis] | 299 // [LenientThis] |
297 // Make sure that info.Holder() really points to an instance if [LenientThis]. | 300 // Make sure that info.Holder() really points to an instance if [LenientThis]. |
298 if (!{{v8_class}}::hasInstance(info.Holder(), isolate)) | 301 if (!{{v8_class}}::hasInstance(holder, isolate)) |
299 return; // Return silently because of [LenientThis]. | 302 return; // Return silently because of [LenientThis]. |
300 {% endif %} | 303 {% endif %} |
301 | 304 |
302 {% if not attribute.is_static and not attribute.is_replaceable %} | 305 {% if not attribute.is_static and not attribute.is_replaceable and not attribu te.is_put_forwards %} |
303 v8::Local<v8::Object> holder = info.Holder(); | |
304 {% if attribute.is_put_forwards %} | |
305 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); | |
306 {{attribute.cpp_type}} impl = WTF::GetPtr(proxyImpl->{{attribute.name}}()); | |
307 if (!impl) | |
308 return; | |
309 {% else %} | |
310 {% set local_dom_window_only = interface_name == 'Window' and not attribute.ha s_cross_origin_setter %} | 306 {% set local_dom_window_only = interface_name == 'Window' and not attribute.ha s_cross_origin_setter %} |
311 {% if local_dom_window_only %} | 307 {% if local_dom_window_only %} |
312 {% if attribute.is_check_security_for_receiver %} | 308 {% if attribute.is_check_security_for_receiver %} |
313 {{cpp_class}}* uncheckedImpl = {{v8_class}}::toImpl(holder); | 309 {{cpp_class}}* uncheckedImpl = {{v8_class}}::toImpl(holder); |
314 {% else %} | 310 {% else %} |
315 // Same-origin attributes setters are never exposed via the cross-origin | 311 // Same-origin attributes setters are never exposed via the cross-origin |
316 // interceptors. Since same-origin access requires a LocalDOMWindow, it is | 312 // interceptors. Since same-origin access requires a LocalDOMWindow, it is |
317 // safe to downcast here. | 313 // safe to downcast here. |
318 LocalDOMWindow* impl = ToLocalDOMWindow({{v8_class}}::toImpl(holder)); | 314 LocalDOMWindow* impl = ToLocalDOMWindow({{v8_class}}::toImpl(holder)); |
319 {% endif %}{# attribute.is_check_security_for_receiver #} | 315 {% endif %}{# attribute.is_check_security_for_receiver #} |
320 {% else %} | 316 {% else %} |
321 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 317 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
322 {% endif %}{# local_dom_window_only #} | 318 {% endif %}{# local_dom_window_only #} |
323 {% endif %} | 319 {% endif %} |
324 {% endif %} | |
325 | 320 |
326 {% if attribute.is_check_security_for_receiver and not attribute.is_data_type_ property %} | 321 {% if attribute.is_check_security_for_receiver and not attribute.is_data_type_ property %} |
327 // Perform a security check for the receiver object. | 322 // Perform a security check for the receiver object. |
328 {{define_exception_state}} | 323 {{define_exception_state}} |
329 {% if local_dom_window_only %} | 324 {% if local_dom_window_only %} |
330 if (!BindingSecurity::ShouldAllowAccessTo(CurrentDOMWindow(isolate), unchecked Impl, exceptionState)) { | 325 if (!BindingSecurity::ShouldAllowAccessTo(CurrentDOMWindow(isolate), unchecked Impl, exceptionState)) { |
331 {% else %} | 326 {% else %} |
332 if (!BindingSecurity::ShouldAllowAccessTo(CurrentDOMWindow(isolate), impl, exc eptionState)) { | 327 if (!BindingSecurity::ShouldAllowAccessTo(CurrentDOMWindow(isolate), impl, exc eptionState)) { |
333 {% endif %}{# local_dom_window_only #} | 328 {% endif %}{# local_dom_window_only #} |
334 V8SetReturnValue(info, v8Value); | 329 V8SetReturnValue(info, v8Value); |
335 return; | 330 return; |
336 } | 331 } |
337 {% if local_dom_window_only %} | 332 {% if local_dom_window_only %} |
338 LocalDOMWindow* impl = ToLocalDOMWindow(uncheckedImpl); | 333 LocalDOMWindow* impl = ToLocalDOMWindow(uncheckedImpl); |
339 {% endif %}{# local_dom_window_only #} | 334 {% endif %}{# local_dom_window_only #} |
340 {% endif %} | 335 {% endif %} |
341 | 336 |
342 {% if attribute.is_check_security_for_return_value %} | 337 {% if attribute.is_check_security_for_return_value %} |
343 #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 #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. |
344 {% endif %} | 339 {% endif %} |
345 | 340 |
341 {% if attribute.is_put_forwards %} | |
342 // [PutForwards] => {{attribute.name}}.{{attribute.target_attribute_name}} | |
343 {{define_exception_state}} | |
344 v8::Local<v8::Value> target; | |
345 if (!holder->Get(isolate->GetCurrentContext(), V8String(isolate, "{{attribute. name}}")).ToLocal(&target)) | |
haraken
2017/05/10 14:40:03
Just to confirm: If the author script overrides th
| |
346 return; | |
347 if (!target->IsObject()) { | |
348 exceptionState.ThrowTypeError("The attribute value is not an object"); | |
349 return; | |
350 } | |
351 v8::Maybe<bool> result = target.As<v8::Object>()->Set(isolate->GetCurrentConte xt(), V8String(isolate, "{{attribute.target_attribute_name}}"), v8Value); | |
haraken
2017/05/10 14:40:03
Ditto. The customized setter can be called.
haraken
2017/05/10 14:40:03
We prefer avoid using Maybe. You can use ...Set().
| |
352 if (result.IsNothing() || !result.FromJust()) | |
353 return; | |
354 {% else %}{# attribute.is_put_forwards #} | |
346 {% if attribute.is_custom_element_callbacks or | 355 {% if attribute.is_custom_element_callbacks or |
347 (attribute.is_reflect and not (attribute.idl_type == 'DOMString' and is_ node)) %} | 356 (attribute.is_reflect and not (attribute.idl_type == 'DOMString' and is_ node)) %} |
348 // Skip on compact node DOMString getters. | 357 // Skip on compact node DOMString getters. |
349 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; | 358 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; |
350 {% endif %} | 359 {% endif %} |
351 | 360 |
352 {% if attribute.has_setter_exception_state %} | 361 {% if attribute.has_setter_exception_state %} |
353 {{define_exception_state}} | 362 {{define_exception_state}} |
354 {% endif %} | 363 {% endif %} |
355 | 364 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 {% endif %} | 410 {% endif %} |
402 {{attribute.cpp_setter}}; | 411 {{attribute.cpp_setter}}; |
403 | 412 |
404 {% if attribute.cached_attribute_validation_method %} | 413 {% if attribute.cached_attribute_validation_method %} |
405 // [CachedAttribute] | 414 // [CachedAttribute] |
406 // Invalidate the cached value. | 415 // Invalidate the cached value. |
407 V8PrivateProperty::GetSymbol( | 416 V8PrivateProperty::GetSymbol( |
408 isolate, "{{cpp_class}}#{{attribute.name.capitalize()}}") | 417 isolate, "{{cpp_class}}#{{attribute.name.capitalize()}}") |
409 .DeleteProperty(holder, v8::Undefined(isolate)); | 418 .DeleteProperty(holder, v8::Undefined(isolate)); |
410 {% endif %} | 419 {% endif %} |
420 {% endif %}{# attribute.is_put_forwards #} | |
411 } | 421 } |
412 {% endfilter %}{# format_remove_duplicates #} | 422 {% endfilter %}{# format_remove_duplicates #} |
413 {% endmacro %} | 423 {% endmacro %} |
414 | 424 |
415 | 425 |
416 {##############################################################################} | 426 {##############################################################################} |
417 {% macro attribute_setter_callback(attribute, world_suffix) %} | 427 {% macro attribute_setter_callback(attribute, world_suffix) %} |
418 void {{v8_class_or_partial}}::{{attribute.name}}AttributeSetterCallback{{world_s uffix}}( | 428 void {{v8_class_or_partial}}::{{attribute.name}}AttributeSetterCallback{{world_s uffix}}( |
419 {%- if attribute.is_data_type_property %} | 429 {%- if attribute.is_data_type_property %} |
420 v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInf o<void>& info | 430 v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInf o<void>& info |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration[] = { | 528 static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration[] = { |
519 {{attribute_configuration(attribute)}} | 529 {{attribute_configuration(attribute)}} |
520 }; | 530 }; |
521 for (const auto& accessorConfig : accessorConfiguration) | 531 for (const auto& accessorConfig : accessorConfiguration) |
522 V8DOMConfiguration::InstallAccessor(isolate, world, v8::Local<v8::Object>(), p rototypeObject, interfaceObject, signature, accessorConfig); | 532 V8DOMConfiguration::InstallAccessor(isolate, world, v8::Local<v8::Object>(), p rototypeObject, interfaceObject, signature, accessorConfig); |
523 {% endfilter %}{# runtime_enabled #} | 533 {% endfilter %}{# runtime_enabled #} |
524 {% endfilter %}{# secure_context #} | 534 {% endfilter %}{# secure_context #} |
525 {% endfilter %}{# exposed #} | 535 {% endfilter %}{# exposed #} |
526 {% endfor %} | 536 {% endfor %} |
527 {% endmacro %} | 537 {% endmacro %} |
OLD | NEW |