TextEvent.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/Bindings/TextEventPrototype.h>
  8. #include <LibWeb/UIEvents/TextEvent.h>
  9. namespace Web::UIEvents {
  10. GC_DEFINE_ALLOCATOR(TextEvent);
  11. GC::Ref<TextEvent> TextEvent::create(JS::Realm& realm, FlyString const& event_name)
  12. {
  13. return realm.create<TextEvent>(realm, event_name);
  14. }
  15. TextEvent::TextEvent(JS::Realm& realm, FlyString const& event_name)
  16. : UIEvent(realm, event_name)
  17. {
  18. }
  19. TextEvent::~TextEvent() = default;
  20. void TextEvent::initialize(JS::Realm& realm)
  21. {
  22. Base::initialize(realm);
  23. WEB_SET_PROTOTYPE_FOR_INTERFACE(TextEvent);
  24. }
  25. // https://w3c.github.io/uievents/#dom-textevent-inittextevent
  26. void TextEvent::init_text_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, String const& data)
  27. {
  28. // Initializes attributes of a TextEvent object. This method has the same behavior as UIEvent.initUIEvent().
  29. // The value of detail remains undefined.
  30. // 1. If this’s dispatch flag is set, then return.
  31. if (dispatched())
  32. return;
  33. // 2. Initialize this with type, bubbles, and cancelable.
  34. initialize_event(type, bubbles, cancelable);
  35. // Implementation Defined: Initialise other values.
  36. m_view = view;
  37. m_data = data;
  38. }
  39. }