ErrorEvent.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/DOM/Event.h>
  8. namespace Web::HTML {
  9. // https://html.spec.whatwg.org/multipage/webappapis.html#erroreventinit
  10. struct ErrorEventInit : public DOM::EventInit {
  11. String message { "" };
  12. String filename { "" }; // FIXME: This should be a USVString.
  13. u32 lineno { 0 };
  14. u32 colno { 0 };
  15. JS::Value error { JS::js_null() };
  16. };
  17. // https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
  18. class ErrorEvent final : public DOM::Event {
  19. WEB_PLATFORM_OBJECT(ErrorEvent, DOM::Event);
  20. public:
  21. static ErrorEvent* create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init = {});
  22. static ErrorEvent* construct_impl(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init);
  23. virtual ~ErrorEvent() override;
  24. // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-message
  25. String const& message() const { return m_message; }
  26. // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-filename
  27. String const& filename() const { return m_filename; }
  28. // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-lineno
  29. u32 lineno() const { return m_lineno; }
  30. // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-colno
  31. u32 colno() const { return m_colno; }
  32. // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-error
  33. JS::Value error() const { return m_error; }
  34. private:
  35. ErrorEvent(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init);
  36. virtual void visit_edges(Cell::Visitor&) override;
  37. String m_message { "" };
  38. String m_filename { "" }; // FIXME: This should be a USVString.
  39. u32 m_lineno { 0 };
  40. u32 m_colno { 0 };
  41. JS::Value m_error;
  42. };
  43. }