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"
11 #include "mozilla/StaticPtr.h"
13 using namespace mozilla
;
14 using namespace mozilla::a11y
;
16 ////////////////////////////////////////////////////////////////////////////////
18 ////////////////////////////////////////////////////////////////////////////////
20 void nsEventShell::FireEvent(AccEvent
* aEvent
) {
21 if (!aEvent
|| aEvent
->mEventRule
== AccEvent::eDoNotEmit
) return;
23 Accessible
* accessible
= aEvent
->GetAccessible();
24 NS_ENSURE_TRUE_VOID(accessible
);
26 nsINode
* node
= accessible
->GetNode();
28 sEventTargetNode
= node
;
29 sEventFromUserInput
= aEvent
->IsFromUserInput();
33 if (logging::IsEnabled(logging::eEvents
)) {
34 logging::MsgBegin("EVENTS", "events fired");
36 GetAccService()->GetStringEventType(aEvent
->GetEventType(), type
);
37 logging::MsgEntry("type: %s", NS_ConvertUTF16toUTF8(type
).get());
38 logging::AccessibleInfo("target", aEvent
->GetAccessible());
43 accessible
->HandleAccEvent(aEvent
);
44 aEvent
->mEventRule
= AccEvent::eDoNotEmit
;
46 sEventTargetNode
= nullptr;
49 void nsEventShell::FireEvent(uint32_t aEventType
, Accessible
* aAccessible
,
50 EIsFromUserInput aIsFromUserInput
) {
51 NS_ENSURE_TRUE_VOID(aAccessible
);
53 RefPtr
<AccEvent
> event
=
54 new AccEvent(aEventType
, aAccessible
, aIsFromUserInput
);
59 void nsEventShell::GetEventAttributes(nsINode
* aNode
,
60 nsIPersistentProperties
* aAttributes
) {
61 if (aNode
!= sEventTargetNode
) return;
63 nsAccUtils::SetAccAttr(aAttributes
, nsGkAtoms::eventFromInput
,
64 sEventFromUserInput
? NS_LITERAL_STRING("true")
65 : NS_LITERAL_STRING("false"));
68 ////////////////////////////////////////////////////////////////////////////////
69 // nsEventShell: private
71 bool nsEventShell::sEventFromUserInput
= false;
72 StaticRefPtr
<nsINode
> nsEventShell::sEventTargetNode
;