ErrorEvent.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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/HTML/ErrorEvent.h>
  8. namespace Web::HTML {
  9. JS_DEFINE_ALLOCATOR(ErrorEvent);
  10. JS::NonnullGCPtr<ErrorEvent> ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
  11. {
  12. return realm.heap().allocate<ErrorEvent>(realm, realm, event_name, event_init);
  13. }
  14. WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
  15. {
  16. return create(realm, event_name, event_init);
  17. }
  18. ErrorEvent::ErrorEvent(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
  19. : DOM::Event(realm, event_name)
  20. , m_message(event_init.message)
  21. , m_filename(event_init.filename)
  22. , m_lineno(event_init.lineno)
  23. , m_colno(event_init.colno)
  24. , m_error(event_init.error)
  25. {
  26. }
  27. ErrorEvent::~ErrorEvent() = default;
  28. void ErrorEvent::initialize(JS::Realm& realm)
  29. {
  30. Base::initialize(realm);
  31. WEB_SET_PROTOTYPE_FOR_INTERFACE(ErrorEvent);
  32. }
  33. void ErrorEvent::visit_edges(Cell::Visitor& visitor)
  34. {
  35. Base::visit_edges(visitor);
  36. visitor.visit(m_error);
  37. }
  38. }