2010-01-18 16:16:07 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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 16:16:07 +00:00
|
|
|
|
|
|
|
#include "nsEventShell.h"
|
|
|
|
|
2010-04-27 06:52:03 +00:00
|
|
|
#include "nsAccUtils.h"
|
2010-01-18 16:17:01 +00:00
|
|
|
|
2013-05-21 16:03:33 +00:00
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-11-18 02:01:44 +00:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2010-01-20 11:16:32 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsEventShell
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-01-18 16:17:01 +00:00
|
|
|
void
|
2010-08-25 02:08:28 +00:00
|
|
|
nsEventShell::FireEvent(AccEvent* aEvent)
|
2010-01-18 16:17:01 +00:00
|
|
|
{
|
|
|
|
if (!aEvent)
|
|
|
|
return;
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* accessible = aEvent->GetAccessible();
|
2012-09-14 10:00:31 +00:00
|
|
|
NS_ENSURE_TRUE_VOID(accessible);
|
2010-01-18 16:17:01 +00:00
|
|
|
|
2012-11-20 04:53:38 +00:00
|
|
|
nsINode* node = accessible->GetNode();
|
2010-01-20 11:16:32 +00:00
|
|
|
if (node) {
|
|
|
|
sEventTargetNode = node;
|
|
|
|
sEventFromUserInput = aEvent->IsFromUserInput();
|
|
|
|
}
|
|
|
|
|
2010-06-12 04:04:24 +00:00
|
|
|
accessible->HandleAccEvent(aEvent);
|
2010-01-20 11:16:32 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
sEventTargetNode = nullptr;
|
2010-01-18 16:17:01 +00:00
|
|
|
}
|
2010-01-18 16:16:07 +00:00
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible,
|
2010-10-21 04:16:10 +00:00
|
|
|
EIsFromUserInput aIsFromUserInput)
|
2010-01-18 16:16:07 +00:00
|
|
|
{
|
2012-09-14 10:00:31 +00:00
|
|
|
NS_ENSURE_TRUE_VOID(aAccessible);
|
2010-01-18 16:16:07 +00:00
|
|
|
|
2010-08-25 02:08:28 +00:00
|
|
|
nsRefPtr<AccEvent> event = new AccEvent(aEventType, aAccessible,
|
2010-10-21 04:16:10 +00:00
|
|
|
aIsFromUserInput);
|
2010-01-18 16:16:07 +00:00
|
|
|
|
2010-01-18 16:17:01 +00:00
|
|
|
FireEvent(event);
|
2010-01-18 16:16:07 +00:00
|
|
|
}
|
2010-01-20 11:16:32 +00:00
|
|
|
|
|
|
|
void
|
2010-06-11 08:23:18 +00:00
|
|
|
nsEventShell::GetEventAttributes(nsINode *aNode,
|
2010-01-20 11:16:32 +00:00
|
|
|
nsIPersistentProperties *aAttributes)
|
|
|
|
{
|
|
|
|
if (aNode != sEventTargetNode)
|
|
|
|
return;
|
|
|
|
|
2011-06-03 21:35:17 +00:00
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput,
|
2010-01-20 11:16:32 +00:00
|
|
|
sEventFromUserInput ? NS_LITERAL_STRING("true") :
|
|
|
|
NS_LITERAL_STRING("false"));
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsEventShell: private
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsEventShell::sEventFromUserInput = false;
|
2013-05-21 16:03:33 +00:00
|
|
|
StaticRefPtr<nsINode> nsEventShell::sEventTargetNode;
|