michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ 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: #include "nsISupports.idl" michael@0: michael@0: typedef short TextBoundaryType; michael@0: typedef short PivotMoveReason; michael@0: michael@0: interface nsIAccessible; michael@0: interface nsIAccessibleText; michael@0: interface nsIAccessibleTraversalRule; michael@0: interface nsIAccessiblePivotObserver; michael@0: michael@0: /** michael@0: * The pivot interface encapsulates a reference to a single place in an accessible michael@0: * subtree. The pivot is a point or a range in the accessible tree. This interface michael@0: * provides traversal methods to move the pivot to next/prev state that complies michael@0: * to a given rule. michael@0: */ michael@0: [scriptable, uuid(c2938033-e240-4fe5-9cb6-e7ad649ccd10)] michael@0: interface nsIAccessiblePivot : nsISupports michael@0: { michael@0: const TextBoundaryType CHAR_BOUNDARY = 0; michael@0: const TextBoundaryType WORD_BOUNDARY = 1; michael@0: const TextBoundaryType LINE_BOUNDARY = 2; michael@0: const TextBoundaryType ATTRIBUTE_RANGE_BOUNDARY = 3; michael@0: michael@0: const PivotMoveReason REASON_NONE = 0; michael@0: const PivotMoveReason REASON_NEXT = 1; michael@0: const PivotMoveReason REASON_PREV = 2; michael@0: const PivotMoveReason REASON_FIRST = 3; michael@0: const PivotMoveReason REASON_LAST = 4; michael@0: const PivotMoveReason REASON_TEXT = 5; michael@0: const PivotMoveReason REASON_POINT = 6; michael@0: michael@0: /** michael@0: * The accessible the pivot is currently pointed at. michael@0: */ michael@0: attribute nsIAccessible position; michael@0: michael@0: /** michael@0: * The root of the subtree in which the pivot traverses. michael@0: */ michael@0: readonly attribute nsIAccessible root; michael@0: michael@0: /** michael@0: * The temporary modal root to which traversal is limited to. michael@0: */ michael@0: attribute nsIAccessible modalRoot; michael@0: michael@0: /** michael@0: * The start offset of the text range the pivot points at, otherwise -1. michael@0: */ michael@0: readonly attribute long startOffset; michael@0: michael@0: /** michael@0: * The end offset of the text range the pivot points at, otherwise -1. michael@0: */ michael@0: readonly attribute long endOffset; michael@0: michael@0: /** michael@0: * Set the pivot's text range in a text accessible. michael@0: * michael@0: * @param aTextAccessible [in] the text accessible that contains the desired michael@0: * range. michael@0: * @param aStartOffset [in] the start offset to set. michael@0: * @param aEndOffset [in] the end offset to set. michael@0: * @throws NS_ERROR_INVALID_ARG when the offset exceeds the accessible's michael@0: * character count. michael@0: */ michael@0: void setTextRange(in nsIAccessibleText aTextAccessible, michael@0: in long aStartOffset, in long aEndOffset); michael@0: michael@0: /** michael@0: * Move pivot to next object, from current position or given anchor, michael@0: * complying to given traversal rule. michael@0: * michael@0: * @param aRule [in] traversal rule to use. michael@0: * @param aAnchor [in] accessible to start search from, if not provided, michael@0: * current position will be used. michael@0: * @param aIncludeStart [in] include anchor accessible in search. michael@0: * @return true on success, false if there are no new nodes to traverse to. michael@0: */ michael@0: [optional_argc] boolean moveNext(in nsIAccessibleTraversalRule aRule, michael@0: [optional] in nsIAccessible aAnchor, michael@0: [optional] in boolean aIncludeStart); michael@0: michael@0: /** michael@0: * Move pivot to previous object, from current position or given anchor, michael@0: * complying to given traversal rule. michael@0: * michael@0: * @param aRule [in] traversal rule to use. michael@0: * @param aAnchor [in] accessible to start search from, if not provided, michael@0: * current position will be used. michael@0: * @param aIncludeStart [in] include anchor accessible in search. michael@0: * @return true on success, false if there are no new nodes to traverse to. michael@0: */ michael@0: [optional_argc] boolean movePrevious(in nsIAccessibleTraversalRule aRule, michael@0: [optional] in nsIAccessible aAnchor, michael@0: [optional] in boolean aIncludeStart); michael@0: michael@0: /** michael@0: * Move pivot to first object in subtree complying to given traversal rule. michael@0: * michael@0: * @param aRule [in] traversal rule to use. michael@0: * @return true on success, false if there are no new nodes to traverse to. michael@0: */ michael@0: boolean moveFirst(in nsIAccessibleTraversalRule aRule); michael@0: michael@0: /** michael@0: * Move pivot to last object in subtree complying to given traversal rule. michael@0: * michael@0: * @param aRule [in] traversal rule to use. michael@0: * @return true on success, false if there are no new nodes to traverse to. michael@0: */ michael@0: boolean moveLast(in nsIAccessibleTraversalRule aRule); michael@0: michael@0: /** michael@0: * Move pivot to next text range. michael@0: * michael@0: * @param aBoundary [in] type of boundary for next text range, character, word, michael@0: * etc. michael@0: * @return true on success, false if there are is no more text. michael@0: */ michael@0: boolean moveNextByText(in TextBoundaryType aBoundary); michael@0: michael@0: /** michael@0: * Move pivot to previous text range. michael@0: * michael@0: * @param aBoundary [in] type of boundary for previous text range, character, michael@0: * word, etc. michael@0: * @return true on success, false if there are is no more text. michael@0: */ michael@0: boolean movePreviousByText(in TextBoundaryType aBoundary); michael@0: michael@0: /** michael@0: * Move pivot to given coordinate in screen pixels. michael@0: * michael@0: * @param aRule [in] raversal rule to use. michael@0: * @param aX [in] screen's x coordinate michael@0: * @param aY [in] screen's y coordinate michael@0: * @param aIgnoreNoMatch [in] don't unset position if no object was found at michael@0: * point. michael@0: * @return true on success, false if the pivot has not been moved. michael@0: */ michael@0: boolean moveToPoint(in nsIAccessibleTraversalRule aRule, michael@0: in long aX, in long aY, michael@0: in boolean aIgnoreNoMatch); michael@0: michael@0: /** michael@0: * Add an observer for pivot changes. michael@0: * michael@0: * @param aObserver [in] the observer object to be notified of pivot changes. michael@0: */ michael@0: void addObserver(in nsIAccessiblePivotObserver aObserver); michael@0: michael@0: /** michael@0: * Remove an observer for pivot changes. michael@0: * michael@0: * @param aObserver [in] the observer object to remove from being notified. michael@0: */ michael@0: void removeObserver(in nsIAccessiblePivotObserver aObserver); michael@0: }; michael@0: michael@0: /** michael@0: * An observer interface for pivot changes. michael@0: */ michael@0: [scriptable, uuid(b6508c5e-c081-467d-835c-613eedf9ee9b)] michael@0: interface nsIAccessiblePivotObserver : nsISupports michael@0: { michael@0: /** michael@0: * Called when the pivot changes. michael@0: * michael@0: * @param aPivot [in] the pivot that has changed. michael@0: * @param aOldAccessible [in] the old pivot position before the change, or null. michael@0: * @param aOldStart [in] the old start offset, or -1. michael@0: * @param aOldEnd [in] the old end offset, or -1. michael@0: * @param aReason [in] the reason for the pivot change. michael@0: */ michael@0: void onPivotChanged(in nsIAccessiblePivot aPivot, michael@0: in nsIAccessible aOldAccessible, michael@0: in long aOldStart, in long aOldEnd, michael@0: in PivotMoveReason aReason); michael@0: }; michael@0: michael@0: [scriptable, uuid(4d9c4352-20f5-4c54-9580-0c77bb6b1115)] michael@0: interface nsIAccessibleTraversalRule : nsISupports michael@0: { michael@0: /* Ignore this accessible object */ michael@0: const unsigned short FILTER_IGNORE = 0x0; michael@0: /* Accept this accessible object */ michael@0: const unsigned short FILTER_MATCH = 0x1; michael@0: /* Don't traverse accessibles children */ michael@0: const unsigned short FILTER_IGNORE_SUBTREE = 0x2; michael@0: michael@0: /* Pre-filters */ michael@0: const unsigned long PREFILTER_INVISIBLE = 0x00000001; michael@0: const unsigned long PREFILTER_OFFSCREEN = 0x00000002; michael@0: const unsigned long PREFILTER_NOT_FOCUSABLE = 0x00000004; michael@0: const unsigned long PREFILTER_ARIA_HIDDEN = 0x00000008; michael@0: const unsigned long PREFILTER_TRANSPARENT = 0x00000010; michael@0: michael@0: /** michael@0: * Pre-filter bitfield to filter out obviously ignorable nodes and lighten michael@0: * the load on match(). michael@0: */ michael@0: readonly attribute unsigned long preFilter; michael@0: michael@0: /** michael@0: * Retrieve a list of roles that the traversal rule should test for. Any node michael@0: * with a role not in this list will automatically be ignored. An empty list michael@0: * will match all roles. It should be assumed that this method is called once michael@0: * at the start of a traversal, so changing the method's return result after michael@0: * that would have no affect. michael@0: * michael@0: * @param aRoles [out] an array of the roles to match. michael@0: * @param aCount [out] the length of the array. michael@0: */ michael@0: void getMatchRoles([array, size_is(aCount)]out unsigned long aRoles, michael@0: [retval]out unsigned long aCount); michael@0: michael@0: /** michael@0: * Determines if a given accessible is to be accepted in our traversal rule michael@0: * michael@0: * @param aAccessible [in] accessible to examine. michael@0: * @return a bitfield of FILTER_MATCH and FILTER_IGNORE_SUBTREE. michael@0: */ michael@0: unsigned short match(in nsIAccessible aAccessible); michael@0: };