2010-01-18 19:16:07 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-01-18 19:16:07 +03:00
|
|
|
|
|
|
|
#include "nsEventShell.h"
|
|
|
|
|
2010-04-27 10:52:03 +04:00
|
|
|
#include "nsAccUtils.h"
|
2010-01-18 19:17:01 +03:00
|
|
|
|
2013-05-21 20:03:33 +04:00
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-11-18 06:01:44 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2010-01-20 14:16:32 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsEventShell
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-01-18 19:17:01 +03:00
|
|
|
void
|
2010-08-25 06:08:28 +04:00
|
|
|
nsEventShell::FireEvent(AccEvent* aEvent)
|
2010-01-18 19:17:01 +03:00
|
|
|
{
|
2016-09-29 22:44:18 +03:00
|
|
|
if (!aEvent || aEvent->mEventRule == AccEvent::eDoNotEmit)
|
2010-01-18 19:17:01 +03:00
|
|
|
return;
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* accessible = aEvent->GetAccessible();
|
2012-09-14 14:00:31 +04:00
|
|
|
NS_ENSURE_TRUE_VOID(accessible);
|
2010-01-18 19:17:01 +03:00
|
|
|
|
2012-11-20 08:53:38 +04:00
|
|
|
nsINode* node = accessible->GetNode();
|
2010-01-20 14:16:32 +03:00
|
|
|
if (node) {
|
|
|
|
sEventTargetNode = node;
|
|
|
|
sEventFromUserInput = aEvent->IsFromUserInput();
|
|
|
|
}
|
|
|
|
|
2016-04-06 01:39:55 +03:00
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eEvents)) {
|
|
|
|
logging::MsgBegin("EVENTS", "events fired");
|
|
|
|
nsAutoString type;
|
|
|
|
GetAccService()->GetStringEventType(aEvent->GetEventType(), type);
|
|
|
|
logging::MsgEntry("type: %s", NS_ConvertUTF16toUTF8(type).get());
|
|
|
|
logging::AccessibleInfo("target", aEvent->GetAccessible());
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-06-12 08:04:24 +04:00
|
|
|
accessible->HandleAccEvent(aEvent);
|
2016-09-29 22:44:18 +03:00
|
|
|
aEvent->mEventRule = AccEvent::eDoNotEmit;
|
2010-01-20 14:16:32 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
sEventTargetNode = nullptr;
|
2010-01-18 19:17:01 +03:00
|
|
|
}
|
2010-01-18 19:16:07 +03:00
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible,
|
2010-10-21 08:16:10 +04:00
|
|
|
EIsFromUserInput aIsFromUserInput)
|
2010-01-18 19:16:07 +03:00
|
|
|
{
|
2012-09-14 14:00:31 +04:00
|
|
|
NS_ENSURE_TRUE_VOID(aAccessible);
|
2010-01-18 19:16:07 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<AccEvent> event = new AccEvent(aEventType, aAccessible,
|
2010-10-21 08:16:10 +04:00
|
|
|
aIsFromUserInput);
|
2010-01-18 19:16:07 +03:00
|
|
|
|
2010-01-18 19:17:01 +03:00
|
|
|
FireEvent(event);
|
2010-01-18 19:16:07 +03:00
|
|
|
}
|
2010-01-20 14:16:32 +03:00
|
|
|
|
|
|
|
void
|
2010-06-11 12:23:18 +04:00
|
|
|
nsEventShell::GetEventAttributes(nsINode *aNode,
|
2010-01-20 14:16:32 +03:00
|
|
|
nsIPersistentProperties *aAttributes)
|
|
|
|
{
|
|
|
|
if (aNode != sEventTargetNode)
|
|
|
|
return;
|
|
|
|
|
2011-06-04 01:35:17 +04:00
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput,
|
2010-01-20 14:16:32 +03:00
|
|
|
sEventFromUserInput ? NS_LITERAL_STRING("true") :
|
|
|
|
NS_LITERAL_STRING("false"));
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsEventShell: private
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsEventShell::sEventFromUserInput = false;
|
2013-05-21 20:03:33 +04:00
|
|
|
StaticRefPtr<nsINode> nsEventShell::sEventTargetNode;
|