|
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_EventQueue_h_ |
|
7 #define mozilla_a11y_EventQueue_h_ |
|
8 |
|
9 #include "AccEvent.h" |
|
10 |
|
11 namespace mozilla { |
|
12 namespace a11y { |
|
13 |
|
14 class DocAccessible; |
|
15 |
|
16 /** |
|
17 * Used to organize and coalesce pending events. |
|
18 */ |
|
19 class EventQueue |
|
20 { |
|
21 protected: |
|
22 EventQueue(DocAccessible* aDocument) : mDocument(aDocument) { } |
|
23 |
|
24 /** |
|
25 * Put an accessible event into the queue to process it later. |
|
26 */ |
|
27 bool PushEvent(AccEvent* aEvent); |
|
28 |
|
29 /** |
|
30 * Process events from the queue and fires events. |
|
31 */ |
|
32 void ProcessEventQueue(); |
|
33 |
|
34 private: |
|
35 EventQueue(const EventQueue&) MOZ_DELETE; |
|
36 EventQueue& operator = (const EventQueue&) MOZ_DELETE; |
|
37 |
|
38 // Event queue processing |
|
39 /** |
|
40 * Coalesce redundant events from the queue. |
|
41 */ |
|
42 void CoalesceEvents(); |
|
43 |
|
44 /** |
|
45 * Coalesce events from the same subtree. |
|
46 */ |
|
47 void CoalesceReorderEvents(AccEvent* aTailEvent); |
|
48 |
|
49 /** |
|
50 * Coalesce two selection change events within the same select control. |
|
51 */ |
|
52 void CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent, |
|
53 AccSelChangeEvent* aThisEvent, |
|
54 uint32_t aThisIndex); |
|
55 |
|
56 /** |
|
57 * Coalesce text change events caused by sibling hide events. |
|
58 */ |
|
59 void CoalesceTextChangeEventsFor(AccHideEvent* aTailEvent, |
|
60 AccHideEvent* aThisEvent); |
|
61 void CoalesceTextChangeEventsFor(AccShowEvent* aTailEvent, |
|
62 AccShowEvent* aThisEvent); |
|
63 |
|
64 /** |
|
65 * Create text change event caused by hide or show event. When a node is |
|
66 * hidden/removed or shown/appended, the text in an ancestor hyper text will |
|
67 * lose or get new characters. |
|
68 */ |
|
69 void CreateTextChangeEventFor(AccMutationEvent* aEvent); |
|
70 |
|
71 protected: |
|
72 |
|
73 /** |
|
74 * The document accessible reference owning this queue. |
|
75 */ |
|
76 DocAccessible* mDocument; |
|
77 |
|
78 /** |
|
79 * Pending events array. Don't make this an nsAutoTArray; we use |
|
80 * SwapElements() on it. |
|
81 */ |
|
82 nsTArray<nsRefPtr<AccEvent> > mEvents; |
|
83 }; |
|
84 |
|
85 } // namespace a11y |
|
86 } // namespace mozilla |
|
87 |
|
88 #endif // mozilla_a11y_EventQueue_h_ |