ErrorEvent.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/ErrorEventPrototype.h>
  7. #include <LibWeb/HTML/ErrorEvent.h>
  8. #include <LibWeb/HTML/Window.h>
  9. namespace Web::HTML {
  10. ErrorEvent* ErrorEvent::create(HTML::Window& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
  11. {
  12. return window_object.heap().allocate<ErrorEvent>(window_object.realm(), window_object, event_name, event_init);
  13. }
  14. ErrorEvent* ErrorEvent::create_with_global_object(HTML::Window& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
  15. {
  16. return create(window_object, event_name, event_init);
  17. }
  18. ErrorEvent::ErrorEvent(HTML::Window& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
  19. : DOM::Event(window_object, 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. set_prototype(&window_object.ensure_web_prototype<Bindings::ErrorEventPrototype>("ErrorEvent"));
  27. }
  28. ErrorEvent::~ErrorEvent() = default;
  29. void ErrorEvent::visit_edges(Cell::Visitor& visitor)
  30. {
  31. Base::visit_edges(visitor);
  32. visitor.visit(m_error);
  33. }
  34. }