accessible/src/base/SelectionManager.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/base/SelectionManager.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,98 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_a11y_SelectionManager_h__
    1.10 +#define mozilla_a11y_SelectionManager_h__
    1.11 +
    1.12 +#include "nsIFrame.h"
    1.13 +#include "nsISelectionListener.h"
    1.14 +
    1.15 +class nsIPresShell;
    1.16 +
    1.17 +namespace mozilla {
    1.18 +
    1.19 +namespace dom {
    1.20 +class Element;
    1.21 +}
    1.22 +
    1.23 +namespace a11y {
    1.24 +
    1.25 +class AccEvent;
    1.26 +
    1.27 +/**
    1.28 + * This special accessibility class is for the caret and selection management.
    1.29 + * There is only 1 visible caret per top level window. However, there may be
    1.30 + * several visible selections.
    1.31 + *
    1.32 + * The important selections are the one owned by each document, and the one in
    1.33 + * the currently focused control.
    1.34 + *
    1.35 + * On Windows this class is used to move an invisible system caret that
    1.36 + * shadows the Mozilla caret. Windows will also automatically map this to
    1.37 + * the MSAA caret accessible object (via OBJID_CARET) (as opposed to the root
    1.38 + * accessible tree for a window which is retrieved with OBJID_CLIENT).
    1.39 + *
    1.40 + * For ATK and IAccessible2, this class is used to fire caret move and
    1.41 + * selection change events.
    1.42 + */
    1.43 +
    1.44 +struct SelData;
    1.45 +
    1.46 +class SelectionManager : public nsISelectionListener
    1.47 +{
    1.48 +public:
    1.49 +  // nsISupports
    1.50 +  // implemented by derived nsAccessibilityService
    1.51 +
    1.52 +  // nsISelectionListener
    1.53 +  NS_DECL_NSISELECTIONLISTENER
    1.54 +
    1.55 +  // SelectionManager
    1.56 +  void Shutdown() { ClearControlSelectionListener(); }
    1.57 +
    1.58 +  /**
    1.59 +   * Listen to selection events on the focused control.
    1.60 +   *
    1.61 +   * Note: only one control's selection events are listened to at a time. This
    1.62 +   * will remove the previous control's selection listener.
    1.63 +   */
    1.64 +  void SetControlSelectionListener(dom::Element* aFocusedElm);
    1.65 +
    1.66 +  /**
    1.67 +   * Stop listening to selection events on the control.
    1.68 +   */
    1.69 +  void ClearControlSelectionListener();
    1.70 +
    1.71 +  /**
    1.72 +   * Listen to selection events on the document.
    1.73 +   */
    1.74 +  void AddDocSelectionListener(nsIPresShell* aPresShell);
    1.75 +
    1.76 +  /**
    1.77 +   * Stop listening to selection events for a given document
    1.78 +   */
    1.79 +  void RemoveDocSelectionListener(nsIPresShell* aShell);
    1.80 +
    1.81 +  /**
    1.82 +   * Process delayed event, results in caret move and text selection change
    1.83 +   * events.
    1.84 +   */
    1.85 +  void ProcessTextSelChangeEvent(AccEvent* aEvent);
    1.86 +
    1.87 +protected:
    1.88 +  /**
    1.89 +   * Process DOM selection change. Fire selection and caret move events.
    1.90 +   */
    1.91 +  void ProcessSelectionChanged(SelData* aSelData);
    1.92 +
    1.93 +private:
    1.94 +  // Currently focused control.
    1.95 +  nsWeakFrame mCurrCtrlFrame;
    1.96 +};
    1.97 +
    1.98 +} // namespace a11y
    1.99 +} // namespace mozilla
   1.100 +
   1.101 +#endif

mercurial