UIEvent.cpp 1.2 KB

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