Bug 1733869 [wpt PR 30916] - Add a note about counterintuitive send_keys() code point...
[gecko.git] / accessible / base / EventTree.h
blob59b269f6d31ec9045f1544bd3d92c175c0066d0b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_a11y_EventTree_h_
7 #define mozilla_a11y_EventTree_h_
9 #include "AccEvent.h"
10 #include "LocalAccessible.h"
12 #include "mozilla/a11y/DocAccessible.h"
13 #include "mozilla/RefPtr.h"
14 #include "mozilla/UniquePtr.h"
16 namespace mozilla {
17 namespace a11y {
19 class NotificationController;
21 /**
22 * This class makes sure required tasks are done before and after tree
23 * mutations. Currently this only includes group info invalidation. You must
24 * have an object of this class on the stack when calling methods that mutate
25 * the accessible tree.
27 class TreeMutation final {
28 public:
29 static const bool kNoEvents = true;
30 static const bool kNoShutdown = true;
32 explicit TreeMutation(LocalAccessible* aParent, bool aNoEvents = false);
33 ~TreeMutation();
35 void AfterInsertion(LocalAccessible* aChild);
36 void BeforeRemoval(LocalAccessible* aChild, bool aNoShutdown = false);
37 void Done();
39 private:
40 NotificationController* Controller() const {
41 return mParent->Document()->Controller();
44 static EventTree* const kNoEventTree;
46 #ifdef A11Y_LOG
47 static const char* PrefixLog(void* aData, LocalAccessible*);
48 #endif
50 LocalAccessible* mParent;
51 uint32_t mStartIdx;
52 uint32_t mStateFlagsCopy;
55 * True if mutation events should be queued.
57 bool mQueueEvents;
59 #ifdef DEBUG
60 bool mIsDone;
61 #endif
64 /**
65 * A mutation events coalescence structure.
67 class EventTree final {
68 public:
69 EventTree()
70 : mFirst(nullptr),
71 mNext(nullptr),
72 mContainer(nullptr),
73 mFireReorder(false) {}
74 explicit EventTree(LocalAccessible* aContainer, bool aFireReorder)
75 : mFirst(nullptr),
76 mNext(nullptr),
77 mContainer(aContainer),
78 mFireReorder(aFireReorder) {}
79 ~EventTree() { Clear(); }
81 void Shown(LocalAccessible* aTarget);
82 void Hidden(LocalAccessible*, bool);
84 /**
85 * Return an event tree node for the given accessible.
87 const EventTree* Find(const LocalAccessible* aContainer) const;
89 /**
90 * Add a mutation event to this event tree.
92 void Mutated(AccMutationEvent* aEv);
94 #ifdef A11Y_LOG
95 void Log(uint32_t aLevel = UINT32_MAX) const;
96 #endif
98 private:
99 /**
100 * Processes the event queue and fires events.
102 void Process(const RefPtr<DocAccessible>& aDeathGrip);
105 * Return an event subtree for the given accessible.
107 EventTree* FindOrInsert(LocalAccessible* aContainer);
109 void Clear();
111 UniquePtr<EventTree> mFirst;
112 UniquePtr<EventTree> mNext;
114 LocalAccessible* mContainer;
115 nsTArray<RefPtr<AccMutationEvent>> mDependentEvents;
116 bool mFireReorder;
118 static NotificationController* Controller(LocalAccessible* aAcc) {
119 return aAcc->Document()->Controller();
122 friend class NotificationController;
125 } // namespace a11y
126 } // namespace mozilla
128 #endif // mozilla_a11y_EventQueue_h_