1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/base/nsEventShell.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsEventShell.h" 1.10 + 1.11 +#include "nsAccUtils.h" 1.12 + 1.13 +#include "mozilla/StaticPtr.h" 1.14 + 1.15 +using namespace mozilla; 1.16 +using namespace mozilla::a11y; 1.17 + 1.18 +//////////////////////////////////////////////////////////////////////////////// 1.19 +// nsEventShell 1.20 +//////////////////////////////////////////////////////////////////////////////// 1.21 + 1.22 +void 1.23 +nsEventShell::FireEvent(AccEvent* aEvent) 1.24 +{ 1.25 + if (!aEvent) 1.26 + return; 1.27 + 1.28 + Accessible* accessible = aEvent->GetAccessible(); 1.29 + NS_ENSURE_TRUE_VOID(accessible); 1.30 + 1.31 + nsINode* node = accessible->GetNode(); 1.32 + if (node) { 1.33 + sEventTargetNode = node; 1.34 + sEventFromUserInput = aEvent->IsFromUserInput(); 1.35 + } 1.36 + 1.37 + accessible->HandleAccEvent(aEvent); 1.38 + 1.39 + sEventTargetNode = nullptr; 1.40 +} 1.41 + 1.42 +void 1.43 +nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible, 1.44 + EIsFromUserInput aIsFromUserInput) 1.45 +{ 1.46 + NS_ENSURE_TRUE_VOID(aAccessible); 1.47 + 1.48 + nsRefPtr<AccEvent> event = new AccEvent(aEventType, aAccessible, 1.49 + aIsFromUserInput); 1.50 + 1.51 + FireEvent(event); 1.52 +} 1.53 + 1.54 +void 1.55 +nsEventShell::GetEventAttributes(nsINode *aNode, 1.56 + nsIPersistentProperties *aAttributes) 1.57 +{ 1.58 + if (aNode != sEventTargetNode) 1.59 + return; 1.60 + 1.61 + nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput, 1.62 + sEventFromUserInput ? NS_LITERAL_STRING("true") : 1.63 + NS_LITERAL_STRING("false")); 1.64 +} 1.65 + 1.66 +//////////////////////////////////////////////////////////////////////////////// 1.67 +// nsEventShell: private 1.68 + 1.69 +bool nsEventShell::sEventFromUserInput = false; 1.70 +StaticRefPtr<nsINode> nsEventShell::sEventTargetNode;