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_
10 #include "LocalAccessible.h"
12 #include "mozilla/a11y/DocAccessible.h"
13 #include "mozilla/RefPtr.h"
14 #include "mozilla/UniquePtr.h"
19 class NotificationController
;
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
{
29 static const bool kNoEvents
= true;
30 static const bool kNoShutdown
= true;
32 explicit TreeMutation(LocalAccessible
* aParent
, bool aNoEvents
= false);
35 void AfterInsertion(LocalAccessible
* aChild
);
36 void BeforeRemoval(LocalAccessible
* aChild
, bool aNoShutdown
= false);
40 NotificationController
* Controller() const {
41 return mParent
->Document()->Controller();
44 static EventTree
* const kNoEventTree
;
47 static const char* PrefixLog(void* aData
, LocalAccessible
*);
50 LocalAccessible
* mParent
;
52 uint32_t mStateFlagsCopy
;
55 * True if mutation events should be queued.
65 * A mutation events coalescence structure.
67 class EventTree final
{
73 mFireReorder(false) {}
74 explicit EventTree(LocalAccessible
* aContainer
, bool aFireReorder
)
77 mContainer(aContainer
),
78 mFireReorder(aFireReorder
) {}
79 ~EventTree() { Clear(); }
81 void Shown(LocalAccessible
* aTarget
);
82 void Hidden(LocalAccessible
*, bool);
85 * Return an event tree node for the given accessible.
87 const EventTree
* Find(const LocalAccessible
* aContainer
) const;
90 * Add a mutation event to this event tree.
92 void Mutated(AccMutationEvent
* aEv
);
95 void Log(uint32_t aLevel
= UINT32_MAX
) const;
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
);
111 UniquePtr
<EventTree
> mFirst
;
112 UniquePtr
<EventTree
> mNext
;
114 LocalAccessible
* mContainer
;
115 nsTArray
<RefPtr
<AccMutationEvent
>> mDependentEvents
;
118 static NotificationController
* Controller(LocalAccessible
* aAcc
) {
119 return aAcc
->Document()->Controller();
122 friend class NotificationController
;
126 } // namespace mozilla
128 #endif // mozilla_a11y_EventQueue_h_