MessageEvent.h 959 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/DOM/Event.h>
  8. namespace Web::HTML {
  9. class MessageEvent : public DOM::Event {
  10. public:
  11. using WrapperType = Bindings::MessageEventWrapper;
  12. static NonnullRefPtr<MessageEvent> create(const FlyString& event_name, JS::Value data, String const& origin)
  13. {
  14. return adopt_ref(*new MessageEvent(event_name, data, origin));
  15. }
  16. virtual ~MessageEvent() override = default;
  17. JS::Value data() const { return m_data; }
  18. String const& origin() const { return m_origin; }
  19. String const& last_event_id() const { return m_last_event_id; }
  20. protected:
  21. MessageEvent(const FlyString& event_name, JS::Value data, String origin)
  22. : DOM::Event(event_name)
  23. , m_data(data)
  24. , m_origin(move(origin))
  25. {
  26. }
  27. JS::Value m_data;
  28. String m_origin;
  29. String m_last_event_id;
  30. };
  31. }