ErrorEvent.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. auto event = realm.create<ErrorEvent>(realm, event_name, event_init);
  14. event->set_is_trusted(true);
  15. return event;
  16. }
  17. WebIDL::ExceptionOr<GC::Ref<ErrorEvent>> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
  18. {
  19. return realm.create<ErrorEvent>(realm, event_name, event_init);
  20. }
  21. ErrorEvent::ErrorEvent(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
  22. : DOM::Event(realm, event_name)
  23. , m_message(event_init.message)
  24. , m_filename(event_init.filename)
  25. , m_lineno(event_init.lineno)
  26. , m_colno(event_init.colno)
  27. , m_error(event_init.error)
  28. {
  29. }
  30. ErrorEvent::~ErrorEvent() = default;
  31. void ErrorEvent::initialize(JS::Realm& realm)
  32. {
  33. Base::initialize(realm);
  34. WEB_SET_PROTOTYPE_FOR_INTERFACE(ErrorEvent);
  35. }
  36. void ErrorEvent::visit_edges(Cell::Visitor& visitor)
  37. {
  38. Base::visit_edges(visitor);
  39. visitor.visit(m_error);
  40. }
  41. }