UIEvent.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/Bindings/UIEventPrototype.h>
  8. #include <LibWeb/HTML/WindowProxy.h>
  9. #include <LibWeb/UIEvents/UIEvent.h>
  10. namespace Web::UIEvents {
  11. GC_DEFINE_ALLOCATOR(UIEvent);
  12. GC::Ref<UIEvent> UIEvent::create(JS::Realm& realm, FlyString const& event_name)
  13. {
  14. return realm.create<UIEvent>(realm, event_name);
  15. }
  16. WebIDL::ExceptionOr<GC::Ref<UIEvent>> UIEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, UIEventInit const& event_init)
  17. {
  18. return realm.create<UIEvent>(realm, event_name, event_init);
  19. }
  20. UIEvent::UIEvent(JS::Realm& realm, FlyString const& event_name)
  21. : Event(realm, event_name)
  22. {
  23. }
  24. UIEvent::UIEvent(JS::Realm& realm, FlyString const& event_name, UIEventInit const& event_init)
  25. : Event(realm, event_name, event_init)
  26. , m_view(event_init.view)
  27. , m_detail(event_init.detail)
  28. {
  29. }
  30. UIEvent::~UIEvent() = default;
  31. void UIEvent::initialize(JS::Realm& realm)
  32. {
  33. Base::initialize(realm);
  34. WEB_SET_PROTOTYPE_FOR_INTERFACE(UIEvent);
  35. }
  36. void UIEvent::visit_edges(Cell::Visitor& visitor)
  37. {
  38. Base::visit_edges(visitor);
  39. visitor.visit(m_view);
  40. }
  41. }