DOMEventListener.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/FlyString.h>
  8. #include <LibGC/Ptr.h>
  9. #include <LibJS/Runtime/Object.h>
  10. #include <LibWeb/Forward.h>
  11. namespace Web::DOM {
  12. // https://dom.spec.whatwg.org/#concept-event-listener
  13. // NOTE: The spec calls this "event listener", and it's *importantly* not the same as "EventListener"
  14. class DOMEventListener : public JS::Cell {
  15. GC_CELL(DOMEventListener, JS::Cell);
  16. GC_DECLARE_ALLOCATOR(DOMEventListener);
  17. public:
  18. DOMEventListener();
  19. ~DOMEventListener();
  20. // type (a string)
  21. FlyString type;
  22. // callback (null or an EventListener object)
  23. GC::Ptr<IDLEventListener> callback;
  24. // signal (null or an AbortSignal object)
  25. GC::Ptr<DOM::AbortSignal> signal;
  26. // capture (a boolean, initially false)
  27. bool capture { false };
  28. // passive (a boolean, initially false)
  29. bool passive { false };
  30. // once (a boolean, initially false)
  31. bool once { false };
  32. // removed (a boolean for bookkeeping purposes, initially false)
  33. bool removed { false };
  34. private:
  35. virtual void visit_edges(Cell::Visitor&) override;
  36. };
  37. }