Bug 1883888 [wpt PR 44943] - Name unhandledrejection event correctly, a=testonly
[gecko.git] / accessible / base / nsEventShell.h
blobff2e062750be73db3798cc96f0e3f669c525719a
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 _nsEventShell_H_
7 #define _nsEventShell_H_
9 #include "AccEvent.h"
11 namespace mozilla {
12 template <typename T>
13 class StaticRefPtr;
16 /**
17 * Used for everything about events.
19 class nsEventShell {
20 public:
21 /**
22 * Fire the accessible event.
24 static void FireEvent(mozilla::a11y::AccEvent* aEvent);
26 /**
27 * Fire accessible event of the given type for the given accessible.
29 * @param aEventType [in] the event type
30 * @param aAccessible [in] the event target
32 static void FireEvent(uint32_t aEventType,
33 mozilla::a11y::LocalAccessible* aAccessible,
34 mozilla::a11y::EIsFromUserInput aIsFromUserInput =
35 mozilla::a11y::eAutoDetect);
37 /**
38 * Fire state change event.
40 static void FireEvent(mozilla::a11y::LocalAccessible* aTarget,
41 uint64_t aState, bool aIsEnabled,
42 bool aIsFromUserInput) {
43 RefPtr<mozilla::a11y::AccStateChangeEvent> stateChangeEvent =
44 new mozilla::a11y::AccStateChangeEvent(
45 aTarget, aState, aIsEnabled,
46 (aIsFromUserInput ? mozilla::a11y::eFromUserInput
47 : mozilla::a11y::eNoUserInput));
48 FireEvent(stateChangeEvent);
51 /**
52 * Append 'event-from-input' object attribute if the accessible event has
53 * been fired just now for the given node.
55 * @param aNode [in] the DOM node
56 * @param aAttributes [in, out] the attributes
58 static void GetEventAttributes(nsINode* aNode,
59 mozilla::a11y::AccAttributes* aAttributes);
61 private:
62 static mozilla::StaticRefPtr<nsINode> sEventTargetNode;
63 static bool sEventFromUserInput;
66 #endif