ToggleEvent.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/FlyString.h>
  8. #include <AK/String.h>
  9. #include <LibWeb/DOM/Event.h>
  10. namespace Web::HTML {
  11. struct ToggleEventInit : public DOM::EventInit {
  12. String old_state;
  13. String new_state;
  14. };
  15. class ToggleEvent : public DOM::Event {
  16. WEB_PLATFORM_OBJECT(ToggleEvent, DOM::Event);
  17. public:
  18. [[nodiscard]] static JS::NonnullGCPtr<ToggleEvent> create(JS::Realm&, FlyString const& event_name, ToggleEventInit = {});
  19. static WebIDL::ExceptionOr<JS::NonnullGCPtr<ToggleEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ToggleEventInit);
  20. // https://html.spec.whatwg.org/multipage/interaction.html#dom-toggleevent-oldstate
  21. String const& old_state() const { return m_old_state; }
  22. // https://html.spec.whatwg.org/multipage/interaction.html#dom-toggleevent-newstate
  23. String const& new_state() const { return m_new_state; }
  24. private:
  25. ToggleEvent(JS::Realm&, FlyString const& event_name, ToggleEventInit event_init);
  26. virtual void initialize(JS::Realm&) override;
  27. String m_old_state;
  28. String m_new_state;
  29. };
  30. }