Bug 881092 - Allow decoding files we know we can't play, in the context of WebAudio...
[gecko.git] / accessible / src / base / FocusManager.h
blob1955a84193c48cecd4e5dfc0f5796902ccb8b9c7
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"
9 #include "mozilla/dom/Element.h"
11 namespace mozilla {
12 namespace a11y {
14 class AccEvent;
15 class Accessible;
16 class DocAccessible;
18 /**
19 * Manage the accessible focus. Used to fire and process accessible events.
21 class FocusManager
23 public:
24 virtual ~FocusManager();
26 /**
27 * Return a focused accessible.
29 Accessible* FocusedAccessible() const;
31 /**
32 * Return true if given accessible is focused.
34 bool IsFocused(const Accessible* aAccessible) const;
36 /**
37 * Return true if the given accessible is an active item, i.e. an item that
38 * is current within the active widget.
40 inline bool IsActiveItem(const Accessible* aAccessible)
41 { return aAccessible == mActiveItem; }
43 /**
44 * Return true if given DOM node has DOM focus.
46 inline bool HasDOMFocus(const nsINode* aNode) const
47 { return aNode == FocusedDOMNode(); }
49 /**
50 * Return true if focused accessible is within the given container.
52 bool IsFocusWithin(const Accessible* aContainer) const;
54 /**
55 * Return whether the given accessible is focused or contains the focus or
56 * contained by focused accessible.
58 enum FocusDisposition {
59 eNone,
60 eFocused,
61 eContainsFocus,
62 eContainedByFocus
64 FocusDisposition IsInOrContainsFocus(const Accessible* aAccessible) const;
66 //////////////////////////////////////////////////////////////////////////////
67 // Focus notifications and processing (don't use until you know what you do).
69 /**
70 * Called when DOM focus event is fired.
72 void NotifyOfDOMFocus(nsISupports* aTarget);
74 /**
75 * Called when DOM blur event is fired.
77 void NotifyOfDOMBlur(nsISupports* aTarget);
79 /**
80 * Called when active item is changed. Note: must be called when accessible
81 * tree is up to date.
83 void ActiveItemChanged(Accessible* aItem, bool aCheckIfActive = true);
85 /**
86 * Dispatch delayed focus event for the current focus accessible.
88 void ForceFocusEvent();
90 /**
91 * Dispatch delayed focus event for the given target.
93 void DispatchFocusEvent(DocAccessible* aDocument, Accessible* aTarget);
95 /**
96 * Process DOM focus notification.
98 void ProcessDOMFocus(nsINode* aTarget);
101 * Process the delayed accessible event.
102 * do.
104 void ProcessFocusEvent(AccEvent* aEvent);
106 protected:
107 FocusManager();
109 private:
110 FocusManager(const FocusManager&);
111 FocusManager& operator =(const FocusManager&);
114 * Return DOM node having DOM focus.
116 nsINode* FocusedDOMNode() const;
119 * Return DOM document having DOM focus.
121 nsIDocument* FocusedDOMDocument() const;
123 private:
124 nsRefPtr<Accessible> mActiveItem;
125 nsRefPtr<Accessible> mActiveARIAMenubar;
128 } // namespace a11y
129 } // namespace mozilla
131 #endif