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.

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

mercurial