/src/mozilla-central/accessible/base/EventTree.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
5 | | |
6 | | #ifndef mozilla_a11y_EventTree_h_ |
7 | | #define mozilla_a11y_EventTree_h_ |
8 | | |
9 | | #include "AccEvent.h" |
10 | | #include "Accessible.h" |
11 | | |
12 | | #include "mozilla/a11y/DocAccessible.h" |
13 | | #include "mozilla/RefPtr.h" |
14 | | #include "mozilla/UniquePtr.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace a11y { |
18 | | |
19 | | class NotificationController; |
20 | | |
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. |
26 | | */ |
27 | | class TreeMutation final |
28 | | { |
29 | | public: |
30 | | static const bool kNoEvents = true; |
31 | | static const bool kNoShutdown = true; |
32 | | |
33 | | explicit TreeMutation(Accessible* aParent, bool aNoEvents = false); |
34 | | ~TreeMutation(); |
35 | | |
36 | | void AfterInsertion(Accessible* aChild); |
37 | | void BeforeRemoval(Accessible* aChild, bool aNoShutdown = false); |
38 | | void Done(); |
39 | | |
40 | | private: |
41 | | NotificationController* Controller() const |
42 | 0 | { return mParent->Document()->Controller(); } |
43 | | |
44 | | static EventTree* const kNoEventTree; |
45 | | |
46 | | #ifdef A11Y_LOG |
47 | | static const char* PrefixLog(void* aData, Accessible*); |
48 | | #endif |
49 | | |
50 | | Accessible* mParent; |
51 | | uint32_t mStartIdx; |
52 | | uint32_t mStateFlagsCopy; |
53 | | |
54 | | /* |
55 | | * True if mutation events should be queued. |
56 | | */ |
57 | | bool mQueueEvents; |
58 | | |
59 | | #ifdef DEBUG |
60 | | bool mIsDone; |
61 | | #endif |
62 | | }; |
63 | | |
64 | | |
65 | | /** |
66 | | * A mutation events coalescence structure. |
67 | | */ |
68 | | class EventTree final { |
69 | | public: |
70 | | EventTree() : |
71 | 0 | mFirst(nullptr), mNext(nullptr), mContainer(nullptr), mFireReorder(false) { } |
72 | | explicit EventTree(Accessible* aContainer, bool aFireReorder) : |
73 | | mFirst(nullptr), mNext(nullptr), mContainer(aContainer), |
74 | 0 | mFireReorder(aFireReorder) { } |
75 | 0 | ~EventTree() { Clear(); } |
76 | | |
77 | | void Shown(Accessible* aTarget); |
78 | | void Hidden(Accessible*, bool); |
79 | | |
80 | | /** |
81 | | * Return an event tree node for the given accessible. |
82 | | */ |
83 | | const EventTree* Find(const Accessible* aContainer) const; |
84 | | |
85 | | /** |
86 | | * Add a mutation event to this event tree. |
87 | | */ |
88 | | void Mutated(AccMutationEvent* aEv); |
89 | | |
90 | | #ifdef A11Y_LOG |
91 | | void Log(uint32_t aLevel = UINT32_MAX) const; |
92 | | #endif |
93 | | |
94 | | private: |
95 | | /** |
96 | | * Processes the event queue and fires events. |
97 | | */ |
98 | | void Process(const RefPtr<DocAccessible>& aDeathGrip); |
99 | | |
100 | | /** |
101 | | * Return an event subtree for the given accessible. |
102 | | */ |
103 | | EventTree* FindOrInsert(Accessible* aContainer); |
104 | | |
105 | | void Clear(); |
106 | | |
107 | | UniquePtr<EventTree> mFirst; |
108 | | UniquePtr<EventTree> mNext; |
109 | | |
110 | | Accessible* mContainer; |
111 | | nsTArray<RefPtr<AccMutationEvent>> mDependentEvents; |
112 | | bool mFireReorder; |
113 | | |
114 | | static NotificationController* Controller(Accessible* aAcc) |
115 | 0 | { return aAcc->Document()->Controller(); } |
116 | | |
117 | | friend class NotificationController; |
118 | | }; |
119 | | |
120 | | |
121 | | } // namespace a11y |
122 | | } // namespace mozilla |
123 | | |
124 | | #endif // mozilla_a11y_EventQueue_h_ |