|
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 _nsEventShell_H_ |
|
7 #define _nsEventShell_H_ |
|
8 |
|
9 #include "AccEvent.h" |
|
10 |
|
11 namespace mozilla { |
|
12 template<typename T> class StaticRefPtr; |
|
13 } |
|
14 class nsIPersistentProperties; |
|
15 |
|
16 /** |
|
17 * Used for everything about events. |
|
18 */ |
|
19 class nsEventShell |
|
20 { |
|
21 public: |
|
22 |
|
23 /** |
|
24 * Fire the accessible event. |
|
25 */ |
|
26 static void FireEvent(mozilla::a11y::AccEvent* aEvent); |
|
27 |
|
28 /** |
|
29 * Fire accessible event of the given type for the given accessible. |
|
30 * |
|
31 * @param aEventType [in] the event type |
|
32 * @param aAccessible [in] the event target |
|
33 */ |
|
34 static void FireEvent(uint32_t aEventType, |
|
35 mozilla::a11y::Accessible* aAccessible, |
|
36 mozilla::a11y::EIsFromUserInput aIsFromUserInput = mozilla::a11y::eAutoDetect); |
|
37 |
|
38 /** |
|
39 * Fire state change event. |
|
40 */ |
|
41 static void FireEvent(mozilla::a11y::Accessible* aTarget, uint64_t aState, |
|
42 bool aIsEnabled, bool aIsFromUserInput) |
|
43 { |
|
44 nsRefPtr<mozilla::a11y::AccStateChangeEvent> stateChangeEvent = |
|
45 new mozilla::a11y::AccStateChangeEvent(aTarget, aState, aIsEnabled, |
|
46 (aIsFromUserInput ? |
|
47 mozilla::a11y::eFromUserInput : |
|
48 mozilla::a11y::eNoUserInput)); |
|
49 FireEvent(stateChangeEvent); |
|
50 } |
|
51 |
|
52 /** |
|
53 * Append 'event-from-input' object attribute if the accessible event has |
|
54 * been fired just now for the given node. |
|
55 * |
|
56 * @param aNode [in] the DOM node |
|
57 * @param aAttributes [in, out] the attributes |
|
58 */ |
|
59 static void GetEventAttributes(nsINode *aNode, |
|
60 nsIPersistentProperties *aAttributes); |
|
61 |
|
62 private: |
|
63 static mozilla::StaticRefPtr<nsINode> sEventTargetNode; |
|
64 static bool sEventFromUserInput; |
|
65 }; |
|
66 |
|
67 #endif |