accessible/src/base/nsEventShell.cpp

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:4792759bfbc9
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 #include "nsEventShell.h"
7
8 #include "nsAccUtils.h"
9
10 #include "mozilla/StaticPtr.h"
11
12 using namespace mozilla;
13 using namespace mozilla::a11y;
14
15 ////////////////////////////////////////////////////////////////////////////////
16 // nsEventShell
17 ////////////////////////////////////////////////////////////////////////////////
18
19 void
20 nsEventShell::FireEvent(AccEvent* aEvent)
21 {
22 if (!aEvent)
23 return;
24
25 Accessible* accessible = aEvent->GetAccessible();
26 NS_ENSURE_TRUE_VOID(accessible);
27
28 nsINode* node = accessible->GetNode();
29 if (node) {
30 sEventTargetNode = node;
31 sEventFromUserInput = aEvent->IsFromUserInput();
32 }
33
34 accessible->HandleAccEvent(aEvent);
35
36 sEventTargetNode = nullptr;
37 }
38
39 void
40 nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible,
41 EIsFromUserInput aIsFromUserInput)
42 {
43 NS_ENSURE_TRUE_VOID(aAccessible);
44
45 nsRefPtr<AccEvent> event = new AccEvent(aEventType, aAccessible,
46 aIsFromUserInput);
47
48 FireEvent(event);
49 }
50
51 void
52 nsEventShell::GetEventAttributes(nsINode *aNode,
53 nsIPersistentProperties *aAttributes)
54 {
55 if (aNode != sEventTargetNode)
56 return;
57
58 nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput,
59 sEventFromUserInput ? NS_LITERAL_STRING("true") :
60 NS_LITERAL_STRING("false"));
61 }
62
63 ////////////////////////////////////////////////////////////////////////////////
64 // nsEventShell: private
65
66 bool nsEventShell::sEventFromUserInput = false;
67 StaticRefPtr<nsINode> nsEventShell::sEventTargetNode;

mercurial