Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef _nsEventShell_H_ |
michael@0 | 7 | #define _nsEventShell_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "AccEvent.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | template<typename T> class StaticRefPtr; |
michael@0 | 13 | } |
michael@0 | 14 | class nsIPersistentProperties; |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * Used for everything about events. |
michael@0 | 18 | */ |
michael@0 | 19 | class nsEventShell |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | |
michael@0 | 23 | /** |
michael@0 | 24 | * Fire the accessible event. |
michael@0 | 25 | */ |
michael@0 | 26 | static void FireEvent(mozilla::a11y::AccEvent* aEvent); |
michael@0 | 27 | |
michael@0 | 28 | /** |
michael@0 | 29 | * Fire accessible event of the given type for the given accessible. |
michael@0 | 30 | * |
michael@0 | 31 | * @param aEventType [in] the event type |
michael@0 | 32 | * @param aAccessible [in] the event target |
michael@0 | 33 | */ |
michael@0 | 34 | static void FireEvent(uint32_t aEventType, |
michael@0 | 35 | mozilla::a11y::Accessible* aAccessible, |
michael@0 | 36 | mozilla::a11y::EIsFromUserInput aIsFromUserInput = mozilla::a11y::eAutoDetect); |
michael@0 | 37 | |
michael@0 | 38 | /** |
michael@0 | 39 | * Fire state change event. |
michael@0 | 40 | */ |
michael@0 | 41 | static void FireEvent(mozilla::a11y::Accessible* aTarget, uint64_t aState, |
michael@0 | 42 | bool aIsEnabled, bool aIsFromUserInput) |
michael@0 | 43 | { |
michael@0 | 44 | nsRefPtr<mozilla::a11y::AccStateChangeEvent> stateChangeEvent = |
michael@0 | 45 | new mozilla::a11y::AccStateChangeEvent(aTarget, aState, aIsEnabled, |
michael@0 | 46 | (aIsFromUserInput ? |
michael@0 | 47 | mozilla::a11y::eFromUserInput : |
michael@0 | 48 | mozilla::a11y::eNoUserInput)); |
michael@0 | 49 | FireEvent(stateChangeEvent); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | /** |
michael@0 | 53 | * Append 'event-from-input' object attribute if the accessible event has |
michael@0 | 54 | * been fired just now for the given node. |
michael@0 | 55 | * |
michael@0 | 56 | * @param aNode [in] the DOM node |
michael@0 | 57 | * @param aAttributes [in, out] the attributes |
michael@0 | 58 | */ |
michael@0 | 59 | static void GetEventAttributes(nsINode *aNode, |
michael@0 | 60 | nsIPersistentProperties *aAttributes); |
michael@0 | 61 | |
michael@0 | 62 | private: |
michael@0 | 63 | static mozilla::StaticRefPtr<nsINode> sEventTargetNode; |
michael@0 | 64 | static bool sEventFromUserInput; |
michael@0 | 65 | }; |
michael@0 | 66 | |
michael@0 | 67 | #endif |