ErrorEvent.cpp 1.3 KB

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