event.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/wrappable.h"
  7. #include "shell/common/gin_helper/constructible.h"
  8. namespace gin {
  9. template <typename T>
  10. class Handle;
  11. } // namespace gin
  12. namespace v8 {
  13. class Isolate;
  14. template <typename T>
  15. class Local;
  16. class Object;
  17. class ObjectTemplate;
  18. } // namespace v8
  19. namespace gin_helper::internal {
  20. class Event final : public gin::Wrappable<Event>,
  21. public gin_helper::Constructible<Event> {
  22. public:
  23. // gin_helper::Constructible
  24. static gin::Handle<Event> New(v8::Isolate* isolate);
  25. static v8::Local<v8::ObjectTemplate> FillObjectTemplate(
  26. v8::Isolate* isolate,
  27. v8::Local<v8::ObjectTemplate> prototype);
  28. static const char* GetClassName() { return "Event"; }
  29. // gin::Wrappable
  30. static gin::WrapperInfo kWrapperInfo;
  31. const char* GetTypeName() override;
  32. ~Event() override;
  33. void PreventDefault() { default_prevented_ = true; }
  34. bool GetDefaultPrevented() { return default_prevented_; }
  35. private:
  36. Event();
  37. bool default_prevented_ = false;
  38. };
  39. } // namespace gin_helper::internal
  40. #endif // ELECTRON_SHELL_COMMON_GIN_HELPER_EVENT_H_