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