/src/mozilla-central/accessible/base/nsEventShell.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include "Logging.h" |
10 | | |
11 | | #include "mozilla/StaticPtr.h" |
12 | | |
13 | | using namespace mozilla; |
14 | | using namespace mozilla::a11y; |
15 | | |
16 | | //////////////////////////////////////////////////////////////////////////////// |
17 | | // nsEventShell |
18 | | //////////////////////////////////////////////////////////////////////////////// |
19 | | |
20 | | void |
21 | | nsEventShell::FireEvent(AccEvent* aEvent) |
22 | 0 | { |
23 | 0 | if (!aEvent || aEvent->mEventRule == AccEvent::eDoNotEmit) |
24 | 0 | return; |
25 | 0 | |
26 | 0 | Accessible* accessible = aEvent->GetAccessible(); |
27 | 0 | NS_ENSURE_TRUE_VOID(accessible); |
28 | 0 |
|
29 | 0 | nsINode* node = accessible->GetNode(); |
30 | 0 | if (node) { |
31 | 0 | sEventTargetNode = node; |
32 | 0 | sEventFromUserInput = aEvent->IsFromUserInput(); |
33 | 0 | } |
34 | 0 |
|
35 | 0 | #ifdef A11Y_LOG |
36 | 0 | if (logging::IsEnabled(logging::eEvents)) { |
37 | 0 | logging::MsgBegin("EVENTS", "events fired"); |
38 | 0 | nsAutoString type; |
39 | 0 | GetAccService()->GetStringEventType(aEvent->GetEventType(), type); |
40 | 0 | logging::MsgEntry("type: %s", NS_ConvertUTF16toUTF8(type).get()); |
41 | 0 | logging::AccessibleInfo("target", aEvent->GetAccessible()); |
42 | 0 | logging::MsgEnd(); |
43 | 0 | } |
44 | 0 | #endif |
45 | 0 |
|
46 | 0 | accessible->HandleAccEvent(aEvent); |
47 | 0 | aEvent->mEventRule = AccEvent::eDoNotEmit; |
48 | 0 |
|
49 | 0 | sEventTargetNode = nullptr; |
50 | 0 | } |
51 | | |
52 | | void |
53 | | nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible, |
54 | | EIsFromUserInput aIsFromUserInput) |
55 | 0 | { |
56 | 0 | NS_ENSURE_TRUE_VOID(aAccessible); |
57 | 0 |
|
58 | 0 | RefPtr<AccEvent> event = new AccEvent(aEventType, aAccessible, |
59 | 0 | aIsFromUserInput); |
60 | 0 |
|
61 | 0 | FireEvent(event); |
62 | 0 | } |
63 | | |
64 | | void |
65 | | nsEventShell::GetEventAttributes(nsINode *aNode, |
66 | | nsIPersistentProperties *aAttributes) |
67 | 0 | { |
68 | 0 | if (aNode != sEventTargetNode) |
69 | 0 | return; |
70 | 0 | |
71 | 0 | nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput, |
72 | 0 | sEventFromUserInput ? NS_LITERAL_STRING("true") : |
73 | 0 | NS_LITERAL_STRING("false")); |
74 | 0 | } |
75 | | |
76 | | //////////////////////////////////////////////////////////////////////////////// |
77 | | // nsEventShell: private |
78 | | |
79 | | bool nsEventShell::sEventFromUserInput = false; |
80 | | StaticRefPtr<nsINode> nsEventShell::sEventTargetNode; |