event.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (c) 2023 Salesforce, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_H_
  5. #define ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_H_
  6. #include "gin/handle.h"
  7. #include "gin/wrappable.h"
  8. #include "shell/common/gin_helper/constructible.h"
  9. namespace v8 {
  10. class Isolate;
  11. template <typename T>
  12. class Local;
  13. class Object;
  14. class ObjectTemplate;
  15. } // namespace v8
  16. namespace gin_helper::internal {
  17. class Event : public gin::Wrappable<Event>,
  18. public gin_helper::Constructible<Event> {
  19. public:
  20. // gin_helper::Constructible
  21. static gin::Handle<Event> New(v8::Isolate* isolate);
  22. static v8::Local<v8::ObjectTemplate> FillObjectTemplate(
  23. v8::Isolate* isolate,
  24. v8::Local<v8::ObjectTemplate> prototype);
  25. static const char* GetClassName() { return "Event"; }
  26. // gin::Wrappable
  27. static gin::WrapperInfo kWrapperInfo;
  28. const char* GetTypeName() override;
  29. ~Event() override;
  30. void PreventDefault() { default_prevented_ = true; }
  31. bool GetDefaultPrevented() { return default_prevented_; }
  32. private:
  33. Event();
  34. bool default_prevented_ = false;
  35. };
  36. } // namespace gin_helper::internal
  37. #endif // ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_H_