michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsEventShell.h" michael@0: michael@0: #include "nsAccUtils.h" michael@0: michael@0: #include "mozilla/StaticPtr.h" michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::a11y; michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // nsEventShell michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: void michael@0: nsEventShell::FireEvent(AccEvent* aEvent) michael@0: { michael@0: if (!aEvent) michael@0: return; michael@0: michael@0: Accessible* accessible = aEvent->GetAccessible(); michael@0: NS_ENSURE_TRUE_VOID(accessible); michael@0: michael@0: nsINode* node = accessible->GetNode(); michael@0: if (node) { michael@0: sEventTargetNode = node; michael@0: sEventFromUserInput = aEvent->IsFromUserInput(); michael@0: } michael@0: michael@0: accessible->HandleAccEvent(aEvent); michael@0: michael@0: sEventTargetNode = nullptr; michael@0: } michael@0: michael@0: void michael@0: nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible, michael@0: EIsFromUserInput aIsFromUserInput) michael@0: { michael@0: NS_ENSURE_TRUE_VOID(aAccessible); michael@0: michael@0: nsRefPtr event = new AccEvent(aEventType, aAccessible, michael@0: aIsFromUserInput); michael@0: michael@0: FireEvent(event); michael@0: } michael@0: michael@0: void michael@0: nsEventShell::GetEventAttributes(nsINode *aNode, michael@0: nsIPersistentProperties *aAttributes) michael@0: { michael@0: if (aNode != sEventTargetNode) michael@0: return; michael@0: michael@0: nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput, michael@0: sEventFromUserInput ? NS_LITERAL_STRING("true") : michael@0: NS_LITERAL_STRING("false")); michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // nsEventShell: private michael@0: michael@0: bool nsEventShell::sEventFromUserInput = false; michael@0: StaticRefPtr nsEventShell::sEventTargetNode;