1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 dictionary OpenPopupOptions {
7 // manner in which to anchor the popup to node
8 DOMString position = "";
13 // isContextMenu true for context menus, false for other popups
14 boolean isContextMenu = false;
15 // true if popup node attributes override position
16 boolean attributesOverride = false;
17 // triggerEvent the event that triggered this popup (mouse click for example)
18 Event? triggerEvent = null;
21 dictionary ActivateMenuItemOptions {
22 boolean altKey = false;
23 boolean metaKey = false;
24 boolean ctrlKey = false;
25 boolean shiftKey = false;
29 typedef (DOMString or OpenPopupOptions) StringOrOpenPopupOptions;
33 interface XULPopupElement : XULElement
35 [HTMLConstructor] constructor();
38 * Open the popup relative to a specified node at a specific location.
40 * If the popup is already open, calling this method has no effect.
42 * The popup may be either anchored to another node or opened freely.
43 * To anchor a popup to a node, supply an anchor node and set the position
44 * to a string indicating the manner in which the popup should be anchored.
45 * Possible values for position are:
46 * before_start, before_end, after_start, after_end,
47 * start_before, start_after, end_before, end_after,
48 * overlap, after_pointer
50 * The anchor node does not need to be in the same document as the popup.
52 * If the attributesOverride argument is true, the popupanchor, popupalign
53 * and position attributes on the popup node override the position value
54 * argument. If attributesOverride is false, the attributes are only used
55 * if position is empty.
57 * For an anchored popup, the x and y arguments may be used to offset the
58 * popup from its anchored position by some distance, measured in CSS pixels.
59 * x increases to the right and y increases down. Negative values may also
60 * be used to move to the left and upwards respectively.
62 * Unanchored popups may be created by supplying null as the anchor node.
63 * An unanchored popup appears at the position specified by x and y,
64 * relative to the viewport of the document containing the popup node. In
65 * this case, position and attributesOverride are ignored.
67 * @param anchorElement the node to anchor the popup to, may be null
68 * @param options either options to use, or a string position
69 * @param x horizontal offset
70 * @param y vertical offset
71 * @param isContextMenu true for context menus, false for other popups
72 * @param attributesOverride true if popup node attributes override position
73 * @param triggerEvent the event that triggered this popup (mouse click for example)
75 undefined openPopup(optional Element? anchorElement = null,
76 optional StringOrOpenPopupOptions options = {},
79 optional boolean isContextMenu = false,
80 optional boolean attributesOverride = false,
81 optional Event? triggerEvent = null);
84 * Open the popup at a specific screen position specified by x and y. This
85 * position may be adjusted if it would cause the popup to be off of the
86 * screen. The x and y coordinates are measured in CSS pixels, and like all
87 * screen coordinates, are given relative to the top left of the primary
90 * @param isContextMenu true for context menus, false for other popups
91 * @param x horizontal screen position
92 * @param y vertical screen position
93 * @param triggerEvent the event that triggered this popup (mouse click for example)
95 undefined openPopupAtScreen(optional long x = 0, optional long y = 0,
96 optional boolean isContextMenu = false,
97 optional Event? triggerEvent = null);
100 * Open the popup anchored at a specific screen rectangle. This function is
101 * similar to openPopup except that that rectangle of the anchor is supplied
102 * rather than an element. The anchor rectangle arguments are screen
105 * If the popup is already open, calling this method has no effect.
107 undefined openPopupAtScreenRect(optional DOMString position = "",
110 optional long width = 0,
111 optional long height = 0,
112 optional boolean isContextMenu = false,
113 optional boolean attributesOverride = false,
114 optional Event? triggerEvent = null);
117 * Hide the popup if it is open. The cancel argument is used as a hint that
118 * the popup is being closed because it has been cancelled, rather than
119 * something being selected within the panel.
121 * @param cancel if true, then the popup is being cancelled.
123 undefined hidePopup(optional boolean cancel = false);
126 * Activate the item itemElement. This is the recommended way to "click" a
127 * menuitem in automated tests that involve menus.
128 * Fires the command event for the item and then closes the menu.
130 * Throws an InvalidStateError if the menu is not currently open, or if the
131 * menuitem is not inside this menu, or if the menuitem is hidden. The menuitem
132 * may be an item in a submenu, but that submenu must be open.
134 * @param itemElement The menuitem to activate.
135 * @param options Which modifier keys and button should be set on the command
139 undefined activateItem(Element itemElement,
140 optional ActivateMenuItemOptions options = {});
143 * Attribute getter and setter for label.
146 attribute DOMString label;
149 * Attribute getter and setter for position.
152 attribute DOMString position;
155 * Returns the state of the popup:
156 * closed - the popup is closed
157 * open - the popup is open
158 * showing - the popup is in the process of being shown
159 * hiding - the popup is in the process of being hidden
161 readonly attribute DOMString state;
164 * The node that triggered the popup. If the popup is not open, will return
167 readonly attribute Node? triggerNode;
170 * Retrieve the anchor that was specified to openPopup or for menupopups in a
171 * menu, the parent menu.
173 readonly attribute Element? anchorNode;
176 * Retrieve the screen rectangle of the popup, including the area occupied by
177 * any titlebar or borders present.
179 DOMRect getOuterScreenRect();
182 * Move the popup to a point on screen in CSS pixels.
184 undefined moveTo(long left, long top);
187 * Move an open popup to the given anchor position. The arguments have the same
188 * meaning as the corresponding argument to openPopup. This method has no effect
189 * on popups that are not open.
191 undefined moveToAnchor(optional Element? anchorElement = null,
192 optional DOMString position = "",
193 optional long x = 0, optional long y = 0,
194 optional boolean attributesOverride = false);
197 * Size the popup to the given dimensions
199 undefined sizeTo(long width, long height);
201 undefined setConstraintRect(DOMRectReadOnly rect);
203 readonly attribute boolean isWaylandDragSource;
204 readonly attribute boolean isWaylandPopup;