accessible/src/base/FocusManager.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef mozilla_a11y_FocusManager_h_
     6 #define mozilla_a11y_FocusManager_h_
     8 #include "nsAutoPtr.h"
    10 class nsINode;
    11 class nsIDocument;
    12 class nsISupports;
    14 namespace mozilla {
    15 namespace a11y {
    17 class AccEvent;
    18 class Accessible;
    19 class DocAccessible;
    21 /**
    22  * Manage the accessible focus. Used to fire and process accessible events.
    23  */
    24 class FocusManager
    25 {
    26 public:
    27   virtual ~FocusManager();
    29   /**
    30    * Return a focused accessible.
    31    */
    32   Accessible* FocusedAccessible() const;
    34   /**
    35    * Return true if given accessible is focused.
    36    */
    37   bool IsFocused(const Accessible* aAccessible) const;
    39   /**
    40    * Return true if the given accessible is an active item, i.e. an item that
    41    * is current within the active widget.
    42    */
    43   inline bool IsActiveItem(const Accessible* aAccessible)
    44     { return aAccessible == mActiveItem; }
    46   /**
    47    * Return true if given DOM node has DOM focus.
    48    */
    49   inline bool HasDOMFocus(const nsINode* aNode) const
    50     { return aNode == FocusedDOMNode(); }
    52   /**
    53    * Return true if focused accessible is within the given container.
    54    */
    55   bool IsFocusWithin(const Accessible* aContainer) const;
    57   /**
    58    * Return whether the given accessible is focused or contains the focus or
    59    * contained by focused accessible.
    60    */
    61   enum FocusDisposition {
    62     eNone,
    63     eFocused,
    64     eContainsFocus,
    65     eContainedByFocus
    66   };
    67   FocusDisposition IsInOrContainsFocus(const Accessible* aAccessible) const;
    69   //////////////////////////////////////////////////////////////////////////////
    70   // Focus notifications and processing (don't use until you know what you do).
    72   /**
    73    * Called when DOM focus event is fired.
    74    */
    75   void NotifyOfDOMFocus(nsISupports* aTarget);
    77   /**
    78    * Called when DOM blur event is fired.
    79    */
    80   void NotifyOfDOMBlur(nsISupports* aTarget);
    82   /**
    83    * Called when active item is changed. Note: must be called when accessible
    84    * tree is up to date.
    85    */
    86   void ActiveItemChanged(Accessible* aItem, bool aCheckIfActive = true);
    88   /**
    89    * Dispatch delayed focus event for the current focus accessible.
    90    */
    91   void ForceFocusEvent();
    93   /**
    94    * Dispatch delayed focus event for the given target.
    95    */
    96   void DispatchFocusEvent(DocAccessible* aDocument, Accessible* aTarget);
    98   /**
    99    * Process DOM focus notification.
   100    */
   101   void ProcessDOMFocus(nsINode* aTarget);
   103   /**
   104    * Process the delayed accessible event.
   105    * do.
   106    */
   107   void ProcessFocusEvent(AccEvent* aEvent);
   109 protected:
   110   FocusManager();
   112 private:
   113   FocusManager(const FocusManager&);
   114   FocusManager& operator =(const FocusManager&);
   116   /**
   117    * Return DOM node having DOM focus.
   118    */
   119   nsINode* FocusedDOMNode() const;
   121   /**
   122    * Return DOM document having DOM focus.
   123    */
   124   nsIDocument* FocusedDOMDocument() const;
   126 private:
   127   nsRefPtr<Accessible> mActiveItem;
   128   nsRefPtr<Accessible> mActiveARIAMenubar;
   129 };
   131 } // namespace a11y
   132 } // namespace mozilla
   134 #endif

mercurial