dom/interfaces/base/nsIFocusManager.idl

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "domstubs.idl"
michael@0 7
michael@0 8 interface nsIDocument;
michael@0 9 interface nsIContent;
michael@0 10
michael@0 11 [scriptable, uuid(51db277b-7ee7-4bce-9b84-fd2efcd2c8bd)]
michael@0 12 /**
michael@0 13 * The focus manager deals with all focus related behaviour. Only one element
michael@0 14 * in the entire application may have the focus at a time; this element
michael@0 15 * receives any keyboard events. While there is only one application-wide
michael@0 16 * focused element, each nsIDOMWindow maintains a reference to the element
michael@0 17 * that would be focused if the window was active.
michael@0 18 *
michael@0 19 * If the window's reference is to a frame element (iframe, browser,
michael@0 20 * editor), then the child window contains the element that is currently
michael@0 21 * focused. If the window's reference is to a root element, then the root is
michael@0 22 * focused. If a window's reference is null, then no element is focused, yet
michael@0 23 * the window is still focused.
michael@0 24 *
michael@0 25 * The blur event is fired on an element when it loses the application focus.
michael@0 26 * After this blur event, if the focus is moving away from a document, two
michael@0 27 * additional blur events are fired on the old document and window containing
michael@0 28 * the focus respectively.
michael@0 29 *
michael@0 30 * When a new document is focused, two focus events are fired on the new
michael@0 31 * document and window respectively. Then the focus event is fired on an
michael@0 32 * element when it gains the application focus.
michael@0 33 *
michael@0 34 * A special case is that the root element may be focused, yet does not
michael@0 35 * receive the element focus and blur events. Instead a focus outline may be
michael@0 36 * drawn around the document.
michael@0 37 *
michael@0 38 * Blur and focus events do not bubble as per the W3C DOM Events spec.
michael@0 39 */
michael@0 40 interface nsIFocusManager : nsISupports
michael@0 41 {
michael@0 42 /**
michael@0 43 * The most active (frontmost) window, or null if no window that is part of
michael@0 44 * the application is active. Setting the activeWindow raises it, and
michael@0 45 * focuses the current child window's current element, if any. Setting this
michael@0 46 * to null or to a non-top-level window throws an NS_ERROR_INVALID_ARG
michael@0 47 * exception.
michael@0 48 */
michael@0 49 attribute nsIDOMWindow activeWindow;
michael@0 50
michael@0 51 /**
michael@0 52 * The child window within the activeWindow that is focused. This will
michael@0 53 * always be activeWindow, a child window of activeWindow or null if no
michael@0 54 * child window is focused. Setting the focusedWindow changes the focused
michael@0 55 * window and raises the toplevel window it is in. If the current focus
michael@0 56 * within the new focusedWindow is a frame element, then the focusedWindow
michael@0 57 * will actually be set to the child window and the current element within
michael@0 58 * that set as the focused element. This process repeats downwards until a
michael@0 59 * non-frame element is found.
michael@0 60 */
michael@0 61 attribute nsIDOMWindow focusedWindow;
michael@0 62
michael@0 63 /**
michael@0 64 * The element that is currently focused. This will always be an element
michael@0 65 * within the document loaded in focusedWindow or null if no element in that
michael@0 66 * document is focused.
michael@0 67 */
michael@0 68 readonly attribute nsIDOMElement focusedElement;
michael@0 69
michael@0 70 /**
michael@0 71 * Returns the method that was used to focus the element in window. This
michael@0 72 * will either be 0, FLAG_BYMOUSE or FLAG_BYKEY. If window is null, then
michael@0 73 * the current focusedWindow will be used by default. This has the result
michael@0 74 * of retrieving the method that was used to focus the currently focused
michael@0 75 * element.
michael@0 76 */
michael@0 77 uint32_t getLastFocusMethod(in nsIDOMWindow window);
michael@0 78
michael@0 79 /**
michael@0 80 * Changes the focused element reference within the window containing
michael@0 81 * aElement to aElement.
michael@0 82 */
michael@0 83 void setFocus(in nsIDOMElement aElement, in unsigned long aFlags);
michael@0 84
michael@0 85 /**
michael@0 86 * Move the focus to another element. If aStartElement is specified, then
michael@0 87 * movement is done relative to aStartElement. If aStartElement is null,
michael@0 88 * then movement is done relative to the currently focused element. If no
michael@0 89 * element is focused, focus the first focusable element within the
michael@0 90 * document (or the last focusable element if aType is MOVEFOCUS_END). This
michael@0 91 * method is equivalent to setting the focusedElement to the new element.
michael@0 92 *
michael@0 93 * Specifying aStartElement and using MOVEFOCUS_LAST is not currently
michael@0 94 * implemented.
michael@0 95 *
michael@0 96 * If no element is found, and aType is either MOVEFOCUS_ROOT or
michael@0 97 * MOVEFOCUS_CARET, then the focus is cleared. If aType is any other value,
michael@0 98 * the focus is not changed.
michael@0 99 *
michael@0 100 * Returns the element that was focused.
michael@0 101 */
michael@0 102 nsIDOMElement moveFocus(in nsIDOMWindow aWindow, in nsIDOMElement aStartElement,
michael@0 103 in unsigned long aType, in unsigned long aFlags);
michael@0 104
michael@0 105 /**
michael@0 106 * Clears the focused element within aWindow. If the current focusedWindow
michael@0 107 * is a descendant of aWindow, sets the current focusedWindow to aWindow.
michael@0 108 *
michael@0 109 * @throws NS_ERROR_INVALID_ARG if aWindow is null
michael@0 110 */
michael@0 111 void clearFocus(in nsIDOMWindow aWindow);
michael@0 112
michael@0 113 /**
michael@0 114 * Returns the currently focused element within aWindow. If aWindow is equal
michael@0 115 * to the current value of focusedWindow, then the returned element will be
michael@0 116 * the application-wide focused element (the value of focusedElement). The
michael@0 117 * return value will be null if no element is focused.
michael@0 118 *
michael@0 119 * If aDeep is true, then child frames are traversed and the return value
michael@0 120 * may be the element within a child descendant window that is focused. If
michael@0 121 * aDeep if false, then the return value will be the frame element if the
michael@0 122 * focus is in a child frame.
michael@0 123 *
michael@0 124 * aFocusedWindow will be set to the currently focused descendant window of
michael@0 125 * aWindow, or to aWindow if aDeep is false. This will be set even if no
michael@0 126 * element is focused.
michael@0 127 *
michael@0 128 * @throws NS_ERROR_INVALID_ARG if aWindow is null
michael@0 129 */
michael@0 130 nsIDOMElement getFocusedElementForWindow(in nsIDOMWindow aWindow, in boolean aDeep,
michael@0 131 out nsIDOMWindow aFocusedWindow);
michael@0 132
michael@0 133 /**
michael@0 134 * Moves the selection caret within aWindow to the current focus.
michael@0 135 */
michael@0 136 void moveCaretToFocus(in nsIDOMWindow aWindow);
michael@0 137
michael@0 138 /***
michael@0 139 * Check if given element is focusable.
michael@0 140 */
michael@0 141 boolean elementIsFocusable(in nsIDOMElement aElement, in unsigned long aFlags);
michael@0 142
michael@0 143 /*
michael@0 144 * Raise the window when switching focus
michael@0 145 */
michael@0 146 const unsigned long FLAG_RAISE = 1;
michael@0 147
michael@0 148 /**
michael@0 149 * Do not scroll the element to focus into view
michael@0 150 */
michael@0 151 const unsigned long FLAG_NOSCROLL = 2;
michael@0 152
michael@0 153 /**
michael@0 154 * If attempting to change focus in a window that is not focused, do not
michael@0 155 * switch focus to that window. Instead, just update the focus within that
michael@0 156 * window and leave the application focus as is. This flag will have no
michael@0 157 * effect if a child window is focused and an attempt is made to adjust the
michael@0 158 * focus in an ancestor, as the frame must be switched in this case.
michael@0 159 */
michael@0 160 const unsigned long FLAG_NOSWITCHFRAME = 4;
michael@0 161
michael@0 162 /**
michael@0 163 * This flag is only used when passed to moveFocus. If set, focus is never
michael@0 164 * moved to the parent frame of the starting element's document, instead
michael@0 165 * iterating around to the beginning of that document again. Child frames
michael@0 166 * are navigated as normal.
michael@0 167 */
michael@0 168 const unsigned long FLAG_NOPARENTFRAME = 8;
michael@0 169
michael@0 170 /**
michael@0 171 * Focus is changing due to a mouse operation, for instance the mouse was
michael@0 172 * clicked on an element.
michael@0 173 */
michael@0 174 const unsigned long FLAG_BYMOUSE = 0x1000;
michael@0 175
michael@0 176 /**
michael@0 177 * Focus is changing due to a key operation, for instance pressing the tab
michael@0 178 * key. This flag would normally be passed when MOVEFOCUS_FORWARD or
michael@0 179 * MOVEFOCUS_BACKWARD is used.
michael@0 180 */
michael@0 181 const unsigned long FLAG_BYKEY = 0x2000;
michael@0 182
michael@0 183 /**
michael@0 184 * Focus is changing due to a call to MoveFocus. This flag will be implied
michael@0 185 * when MoveFocus is called except when one of the other mechanisms (mouse
michael@0 186 * or key) is specified, or when the type is MOVEFOCUS_ROOT or
michael@0 187 * MOVEFOCUS_CARET.
michael@0 188 */
michael@0 189 const unsigned long FLAG_BYMOVEFOCUS = 0x4000;
michael@0 190
michael@0 191 /**
michael@0 192 * Always show the focus ring or other indicator of focus, regardless of
michael@0 193 * other state.
michael@0 194 */
michael@0 195 const unsigned long FLAG_SHOWRING = 0x100000;
michael@0 196
michael@0 197 // these constants are used with the aType argument to MoveFocus
michael@0 198
michael@0 199 /** move focus forward one element, used when pressing TAB */
michael@0 200 const unsigned long MOVEFOCUS_FORWARD = 1;
michael@0 201 /** move focus backward one element, used when pressing Shift+TAB */
michael@0 202 const unsigned long MOVEFOCUS_BACKWARD = 2;
michael@0 203 /** move focus forward to the next frame document, used when pressing F6 */
michael@0 204 const unsigned long MOVEFOCUS_FORWARDDOC = 3;
michael@0 205 /** move focus forward to the previous frame document, used when pressing Shift+F6 */
michael@0 206 const unsigned long MOVEFOCUS_BACKWARDDOC = 4;
michael@0 207 /** move focus to the first focusable element */
michael@0 208 const unsigned long MOVEFOCUS_FIRST = 5;
michael@0 209 /** move focus to the last focusable element */
michael@0 210 const unsigned long MOVEFOCUS_LAST = 6;
michael@0 211 /** move focus to the root element in the document */
michael@0 212 const unsigned long MOVEFOCUS_ROOT = 7;
michael@0 213 /** move focus to a link at the position of the caret. This is a special value used to
michael@0 214 * focus links as the caret moves over them in caret browsing mode.
michael@0 215 */
michael@0 216 const unsigned long MOVEFOCUS_CARET = 8;
michael@0 217
michael@0 218 /**
michael@0 219 * Called when a window has been raised.
michael@0 220 */
michael@0 221 [noscript] void windowRaised(in nsIDOMWindow aWindow);
michael@0 222
michael@0 223 /**
michael@0 224 * Called when a window has been lowered.
michael@0 225 */
michael@0 226 [noscript] void windowLowered(in nsIDOMWindow aWindow);
michael@0 227
michael@0 228 /**
michael@0 229 * Called when a new document in a window is shown.
michael@0 230 *
michael@0 231 * If aNeedsFocus is true, then focus events are expected to be fired on the
michael@0 232 * window if this window is in the focused window chain.
michael@0 233 */
michael@0 234 [noscript] void windowShown(in nsIDOMWindow aWindow, in boolean aNeedsFocus);
michael@0 235
michael@0 236 /**
michael@0 237 * Called when a document in a window has been hidden or otherwise can no
michael@0 238 * longer accept focus.
michael@0 239 */
michael@0 240 [noscript] void windowHidden(in nsIDOMWindow aWindow);
michael@0 241
michael@0 242 /**
michael@0 243 * Fire any events that have been delayed due to synchronized actions.
michael@0 244 */
michael@0 245 [noscript] void fireDelayedEvents(in nsIDocument aDocument);
michael@0 246
michael@0 247 /**
michael@0 248 * Indicate that a plugin wishes to take the focus. This is similar to a
michael@0 249 * normal focus except that the widget focus is not changed. Updating the
michael@0 250 * widget focus state is the responsibility of the caller.
michael@0 251 */
michael@0 252 [noscript] void focusPlugin(in nsIContent aPlugin);
michael@0 253 };

mercurial