Readonly
activeIn the parent process: The BrowsingContext corresponding to activeWindow. In content processes: The top-level Web content browsing context that focus is in if the application is active and focus is in Web content.
Readonly
activeThe most active (frontmost) window, or null if no window that is part of the application is active. Do not use outside the parent process.
Readonly
focusedParent-process only: The content BrowsingContext that currently has focus, if any. Note this can be different from activeBrowsingContext in the case of subframes.
Readonly
focusedThe element that is currently focused. This will always be an element within the document loaded in focusedWindow or null if no element in that document is focused.
The child window within the activeWindow that is focused. This will always be activeWindow, a child window of activeWindow or null if no child window is focused. Setting the focusedWindow changes the focused window and raises the toplevel window it is in. If the current focus within the new focusedWindow is a frame element, then the focusedWindow will actually be set to the child window and the current element within that set as the focused element. This process repeats downwards until a non-frame element is found. The setter for this attribute defaults to CallerType::System. If focus is in another process, this is null in content processes and the closest ancestor in the parent process.
Optional
aInstancePtr: objectA run time mechanism for interface discovery.
NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.
aInstancePtr must not be null.
[in] A requested interface IID
[out] A pointer to an interface pointer to receive the result.
Returns the currently focused element within aWindow. If aWindow is equal to the current value of focusedWindow, then the returned element will be the application-wide focused element (the value of focusedElement). The return value will be null if no element is focused.
If aDeep is true, then child frames are traversed and the return value may be the element within a child descendant window that is focused. If aDeep if false, then the return value will be the frame element if the focus is in a child frame.
aFocusedWindow will be set to the currently focused descendant window of aWindow, or to aWindow if aDeep is false. This will be set even if no element is focused.
NS_ERROR_INVALID_ARG if aWindow is null
Returns the method that was used to focus the element in window. This will either be 0, FLAG_BYMOUSE or FLAG_BYKEY. If window is null, then the current focusedWindow will be used by default. This has the result of retrieving the method that was used to focus the currently focused element.
Move the focus to another element. If aStartElement is specified, then movement is done relative to aStartElement. If aStartElement is null, then movement is done relative to the currently focused element. If no element is focused, focus the first focusable element within the document (or the last focusable element if aType is MOVEFOCUS_END). This method is equivalent to setting the focusedElement to the new element.
Specifying aStartElement and using MOVEFOCUS_LAST is not currently implemented.
If no element is found, and aType is either MOVEFOCUS_ROOT or MOVEFOCUS_CARET, then the focus is cleared. If aType is any other value, the focus is not changed.
Returns the element that was focused (see setFocus). The return value may be null if focus was moved into a child process.
Changes the focused element reference within the window containing
aElement to aElement or potentially redirects it to an anonymous
descendant of it (e.g., for <input type="number">
the focus is redirected
to its descendant <input type="text">
).
Generated using TypeDoc
The focus manager deals with all focus related behaviour. Only one element in the entire application may have the focus at a time; this element receives any keyboard events. While there is only one application-wide focused element, each nsIDOMWindow maintains a reference to the element that would be focused if the window was active.
If the window's reference is to a frame element (iframe, browser, editor), then the child window contains the element that is currently focused. If the window's reference is to a root element, then the root is focused. If a window's reference is null, then no element is focused, yet the window is still focused.
The blur event is fired on an element when it loses the application focus. After this blur event, if the focus is moving away from a document, two additional blur events are fired on the old document and window containing the focus respectively.
When a new document is focused, two focus events are fired on the new document and window respectively. Then the focus event is fired on an element when it gains the application focus.
A special case is that the root element may be focused, yet does not receive the element focus and blur events. Instead a focus outline may be drawn around the document.
Blur and focus events do not bubble as per the W3C DOM Events spec.