michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __nsAccessibilityService_h__ michael@0: #define __nsAccessibilityService_h__ michael@0: michael@0: #include "nsIAccessibilityService.h" michael@0: michael@0: #include "mozilla/a11y/DocManager.h" michael@0: #include "mozilla/a11y/FocusManager.h" michael@0: #include "mozilla/a11y/SelectionManager.h" michael@0: michael@0: #include "nsIObserver.h" michael@0: michael@0: class nsImageFrame; michael@0: class nsObjectFrame; michael@0: class nsITreeView; michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: class ApplicationAccessible; michael@0: michael@0: /** michael@0: * Return focus manager. michael@0: */ michael@0: FocusManager* FocusMgr(); michael@0: michael@0: /** michael@0: * Return selection manager. michael@0: */ michael@0: SelectionManager* SelectionMgr(); michael@0: michael@0: /** michael@0: * Returns the application accessible. michael@0: */ michael@0: ApplicationAccessible* ApplicationAcc(); michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: class nsAccessibilityService : public mozilla::a11y::DocManager, michael@0: public mozilla::a11y::FocusManager, michael@0: public mozilla::a11y::SelectionManager, michael@0: public nsIAccessibilityService, michael@0: public nsIObserver michael@0: { michael@0: public: michael@0: typedef mozilla::a11y::Accessible Accessible; michael@0: typedef mozilla::a11y::DocAccessible DocAccessible; michael@0: michael@0: virtual ~nsAccessibilityService(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIACCESSIBLERETRIEVAL michael@0: NS_DECL_NSIOBSERVER michael@0: michael@0: // nsIAccessibilityService michael@0: virtual Accessible* GetRootDocumentAccessible(nsIPresShell* aPresShell, michael@0: bool aCanCreate); michael@0: already_AddRefed michael@0: CreatePluginAccessible(nsObjectFrame* aFrame, nsIContent* aContent, michael@0: Accessible* aContext); michael@0: michael@0: /** michael@0: * Adds/remove ATK root accessible for gtk+ native window to/from children michael@0: * of the application accessible. michael@0: */ michael@0: virtual Accessible* AddNativeRootAccessible(void* aAtkAccessible); michael@0: virtual void RemoveNativeRootAccessible(Accessible* aRootAccessible); michael@0: michael@0: /** michael@0: * Notification used to update the accessible tree when deck panel is michael@0: * switched. michael@0: */ michael@0: void DeckPanelSwitched(nsIPresShell* aPresShell, nsIContent* aDeckNode, michael@0: nsIFrame* aPrevBoxFrame, nsIFrame* aCurrentBoxFrame); michael@0: michael@0: /** michael@0: * Notification used to update the accessible tree when new content is michael@0: * inserted. michael@0: */ michael@0: void ContentRangeInserted(nsIPresShell* aPresShell, nsIContent* aContainer, michael@0: nsIContent* aStartChild, nsIContent* aEndChild); michael@0: michael@0: /** michael@0: * Notification used to update the accessible tree when content is removed. michael@0: */ michael@0: void ContentRemoved(nsIPresShell* aPresShell, nsIContent* aContainer, michael@0: nsIContent* aChild); michael@0: michael@0: virtual void UpdateText(nsIPresShell* aPresShell, nsIContent* aContent); michael@0: michael@0: /** michael@0: * Update XUL:tree accessible tree when treeview is changed. michael@0: */ michael@0: void TreeViewChanged(nsIPresShell* aPresShell, nsIContent* aContent, michael@0: nsITreeView* aView); michael@0: michael@0: /** michael@0: * Notify of input@type="element" value change. michael@0: */ michael@0: void RangeValueChanged(nsIPresShell* aPresShell, nsIContent* aContent); michael@0: michael@0: /** michael@0: * Update list bullet accessible. michael@0: */ michael@0: virtual void UpdateListBullet(nsIPresShell* aPresShell, michael@0: nsIContent* aHTMLListItemContent, michael@0: bool aHasBullet); michael@0: michael@0: /** michael@0: * Update the image map. michael@0: */ michael@0: void UpdateImageMap(nsImageFrame* aImageFrame); michael@0: michael@0: /** michael@0: * Update the label accessible tree when rendered @value is changed. michael@0: */ michael@0: void UpdateLabelValue(nsIPresShell* aPresShell, nsIContent* aLabelElm, michael@0: const nsString& aNewValue); michael@0: michael@0: /** michael@0: * Notify accessibility that anchor jump has been accomplished to the given michael@0: * target. Used by layout. michael@0: */ michael@0: void NotifyOfAnchorJumpTo(nsIContent *aTarget); michael@0: michael@0: /** michael@0: * Notify that presshell is activated. michael@0: */ michael@0: virtual void PresShellActivated(nsIPresShell* aPresShell); michael@0: michael@0: /** michael@0: * Recreate an accessible for the given content node in the presshell. michael@0: */ michael@0: void RecreateAccessible(nsIPresShell* aPresShell, nsIContent* aContent); michael@0: michael@0: virtual void FireAccessibleEvent(uint32_t aEvent, Accessible* aTarget); michael@0: michael@0: // nsAccessibiltiyService michael@0: michael@0: /** michael@0: * Return true if accessibility service has been shutdown. michael@0: */ michael@0: static bool IsShutdown() { return gIsShutdown; } michael@0: michael@0: /** michael@0: * Return an accessible for the given DOM node from the cache or create new michael@0: * one. michael@0: * michael@0: * @param aNode [in] the given node michael@0: * @param aContext [in] context the accessible is created in michael@0: * @param aIsSubtreeHidden [out, optional] indicates whether the node's michael@0: * frame and its subtree is hidden michael@0: */ michael@0: Accessible* GetOrCreateAccessible(nsINode* aNode, Accessible* aContext, michael@0: bool* aIsSubtreeHidden = nullptr); michael@0: michael@0: private: michael@0: // nsAccessibilityService creation is controlled by friend michael@0: // NS_GetAccessibilityService, keep constructors private. michael@0: nsAccessibilityService(); michael@0: nsAccessibilityService(const nsAccessibilityService&); michael@0: nsAccessibilityService& operator =(const nsAccessibilityService&); michael@0: michael@0: private: michael@0: /** michael@0: * Initialize accessibility service. michael@0: */ michael@0: bool Init(); michael@0: michael@0: /** michael@0: * Shutdowns accessibility service. michael@0: */ michael@0: void Shutdown(); michael@0: michael@0: /** michael@0: * Create accessible for the element having XBL bindings. michael@0: */ michael@0: already_AddRefed michael@0: CreateAccessibleByType(nsIContent* aContent, DocAccessible* aDoc); michael@0: michael@0: /** michael@0: * Create accessible for HTML node by tag name. michael@0: */ michael@0: already_AddRefed michael@0: CreateHTMLAccessibleByMarkup(nsIFrame* aFrame, nsIContent* aContent, michael@0: Accessible* aContext); michael@0: michael@0: /** michael@0: * Create an accessible whose type depends on the given frame. michael@0: */ michael@0: already_AddRefed michael@0: CreateAccessibleByFrameType(nsIFrame* aFrame, nsIContent* aContent, michael@0: Accessible* aContext); michael@0: michael@0: #ifdef MOZ_XUL michael@0: /** michael@0: * Create accessible for XUL tree element. michael@0: */ michael@0: already_AddRefed michael@0: CreateAccessibleForXULTree(nsIContent* aContent, DocAccessible* aDoc); michael@0: #endif michael@0: michael@0: /** michael@0: * Reference for accessibility service instance. michael@0: */ michael@0: static nsAccessibilityService* gAccessibilityService; michael@0: michael@0: /** michael@0: * Reference for application accessible instance. michael@0: */ michael@0: static mozilla::a11y::ApplicationAccessible* gApplicationAccessible; michael@0: michael@0: /** michael@0: * Indicates whether accessibility service was shutdown. michael@0: */ michael@0: static bool gIsShutdown; michael@0: michael@0: friend nsAccessibilityService* GetAccService(); michael@0: friend mozilla::a11y::FocusManager* mozilla::a11y::FocusMgr(); michael@0: friend mozilla::a11y::SelectionManager* mozilla::a11y::SelectionMgr(); michael@0: friend mozilla::a11y::ApplicationAccessible* mozilla::a11y::ApplicationAcc(); michael@0: michael@0: friend nsresult NS_GetAccessibilityService(nsIAccessibilityService** aResult); michael@0: }; michael@0: michael@0: /** michael@0: * Return the accessibility service instance. (Handy global function) michael@0: */ michael@0: inline nsAccessibilityService* michael@0: GetAccService() michael@0: { michael@0: return nsAccessibilityService::gAccessibilityService; michael@0: } michael@0: michael@0: /** michael@0: * Map nsIAccessibleEvents constants to strings. Used by michael@0: * nsIAccessibleRetrieval::getStringEventType() method. michael@0: */ michael@0: static const char kEventTypeNames[][40] = { michael@0: "unknown", // michael@0: "show", // EVENT_SHOW michael@0: "hide", // EVENT_HIDE michael@0: "reorder", // EVENT_REORDER michael@0: "active decendent change", // EVENT_ACTIVE_DECENDENT_CHANGED michael@0: "focus", // EVENT_FOCUS michael@0: "state change", // EVENT_STATE_CHANGE michael@0: "location change", // EVENT_LOCATION_CHANGE michael@0: "name changed", // EVENT_NAME_CHANGE michael@0: "description change", // EVENT_DESCRIPTION_CHANGE michael@0: "value change", // EVENT_VALUE_CHANGE michael@0: "help change", // EVENT_HELP_CHANGE michael@0: "default action change", // EVENT_DEFACTION_CHANGE michael@0: "action change", // EVENT_ACTION_CHANGE michael@0: "accelerator change", // EVENT_ACCELERATOR_CHANGE michael@0: "selection", // EVENT_SELECTION michael@0: "selection add", // EVENT_SELECTION_ADD michael@0: "selection remove", // EVENT_SELECTION_REMOVE michael@0: "selection within", // EVENT_SELECTION_WITHIN michael@0: "alert", // EVENT_ALERT michael@0: "foreground", // EVENT_FOREGROUND michael@0: "menu start", // EVENT_MENU_START michael@0: "menu end", // EVENT_MENU_END michael@0: "menupopup start", // EVENT_MENUPOPUP_START michael@0: "menupopup end", // EVENT_MENUPOPUP_END michael@0: "capture start", // EVENT_CAPTURE_START michael@0: "capture end", // EVENT_CAPTURE_END michael@0: "movesize start", // EVENT_MOVESIZE_START michael@0: "movesize end", // EVENT_MOVESIZE_END michael@0: "contexthelp start", // EVENT_CONTEXTHELP_START michael@0: "contexthelp end", // EVENT_CONTEXTHELP_END michael@0: "dragdrop start", // EVENT_DRAGDROP_START michael@0: "dragdrop end", // EVENT_DRAGDROP_END michael@0: "dialog start", // EVENT_DIALOG_START michael@0: "dialog end", // EVENT_DIALOG_END michael@0: "scrolling start", // EVENT_SCROLLING_START michael@0: "scrolling end", // EVENT_SCROLLING_END michael@0: "minimize start", // EVENT_MINIMIZE_START michael@0: "minimize end", // EVENT_MINIMIZE_END michael@0: "document load complete", // EVENT_DOCUMENT_LOAD_COMPLETE michael@0: "document reload", // EVENT_DOCUMENT_RELOAD michael@0: "document load stopped", // EVENT_DOCUMENT_LOAD_STOPPED michael@0: "document attributes changed", // EVENT_DOCUMENT_ATTRIBUTES_CHANGED michael@0: "document content changed", // EVENT_DOCUMENT_CONTENT_CHANGED michael@0: "property changed", // EVENT_PROPERTY_CHANGED michael@0: "page changed", // EVENT_PAGE_CHANGED michael@0: "text attribute changed", // EVENT_TEXT_ATTRIBUTE_CHANGED michael@0: "text caret moved", // EVENT_TEXT_CARET_MOVED michael@0: "text changed", // EVENT_TEXT_CHANGED michael@0: "text inserted", // EVENT_TEXT_INSERTED michael@0: "text removed", // EVENT_TEXT_REMOVED michael@0: "text updated", // EVENT_TEXT_UPDATED michael@0: "text selection changed", // EVENT_TEXT_SELECTION_CHANGED michael@0: "visible data changed", // EVENT_VISIBLE_DATA_CHANGED michael@0: "text column changed", // EVENT_TEXT_COLUMN_CHANGED michael@0: "section changed", // EVENT_SECTION_CHANGED michael@0: "table caption changed", // EVENT_TABLE_CAPTION_CHANGED michael@0: "table model changed", // EVENT_TABLE_MODEL_CHANGED michael@0: "table summary changed", // EVENT_TABLE_SUMMARY_CHANGED michael@0: "table row description changed", // EVENT_TABLE_ROW_DESCRIPTION_CHANGED michael@0: "table row header changed", // EVENT_TABLE_ROW_HEADER_CHANGED michael@0: "table row insert", // EVENT_TABLE_ROW_INSERT michael@0: "table row delete", // EVENT_TABLE_ROW_DELETE michael@0: "table row reorder", // EVENT_TABLE_ROW_REORDER michael@0: "table column description changed", // EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED michael@0: "table column header changed", // EVENT_TABLE_COLUMN_HEADER_CHANGED michael@0: "table column insert", // EVENT_TABLE_COLUMN_INSERT michael@0: "table column delete", // EVENT_TABLE_COLUMN_DELETE michael@0: "table column reorder", // EVENT_TABLE_COLUMN_REORDER michael@0: "window activate", // EVENT_WINDOW_ACTIVATE michael@0: "window create", // EVENT_WINDOW_CREATE michael@0: "window deactivate", // EVENT_WINDOW_DEACTIVATE michael@0: "window destroy", // EVENT_WINDOW_DESTROY michael@0: "window maximize", // EVENT_WINDOW_MAXIMIZE michael@0: "window minimize", // EVENT_WINDOW_MINIMIZE michael@0: "window resize", // EVENT_WINDOW_RESIZE michael@0: "window restore", // EVENT_WINDOW_RESTORE michael@0: "hyperlink end index changed", // EVENT_HYPERLINK_END_INDEX_CHANGED michael@0: "hyperlink number of anchors changed", // EVENT_HYPERLINK_NUMBER_OF_ANCHORS_CHANGED michael@0: "hyperlink selected link changed", // EVENT_HYPERLINK_SELECTED_LINK_CHANGED michael@0: "hypertext link activated", // EVENT_HYPERTEXT_LINK_ACTIVATED michael@0: "hypertext link selected", // EVENT_HYPERTEXT_LINK_SELECTED michael@0: "hyperlink start index changed", // EVENT_HYPERLINK_START_INDEX_CHANGED michael@0: "hypertext changed", // EVENT_HYPERTEXT_CHANGED michael@0: "hypertext links count changed", // EVENT_HYPERTEXT_NLINKS_CHANGED michael@0: "object attribute changed", // EVENT_OBJECT_ATTRIBUTE_CHANGED michael@0: "virtual cursor changed" // EVENT_VIRTUALCURSOR_CHANGED michael@0: }; michael@0: michael@0: #endif /* __nsIAccessibilityService_h__ */ michael@0: