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_
9 #include "mozilla/dom/Element.h"
19 * Manage the accessible focus. Used to fire and process accessible events.
24 virtual ~FocusManager();
27 * Return a focused accessible.
29 Accessible
* FocusedAccessible() const;
32 * Return true if given accessible is focused.
34 bool IsFocused(const Accessible
* aAccessible
) const;
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
; }
44 * Return true if given DOM node has DOM focus.
46 inline bool HasDOMFocus(const nsINode
* aNode
) const
47 { return aNode
== FocusedDOMNode(); }
50 * Return true if focused accessible is within the given container.
52 bool IsFocusWithin(const Accessible
* aContainer
) const;
55 * Return whether the given accessible is focused or contains the focus or
56 * contained by focused accessible.
58 enum FocusDisposition
{
64 FocusDisposition
IsInOrContainsFocus(const Accessible
* aAccessible
) const;
66 //////////////////////////////////////////////////////////////////////////////
67 // Focus notifications and processing (don't use until you know what you do).
70 * Called when DOM focus event is fired.
72 void NotifyOfDOMFocus(nsISupports
* aTarget
);
75 * Called when DOM blur event is fired.
77 void NotifyOfDOMBlur(nsISupports
* aTarget
);
80 * Called when active item is changed. Note: must be called when accessible
83 void ActiveItemChanged(Accessible
* aItem
, bool aCheckIfActive
= true);
86 * Dispatch delayed focus event for the current focus accessible.
88 void ForceFocusEvent();
91 * Dispatch delayed focus event for the given target.
93 void DispatchFocusEvent(DocAccessible
* aDocument
, Accessible
* aTarget
);
96 * Process DOM focus notification.
98 void ProcessDOMFocus(nsINode
* aTarget
);
101 * Process the delayed accessible event.
104 void ProcessFocusEvent(AccEvent
* aEvent
);
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;
124 nsRefPtr
<Accessible
> mActiveItem
;
125 nsRefPtr
<Accessible
> mActiveARIAMenubar
;
129 } // namespace mozilla