Platform.h (4345B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_a11y_Platform_h 8 #define mozilla_a11y_Platform_h 9 10 #include <stdint.h> 11 #include "nsStringFwd.h" 12 #include "Units.h" 13 14 #if defined(ANDROID) 15 # include "nsTArray.h" 16 #endif 17 18 #ifdef MOZ_WIDGET_COCOA 19 # include "mozilla/a11y/Role.h" 20 # include "nsTArray.h" 21 #endif 22 23 namespace mozilla { 24 namespace a11y { 25 26 class Accessible; 27 class RemoteAccessible; 28 29 enum EPlatformDisabledState { 30 ePlatformIsForceEnabled = -1, 31 ePlatformIsEnabled = 0, 32 ePlatformIsDisabled = 1 33 }; 34 35 /** 36 * Return the platform disabled state. 37 */ 38 EPlatformDisabledState PlatformDisabledState(); 39 40 #ifdef MOZ_ACCESSIBILITY_ATK 41 /** 42 * Perform initialization that should be done as soon as possible, in order 43 * to minimize startup time. 44 * XXX: this function and the next defined in ApplicationAccessibleWrap.cpp 45 */ 46 void PreInit(); 47 #endif 48 49 #if defined(MOZ_ACCESSIBILITY_ATK) || defined(XP_DARWIN) 50 /** 51 * Is platform accessibility enabled. 52 * Only used on Linux, MacOS and iOS for now. 53 */ 54 bool ShouldA11yBeEnabled(); 55 #endif 56 57 #if defined(XP_WIN) 58 /* 59 * Name of platform service that instantiated accessibility 60 */ 61 void SetInstantiator(const uint32_t aInstantiatorPid); 62 bool GetInstantiator(nsIFile** aOutInstantiator); 63 #endif 64 65 /** 66 * Called to initialize platform specific accessibility support. 67 * Note this is called after internal accessibility support is initialized. 68 */ 69 void PlatformInit(); 70 71 /** 72 * Shutdown platform accessibility. 73 * Note this is called before internal accessibility support is shutdown. 74 */ 75 void PlatformShutdown(); 76 77 /** 78 * called when a new RemoteAccessible is created, so the platform may setup a 79 * wrapper for it, or take other action. 80 */ 81 void ProxyCreated(RemoteAccessible* aProxy); 82 83 /** 84 * Called just before a RemoteAccessible is destroyed so its wrapper can be 85 * disposed of and other action taken. 86 */ 87 void ProxyDestroyed(RemoteAccessible*); 88 89 /** 90 * Called when an event is fired on an Accessible so that platforms may fire 91 * events if appropriate. 92 */ 93 void PlatformEvent(Accessible* aTarget, uint32_t aEventType); 94 void PlatformStateChangeEvent(Accessible* aTarget, uint64_t aState, 95 bool aEnabled); 96 97 void PlatformFocusEvent(Accessible* aTarget); 98 void PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset, 99 bool aIsSelectionCollapsed, int32_t aGranularity, 100 bool aFromUser); 101 void PlatformTextChangeEvent(Accessible* aTarget, const nsAString& aStr, 102 int32_t aStart, uint32_t aLen, bool aIsInsert, 103 bool aFromUser); 104 void PlatformShowHideEvent(Accessible* aTarget, Accessible* aParent, 105 bool aInsert, bool aFromUser); 106 void PlatformSelectionEvent(Accessible* aTarget, Accessible* aWidget, 107 uint32_t aType); 108 109 #if defined(ANDROID) 110 void PlatformScrollingEvent(Accessible* aTarget, uint32_t aEventType, 111 uint32_t aScrollX, uint32_t aScrollY, 112 uint32_t aMaxScrollX, uint32_t aMaxScrollY); 113 114 void PlatformAnnouncementEvent(Accessible* aTarget, 115 const nsAString& aAnnouncement, 116 uint16_t aPriority); 117 118 bool LocalizeString(const nsAString& aToken, nsAString& aLocalized); 119 #endif 120 121 #ifdef MOZ_WIDGET_COCOA 122 class TextRange; 123 void PlatformTextSelectionChangeEvent(Accessible* aTarget, 124 const nsTArray<TextRange>& aSelection); 125 126 void PlatformRoleChangedEvent(Accessible* aTarget, const a11y::role& aRole, 127 uint8_t aRoleMapEntryIndex); 128 #endif 129 130 // Get the cache domains needed by any known clients interacting with Gecko. If 131 // any known clients are found, the return value is aCacheDomains bitwise OR'd 132 // with the required cache domains for those clients. Otherwise, the return 133 // value is aCacheDomains unaltered. 134 uint64_t GetCacheDomainsForKnownClients(uint64_t aCacheDomains); 135 136 } // namespace a11y 137 } // namespace mozilla 138 139 #endif // mozilla_a11y_Platform_h