HashChangeEvent.cpp 1.3 KB

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