1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/base/nsEventShell.h 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 +#ifndef _nsEventShell_H_ 1.10 +#define _nsEventShell_H_ 1.11 + 1.12 +#include "AccEvent.h" 1.13 + 1.14 +namespace mozilla { 1.15 +template<typename T> class StaticRefPtr; 1.16 +} 1.17 +class nsIPersistentProperties; 1.18 + 1.19 +/** 1.20 + * Used for everything about events. 1.21 + */ 1.22 +class nsEventShell 1.23 +{ 1.24 +public: 1.25 + 1.26 + /** 1.27 + * Fire the accessible event. 1.28 + */ 1.29 + static void FireEvent(mozilla::a11y::AccEvent* aEvent); 1.30 + 1.31 + /** 1.32 + * Fire accessible event of the given type for the given accessible. 1.33 + * 1.34 + * @param aEventType [in] the event type 1.35 + * @param aAccessible [in] the event target 1.36 + */ 1.37 + static void FireEvent(uint32_t aEventType, 1.38 + mozilla::a11y::Accessible* aAccessible, 1.39 + mozilla::a11y::EIsFromUserInput aIsFromUserInput = mozilla::a11y::eAutoDetect); 1.40 + 1.41 + /** 1.42 + * Fire state change event. 1.43 + */ 1.44 + static void FireEvent(mozilla::a11y::Accessible* aTarget, uint64_t aState, 1.45 + bool aIsEnabled, bool aIsFromUserInput) 1.46 + { 1.47 + nsRefPtr<mozilla::a11y::AccStateChangeEvent> stateChangeEvent = 1.48 + new mozilla::a11y::AccStateChangeEvent(aTarget, aState, aIsEnabled, 1.49 + (aIsFromUserInput ? 1.50 + mozilla::a11y::eFromUserInput : 1.51 + mozilla::a11y::eNoUserInput)); 1.52 + FireEvent(stateChangeEvent); 1.53 + } 1.54 + 1.55 + /** 1.56 + * Append 'event-from-input' object attribute if the accessible event has 1.57 + * been fired just now for the given node. 1.58 + * 1.59 + * @param aNode [in] the DOM node 1.60 + * @param aAttributes [in, out] the attributes 1.61 + */ 1.62 + static void GetEventAttributes(nsINode *aNode, 1.63 + nsIPersistentProperties *aAttributes); 1.64 + 1.65 +private: 1.66 + static mozilla::StaticRefPtr<nsINode> sEventTargetNode; 1.67 + static bool sEventFromUserInput; 1.68 +}; 1.69 + 1.70 +#endif