Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 #include "nsEventShell.h"
8 #include "nsAccUtils.h"
10 #include "mozilla/StaticPtr.h"
12 using namespace mozilla;
13 using namespace mozilla::a11y;
15 ////////////////////////////////////////////////////////////////////////////////
16 // nsEventShell
17 ////////////////////////////////////////////////////////////////////////////////
19 void
20 nsEventShell::FireEvent(AccEvent* aEvent)
21 {
22 if (!aEvent)
23 return;
25 Accessible* accessible = aEvent->GetAccessible();
26 NS_ENSURE_TRUE_VOID(accessible);
28 nsINode* node = accessible->GetNode();
29 if (node) {
30 sEventTargetNode = node;
31 sEventFromUserInput = aEvent->IsFromUserInput();
32 }
34 accessible->HandleAccEvent(aEvent);
36 sEventTargetNode = nullptr;
37 }
39 void
40 nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible,
41 EIsFromUserInput aIsFromUserInput)
42 {
43 NS_ENSURE_TRUE_VOID(aAccessible);
45 nsRefPtr<AccEvent> event = new AccEvent(aEventType, aAccessible,
46 aIsFromUserInput);
48 FireEvent(event);
49 }
51 void
52 nsEventShell::GetEventAttributes(nsINode *aNode,
53 nsIPersistentProperties *aAttributes)
54 {
55 if (aNode != sEventTargetNode)
56 return;
58 nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput,
59 sEventFromUserInput ? NS_LITERAL_STRING("true") :
60 NS_LITERAL_STRING("false"));
61 }
63 ////////////////////////////////////////////////////////////////////////////////
64 // nsEventShell: private
66 bool nsEventShell::sEventFromUserInput = false;
67 StaticRefPtr<nsINode> nsEventShell::sEventTargetNode;