PopStateEvent.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGC/Heap.h>
  7. #include <LibJS/Runtime/Realm.h>
  8. #include <LibWeb/Bindings/Intrinsics.h>
  9. #include <LibWeb/Bindings/PopStateEventPrototype.h>
  10. #include <LibWeb/HTML/PopStateEvent.h>
  11. namespace Web::HTML {
  12. GC_DEFINE_ALLOCATOR(PopStateEvent);
  13. [[nodiscard]] GC::Ref<PopStateEvent> PopStateEvent::create(JS::Realm& realm, FlyString const& event_name, PopStateEventInit const& event_init)
  14. {
  15. return realm.create<PopStateEvent>(realm, event_name, event_init);
  16. }
  17. GC::Ref<PopStateEvent> PopStateEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PopStateEventInit const& event_init)
  18. {
  19. return realm.create<PopStateEvent>(realm, event_name, event_init);
  20. }
  21. PopStateEvent::PopStateEvent(JS::Realm& realm, FlyString const& event_name, PopStateEventInit const& event_init)
  22. : DOM::Event(realm, event_name, event_init)
  23. , m_state(event_init.state)
  24. {
  25. }
  26. void PopStateEvent::initialize(JS::Realm& realm)
  27. {
  28. Base::initialize(realm);
  29. WEB_SET_PROTOTYPE_FOR_INTERFACE(PopStateEvent);
  30. }
  31. void PopStateEvent::visit_edges(JS::Cell::Visitor& visitor)
  32. {
  33. Base::visit_edges(visitor);
  34. visitor.visit(m_state);
  35. }
  36. }