michael@0: /* -*- Mode: C++; tab-width: 4; 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 mozilla_a11y_SelectionManager_h__ michael@0: #define mozilla_a11y_SelectionManager_h__ michael@0: michael@0: #include "nsIFrame.h" michael@0: #include "nsISelectionListener.h" michael@0: michael@0: class nsIPresShell; michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace dom { michael@0: class Element; michael@0: } michael@0: michael@0: namespace a11y { michael@0: michael@0: class AccEvent; michael@0: michael@0: /** michael@0: * This special accessibility class is for the caret and selection management. michael@0: * There is only 1 visible caret per top level window. However, there may be michael@0: * several visible selections. michael@0: * michael@0: * The important selections are the one owned by each document, and the one in michael@0: * the currently focused control. michael@0: * michael@0: * On Windows this class is used to move an invisible system caret that michael@0: * shadows the Mozilla caret. Windows will also automatically map this to michael@0: * the MSAA caret accessible object (via OBJID_CARET) (as opposed to the root michael@0: * accessible tree for a window which is retrieved with OBJID_CLIENT). michael@0: * michael@0: * For ATK and IAccessible2, this class is used to fire caret move and michael@0: * selection change events. michael@0: */ michael@0: michael@0: struct SelData; michael@0: michael@0: class SelectionManager : public nsISelectionListener michael@0: { michael@0: public: michael@0: // nsISupports michael@0: // implemented by derived nsAccessibilityService michael@0: michael@0: // nsISelectionListener michael@0: NS_DECL_NSISELECTIONLISTENER michael@0: michael@0: // SelectionManager michael@0: void Shutdown() { ClearControlSelectionListener(); } michael@0: michael@0: /** michael@0: * Listen to selection events on the focused control. michael@0: * michael@0: * Note: only one control's selection events are listened to at a time. This michael@0: * will remove the previous control's selection listener. michael@0: */ michael@0: void SetControlSelectionListener(dom::Element* aFocusedElm); michael@0: michael@0: /** michael@0: * Stop listening to selection events on the control. michael@0: */ michael@0: void ClearControlSelectionListener(); michael@0: michael@0: /** michael@0: * Listen to selection events on the document. michael@0: */ michael@0: void AddDocSelectionListener(nsIPresShell* aPresShell); michael@0: michael@0: /** michael@0: * Stop listening to selection events for a given document michael@0: */ michael@0: void RemoveDocSelectionListener(nsIPresShell* aShell); michael@0: michael@0: /** michael@0: * Process delayed event, results in caret move and text selection change michael@0: * events. michael@0: */ michael@0: void ProcessTextSelChangeEvent(AccEvent* aEvent); michael@0: michael@0: protected: michael@0: /** michael@0: * Process DOM selection change. Fire selection and caret move events. michael@0: */ michael@0: void ProcessSelectionChanged(SelData* aSelData); michael@0: michael@0: private: michael@0: // Currently focused control. michael@0: nsWeakFrame mCurrCtrlFrame; michael@0: }; michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: #endif