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"
|
2018-03-12 21:03:55 +03:00
|
|
|
#include "Logging.h"
|
2021-06-11 02:07:05 +03:00
|
|
|
#include "AccAttributes.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-08-25 06:08:28 +04:00
|
|
|
void nsEventShell::FireEvent(AccEvent* aEvent) {
|
2016-09-29 22:44:18 +03:00
|
|
|
if (!aEvent || aEvent->mEventRule == AccEvent::eDoNotEmit) return;
|
2010-01-18 19:17:01 +03:00
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* 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
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
void nsEventShell::FireEvent(uint32_t aEventType, LocalAccessible* aAccessible,
|
2010-10-21 08:16:10 +04:00
|
|
|
EIsFromUserInput aIsFromUserInput) {
|
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, 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
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
void nsEventShell::GetEventAttributes(nsINode* aNode,
|
2021-06-11 02:07:05 +03:00
|
|
|
AccAttributes* aAttributes) {
|
2010-01-20 14:16:32 +03:00
|
|
|
if (aNode != sEventTargetNode) return;
|
|
|
|
|
2021-06-11 02:07:06 +03:00
|
|
|
aAttributes->SetAttribute(nsGkAtoms::eventFromInput, sEventFromUserInput);
|
2010-01-20 14:16:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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;
|