ErrorEvent.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/ErrorEventPrototype.h>
  7. #include <LibWeb/Bindings/Intrinsics.h>
  8. #include <LibWeb/HTML/ErrorEvent.h>
  9. namespace Web::HTML {
  10. GC_DEFINE_ALLOCATOR(ErrorEvent);
  11. GC::Ref<ErrorEvent> ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
  12. {
  13. return realm.create<ErrorEvent>(realm, event_name, event_init);
  14. }
  15. WebIDL::ExceptionOr<GC::Ref<ErrorEvent>> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
  16. {
  17. return create(realm, event_name, event_init);
  18. }
  19. ErrorEvent::ErrorEvent(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
  20. : DOM::Event(realm, event_name)
  21. , m_message(event_init.message)
  22. , m_filename(event_init.filename)
  23. , m_lineno(event_init.lineno)
  24. , m_colno(event_init.colno)
  25. , m_error(event_init.error)
  26. {
  27. }
  28. ErrorEvent::~ErrorEvent() = default;
  29. void ErrorEvent::initialize(JS::Realm& realm)
  30. {
  31. Base::initialize(realm);
  32. WEB_SET_PROTOTYPE_FOR_INTERFACE(ErrorEvent);
  33. }
  34. void ErrorEvent::visit_edges(Cell::Visitor& visitor)
  35. {
  36. Base::visit_edges(visitor);
  37. visitor.visit(m_error);
  38. }
  39. }