|
1 /* -*- Mode: C++; tab-width: 4; 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_SelectionManager_h__ |
|
7 #define mozilla_a11y_SelectionManager_h__ |
|
8 |
|
9 #include "nsIFrame.h" |
|
10 #include "nsISelectionListener.h" |
|
11 |
|
12 class nsIPresShell; |
|
13 |
|
14 namespace mozilla { |
|
15 |
|
16 namespace dom { |
|
17 class Element; |
|
18 } |
|
19 |
|
20 namespace a11y { |
|
21 |
|
22 class AccEvent; |
|
23 |
|
24 /** |
|
25 * This special accessibility class is for the caret and selection management. |
|
26 * There is only 1 visible caret per top level window. However, there may be |
|
27 * several visible selections. |
|
28 * |
|
29 * The important selections are the one owned by each document, and the one in |
|
30 * the currently focused control. |
|
31 * |
|
32 * On Windows this class is used to move an invisible system caret that |
|
33 * shadows the Mozilla caret. Windows will also automatically map this to |
|
34 * the MSAA caret accessible object (via OBJID_CARET) (as opposed to the root |
|
35 * accessible tree for a window which is retrieved with OBJID_CLIENT). |
|
36 * |
|
37 * For ATK and IAccessible2, this class is used to fire caret move and |
|
38 * selection change events. |
|
39 */ |
|
40 |
|
41 struct SelData; |
|
42 |
|
43 class SelectionManager : public nsISelectionListener |
|
44 { |
|
45 public: |
|
46 // nsISupports |
|
47 // implemented by derived nsAccessibilityService |
|
48 |
|
49 // nsISelectionListener |
|
50 NS_DECL_NSISELECTIONLISTENER |
|
51 |
|
52 // SelectionManager |
|
53 void Shutdown() { ClearControlSelectionListener(); } |
|
54 |
|
55 /** |
|
56 * Listen to selection events on the focused control. |
|
57 * |
|
58 * Note: only one control's selection events are listened to at a time. This |
|
59 * will remove the previous control's selection listener. |
|
60 */ |
|
61 void SetControlSelectionListener(dom::Element* aFocusedElm); |
|
62 |
|
63 /** |
|
64 * Stop listening to selection events on the control. |
|
65 */ |
|
66 void ClearControlSelectionListener(); |
|
67 |
|
68 /** |
|
69 * Listen to selection events on the document. |
|
70 */ |
|
71 void AddDocSelectionListener(nsIPresShell* aPresShell); |
|
72 |
|
73 /** |
|
74 * Stop listening to selection events for a given document |
|
75 */ |
|
76 void RemoveDocSelectionListener(nsIPresShell* aShell); |
|
77 |
|
78 /** |
|
79 * Process delayed event, results in caret move and text selection change |
|
80 * events. |
|
81 */ |
|
82 void ProcessTextSelChangeEvent(AccEvent* aEvent); |
|
83 |
|
84 protected: |
|
85 /** |
|
86 * Process DOM selection change. Fire selection and caret move events. |
|
87 */ |
|
88 void ProcessSelectionChanged(SelData* aSelData); |
|
89 |
|
90 private: |
|
91 // Currently focused control. |
|
92 nsWeakFrame mCurrCtrlFrame; |
|
93 }; |
|
94 |
|
95 } // namespace a11y |
|
96 } // namespace mozilla |
|
97 |
|
98 #endif |