accessible/src/base/nsAccessibilityService.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

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 __nsAccessibilityService_h__
michael@0 7 #define __nsAccessibilityService_h__
michael@0 8
michael@0 9 #include "nsIAccessibilityService.h"
michael@0 10
michael@0 11 #include "mozilla/a11y/DocManager.h"
michael@0 12 #include "mozilla/a11y/FocusManager.h"
michael@0 13 #include "mozilla/a11y/SelectionManager.h"
michael@0 14
michael@0 15 #include "nsIObserver.h"
michael@0 16
michael@0 17 class nsImageFrame;
michael@0 18 class nsObjectFrame;
michael@0 19 class nsITreeView;
michael@0 20
michael@0 21 namespace mozilla {
michael@0 22 namespace a11y {
michael@0 23
michael@0 24 class ApplicationAccessible;
michael@0 25
michael@0 26 /**
michael@0 27 * Return focus manager.
michael@0 28 */
michael@0 29 FocusManager* FocusMgr();
michael@0 30
michael@0 31 /**
michael@0 32 * Return selection manager.
michael@0 33 */
michael@0 34 SelectionManager* SelectionMgr();
michael@0 35
michael@0 36 /**
michael@0 37 * Returns the application accessible.
michael@0 38 */
michael@0 39 ApplicationAccessible* ApplicationAcc();
michael@0 40
michael@0 41 } // namespace a11y
michael@0 42 } // namespace mozilla
michael@0 43
michael@0 44 class nsAccessibilityService : public mozilla::a11y::DocManager,
michael@0 45 public mozilla::a11y::FocusManager,
michael@0 46 public mozilla::a11y::SelectionManager,
michael@0 47 public nsIAccessibilityService,
michael@0 48 public nsIObserver
michael@0 49 {
michael@0 50 public:
michael@0 51 typedef mozilla::a11y::Accessible Accessible;
michael@0 52 typedef mozilla::a11y::DocAccessible DocAccessible;
michael@0 53
michael@0 54 virtual ~nsAccessibilityService();
michael@0 55
michael@0 56 NS_DECL_ISUPPORTS_INHERITED
michael@0 57 NS_DECL_NSIACCESSIBLERETRIEVAL
michael@0 58 NS_DECL_NSIOBSERVER
michael@0 59
michael@0 60 // nsIAccessibilityService
michael@0 61 virtual Accessible* GetRootDocumentAccessible(nsIPresShell* aPresShell,
michael@0 62 bool aCanCreate);
michael@0 63 already_AddRefed<Accessible>
michael@0 64 CreatePluginAccessible(nsObjectFrame* aFrame, nsIContent* aContent,
michael@0 65 Accessible* aContext);
michael@0 66
michael@0 67 /**
michael@0 68 * Adds/remove ATK root accessible for gtk+ native window to/from children
michael@0 69 * of the application accessible.
michael@0 70 */
michael@0 71 virtual Accessible* AddNativeRootAccessible(void* aAtkAccessible);
michael@0 72 virtual void RemoveNativeRootAccessible(Accessible* aRootAccessible);
michael@0 73
michael@0 74 /**
michael@0 75 * Notification used to update the accessible tree when deck panel is
michael@0 76 * switched.
michael@0 77 */
michael@0 78 void DeckPanelSwitched(nsIPresShell* aPresShell, nsIContent* aDeckNode,
michael@0 79 nsIFrame* aPrevBoxFrame, nsIFrame* aCurrentBoxFrame);
michael@0 80
michael@0 81 /**
michael@0 82 * Notification used to update the accessible tree when new content is
michael@0 83 * inserted.
michael@0 84 */
michael@0 85 void ContentRangeInserted(nsIPresShell* aPresShell, nsIContent* aContainer,
michael@0 86 nsIContent* aStartChild, nsIContent* aEndChild);
michael@0 87
michael@0 88 /**
michael@0 89 * Notification used to update the accessible tree when content is removed.
michael@0 90 */
michael@0 91 void ContentRemoved(nsIPresShell* aPresShell, nsIContent* aContainer,
michael@0 92 nsIContent* aChild);
michael@0 93
michael@0 94 virtual void UpdateText(nsIPresShell* aPresShell, nsIContent* aContent);
michael@0 95
michael@0 96 /**
michael@0 97 * Update XUL:tree accessible tree when treeview is changed.
michael@0 98 */
michael@0 99 void TreeViewChanged(nsIPresShell* aPresShell, nsIContent* aContent,
michael@0 100 nsITreeView* aView);
michael@0 101
michael@0 102 /**
michael@0 103 * Notify of input@type="element" value change.
michael@0 104 */
michael@0 105 void RangeValueChanged(nsIPresShell* aPresShell, nsIContent* aContent);
michael@0 106
michael@0 107 /**
michael@0 108 * Update list bullet accessible.
michael@0 109 */
michael@0 110 virtual void UpdateListBullet(nsIPresShell* aPresShell,
michael@0 111 nsIContent* aHTMLListItemContent,
michael@0 112 bool aHasBullet);
michael@0 113
michael@0 114 /**
michael@0 115 * Update the image map.
michael@0 116 */
michael@0 117 void UpdateImageMap(nsImageFrame* aImageFrame);
michael@0 118
michael@0 119 /**
michael@0 120 * Update the label accessible tree when rendered @value is changed.
michael@0 121 */
michael@0 122 void UpdateLabelValue(nsIPresShell* aPresShell, nsIContent* aLabelElm,
michael@0 123 const nsString& aNewValue);
michael@0 124
michael@0 125 /**
michael@0 126 * Notify accessibility that anchor jump has been accomplished to the given
michael@0 127 * target. Used by layout.
michael@0 128 */
michael@0 129 void NotifyOfAnchorJumpTo(nsIContent *aTarget);
michael@0 130
michael@0 131 /**
michael@0 132 * Notify that presshell is activated.
michael@0 133 */
michael@0 134 virtual void PresShellActivated(nsIPresShell* aPresShell);
michael@0 135
michael@0 136 /**
michael@0 137 * Recreate an accessible for the given content node in the presshell.
michael@0 138 */
michael@0 139 void RecreateAccessible(nsIPresShell* aPresShell, nsIContent* aContent);
michael@0 140
michael@0 141 virtual void FireAccessibleEvent(uint32_t aEvent, Accessible* aTarget);
michael@0 142
michael@0 143 // nsAccessibiltiyService
michael@0 144
michael@0 145 /**
michael@0 146 * Return true if accessibility service has been shutdown.
michael@0 147 */
michael@0 148 static bool IsShutdown() { return gIsShutdown; }
michael@0 149
michael@0 150 /**
michael@0 151 * Return an accessible for the given DOM node from the cache or create new
michael@0 152 * one.
michael@0 153 *
michael@0 154 * @param aNode [in] the given node
michael@0 155 * @param aContext [in] context the accessible is created in
michael@0 156 * @param aIsSubtreeHidden [out, optional] indicates whether the node's
michael@0 157 * frame and its subtree is hidden
michael@0 158 */
michael@0 159 Accessible* GetOrCreateAccessible(nsINode* aNode, Accessible* aContext,
michael@0 160 bool* aIsSubtreeHidden = nullptr);
michael@0 161
michael@0 162 private:
michael@0 163 // nsAccessibilityService creation is controlled by friend
michael@0 164 // NS_GetAccessibilityService, keep constructors private.
michael@0 165 nsAccessibilityService();
michael@0 166 nsAccessibilityService(const nsAccessibilityService&);
michael@0 167 nsAccessibilityService& operator =(const nsAccessibilityService&);
michael@0 168
michael@0 169 private:
michael@0 170 /**
michael@0 171 * Initialize accessibility service.
michael@0 172 */
michael@0 173 bool Init();
michael@0 174
michael@0 175 /**
michael@0 176 * Shutdowns accessibility service.
michael@0 177 */
michael@0 178 void Shutdown();
michael@0 179
michael@0 180 /**
michael@0 181 * Create accessible for the element having XBL bindings.
michael@0 182 */
michael@0 183 already_AddRefed<Accessible>
michael@0 184 CreateAccessibleByType(nsIContent* aContent, DocAccessible* aDoc);
michael@0 185
michael@0 186 /**
michael@0 187 * Create accessible for HTML node by tag name.
michael@0 188 */
michael@0 189 already_AddRefed<Accessible>
michael@0 190 CreateHTMLAccessibleByMarkup(nsIFrame* aFrame, nsIContent* aContent,
michael@0 191 Accessible* aContext);
michael@0 192
michael@0 193 /**
michael@0 194 * Create an accessible whose type depends on the given frame.
michael@0 195 */
michael@0 196 already_AddRefed<Accessible>
michael@0 197 CreateAccessibleByFrameType(nsIFrame* aFrame, nsIContent* aContent,
michael@0 198 Accessible* aContext);
michael@0 199
michael@0 200 #ifdef MOZ_XUL
michael@0 201 /**
michael@0 202 * Create accessible for XUL tree element.
michael@0 203 */
michael@0 204 already_AddRefed<Accessible>
michael@0 205 CreateAccessibleForXULTree(nsIContent* aContent, DocAccessible* aDoc);
michael@0 206 #endif
michael@0 207
michael@0 208 /**
michael@0 209 * Reference for accessibility service instance.
michael@0 210 */
michael@0 211 static nsAccessibilityService* gAccessibilityService;
michael@0 212
michael@0 213 /**
michael@0 214 * Reference for application accessible instance.
michael@0 215 */
michael@0 216 static mozilla::a11y::ApplicationAccessible* gApplicationAccessible;
michael@0 217
michael@0 218 /**
michael@0 219 * Indicates whether accessibility service was shutdown.
michael@0 220 */
michael@0 221 static bool gIsShutdown;
michael@0 222
michael@0 223 friend nsAccessibilityService* GetAccService();
michael@0 224 friend mozilla::a11y::FocusManager* mozilla::a11y::FocusMgr();
michael@0 225 friend mozilla::a11y::SelectionManager* mozilla::a11y::SelectionMgr();
michael@0 226 friend mozilla::a11y::ApplicationAccessible* mozilla::a11y::ApplicationAcc();
michael@0 227
michael@0 228 friend nsresult NS_GetAccessibilityService(nsIAccessibilityService** aResult);
michael@0 229 };
michael@0 230
michael@0 231 /**
michael@0 232 * Return the accessibility service instance. (Handy global function)
michael@0 233 */
michael@0 234 inline nsAccessibilityService*
michael@0 235 GetAccService()
michael@0 236 {
michael@0 237 return nsAccessibilityService::gAccessibilityService;
michael@0 238 }
michael@0 239
michael@0 240 /**
michael@0 241 * Map nsIAccessibleEvents constants to strings. Used by
michael@0 242 * nsIAccessibleRetrieval::getStringEventType() method.
michael@0 243 */
michael@0 244 static const char kEventTypeNames[][40] = {
michael@0 245 "unknown", //
michael@0 246 "show", // EVENT_SHOW
michael@0 247 "hide", // EVENT_HIDE
michael@0 248 "reorder", // EVENT_REORDER
michael@0 249 "active decendent change", // EVENT_ACTIVE_DECENDENT_CHANGED
michael@0 250 "focus", // EVENT_FOCUS
michael@0 251 "state change", // EVENT_STATE_CHANGE
michael@0 252 "location change", // EVENT_LOCATION_CHANGE
michael@0 253 "name changed", // EVENT_NAME_CHANGE
michael@0 254 "description change", // EVENT_DESCRIPTION_CHANGE
michael@0 255 "value change", // EVENT_VALUE_CHANGE
michael@0 256 "help change", // EVENT_HELP_CHANGE
michael@0 257 "default action change", // EVENT_DEFACTION_CHANGE
michael@0 258 "action change", // EVENT_ACTION_CHANGE
michael@0 259 "accelerator change", // EVENT_ACCELERATOR_CHANGE
michael@0 260 "selection", // EVENT_SELECTION
michael@0 261 "selection add", // EVENT_SELECTION_ADD
michael@0 262 "selection remove", // EVENT_SELECTION_REMOVE
michael@0 263 "selection within", // EVENT_SELECTION_WITHIN
michael@0 264 "alert", // EVENT_ALERT
michael@0 265 "foreground", // EVENT_FOREGROUND
michael@0 266 "menu start", // EVENT_MENU_START
michael@0 267 "menu end", // EVENT_MENU_END
michael@0 268 "menupopup start", // EVENT_MENUPOPUP_START
michael@0 269 "menupopup end", // EVENT_MENUPOPUP_END
michael@0 270 "capture start", // EVENT_CAPTURE_START
michael@0 271 "capture end", // EVENT_CAPTURE_END
michael@0 272 "movesize start", // EVENT_MOVESIZE_START
michael@0 273 "movesize end", // EVENT_MOVESIZE_END
michael@0 274 "contexthelp start", // EVENT_CONTEXTHELP_START
michael@0 275 "contexthelp end", // EVENT_CONTEXTHELP_END
michael@0 276 "dragdrop start", // EVENT_DRAGDROP_START
michael@0 277 "dragdrop end", // EVENT_DRAGDROP_END
michael@0 278 "dialog start", // EVENT_DIALOG_START
michael@0 279 "dialog end", // EVENT_DIALOG_END
michael@0 280 "scrolling start", // EVENT_SCROLLING_START
michael@0 281 "scrolling end", // EVENT_SCROLLING_END
michael@0 282 "minimize start", // EVENT_MINIMIZE_START
michael@0 283 "minimize end", // EVENT_MINIMIZE_END
michael@0 284 "document load complete", // EVENT_DOCUMENT_LOAD_COMPLETE
michael@0 285 "document reload", // EVENT_DOCUMENT_RELOAD
michael@0 286 "document load stopped", // EVENT_DOCUMENT_LOAD_STOPPED
michael@0 287 "document attributes changed", // EVENT_DOCUMENT_ATTRIBUTES_CHANGED
michael@0 288 "document content changed", // EVENT_DOCUMENT_CONTENT_CHANGED
michael@0 289 "property changed", // EVENT_PROPERTY_CHANGED
michael@0 290 "page changed", // EVENT_PAGE_CHANGED
michael@0 291 "text attribute changed", // EVENT_TEXT_ATTRIBUTE_CHANGED
michael@0 292 "text caret moved", // EVENT_TEXT_CARET_MOVED
michael@0 293 "text changed", // EVENT_TEXT_CHANGED
michael@0 294 "text inserted", // EVENT_TEXT_INSERTED
michael@0 295 "text removed", // EVENT_TEXT_REMOVED
michael@0 296 "text updated", // EVENT_TEXT_UPDATED
michael@0 297 "text selection changed", // EVENT_TEXT_SELECTION_CHANGED
michael@0 298 "visible data changed", // EVENT_VISIBLE_DATA_CHANGED
michael@0 299 "text column changed", // EVENT_TEXT_COLUMN_CHANGED
michael@0 300 "section changed", // EVENT_SECTION_CHANGED
michael@0 301 "table caption changed", // EVENT_TABLE_CAPTION_CHANGED
michael@0 302 "table model changed", // EVENT_TABLE_MODEL_CHANGED
michael@0 303 "table summary changed", // EVENT_TABLE_SUMMARY_CHANGED
michael@0 304 "table row description changed", // EVENT_TABLE_ROW_DESCRIPTION_CHANGED
michael@0 305 "table row header changed", // EVENT_TABLE_ROW_HEADER_CHANGED
michael@0 306 "table row insert", // EVENT_TABLE_ROW_INSERT
michael@0 307 "table row delete", // EVENT_TABLE_ROW_DELETE
michael@0 308 "table row reorder", // EVENT_TABLE_ROW_REORDER
michael@0 309 "table column description changed", // EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED
michael@0 310 "table column header changed", // EVENT_TABLE_COLUMN_HEADER_CHANGED
michael@0 311 "table column insert", // EVENT_TABLE_COLUMN_INSERT
michael@0 312 "table column delete", // EVENT_TABLE_COLUMN_DELETE
michael@0 313 "table column reorder", // EVENT_TABLE_COLUMN_REORDER
michael@0 314 "window activate", // EVENT_WINDOW_ACTIVATE
michael@0 315 "window create", // EVENT_WINDOW_CREATE
michael@0 316 "window deactivate", // EVENT_WINDOW_DEACTIVATE
michael@0 317 "window destroy", // EVENT_WINDOW_DESTROY
michael@0 318 "window maximize", // EVENT_WINDOW_MAXIMIZE
michael@0 319 "window minimize", // EVENT_WINDOW_MINIMIZE
michael@0 320 "window resize", // EVENT_WINDOW_RESIZE
michael@0 321 "window restore", // EVENT_WINDOW_RESTORE
michael@0 322 "hyperlink end index changed", // EVENT_HYPERLINK_END_INDEX_CHANGED
michael@0 323 "hyperlink number of anchors changed", // EVENT_HYPERLINK_NUMBER_OF_ANCHORS_CHANGED
michael@0 324 "hyperlink selected link changed", // EVENT_HYPERLINK_SELECTED_LINK_CHANGED
michael@0 325 "hypertext link activated", // EVENT_HYPERTEXT_LINK_ACTIVATED
michael@0 326 "hypertext link selected", // EVENT_HYPERTEXT_LINK_SELECTED
michael@0 327 "hyperlink start index changed", // EVENT_HYPERLINK_START_INDEX_CHANGED
michael@0 328 "hypertext changed", // EVENT_HYPERTEXT_CHANGED
michael@0 329 "hypertext links count changed", // EVENT_HYPERTEXT_NLINKS_CHANGED
michael@0 330 "object attribute changed", // EVENT_OBJECT_ATTRIBUTE_CHANGED
michael@0 331 "virtual cursor changed" // EVENT_VIRTUALCURSOR_CHANGED
michael@0 332 };
michael@0 333
michael@0 334 #endif /* __nsIAccessibilityService_h__ */
michael@0 335

mercurial