1{% filter format_blink_cpp_source_code %} 2 3{% include 'copyright_block.txt' %} 4#ifndef {{header_guard}} 5#define {{header_guard}} 6 7{% for filename in header_includes %} 8#include "{{filename}}" 9{% endfor %} 10 11namespace blink { 12 13{% for forward_declaration in forward_declarations %} 14class {{forward_declaration}}; 15{% endfor %} 16 17{% if is_legacy_callback_interface %} 18{{exported}}extern const WrapperTypeInfo {{snake_case_v8_class}}_wrapper_type_info; 19{% endif %} 20 21class {{exported}}{{v8_class}} final : public CallbackInterfaceBase { 22 public: 23{% if is_legacy_callback_interface %} 24 // Support of "legacy callback interface" 25 static v8::Local<v8::FunctionTemplate> DomTemplate(v8::Isolate*, const DOMWrapperWorld&); 26 static constexpr const WrapperTypeInfo* GetWrapperTypeInfo() { 27 return &{{snake_case_v8_class}}_wrapper_type_info; 28 } 29 30 // Constants 31{% for constant in constants %} 32 static constexpr {{constant.cpp_type}} {{constant.name}} = {{constant.value}}; 33{% endfor %} 34 35{% endif %} 36 static {{v8_class}}* Create(v8::Local<v8::Object> callback_object) { 37 return MakeGarbageCollected<{{v8_class}}>(callback_object); 38 } 39 40{% set single_operation_enum_value = 41 'kSingleOperation' if is_single_operation_callback_interface else 42 'kNotSingleOperation' %} 43 explicit {{v8_class}}(v8::Local<v8::Object> callback_object) 44 : CallbackInterfaceBase(callback_object, 45 {{single_operation_enum_value}}) {} 46 ~{{v8_class}}() override = default; 47 48 // NameClient overrides: 49 const char* NameInHeapSnapshot() const override; 50 51{% for method in methods %} 52 // Performs "call a user object's operation". 53 // https://heycam.github.io/webidl/#call-a-user-objects-operation 54 v8::Maybe<{{method.cpp_type}}> {{method.name}}({{method.argument_declarations | join(', ')}}) WARN_UNUSED_RESULT; 55 56{% endfor %} 57 58{% if methods|length == 1 and methods[0].idl_type == 'void' %} 59 // Performs "call a user object's operation", and then reports an exception, 60 // if any, to the global error handler such as DevTools' console. 61 void InvokeAndReportException({{methods[0].argument_declarations | join(', ')}}); 62{% endif %} 63 64{% if interface_name == 'EventListener' %} 65 // Returns true if the callback is runnable, otherwise returns false and 66 // throws an exception. 'beforeunload' event need to have priority over pause 67 // of execution contexts. 68 enum class IgnorePause { kDontIgnore, kIgnore }; 69 bool IsRunnableOrThrowException(IgnorePause); 70 71 // Performs "call a user object's operation" for '{{methods[0].name}}' without 72 // checking the runnability check, which must be done prior to this call by 73 // |IsRunnableOrThrowException|. 74 // https://heycam.github.io/webidl/#call-a-user-objects-operation 75 // This function may throw unlike InvokeAndReportException. 76 v8::Maybe<{{methods[0].cpp_type}}> InvokeWithoutRunnabilityCheck({{methods[0].argument_declarations | join(', ')}}) WARN_UNUSED_RESULT; 77{% endif %} 78}; 79 80} // namespace blink 81 82#endif // {{header_guard}} 83 84{% endfilter %}{# format_blink_cpp_source_code #} 85