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/. */
5
6#include "nsISupports.idl"
7#include "domstubs.idl"
8
9/**
10 * nsIDOMWindowUtils is intended for infrequently-used methods related
11 * to the current nsIDOMWindow.  Some of the methods may require
12 * elevated privileges; the method implementations should contain the
13 * necessary security checks.  Access this interface by calling
14 * getInterface on a DOMWindow.
15 *
16 * WARNING: Do not use 'out jsval' parameters in this file.
17 *          SpecialPowers, which is used to access nsIDOMWindowUtils
18 *          in plain mochitests, does not know how to handle them.
19 *          (Use 'jsval' return values instead.)
20 */
21
22%{C++
23#include "nsColor.h"
24class gfxContext;
25struct nsRect;
26%}
27
28[ref] native nsConstRect(const nsRect);
29native nscolor(nscolor);
30[ptr] native gfxContext(gfxContext);
31
32interface nsIArray;
33interface nsICycleCollectorListener;
34interface nsIPreloadedStyleSheet;
35interface nsITransferable;
36interface nsIQueryContentEventResult;
37interface nsIDOMWindow;
38interface nsIFile;
39interface nsIURI;
40interface nsIRunnable;
41interface nsITranslationNodeList;
42interface nsIJSRAIIHelper;
43interface nsIContentPermissionRequest;
44interface nsIObserver;
45
46webidl Animation;
47webidl DOMRect;
48webidl Element;
49webidl EventTarget;
50webidl Event;
51webidl Node;
52webidl NodeList;
53webidl Storage;
54
55[builtinclass, scriptable, uuid(4d6732ca-9da7-4176-b8a1-8dde15cd0bf9)]
56interface nsIDOMWindowUtils : nsISupports {
57
58  /**
59   * Image animation mode of the window. When this attribute's value
60   * is changed, the implementation should set all images in the window
61   * to the given value. That is, when set to kDontAnimMode, all images
62   * will stop animating. The attribute's value must be one of the
63   * animationMode values from imgIContainer.
64   * @note Images may individually override the window's setting after
65   *       the window's mode is set. Therefore images given different modes
66   *       since the last setting of the window's mode may behave
67   *       out of line with the window's overall mode.
68   * @note The attribute's value is the window's overall mode. It may
69   *       for example continue to report kDontAnimMode after all images
70   *       have subsequently been individually animated.
71   * @note Only images immediately in this window are affected;
72   *       this is not recursive to subwindows.
73   * @see imgIContainer
74   */
75  attribute unsigned short imageAnimationMode;
76
77  /**
78   * Whether the charset of the window's current document has been forced by
79   * the user.
80   * Cannot be accessed from unprivileged context (not content-accessible)
81   */
82  readonly attribute boolean docCharsetIsForced;
83
84  /**
85   * Return the conversion of a physical millimeter in CSS pixels.
86   */
87  readonly attribute float physicalMillimeterInCSSPixels;
88
89  /**
90   * Function to get metadata associated with the window's current document
91   * @param aName the name of the metadata.  This should be all lowercase.
92   * @return the value of the metadata, or the empty string if it's not set
93   *
94   * Will throw a DOM security error if called without chrome privileges.
95   */
96  AString getDocumentMetadata(in AString aName);
97
98  /**
99   * Force a synchronous layer transaction for this window if necessary.
100   */
101  [can_run_script]
102  void updateLayerTree();
103
104  /**
105   * Get the last used layer transaction id for this window's refresh driver.
106   */
107  readonly attribute unsigned long long lastTransactionId;
108
109  /**
110   * Information retrieved from the <meta name="viewport"> tag.
111   * See Document::GetViewportInfo for more information.
112   */
113  void getViewportInfo(in uint32_t aDisplayWidth, in uint32_t aDisplayHeight,
114                       out double aDefaultZoom, out boolean aAllowZoom,
115                       out double aMinZoom, out double aMaxZoom,
116                       out uint32_t aWidth, out uint32_t aHeight,
117                       out boolean aAutoSize);
118  /*
119   * Information retrieved from the viewport-fit value of <meta name="viewport">
120   * element.
121   */
122  AString getViewportFitInfo();
123
124  /**
125   * Information about the window size in device pixels.
126   */
127  void getContentViewerSize(out uint32_t aDisplayWidth, out uint32_t aDisplayHeight);
128
129  /**
130   * For any scrollable element, this allows you to override the default
131   * scroll behaviour and force autodir (which allows a mousewheel to
132   * horizontally scroll regions that only scroll on that one axis).
133   *
134   * See the documentation for mousewheel.autodir.enabled and
135   * mousewheel.autodir.honourroot for a more thorough explanation of
136   * what these behaviours do.
137   */
138  void setMousewheelAutodir(in Element aElement, in boolean aEnabled, in boolean aHonourRoot);
139
140  /**
141   * For any scrollable element, this allows you to override the
142   * visible region and draw more than what is visible, which is
143   * useful for asynchronous drawing. The "displayport" will be
144   * <xPx, yPx, widthPx, heightPx> in units of CSS pixels,
145   * regardless of the size of the enclosing container.  This
146   * will *not* trigger reflow.
147   *
148   * For the root scroll area, pass in the root document element.
149   * For scrollable elements, pass in the container element (for
150   * instance, the element with overflow: scroll).
151   *
152   * <x, y> is relative to the top-left of what would normally be
153   * the visible area of the element. This means that the pixels
154   * rendered to the displayport take scrolling into account,
155   * for example.
156   *
157   * It's legal to set a displayport that extends beyond the overflow
158   * area in any direction (left/right/top/bottom).
159   *
160   * It's also legal to set a displayport that extends beyond the
161   * area's bounds.  No pixels are rendered outside the area bounds.
162   *
163   * The caller of this method must have chrome privileges.
164   *
165   * Calling this will always force a recomposite, so it should be
166   * avoided if at all possible. Client code should do checks before
167   * calling this so that duplicate sets are not made with the same
168   * displayport.
169   *
170   * aPriority is recorded along with the displayport rectangle. If this
171   * method is called with a lower priority than the current priority, the
172   * call is ignored.
173   */
174  void setDisplayPortForElement(in float aXPx, in float aYPx,
175                                in float aWidthPx, in float aHeightPx,
176                                in Element aElement,
177                                in uint32_t aPriority);
178  /**
179   * An alternate way to represent a displayport rect as a set of margins and a
180   * base rect to apply those margins to. A consumer of pixels may ask for as
181   * many extra pixels as it would like in each direction. Layout then sets
182   * the base rect to the "visible rect" of the element, which is just the
183   * subrect of the element that is drawn (it does not take in account content
184   * covering the element).
185   *
186   * If both a displayport rect and displayport margins with corresponding base
187   * rect are set with the same priority then the margins will take precendence.
188   *
189   * Specifying an alignment value will ensure that after the base rect has
190   * been expanded by the displayport margins, it will be further expanded so
191   * that each edge is located at a multiple of the "alignment" value.
192   *
193   * Note that both the margin values and alignment are treated as values in
194   * ScreenPixels. Refer to layout/base/Units.h for a description of this unit.
195   * The base rect values are in app units.
196   */
197  void setDisplayPortMarginsForElement(in float aLeftMargin,
198                                       in float aTopMargin,
199                                       in float aRightMargin,
200                                       in float aBottomMargin,
201                                       in Element aElement,
202                                       in uint32_t aPriority);
203
204  void setDisplayPortBaseForElement(in int32_t aX,
205                                    in int32_t aY,
206                                    in int32_t aWidth,
207                                    in int32_t aHeight,
208                                    in Element aElement);
209
210  /**
211   * If |aElement| is a scroll container, returns the amount of layout
212   * space taken up by its scrollbars (that is, the width of the vertical
213   * scrollbar and the height of the horizontal scrollbar) in CSS pixels;
214   * otherwise returns zero.
215   *
216   * Note that on some platforms, scrollbars don't take up layout space
217   * ("overlay scrollbars"). On such platforms, the returned sizes are
218   * always zero.
219   *
220   * Layout scrollbars that normally take up space but were only shown to
221   * scroll the visual viewport inside the layout viewport (the layout viewport
222   * cannot be scrolled) do not take up space but they still return their size
223   * from this function.
224   */
225  void getScrollbarSizes(in Element aElement,
226                         out uint32_t aVerticalScrollbarWidth,
227                         out uint32_t aHorizontalScrollbarHeight);
228
229  /**
230   * Get/set the resolution at which rescalable web content is drawn for
231   * testing purposes.
232   *
233   * Setting a new resolution does *not* trigger reflow.  This API is
234   * entirely separate from textZoom and fullZoom; a resolution scale
235   * can be applied together with both textZoom and fullZoom.
236   *
237   * The effect of this API is for gfx code to allocate more or fewer
238   * pixels for rescalable content by a factor of |resolution| in
239   * both dimensions.
240   *
241   * In addition, the content is scaled by the amount of the resolution,
242   * so that it is displayed at a correspondingly larger or smaller size,
243   * without the need for the caller to set an additional transform.
244   *
245   * The purpose of this API is to allow tests to simulate many of the effects
246   * a non-reflowing scale-zoom, e.g. for pinch-zoom on mobile platforms, and
247   * should be only used for testing purposes.
248   *
249   * The caller of this method must have chrome privileges.
250   *
251   * This is intended to be used by test code only!
252   */
253  void setResolutionAndScaleTo(in float aResolution);
254
255  float getResolution();
256
257  /**
258   * Set a resolution on the presShell which is the "restored" from history.
259   * The display dimensions are compared to their current values and used
260   * to scale the resolution value if necessary, e.g. if the device was
261   * rotated between saving and restoring of the session data.
262   * This resolution should be used when painting for the first time. Calling
263   * this too late may have no effect.
264   */
265  void setRestoreResolution(in float aResolution,
266                            in uint32_t aDisplayWidth,
267                            in uint32_t aDisplayHeight);
268
269  /**
270   * Whether the next paint should be flagged as the first paint for a document.
271   * This gives a way to track the next paint that occurs after the flag is
272   * set. The flag gets cleared after the next paint.
273   *
274   * Can only be accessed with chrome privileges.
275   */
276  attribute boolean isFirstPaint;
277
278  uint32_t getPresShellId();
279
280  /**
281   * Returns whether a given header and value is a CORS-safelisted request
282   * header per https://fetch.spec.whatwg.org/#cors-safelisted-request-header
283   */
284  boolean isCORSSafelistedRequestHeader(in ACString name, in ACString value);
285
286  /**
287   * Following modifiers are for sent*Event() except sendNative*Event().
288   * NOTE: MODIFIER_ALT, MODIFIER_CONTROL, MODIFIER_SHIFT and MODIFIER_META
289   *       are must be same values as Event_Binding::*_MASK for backward
290   *       compatibility.
291   */
292  const long MODIFIER_ALT        = 0x0001;
293  const long MODIFIER_CONTROL    = 0x0002;
294  const long MODIFIER_SHIFT      = 0x0004;
295  const long MODIFIER_META       = 0x0008;
296  const long MODIFIER_ALTGRAPH   = 0x0010;
297  const long MODIFIER_CAPSLOCK   = 0x0020;
298  const long MODIFIER_FN         = 0x0040;
299  const long MODIFIER_FNLOCK     = 0x0080;
300  const long MODIFIER_NUMLOCK    = 0x0100;
301  const long MODIFIER_SCROLLLOCK = 0x0200;
302  const long MODIFIER_SYMBOL     = 0x0400;
303  const long MODIFIER_SYMBOLLOCK = 0x0800;
304  const long MODIFIER_OS         = 0x1000;
305
306  /** Synthesize a mouse event. The event types supported are:
307   *    mousedown, mouseup, mousemove, mouseover, mouseout, mousecancel,
308   *    contextmenu, MozMouseHittest
309   *
310   * Events are sent in coordinates offset by aX and aY from the window.
311   *
312   * Note that additional events may be fired as a result of this call. For
313   * instance, typically a click event will be fired as a result of a
314   * mousedown and mouseup in sequence.
315   *
316   * Normally at this level of events, the mouseover and mouseout events are
317   * only fired when the window is entered or exited. For inter-element
318   * mouseover and mouseout events, a movemove event fired on the new element
319   * should be sufficient to generate the correct over and out events as well.
320   *
321   * Cannot be accessed from unprivileged context (not content-accessible)
322   * Will throw a DOM security error if called without chrome privileges.
323   *
324   * The event is dispatched via the toplevel window, so it could go to any
325   * window under the toplevel window, in some cases it could never reach this
326   * window at all.
327   *
328   * NOTE: mousecancel is used to represent the vanishing of an input device
329   * such as a pen leaving its digitizer by synthesizing a WidgetMouseEvent,
330   * whose mMessage is eMouseExitFromWidget and mExitFrom is
331   * WidgetMouseEvent::eTopLevel.
332   *
333   * @param aType event type
334   * @param aX x offset in CSS pixels
335   * @param aY y offset in CSS pixels
336   * @param aButton button to synthesize
337   * @param aClickCount number of clicks that have been performed
338   * @param aModifiers modifiers pressed, using constants defined as MODIFIER_*
339   * @param aIgnoreRootScrollFrame whether the event should ignore viewport bounds
340   *                           during dispatch
341   * @param aPressure touch input pressure: 0.0 -> 1.0
342   * @param aInputSourceArg input source, see MouseEvent for values,
343   *        defaults to mouse input.
344   * @param aIsDOMEventSynthesized controls Event.isSynthesized value
345   *                               that helps identifying test related events,
346   *                               defaults to true
347   * @param aIsWidgetEventSynthesized controls WidgetMouseEvent.mReason value
348   *                                  defaults to false (WidgetMouseEvent::eReal)
349   * @param aIdentifier A unique identifier for the pointer causing the event,
350   *                    defaulting to nsIDOMWindowUtils::DEFAULT_MOUSE_POINTER_ID.
351   *
352   * returns true if the page called prevent default on this event
353   */
354  [optional_argc, can_run_script]
355  boolean sendMouseEvent(in AString aType,
356                         in float aX,
357                         in float aY,
358                         in long aButton,
359                         in long aClickCount,
360                         in long aModifiers,
361                         [optional] in boolean aIgnoreRootScrollFrame,
362                         [optional] in float aPressure,
363                         [optional] in unsigned short aInputSourceArg,
364                         [optional] in boolean aIsDOMEventSynthesized,
365                         [optional] in boolean aIsWidgetEventSynthesized,
366                         [optional] in long aButtons,
367                         [optional] in unsigned long aIdentifier);
368
369  /** Synthesize a touch event. The event types supported are:
370   *    touchstart, touchend, touchmove, and touchcancel
371   *
372   * Events are sent in coordinates offset by aX and aY from the window.
373   *
374   * Cannot be accessed from unprivileged context (not content-accessible)
375   * Will throw a DOM security error if called without chrome privileges.
376   *
377   * The event is dispatched via the toplevel window, so it could go to any
378   * window under the toplevel window, in some cases it could never reach this
379   * window at all.
380   *
381   * @param aType event type
382   * @param xs array of offsets in CSS pixels for each touch to be sent
383   * @param ys array of offsets in CSS pixels for each touch to be sent
384   * @param rxs array of radii in CSS pixels for each touch to be sent
385   * @param rys array of radii in CSS pixels for each touch to be sent
386   * @param rotationAngles array of angles in degrees for each touch to be sent
387   * @param forces array of forces (floats from 0 to 1) for each touch to be sent
388   * @param count number of touches in this set
389   * @param aModifiers modifiers pressed, using constants defined as MODIFIER_*
390   * @param aIgnoreRootScrollFrame whether the event should ignore viewport bounds
391   *                           during dispatch
392   *
393   * returns true if the page called prevent default on this touch event
394   */
395  [can_run_script]
396  boolean sendTouchEvent(in AString aType,
397                         in Array<uint32_t> aIdentifiers,
398                         in Array<int32_t> aXs,
399                         in Array<int32_t> aYs,
400                         in Array<uint32_t> aRxs,
401                         in Array<uint32_t> aRys,
402                         in Array<float> aRotationAngles,
403                         in Array<float> aForces,
404                         in long aModifiers,
405                         [optional] in boolean aIgnoreRootScrollFrame);
406
407  /** The same as sendMouseEvent but ensures that the event is dispatched to
408   *  this DOM window or one of its children.
409   */
410  [optional_argc, can_run_script]
411  void sendMouseEventToWindow(in AString aType,
412                              in float aX,
413                              in float aY,
414                              in long aButton,
415                              in long aClickCount,
416                              in long aModifiers,
417                              [optional] in boolean aIgnoreRootScrollFrame,
418                              [optional] in float aPressure,
419                              [optional] in unsigned short aInputSourceArg,
420                              [optional] in boolean aIsDOMEventSynthesized,
421                              [optional] in boolean aIsWidgetEventSynthesized,
422                              [optional] in long aButtons,
423                              [optional] in unsigned long aIdentifier);
424
425  /** The same as sendTouchEvent but ensures that the event is dispatched to
426   *  this DOM window or one of its children.
427   */
428  [can_run_script]
429  boolean sendTouchEventToWindow(in AString aType,
430                                 in Array<uint32_t> aIdentifiers,
431                                 in Array<int32_t> aXs,
432                                 in Array<int32_t> aYs,
433                                 in Array<uint32_t> aRxs,
434                                 in Array<uint32_t> aRys,
435                                 in Array<float> aRotationAngles,
436                                 in Array<float> aForces,
437                                 in long aModifiers,
438                                 [optional] in boolean aIgnoreRootScrollFrame);
439
440  /** Synthesize a wheel event for a window. The event types supported is only
441   *  wheel.
442   *
443   * Events are sent in coordinates offset by aX and aY from the window.
444   *
445   * Cannot be accessed from unprivileged context (not content-accessible)
446   * Will throw a DOM security error if called without chrome privileges.
447   *
448   * @param aX                 x offset in CSS pixels
449   * @param aY                 y offset in CSS pixels
450   * @param aDeltaX            deltaX value.
451   * @param aDeltaY            deltaY value.
452   * @param aDeltaZ            deltaZ value.
453   * @param aDeltaMode         deltaMode value which must be one of the
454   *                           WheelEvent DOM_DELTA_* constants.
455   * @param aModifiers         modifiers pressed, using constants defined as
456   *                           MODIFIER_*
457   * @param aLineOrPageDeltaX  If you set this value non-zero for
458   *                           DOM_DELTA_PIXEL event, EventStateManager will
459   *                           dispatch NS_MOUSE_SCROLL event for horizontal
460   *                           scroll.
461   * @param aLineOrPageDeltaY  If you set this value non-zero for
462   *                           DOM_DELTA_PIXEL event, EventStateManager will
463   *                           dispatch NS_MOUSE_SCROLL event for vertical
464   *                           scroll.
465   * @param aOptions           Set following flags.
466   */
467  const unsigned long WHEEL_EVENT_CAUSED_BY_NO_LINE_OR_PAGE_DELTA_DEVICE = 0x0001;
468  const unsigned long WHEEL_EVENT_CAUSED_BY_MOMENTUM                     = 0x0002;
469  const unsigned long WHEEL_EVENT_CUSTOMIZED_BY_USER_PREFS               = 0x0004;
470  // If any of the following flags is specified this method will throw an
471  // exception in case the relevant overflowDelta has an unexpected value.
472  const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_X_ZERO      = 0x0010;
473  const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_X_POSITIVE  = 0x0020;
474  const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_X_NEGATIVE  = 0x0040;
475  const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_ZERO      = 0x0100;
476  const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_POSITIVE  = 0x0200;
477  const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_NEGATIVE  = 0x0400;
478  void sendWheelEvent(in float aX,
479                      in float aY,
480                      in double aDeltaX,
481                      in double aDeltaY,
482                      in double aDeltaZ,
483                      in unsigned long aDeltaMode,
484                      in long aModifiers,
485                      in long aLineOrPageDeltaX,
486                      in long aLineOrPageDeltaY,
487                      in unsigned long aOptions);
488
489  /**
490   * Native modifiers for sendNativeKeyEvent and sendNativeMouseEvent.
491   * TODO: The other sendNative*Event should take these values instead.
492   */
493  const unsigned long NATIVE_MODIFIER_CAPS_LOCK       = 0x00000001;
494  const unsigned long NATIVE_MODIFIER_NUM_LOCK        = 0x00000002;
495  const unsigned long NATIVE_MODIFIER_SHIFT_LEFT      = 0x00000100;
496  const unsigned long NATIVE_MODIFIER_SHIFT_RIGHT     = 0x00000200;
497  const unsigned long NATIVE_MODIFIER_CONTROL_LEFT    = 0x00000400;
498  const unsigned long NATIVE_MODIFIER_CONTROL_RIGHT   = 0x00000800;
499  const unsigned long NATIVE_MODIFIER_ALT_LEFT        = 0x00001000;
500  const unsigned long NATIVE_MODIFIER_ALT_RIGHT       = 0x00002000;
501  const unsigned long NATIVE_MODIFIER_COMMAND_LEFT    = 0x00004000;
502  const unsigned long NATIVE_MODIFIER_COMMAND_RIGHT   = 0x00008000;
503  const unsigned long NATIVE_MODIFIER_HELP            = 0x00010000;
504  // On Windows, AltGraph key emulates the AltRight key on specific keyboard
505  // layouts.  Therefore, this shouldn't be used without `synthesizeNativeKey`.
506  const unsigned long NATIVE_MODIFIER_ALT_GRAPH       = 0x00020000;
507  // Available only on macOS.
508  const unsigned long NATIVE_MODIFIER_FUNCTION        = 0x00100000;
509  // Available only on macOS.  When pressing a key in numeric key pad, this
510  // must be included.
511  const unsigned long NATIVE_MODIFIER_NUMERIC_KEY_PAD = 0x01000000;
512
513  /**
514   * See nsIWidget::SynthesizeNativeKeyEvent
515   *
516   * Cannot be accessed from unprivileged context (not content-accessible)
517   * Will throw a DOM security error if called without chrome privileges.
518   *
519   * When you use this for tests, use the constants defined in NativeKeyCodes.js
520   *
521   * NOTE: The synthesized native event will be fired asynchronously, and upon
522   * completion the observer, if provided, will be notified with a "keyevent"
523   * topic.
524   */
525  void sendNativeKeyEvent(in long aNativeKeyboardLayout,
526                          in long aNativeKeyCode,
527                          in unsigned long aModifierFlags,
528                          in AString aCharacters,
529                          in AString aUnmodifiedCharacters,
530                          [optional] in nsIObserver aObserver);
531
532  /**
533   * See nsIWidget::SynthesizeNativeMouseEvent
534   *
535   * Will be called on the widget that contains aElement.
536   * Cannot be accessed from unprivileged context (not content-accessible)
537   * Will throw a DOM security error if called without chrome privileges.
538   *
539   * @param aScreenX    X offset in the screen in device pixels.
540   * @param aScreenY    Y offset in the screen in derive pixels.
541   * @param aNativeMessage      One of NATIVE_MOUSE_MESSAGE_*
542   * @param aButton     Same as `MouseEvent.button` value.
543   * @param aModifierFlags      See nsIWidget's native modifier flags.
544   * @param aElementOnWidget    An element which is on a widget.
545   * @param aObserver   The synthesized native event will be fired
546   *                    asynchronously, and upon completion the observer, if
547   *                    provided, will be notified with a "mouseevent" topic.
548   */
549  const unsigned long NATIVE_MOUSE_MESSAGE_BUTTON_DOWN  = 0x00000001;
550  const unsigned long NATIVE_MOUSE_MESSAGE_BUTTON_UP    = 0x00000002;
551  const unsigned long NATIVE_MOUSE_MESSAGE_MOVE         = 0x00000003;
552  const unsigned long NATIVE_MOUSE_MESSAGE_ENTER_WINDOW = 0x00000004;
553  const unsigned long NATIVE_MOUSE_MESSAGE_LEAVE_WINDOW = 0x00000005;
554  void sendNativeMouseEvent(in long aScreenX,
555                            in long aScreenY,
556                            in unsigned long aNativeMessage,
557                            in short aButton,
558                            in unsigned long aModifierFlags,
559                            in Element aElementOnWidget,
560                            [optional] in nsIObserver aObserver);
561
562  /**
563   * Suppress animations that are applied to a window by OS when
564   * resizing, moving, changing size mode, ...
565   */
566  void suppressAnimation(in boolean aSuppress);
567
568  /**
569   * The values for sendNativeMouseScrollEvent's aAdditionalFlags.
570   */
571
572  /**
573   * If MOUSESCROLL_PREFER_WIDGET_AT_POINT is set, widget will dispatch
574   * the event to a widget which is under the cursor.  Otherwise, dispatch to
575   * a default target on the platform.  E.g., on Windows, it's focused window.
576   */
577  const unsigned long MOUSESCROLL_PREFER_WIDGET_AT_POINT = 0x00000001;
578
579  /**
580   * Interpret the scroll delta values as lines rather than pixels.
581   */
582  const unsigned long MOUSESCROLL_SCROLL_LINES = 0x00000002;
583
584  /**
585   * The platform specific values of aAdditionalFlags.  Must be over 0x00010000.
586   */
587
588  /**
589   * If MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL is set and aNativeMessage is
590   * WM_VSCROLL or WM_HSCROLL, widget will set the window handle to the lParam
591   * instead of NULL.
592   */
593  const unsigned long MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL = 0x00010000;
594
595  /**
596   * See nsIWidget::SynthesizeNativeMouseScrollEvent
597   *
598   * Will be called on the widget that contains aElement.
599   * Cannot be accessed from unprivileged context (not content-accessible)
600   * Will throw a DOM security error if called without chrome privileges.
601   *
602   * NOTE: The synthesized native event will be fired asynchronously, and upon
603   * completion the observer, if provided, will be notified with a
604   * "mousescrollevent" topic.
605   *
606   * @param aNativeMessage
607   *   On Windows:  WM_MOUSEWHEEL (0x020A), WM_MOUSEHWHEEL(0x020E),
608   *                WM_VSCROLL (0x0115) or WM_HSCROLL (0x114).
609   */
610  void sendNativeMouseScrollEvent(in long aScreenX,
611                                  in long aScreenY,
612                                  in unsigned long aNativeMessage,
613                                  in double aDeltaX,
614                                  in double aDeltaY,
615                                  in double aDeltaZ,
616                                  in unsigned long aModifierFlags,
617                                  in unsigned long aAdditionalFlags,
618                                  in Element aElement,
619                                  [optional] in nsIObserver aObserver);
620
621  /**
622   * Touch states for sendNativeTouchPoint. These values match
623   * nsIWidget's TouchPointerState.
624   */
625
626  // The pointer is in a hover state above the digitizer
627  const long TOUCH_HOVER   = 0x01;
628  // The pointer is in contact with the digitizer
629  const long TOUCH_CONTACT = 0x02;
630  // The pointer has been removed from the digitizer detection area
631  const long TOUCH_REMOVE  = 0x04;
632  // The pointer has been canceled. Will cancel any pending os level
633  // gestures that would be triggered as a result of completion of the
634  // input sequence. This may not cancel moz platform related events
635  // that might get tirggered by input already delivered.
636  const long TOUCH_CANCEL  = 0x08;
637
638  /**
639   * Phase states for sendNativeTouchPadPinch.
640   */
641  const long PHASE_BEGIN = 0;
642  const long PHASE_UPDATE = 1;
643  const long PHASE_END  = 2;
644
645  /**
646   * Create a new or update an existing touch point on the digitizer.
647   * To trigger os level gestures, individual touch points should
648   * transition through a complete set of touch states which should be
649   * sent as individual calls. For example:
650   * tap - msg1:TOUCH_CONTACT, msg2:TOUCH_REMOVE
651   * drag - msg1-n:TOUCH_CONTACT (moving), msgn+1:TOUCH_REMOVE
652   * hover drag - msg1-n:TOUCH_HOVER (moving), msgn+1:TOUCH_REMOVE
653   *
654   * Widget support: Windows 8.0+, Winrt/Win32. Other widgets will throw.
655   *
656   * NOTE: The synthesized native event will be fired asynchronously, and upon
657   * completion the observer, if provided, will be notified with a "touchpoint"
658   * topic.
659   *
660   * @param aPointerId The touch point id to create or update.
661   * @param aTouchState one or more of the touch states listed above
662   * @param aScreenX, aScreenY screen coords of this event
663   * @param aPressure 0.0 -> 1.0 float val indicating pressure
664   * @param aOrientation 0 -> 359 degree value indicating the
665   * orientation of the pointer. Use 90 for normal taps.
666   */
667  void sendNativeTouchPoint(in unsigned long aPointerId,
668                            in unsigned long aTouchState,
669                            in long aScreenX,
670                            in long aScreenY,
671                            in double aPressure,
672                            in unsigned long aOrientation,
673                            [optional] in nsIObserver aObserver);
674  /**
675   * These values indicate touchpad pinch phase states :
676   * PHASE_BEGIN
677   * PHASE_UPDATE
678   * PHASE_END
679   * Widget support: Linux GTK 3.18+.
680   * @param aEventPhase The touchpad pinch phase using states listed above.
681   * @param aScale Events with PHASE_UPDATE will change the zoom level by
682   * the ratio between the scale of the current event and the scale of the last event.
683   * @param aScreenX, aScreenY screen coords of the focus point of this event.
684   * @param aModifierFlags is expected to contain native modifier values.
685   */
686  void sendNativeTouchpadPinch(in unsigned long aEventPhase,
687                               in float aScale,
688                               in long aScreenX,
689                               in long aScreenY,
690                               in long aModifierFlags);
691
692  /**
693   * Simulates native touch based taps on the input digitizer. Events
694   * triggered by this call are injected at the os level. Events do not
695   * bypass widget level input processing and as such can be used to
696   * test widget event logic and async pan-zoom controller functionality.
697   * Cannot be accessed from an unprivileged context.
698   *
699   * Long taps (based on the aLongTap parameter) will be completed
700   * asynchrnously after the call returns. Long tap delay is based on
701   * the ui.click_hold_context_menus.delay pref or 1500 msec if pref
702   * is not set.
703   *
704   * Widget support: Windows 8.0+, Winrt/Win32. Other widgets will
705   * throw.
706   *
707   * NOTE: The synthesized native event will be fired asynchronously, and upon
708   * completion the observer, if provided, will be notified, with a "touchtap"
709   * topic.
710   *
711   * @param aScreenX, aScreenY screen coords of this event
712   * @param aLongTap true if the tap should be long, false for a short
713   * tap.
714   */
715  void sendNativeTouchTap(in long aScreenX,
716                          in long aScreenY,
717                          in boolean aLongTap,
718                          [optional] in nsIObserver aObserver);
719
720  /**
721   * Create a new or update an existing pen input on the digitizer.
722   *
723   * Widget support: Windows 10 1809+. Other widgets will throw.
724   *
725   * NOTE: The synthesized native event will be fired asynchronously, and upon
726   * completion the observer, if provided, will be notified with a "peninput"
727   * topic.
728   *
729   * @param aPointerId The touch point id to create or update.
730   * @param aPointerState one or more of the TOUCH_* listed above
731   * @param aScreenX x screen coord of this event
732   * @param aScreenY y screen coord of this event
733   * @param aPressure 0.0 -> 1.0 float val indicating pressure
734   * @param aRotation 0 -> 359 degree value indicating the rotation of the
735   * pointer. Use 0 for normal taps.
736   * @param aTiltX -90 -> 90 degree value indicating the tilt along the x-axis
737   * of the pointer. Use 0 for normal taps.
738   * @param aTiltY -90 -> 90 degree value indicating the tilt along the y-axis
739   * of the pointer. Use 0 for normal taps.
740   * @param aButton Same as MouseEvent::button.
741   */
742  void sendNativePenInput(in unsigned long aPointerId,
743                          in unsigned long aPointerState,
744                          in long aScreenX,
745                          in long aScreenY,
746                          in double aPressure,
747                          in unsigned long aRotation,
748                          in long aTiltX,
749                          in long aTiltY,
750                          in long aButton,
751                          [optional] in nsIObserver aObserver);
752
753  /**
754   * Cancel any existing touch points or long tap delays. Calling this is safe
755   * even if you're sure there aren't any pointers recorded. You should call
756   * this when tests shut down to reset the digitizer driver. Not doing so can
757   * leave the digitizer in an undetermined state which can screw up subsequent
758   * tests and native input.
759   *
760   * NOTE: The synthesized native event will be fired asynchronously, and upon
761   * completion the observer, if provided, will be notified with a "cleartouch"
762   * topic.
763   */
764  void clearNativeTouchSequence([optional] in nsIObserver aObserver);
765
766  /**
767   * Send a native event as if the user double tapped the touchpad with two
768   * fingers.
769   *
770   * Widget support: macOS.
771   * @param aScreenX, aScreenY screen coords of the focus point of this event.
772   * @param aModifierFlags is expected to contain native modifier values.
773   */
774  void sendNativeTouchpadDoubleTap(in long aScreenX,
775                                   in long aScreenY,
776                                   in long aModifierFlags);
777
778  /**
779   * Send a native event as if the user panned on the touchpad with two
780   * fingers.
781   *
782   * Widget support: Windows.
783   * @param aScreenX, aScreenY screen coords of the focus point of this event.
784   * @param aDeltaX, aDeltaY the amount of delta in the pan.
785   * @param aModifierFlags is expected to contain native modifier values.
786   */
787  void sendNativeTouchpadPan(in unsigned long aEventPhase,
788                             in long aScreenX,
789                             in long aScreenY,
790                             in double aDeltaX,
791                             in double aDeltaY,
792                             in long aModifierFlags);
793
794  /**
795   * Clears the SharedStyleSheetCache.
796   */
797  void clearSharedStyleSheetCache();
798
799  /**
800   * Returns the number of stylesheets that have been parsed on this document.
801   * Useful to test caching.
802   */
803  readonly attribute unsigned long parsedStyleSheets;
804
805  /**
806   * See nsIWidget::ActivateNativeMenuItemAt
807   *
808   * Cannot be accessed from unprivileged context (not content-accessible)
809   * Will throw a DOM security error if called without chrome privileges.
810   */
811  void activateNativeMenuItemAt(in AString indexString);
812
813  /**
814   * See nsIWidget::ForceUpdateNativeMenuAt
815   *
816   * Cannot be accessed from unprivileged context (not content-accessible)
817   * Will throw a DOM security error if called without chrome privileges.
818   */
819  void forceUpdateNativeMenuAt(in AString indexString);
820
821  /**
822   * Returns the current selection as plaintext. Note that the result may be
823   * different from the result of sendQueryContentEvent(QUERY_SELECTED_TEXT).
824   * This result is computed by native API with transferable data. In other
825   * words, when the OS treats the selection as plaintext, it treats current
826   * selection as this result.
827   */
828  AString GetSelectionAsPlaintext();
829
830  /**
831   * Force a garbage collection followed by a cycle collection.
832   *
833   * Will throw a DOM security error if called without chrome privileges in
834   * non-debug builds. Available to all callers in debug builds.
835   *
836   * @param aListener listener that receives information about the CC graph
837   */
838  void garbageCollect([optional] in nsICycleCollectorListener aListener);
839
840  /**
841   * Force a cycle collection without garbage collection.
842   *
843   * Will throw a DOM security error if called without chrome privileges in
844   * non-debug builds. Available to all callers in debug builds.
845   *
846   * @param aListener listener that receives information about the CC graph
847   */
848  void cycleCollect([optional] in nsICycleCollectorListener aListener);
849
850  /**
851   * Trigger whichever GC or CC timer is currently active and waiting to fire.
852   * Don't do this too much for initiating heavy actions, like the start of a IGC.
853   *
854   * @param aReason the reason for the GC, from js/public/GCAPI.h. Defaults to
855   * DOM_WINDOW_UTILS.
856   */
857  void runNextCollectorTimer([optional] in ACString aReason);
858
859  /**
860   * "Poke" the GC: set a timer to run a GC soon (usually 4 seconds), unless
861   * another GC timer has already been set. This is used for testing.
862   *
863   * @param aReason the reason for the GC, from js/public/GCAPI.h. Defaults to
864   * DOM_WINDOW_UTILS.
865   */
866  void pokeGC([optional] in ACString aReason);
867
868  /** Synthesize a simple gesture event for a window. The event types
869   *  supported are: MozSwipeGestureMayStart, MozSwipeGestureStart,
870   *  MozSwipeGestureUpdate, MozSwipeGestureEnd, MozSwipeGesture,
871   *  MozMagnifyGestureStart, MozMagnifyGestureUpdate, MozMagnifyGesture,
872   *  MozRotateGestureStart, MozRotateGestureUpdate, MozRotateGesture,
873   *  MozPressTapGesture, MozTapGesture, and MozEdgeUIGesture.
874   *
875   * Cannot be accessed from unprivileged context (not
876   * content-accessible) Will throw a DOM security error if called
877   * without chrome privileges.
878   *
879   * @param aType event type
880   * @param aX x offset in CSS pixels
881   * @param aY y offset in CSS pixels
882   * @param aDirection direction, using constants defined in SimpleGestureEvent.webidl
883   * @param aDelta  amount of magnification or rotation for magnify and rotation events
884   * @param aModifiers modifiers pressed, using constants defined in Event.webidl
885   * @param aClickCount For tap gestures, the number of taps.
886   */
887  void sendSimpleGestureEvent(in AString aType,
888                              in float aX,
889                              in float aY,
890                              in unsigned long aDirection,
891                              in double aDelta,
892                              in long aModifiers,
893                              [optional] in unsigned long aClickCount);
894
895  /**
896   * Retrieve the element at point aX, aY in the window's document.
897   *
898   * @param aIgnoreRootScrollFrame whether or not to ignore the root scroll
899   *        frame when retrieving the element. If false, this method returns
900   *        null for coordinates outside of the viewport.
901   * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs.
902   */
903  Element elementFromPoint(in float aX,
904                           in float aY,
905                           in boolean aIgnoreRootScrollFrame,
906                           in boolean aFlushLayout);
907
908  /**
909   * Retrieve all nodes that intersect a rect in the window's document.
910   *
911   * @param aX x reference for the rectangle in CSS pixels
912   * @param aY y reference for the rectangle in CSS pixels
913   * @param aTopSize How much to expand up the rectangle
914   * @param aRightSize How much to expand right the rectangle
915   * @param aBottomSize How much to expand down the rectangle
916   * @param aLeftSize How much to expand left the rectangle
917   * @param aIgnoreRootScrollFrame whether or not to ignore the root scroll
918   *        frame when retrieving the element. If false, this method returns
919   *        null for coordinates outside of the viewport.
920   * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs.
921   * @param aOnlyVisible Set to true if you only want nodes that pass a visibility
922   *        hit test.
923   * @param aTransparencyThreshold Only has an effect if aOnlyVisible is true.
924   *        Returns what amount of transparency is considered "opaque enough"
925   *        to consider elements "not visible". The default is effectively "1"
926   *        (so, only opaque elements will stop an element from being
927   *        "visible").
928   */
929  NodeList nodesFromRect(in float aX,
930                         in float aY,
931                         in float aTopSize,
932                         in float aRightSize,
933                         in float aBottomSize,
934                         in float aLeftSize,
935                         in boolean aIgnoreRootScrollFrame,
936                         in boolean aFlushLayout,
937                         in boolean aOnlyVisible,
938                         [optional] in float aTransparencyThreshold);
939
940
941  /**
942   * Get a list of nodes that have meaningful textual content to
943   * be translated. The implementation of this algorithm is in flux
944   * as we experiment and refine which approach works best.
945   *
946   * This method requires chrome privileges.
947   */
948  nsITranslationNodeList getTranslationNodes(in Node aRoot);
949
950  /**
951   * Compare the two canvases, returning the number of differing pixels and
952   * the maximum difference in a channel.  This will throw an error if
953   * the dimensions of the two canvases are different.
954   *
955   * This method requires chrome privileges.
956   */
957  uint32_t compareCanvases(in nsISupports aCanvas1,
958                           in nsISupports aCanvas2,
959                           out unsigned long aMaxDifference);
960
961  /**
962   * Returns true if a MozAfterPaint event has been queued but not yet
963   * fired.
964   */
965  readonly attribute boolean isMozAfterPaintPending;
966
967  /**
968   * Returns true if the InputTaskManager is suspended.
969   */
970  readonly attribute boolean isInputTaskManagerSuspended;
971
972  /**
973   * Suppresses/unsuppresses user initiated event handling in window's document
974   * and subdocuments.
975   *
976   * @throw NS_ERROR_DOM_SECURITY_ERR if called without chrome privileges and
977   *        NS_ERROR_FAILURE if window doesn't have a document.
978   */
979  void suppressEventHandling(in boolean aSuppress);
980
981  /**
982   * Disable or enable non synthetic test mouse events on *all* windows.
983   *
984   * Cannot be accessed from unprivileged context (not content-accessible).
985   * Will throw a DOM security error if called without chrome privileges.
986   *
987   * @param aDisable  If true, disable all non synthetic test mouse events
988   *               on all windows.  Otherwise, enable them.
989   */
990  void disableNonTestMouseEvents(in boolean aDisable);
991
992  /**
993   * Returns the scroll position of the window's currently loaded document.
994   *
995   * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs.
996   * @see nsIDOMWindow::scrollX/Y
997   */
998  void getScrollXY(in boolean aFlushLayout, out long aScrollX, out long aScrollY);
999
1000  /**
1001   * Returns the scroll position of the window's currently loaded document.
1002   *
1003   * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs.
1004   * @see nsIDOMWindow::scrollX/Y
1005   */
1006  void getScrollXYFloat(in boolean aFlushLayout, out float aScrollX, out float aScrollY);
1007
1008  /**
1009   * Returns the scrollbar width of the window's scroll frame.
1010   *
1011   * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs.
1012   */
1013  void getScrollbarSize(in boolean aFlushLayout, out long aWidth, out long aHeight);
1014
1015  /**
1016   * Returns the given element's bounds without flushing pending layout changes.
1017   */
1018  DOMRect getBoundsWithoutFlushing(in Element aElement);
1019
1020  /**
1021   * Scroll the visual viewport to the given coordinates, relative to the
1022   * document origin.
1023   * Only applicable to the window associated with the root content document.
1024   * Note: this does not take effect right away. Rather, the visual scroll
1025   *       request is sent to APZ with the next transaction, and will be
1026   *       reflected in the main thread with the subsequent APZ repaint request.
1027   * Please see the caveats mentioned at PresShell::ScrollToVisual(), and
1028   * request APZ review if adding a new call to this.
1029   */
1030  const long UPDATE_TYPE_RESTORE = 0;
1031  const long UPDATE_TYPE_MAIN_THREAD = 1;
1032  const long SCROLL_MODE_INSTANT = 0;
1033  const long SCROLL_MODE_SMOOTH = 1;
1034  void scrollToVisual(in float aOffsetX, in float aOffsetY,
1035                      in long aUpdateType, in long aScrollMode);
1036
1037  /**
1038   * Returns the offset of the window's visual viewport relative to the
1039   * layout viewport.
1040   */
1041  void getVisualViewportOffsetRelativeToLayoutViewport(out float aOffsetX,
1042                                                       out float aOffsetY);
1043
1044  /**
1045   * Returns the scroll position of the window's visual viewport.
1046   */
1047  void getVisualViewportOffset(out long aOffsetX, out long aOffsetY);
1048
1049  /**
1050   * Transforms the passed in rect from layout relative coords (relative to
1051   * this document) to be is visual coords.
1052   */
1053  DOMRect transformRectLayoutToVisual(in float aX, in float aY,
1054                                      in float aWidth, in float aHeight);
1055
1056  /**
1057   * Transform a rectangle given in coordinates relative to this document
1058   * into CSS coordinates relative to the screen.
1059   */
1060  DOMRect toScreenRectInCSSUnits(in float aX, in float aY,
1061                                 in float aWidth, in float aHeight);
1062
1063  /**
1064   * Transform a rectangle given in coordinates relative to this document
1065   * to the screen.
1066   */
1067  DOMRect toScreenRect(in float aX, in float aY,
1068                       in float aWidth, in float aHeight);
1069
1070  /**
1071   * Transform a rectangle given in coordinates relative to the top level
1072   * parent process widget to the local widget. This window should be in a
1073   * child process.
1074   */
1075  DOMRect convertFromParentProcessWidgetToLocal(in float aX,
1076                                                in float aY,
1077                                                in float aWidth,
1078                                                in float aHeight);
1079
1080  /**
1081   * Sets the maximum height of the dynamic toolbar in Screen pixel units.
1082   */
1083  [can_run_script]
1084  void setDynamicToolbarMaxHeight(in uint32_t aHeightInScreen);
1085
1086  const long FLUSH_NONE = -1;
1087  const long FLUSH_STYLE = 0;
1088  const long FLUSH_LAYOUT = 1;
1089  const long FLUSH_DISPLAY = 2;
1090
1091  /**
1092   * Returns true if a flush of the given type is needed.
1093   */
1094  bool needsFlush(in long aFlushtype);
1095
1096  /**
1097   * Flush pending layout-type notification without flushing throttled
1098   * animations.
1099   */
1100  void flushLayoutWithoutThrottledAnimations();
1101
1102  /**
1103   * Returns the bounds of the window's currently loaded document. This will
1104   * generally be (0, 0, pageWidth, pageHeight) but in some cases (e.g. RTL
1105   * documents) may have a negative left value.
1106   */
1107  DOMRect getRootBounds();
1108
1109  /**
1110   * Get IME open state. TRUE means 'Open', otherwise, 'Close'.
1111   * This property works only when IMEEnabled is IME_STATUS_ENABLED.
1112   */
1113  readonly attribute boolean IMEIsOpen;
1114
1115  /**
1116   * WARNING: These values must be same as nsIWidget's values.
1117   */
1118
1119  /**
1120   * DISABLED means users cannot use IME completely.
1121   * Note that this state is *not* same as |ime-mode: disabled;|.
1122   */
1123  const unsigned long IME_STATUS_DISABLED = 0;
1124
1125  /**
1126   * ENABLED means users can use all functions of IME. This state is same as
1127   * |ime-mode: normal;|.
1128   */
1129  const unsigned long IME_STATUS_ENABLED  = 1;
1130
1131  /**
1132   * PASSWORD means users cannot use most functions of IME. But on GTK2,
1133   * users can use "Simple IM" which only supports dead key inputting.
1134   * The behavior is same as the behavior of the native password field.
1135   * This state is same as |ime-mode: disabled;|.
1136   */
1137  const unsigned long IME_STATUS_PASSWORD = 2;
1138
1139  /**
1140   * Get IME status, see above IME_STATUS_* definitions.
1141   */
1142  readonly attribute unsigned long IMEStatus;
1143
1144  /**
1145   * Get whether current input context (including IME status) in the widget
1146   * is set by content or not.
1147   */
1148  const unsigned long INPUT_CONTEXT_ORIGIN_MAIN = 0;
1149  const unsigned long INPUT_CONTEXT_ORIGIN_CONTENT = 1;
1150  readonly attribute unsigned long inputContextOrigin;
1151
1152  /**
1153   * Get a root node which is observed by IMEContentObserver.
1154   */
1155  readonly attribute Node nodeObservedByIMEContentObserver;
1156
1157  /**
1158   * Get the number of screen pixels per CSS pixel,
1159   * not taking into account any override of the device pixel scale
1160   * that's imposed by Responsive Design Mode.
1161   *
1162   * This is needed to e.g. correctly translate "window.mozInnerScreenX/Y"
1163   * into device pixels even when "window" is the window of a document
1164   * inside an RDM pane.
1165   */
1166  readonly attribute float screenPixelsPerCSSPixelNoOverride;
1167
1168  /**
1169   * Get the current zoom factor.
1170   * This is _approximately_ the same as nsIContentViewer.fullZoom,
1171   * but takes into account Gecko's quantization of the zoom factor, which is
1172   * implemented by adjusting the (integer) number of appUnits per devPixel.
1173   */
1174  readonly attribute float fullZoom;
1175
1176  /**
1177   * Dispatches aEvent as a synthesized trusted event for tests via the
1178   * PresShell object of the window's document.
1179   * The event is dispatched to aTarget, which should be an object
1180   * which implements nsIContent interface (#element, #text, etc).
1181   *
1182   * Cannot be accessed from unprivileged context (not
1183   * content-accessible) Will throw a DOM security error if called
1184   * without chrome privileges.
1185   *
1186   * @note Event handlers won't get aEvent as parameter, but a similar event.
1187   *       Also, aEvent should not be reused.
1188   */
1189  [can_run_script]
1190  boolean dispatchDOMEventViaPresShellForTesting(in Node aTarget,
1191                                                 in Event aEvent);
1192
1193  /**
1194   * Sets WidgetEvent::mFlags::mOnlyChromeDispatch to true to ensure that
1195   * the event is propagated only to chrome.
1196   * Event's .target property will be aTarget.
1197   * Returns the same value as what EventTarget.dispatchEvent does.
1198   */
1199  boolean dispatchEventToChromeOnly(in EventTarget aTarget,
1200                                    in Event aEvent);
1201
1202  /**
1203   * Returns the real classname (possibly of the mostly-transparent security
1204   * wrapper) of aObj.
1205   */
1206  [implicit_jscontext] string getClassName(in jsval aObject);
1207
1208  /**
1209   * Generate a content command event.
1210   *
1211   * Cannot be accessed from unprivileged context (not content-accessible)
1212   * Will throw a DOM security error if called without chrome privileges.
1213   *
1214   * @param aType Type of command content event to send.  Can be one of "cut",
1215   *        "copy", "paste", "delete", "undo", "redo", "insertText" or
1216   *        "pasteTransferable".
1217   * @param aTransferable an instance of nsITransferable when aType is
1218   *        "pasteTransferable"
1219   * @param aString The string to be inserted into focused editor when aType is
1220   *        "insertText"
1221   */
1222  void sendContentCommandEvent(in AString aType,
1223                               [optional] in nsITransferable aTransferable,
1224                               [optional] in AString aString);
1225
1226  /**
1227   * If sendQueryContentEvent()'s aAdditionalFlags argument is
1228   * QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK, plain text generated from content
1229   * is created with "\n".
1230   * Otherwise, platform dependent.  E.g., on Windows, "\r\n" is used.
1231   * aOffset and aLength are offset and length in/of the plain text content.
1232   * This flag also affects the result values such as offset, length and string.
1233   */
1234  const unsigned long QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK = 0x0000;
1235  const unsigned long QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK     = 0x0001;
1236
1237  /**
1238   * sendQueryContentEvent()'s aAdditionalFlags may have one of following
1239   * flags when aType is QUERY_SELECTED_TEXT.  If one of them is set,
1240   * the result is the first range of the selection type.  See also
1241   * nsISelectionController::SELECTION_*.
1242   */
1243  const unsigned long QUERY_CONTENT_FLAG_SELECTION_SPELLCHECK          = 0x0002;
1244  const unsigned long QUERY_CONTENT_FLAG_SELECTION_IME_RAWINPUT        = 0x0004;
1245  const unsigned long QUERY_CONTENT_FLAG_SELECTION_IME_SELECTEDRAWTEXT = 0x0008;
1246  const unsigned long QUERY_CONTENT_FLAG_SELECTION_IME_CONVERTEDTEXT   = 0x0010;
1247  const unsigned long QUERY_CONTENT_FLAG_SELECTION_IME_SELECTEDCONVERTEDTEXT =
1248                                                                         0x0020;
1249  const unsigned long QUERY_CONTENT_FLAG_SELECTION_ACCESSIBILITY       = 0x0040;
1250  const unsigned long QUERY_CONTENT_FLAG_SELECTION_FIND                = 0x0080;
1251  const unsigned long QUERY_CONTENT_FLAG_SELECTION_URLSECONDARY        = 0x0100;
1252  const unsigned long QUERY_CONTENT_FLAG_SELECTION_URLSTRIKEOUT        = 0x0200;
1253
1254  /**
1255   * One of sendQueryContentEvent()'s aAdditionalFlags.  If this is specified,
1256   * aOffset is relative to start of selection or composition.
1257   * Note that this is supported only when QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK
1258   * is not specified for now.
1259   */
1260  const unsigned long QUERY_CONTENT_FLAG_OFFSET_RELATIVE_TO_INSERTION_POINT =
1261                                                                         0x0400;
1262
1263  /**
1264   * Synthesize a query content event. Note that the result value returned here
1265   * is in LayoutDevice pixels rather than CSS pixels.
1266   *
1267   * @param aType  One of the following const values.  And see also each comment
1268   *               for the other parameters and the result.
1269   * @param aAdditionalFlags See the description of QUERY_CONTENT_FLAG_*.
1270   */
1271  nsIQueryContentEventResult sendQueryContentEvent(
1272                               in unsigned long aType,
1273                               in long long aOffset,
1274                               in unsigned long aLength,
1275                               in long aX,
1276                               in long aY,
1277                               [optional] in unsigned long aAdditionalFlags);
1278
1279  /**
1280   * QUERY_SELECTED_TEXT queries the first selection range's information.
1281   *
1282   * @param aOffset   Not used.
1283   * @param aLength   Not used.
1284   * @param aX        Not used.
1285   * @param aY        Not used.
1286   *
1287   * @return offset, reversed and text properties of the result are available.
1288   */
1289  const unsigned long QUERY_SELECTED_TEXT                       = 3200;
1290
1291  /**
1292   * QUERY_TEXT_CONTENT queries the text at the specified range.
1293   *
1294   * @param aOffset   The first character's offset.  0 is the first character.
1295   * @param aLength   The length of getting text.  If the aLength is too long,
1296   *                  the result text is shorter than this value.
1297   * @param aX        Not used.
1298   * @param aY        Not used.
1299   *
1300   * @return text property of the result is available.
1301   */
1302  const unsigned long QUERY_TEXT_CONTENT                        = 3201;
1303
1304  /**
1305   * QUERY_CARET_RECT queries the (collapsed) caret rect of the offset.
1306   * If the actual caret is there at the specified offset, this returns the
1307   * actual caret rect.  Otherwise, this guesses the caret rect from the
1308   * metrics of the text.
1309   *
1310   * @param aOffset   The caret offset.  0 is the left side of the first
1311   *                  caracter in LTR text.
1312   * @param aLength   Not used.
1313   * @param aX        Not used.
1314   * @param aY        Not used.
1315   *
1316   * @return left, top, width and height properties of the result are available.
1317   *         The left and the top properties are offset in the client area of
1318   *         the DOM window.
1319   */
1320  const unsigned long QUERY_CARET_RECT                          = 3203;
1321
1322  /**
1323   * QUERY_TEXT_RECT queries the specified text's rect.
1324   *
1325   * @param aOffset   The first character's offset.  0 is the first character.
1326   * @param aLength   The length of getting text.  If the aLength is too long,
1327   *                  the extra length is ignored.
1328   * @param aX        Not used.
1329   * @param aY        Not used.
1330   *
1331   * @return left, top, width and height properties of the result are available.
1332   *         The left and the top properties are offset in the client area of
1333   *         the DOM window.
1334   */
1335  const unsigned long QUERY_TEXT_RECT                           = 3204;
1336
1337  /**
1338   * QUERY_TEXT_RECT queries the focused editor's rect.
1339   *
1340   * @param aOffset   Not used.
1341   * @param aLength   Not used.
1342   * @param aX        Not used.
1343   * @param aY        Not used.
1344   *
1345   * @return left, top, width and height properties of the result are available.
1346   */
1347  const unsigned long QUERY_EDITOR_RECT                         = 3205;
1348
1349  /**
1350   * QUERY_CHARACTER_AT_POINT queries the character information at the
1351   * specified point.  The point is offset in the window.
1352   * NOTE: If there are some panels at the point, this method send the query
1353   * event to the panel's widget automatically.
1354   *
1355   * @param aOffset   Not used.
1356   * @param aLength   Not used.
1357   * @param aX        X offset in the widget.
1358   * @param aY        Y offset in the widget.
1359   *
1360   * @return offset, notFound, left, top, width and height properties of the
1361   *         result are available.
1362   */
1363  const unsigned long QUERY_CHARACTER_AT_POINT                  = 3208;
1364
1365  /**
1366   * QUERY_TEXT_RECT_ARRAY queries the rects per character
1367   *
1368   * @param aOffset   The first character's offset.  0 is the first character.
1369   * @param aLength   The length of getting text.  If the aLength is too long,
1370   *                  the extra length is ignored.
1371   * @param aX        Not used.
1372   * @param aY        Not used.
1373   */
1374  const unsigned long QUERY_TEXT_RECT_ARRAY                     = 3209;
1375
1376  /**
1377   * Called when the remote child frame has changed its fullscreen state,
1378   * when entering fullscreen, and when the origin which is fullscreen changes.
1379   * aFrameElement is the iframe element which contains the child-process
1380   * fullscreen document.
1381   */
1382  void remoteFrameFullscreenChanged(in Element aFrameElement);
1383
1384  /**
1385   * Called when the remote frame has popped all fullscreen elements off its
1386   * stack, so that the operation can complete on the parent side.
1387   */
1388  void remoteFrameFullscreenReverted();
1389
1390  /**
1391   * Calls the document to handle any pending fullscreen requests.
1392   * It is called when the parent document has entered fullscreen, and
1393   * we want to put the current document into fullscreen as well.
1394   * The return value indicates whether there is any fullscreen request
1395   * handled by this call.
1396   */
1397  boolean handleFullscreenRequests();
1398
1399  /**
1400   * Called when the child frame has fully exit fullscreen, so that the parent
1401   * process can also fully exit.
1402   */
1403  void exitFullscreen();
1404
1405  /**
1406   * If sendQueryContentEvent()'s aAdditionalFlags argument is
1407   * SELECTION_SET_FLAG_USE_NATIVE_LINE_BREAK, aOffset and aLength are offset
1408   * and length in/of plain text generated from content is created with "\n".
1409   * Otherwise, platform dependent.  E.g., on Windows, "\r\n" is used.
1410   */
1411  const unsigned long SELECTION_SET_FLAG_USE_NATIVE_LINE_BREAK = 0x0000;
1412  const unsigned long SELECTION_SET_FLAG_USE_XP_LINE_BREAK     = 0x0001;
1413
1414  /**
1415   * If SELECTION_SET_FLAG_REVERSE is set, the selection is set from
1416   * |aOffset + aLength| to |aOffset|.  Otherwise, it's set from |aOffset| to
1417   * |aOffset + aLength|.
1418   */
1419  const unsigned long SELECTION_SET_FLAG_REVERSE               = 0x0002;
1420
1421  /**
1422   * Synthesize a selection set event to the window.
1423   *
1424   * This sets the selection as the specified information.
1425   *
1426   * @param aOffset  The caret offset of the selection start.
1427   * @param aLength  The length of the selection.  If this is too long, the
1428   *                 extra length is ignored.
1429   * @param aAdditionalFlags See the description of SELECTION_SET_FLAG_*.
1430   * @return True, if succeeded.  Otherwise, false.
1431   */
1432  boolean sendSelectionSetEvent(in unsigned long aOffset,
1433                                in unsigned long aLength,
1434                                [optional] in unsigned long aAdditionalFlags);
1435
1436  /* Selection behaviors - mirror nsIFrame's nsSelectionAmount constants */
1437  const unsigned long SELECT_CHARACTER   = 0;
1438  const unsigned long SELECT_CLUSTER     = 1;
1439  const unsigned long SELECT_WORD        = 2;
1440  const unsigned long SELECT_LINE        = 3;
1441  const unsigned long SELECT_BEGINLINE   = 4;
1442  const unsigned long SELECT_ENDLINE     = 5;
1443  const unsigned long SELECT_PARAGRAPH   = 6;
1444  const unsigned long SELECT_WORDNOSPACE = 7;
1445
1446  /**
1447   * Select content at a client point based on a selection behavior if the
1448   * underlying content is selectable. Selection will accumulate with any
1449   * existing selection, callers should clear selection prior if needed.
1450   * May fire selection changed events. Calls nsFrame's SelectByTypeAtPoint.
1451   *
1452   * @param aX, aY The selection point in client coordinates.
1453   * @param aSelectType The selection behavior requested.
1454   * @return True if a selection occured, false otherwise.
1455   * @throw NS_ERROR_DOM_SECURITY_ERR, NS_ERROR_UNEXPECTED for utils
1456   * issues, and NS_ERROR_INVALID_ARG for coordinates that are outside
1457   * this window.
1458   */
1459  [can_run_script]
1460  boolean selectAtPoint(in float aX,
1461                        in float aY,
1462                        in unsigned long aSelectBehavior);
1463
1464  /**
1465   * Perform the equivalent of:
1466   *   window.getComputedStyle(aElement, aPseudoElement).
1467   *     getPropertyValue(aPropertyName)
1468   * except that, when the link whose presence in history is allowed to
1469   * influence aElement's style is visited, get the value the property
1470   * would have if allowed all properties to change as a result of
1471   * :visited selectors (except for cases where getComputedStyle uses
1472   * data from the frame).
1473   *
1474   * This is easier to implement than adding our property restrictions
1475   * to this API, and is sufficient for the present testing
1476   * requirements (which are essentially testing 'color').
1477   */
1478  AString getVisitedDependentComputedStyle(in Element aElement,
1479                                           in AString aPseudoElement,
1480                                           in AString aPropertyName);
1481
1482  /**
1483   * Put the window into a state where scripts are frozen and events
1484   * suppressed, for use when the window has launched a modal prompt.
1485   */
1486  void enterModalState();
1487
1488  /**
1489   * Resume normal window state, where scripts can run and events are
1490   * delivered.
1491   */
1492  void leaveModalState();
1493
1494  /**
1495   * Is the window is in a modal state? [See enterModalState()]
1496   */
1497  boolean isInModalState();
1498
1499  /**
1500   * Internal desktopMode flag.
1501   */
1502  attribute boolean desktopModeViewport;
1503
1504  /**
1505   * Suspend/resume timeouts on this window and its descendant windows.
1506   */
1507  void suspendTimeouts();
1508  void resumeTimeouts();
1509
1510  /**
1511   * What type of layer manager the widget associated with this window is
1512   * using. "Basic" is unaccelerated; other types are accelerated. Throws an
1513   * error if there is no widget associated with this window.
1514   */
1515  readonly attribute AString layerManagerType;
1516
1517  /**
1518   * True if the layer manager for the widget associated with this window is
1519   * forwarding layers to a remote compositor, false otherwise. Throws an
1520   * error if there is no widget associated with this window.
1521   */
1522  readonly attribute boolean layerManagerRemote;
1523
1524  /**
1525   * True if webrender was requested by the user (via pref or env-var), false
1526   * otherwise. Note that this doesn't represent whether or not webrender is
1527   * *actually* enabled, just whether or not it was requested.
1528   */
1529  readonly attribute boolean isWebRenderRequested;
1530
1531  /**
1532   * Returns the current audio backend as a free-form string.
1533   */
1534  readonly attribute AString currentAudioBackend;
1535
1536  /**
1537   * Returns the max channel counts of the current audio device.
1538   */
1539  readonly attribute unsigned long currentMaxAudioChannels;
1540
1541  /**
1542   * Returns the mean round trip latency in seconds for the default input and
1543   * output device, and the stddev of this latency, as a two element array when
1544   * the Promise succeeds.
1545   */
1546  Promise defaultDevicesRoundTripLatency();
1547
1548  /**
1549   * Returns the preferred sample rate of the current audio device.
1550   */
1551  readonly attribute unsigned long currentPreferredSampleRate;
1552
1553  /**
1554   * Returns all the audio input/output devices.
1555   */
1556  const unsigned short AUDIO_INPUT   = 0;
1557  const unsigned short AUDIO_OUTPUT  = 1;
1558  nsIArray audioDevices(in unsigned short aSide);
1559
1560  /**
1561   * Record (and return) frame-intervals for frames which were presented
1562   *   between calling StartFrameTimeRecording and StopFrameTimeRecording.
1563   *
1564   * - Uses a cyclic buffer and serves concurrent consumers, so if Stop is called too late
1565   *     (elements were overwritten since Start), result is considered invalid and hence empty.
1566   * - Buffer is capable of holding 10 seconds @ 60fps (or more if frames were less frequent).
1567   *     Can be changed (up to 1 hour) via pref: toolkit.framesRecording.bufferSize.
1568   * - Note: the first frame-interval may be longer than expected because last frame
1569   *     might have been presented some time before calling StartFrameTimeRecording.
1570   */
1571
1572  /**
1573   * Returns a handle which represents current recording start position.
1574   */
1575  void startFrameTimeRecording([retval] out unsigned long startIndex);
1576
1577  /**
1578   * Returns array of frame intervals since the time when the given startIndex
1579   * was handed out from startFrameTimeRecording.
1580   */
1581  Array<float> stopFrameTimeRecording(in unsigned long startIndex);
1582
1583  /**
1584   * The DPI of the display
1585   */
1586  readonly attribute float displayDPI;
1587
1588  /**
1589   * advanceTimeAndRefresh allows the caller to take over the refresh
1590   * driver timing for a window.  A call to advanceTimeAndRefresh does
1591   * three things:
1592   *  (1) It marks the refresh driver for this presentation so that it
1593   *      no longer refreshes on its own, but is instead driven entirely
1594   *      by the caller (except for the refresh that happens when a
1595   *      document comes out of the bfcache).
1596   *  (2) It advances the refresh driver's current refresh time by the
1597   *      argument given.  Negative advances are permitted.
1598   *  (3) It does a refresh (i.e., notifies refresh observers) at that
1599   *      new time.
1600   *
1601   * Note that this affects other connected docshells of the same type
1602   * in the same docshell tree, such as parent frames.
1603   *
1604   * When callers have completed their use of advanceTimeAndRefresh,
1605   * they must call restoreNormalRefresh.
1606   */
1607  void advanceTimeAndRefresh(in long long aMilliseconds);
1608
1609  /**
1610   * Undoes the effects of advanceTimeAndRefresh.
1611   */
1612  void restoreNormalRefresh();
1613
1614  /**
1615   * Reports whether the current state is test-controlled refreshes
1616   * (see advanceTimeAndRefresh and restoreNormalRefresh above).
1617   */
1618  readonly attribute bool isTestControllingRefreshes;
1619
1620  /**
1621   * Reports whether APZ is enabled on the widget that this window is attached
1622   * to. If there is no widget it will report the default platform value of
1623   * whether or not APZ is enabled.
1624   */
1625  readonly attribute bool asyncPanZoomEnabled;
1626
1627  /**
1628   * Set async scroll offset on an element. The next composite will render
1629   * with that offset if async scrolling is enabled, and then the offset
1630   * will be removed. Only call this while test-controlled refreshes is enabled.
1631   */
1632  void setAsyncScrollOffset(in Element aElement, in float aX, in float aY);
1633
1634  /**
1635   * Set async zoom value. aRootElement should be the document element of our
1636   * document. The next composite will render with that zoom added to any
1637   * existing zoom if async scrolling is enabled, and then the zoom will be
1638   * removed. Only call this while test-controlled refreshes is enabled.
1639   */
1640  void setAsyncZoom(in Element aRootElement, in float aValue);
1641
1642  /**
1643   * Do a round-trip to the compositor to ensure any pending APZ repaint requests
1644   * get flushed to the main thread. If the function returns true, the flush was
1645   * triggered and an "apz-repaints-flushed" notification will be dispatched via
1646   * the observer service once the flush is complete. If the function returns
1647   * false, an error occurred or a flush is not needed, and the notification
1648   * will not fire. This is intended to be used by test code only!
1649   */
1650  bool flushApzRepaints();
1651
1652  /**
1653   * Sets a flag on the element to forcibly disable APZ on it. This affects
1654   * the result of nsLayoutUtils::ShouldDisableApzForElement when called on
1655   * this element. This function also schedules a repaint to ensure that the
1656   * change takes effect. Note that this is not reversible; it is intended for
1657   * use by test code only.
1658   */
1659  void disableApzForElement(in Element aElement);
1660
1661  /**
1662   * Ask APZ to pan and zoom to the focused input element.
1663   */
1664  [can_run_script] void zoomToFocusedInput();
1665
1666  /**
1667   * Method for testing StyleAnimationValue::ComputeDistance.
1668   *
1669   * Returns the distance between the two values as reported by
1670   * StyleAnimationValue::ComputeDistance for the given element and
1671   * property.
1672   */
1673  double computeAnimationDistance(in Element element,
1674                                  in AString property,
1675                                  in AString value1,
1676                                  in AString value2);
1677
1678  /**
1679   * Returns the computed style for the specified property of given pseudo type
1680   * on the given element after removing styles from declarative animations.
1681   * @param aElement - A target element
1682   * @param aPseudoElement - A pseudo type (e.g. '::before' or null)
1683   * @param aProperty - A longhand CSS property (e.g. 'background-color')
1684   * @param aFlushType - FLUSH_NONE if any pending styles should not happen,
1685   *                     FLUSH_STYLE to flush pending styles.
1686   */
1687  AString getUnanimatedComputedStyle(in Element aElement,
1688                                     in AString aPseudoElement,
1689                                     in AString aProperty,
1690                                     in long aFlushType);
1691
1692  /**
1693   * Returns the effective canvas background color for the window.
1694   */
1695  readonly attribute AString canvasBackgroundColor;
1696
1697  /**
1698   * Get the type of the currently focused html input, if any.
1699   */
1700  readonly attribute AString focusedInputType;
1701
1702  /**
1703   * Get the action hint of the currently focused html input, if any.
1704   */
1705  readonly attribute AString focusedActionHint;
1706
1707  /**
1708   * Get the inputmode of the currently focused editing host, if any.
1709   */
1710  readonly attribute AString focusedInputMode;
1711
1712  /**
1713   * Get the autocapitalize of the currently focused editing host, if any.
1714   */
1715  readonly attribute AString focusedAutocapitalize;
1716
1717  /**
1718   * Find the view ID for a given element. This is the reverse of
1719   * findElementWithViewId().
1720   */
1721  nsViewID getViewId(in Element aElement);
1722
1723  /**
1724   * Check if any PaintedLayer painting has been done for this element,
1725   * clears the painted flags if they have.
1726   */
1727  boolean checkAndClearPaintedState(in Element aElement);
1728
1729  /**
1730   * Check if any display list building has been done for this element,
1731   * clears the display list flags if they have.
1732   */
1733  boolean checkAndClearDisplayListState(in Element aElement);
1734
1735  /**
1736   * Check whether all display items of the primary frame of aElement have been
1737   * assigned to the same single PaintedLayer in the last paint. If that is the
1738   * case, returns whether that PaintedLayer is opaque; if it's not the case, an
1739   * exception is thrown.
1740   */
1741  boolean isPartOfOpaqueLayer(in Element aElement);
1742
1743  /**
1744   * Count the number of different PaintedLayers that the supplied elements have
1745   * been assigned to in the last paint. Throws an exception if any of the
1746   * elements doesn't have a primary frame, or if that frame's display items are
1747   * assigned to any other layers than just a single PaintedLayer per element.
1748   */
1749  unsigned long numberOfAssignedPaintedLayers(in Array<Element> aElements);
1750
1751  /**
1752   * Get internal id of the stored blob, file or file handle.
1753   */
1754  [implicit_jscontext] long long getFileId(in jsval aFile);
1755
1756  /**
1757   * Get internal file path of the stored file or file handle.
1758   *
1759   * TODO: File handle objects are actually not supported at the moment.
1760   */
1761  [implicit_jscontext] AString getFilePath(in jsval aFile);
1762
1763  /**
1764   * Get file ref count info for given database and file id.
1765   *
1766   */
1767  [implicit_jscontext]
1768  boolean getFileReferences(in AString aDatabaseName, in long long aId,
1769                            [optional] in jsval aOptions,
1770                            [optional] out long aRefCnt,
1771                            [optional] out long aDBRefCnt);
1772
1773  void flushPendingFileDeletions();
1774
1775  /**
1776   * Begin opcode-level profiling of all JavaScript execution in the window's
1777   * runtime.
1778   */
1779  [implicit_jscontext]
1780  void startPCCountProfiling();
1781
1782  /**
1783   * Stop opcode-level profiling of JavaScript execution in the runtime, and
1784   * collect all counts for use by getPCCount methods.
1785   */
1786  [implicit_jscontext]
1787  void stopPCCountProfiling();
1788
1789  /**
1790   * Purge collected PC counters.
1791   */
1792  [implicit_jscontext]
1793  void purgePCCounts();
1794
1795  /**
1796   * Get the number of scripts with opcode-level profiling information.
1797   */
1798  [implicit_jscontext]
1799  long getPCCountScriptCount();
1800
1801  /**
1802   * Get a JSON string for a short summary of a script and the PC counts
1803   * accumulated for it.
1804   */
1805  [implicit_jscontext]
1806  AString getPCCountScriptSummary(in long script);
1807
1808  /**
1809   * Get a JSON string with full information about a profiled script,
1810   * including the decompilation of the script and placement of decompiled
1811   * operations within it, and PC counts for each operation.
1812   */
1813  [implicit_jscontext]
1814  AString getPCCountScriptContents(in long script);
1815
1816  /**
1817   * Returns true if painting is suppressed for this window and false
1818   * otherwise.
1819   */
1820  readonly attribute boolean paintingSuppressed;
1821
1822  /**
1823   * Set the viewport size for the purposes of clamping scroll positions for
1824   * the root scroll frame of this document to be (aWidth,aHeight) in CSS pixels.
1825   *
1826   * The caller of this method must have chrome privileges.
1827   */
1828  void setVisualViewportSize(in float aWidth, in float aHeight);
1829
1830  /**
1831   * These are used to control whether dialogs (alert, prompt, confirm) are
1832   * allowed, and to reset the inernal state that controls whether dialogs
1833   * are currently blocked or not.
1834   */
1835  void disableDialogs();
1836  void enableDialogs();
1837  bool areDialogsEnabled();
1838  void resetDialogAbuseState();
1839
1840  const unsigned long AGENT_SHEET = 0;
1841  const unsigned long USER_SHEET = 1;
1842  const unsigned long AUTHOR_SHEET = 2;
1843  /**
1844   * Synchronously loads a style sheet from |sheetURI| and adds it to the list
1845   * of additional style sheets of the document.
1846   *
1847   * These additional style sheets are very much like user/agent sheets loaded
1848   * with loadAndRegisterSheet. The only difference is that they are applied only
1849   * on the document owned by this window.
1850   *
1851   * Sheets added via this API take effect immediately on the document.
1852   */
1853  void loadSheet(in nsIURI sheetURI, in unsigned long type);
1854
1855  /**
1856   * Same as the above method but allows passing the URI as a string.
1857   */
1858  void loadSheetUsingURIString(in ACString sheetURI, in unsigned long type);
1859
1860  /**
1861   * Adds a style sheet to the list of additional style sheets of the document.
1862   *
1863   * Style sheets can be preloaded with nsIStyleSheetService.preloadSheet.
1864   *
1865   * Sheets added via this API take effect immediately on the document.
1866   */
1867  void addSheet(in nsIPreloadedStyleSheet sheet, in unsigned long type);
1868
1869  /**
1870   * Remove the document style sheet at |sheetURI| from the list of additional
1871   * style sheets of the document.  The removal takes effect immediately.
1872   */
1873  void removeSheet(in nsIURI sheetURI, in unsigned long type);
1874
1875  /**
1876   * Same as the above method but allows passing the URI as a string.
1877   */
1878  void removeSheetUsingURIString(in ACString sheetURI, in unsigned long type);
1879
1880  /**
1881   * Returns true if a user input is being handled.
1882   *
1883   * This calls EventStateManager::IsHandlingUserInput().
1884   */
1885  readonly attribute boolean isHandlingUserInput;
1886
1887  /**
1888   * Returns milliseconds elapsed since last user input was started.
1889   * Returns -1 if there wasn't any previous user input.
1890   *
1891   * This relies on EventStateManager::LatestUserInputStart()
1892   */
1893  readonly attribute double millisSinceLastUserInput;
1894
1895  /**
1896   * After calling the method, the window for which this DOMWindowUtils
1897   * was created can be closed using scripts.
1898   */
1899  void allowScriptsToClose();
1900
1901  /**
1902   * Is the parent window's main widget visible?  If it isn't, we probably
1903   * don't want to display any dialogs etc it may request.  This corresponds
1904   * to the visibility check in nsWindowWatcher::OpenWindowInternal().
1905   *
1906   * Will throw a DOM security error if called without chrome privileges or
1907   * NS_ERROR_NOT_AVAILABLE in the unlikely event that the parent window's
1908   * main widget can't be reached.
1909   */
1910  readonly attribute boolean isParentWindowMainWidgetVisible;
1911
1912  /**
1913   * In certain cases the event handling of nodes, form controls in practice,
1914   * may be disabled. Such cases are for example the existence of disabled
1915   * attribute or -moz-user-input: none.
1916   */
1917  boolean isNodeDisabledForEvents(in Node aNode);
1918
1919  /*
1920   * Returns the value of a given property animated on the compositor thread.
1921   * If the property is NOT currently being animated on the compositor thread,
1922   * returns an empty string.
1923   * NOTE: Do not use this function for elements that there was another
1924   * animation running on the compositor before.
1925   */
1926  AString getOMTAStyle(in Element aElement, in AString aProperty,
1927                       [optional] in AString aPseudoElement);
1928
1929  /*
1930   * Returns true if the given animation is being tracked by the pending
1931   * animation tracker for the current document.
1932   */
1933  bool isAnimationInPendingTracker(in Animation aAnimation);
1934
1935  /**
1936   * If aHandlingInput is true, this informs the event state manager that
1937   * we're handling user input. Otherwise, this is a no-op (as by default
1938   * we're not handling user input).
1939   * Remember to call destruct() on the return value!
1940   * See also nsIDOMWindowUtils::isHandlingUserInput.
1941   */
1942  nsIJSRAIIHelper setHandlingUserInput(in boolean aHandlingInput);
1943
1944  /**
1945   * Get the content- and compositor-side APZ test data instances.
1946   * The return values are of type APZTestData (see APZTestData.webidl).
1947   */
1948  [implicit_jscontext] jsval getContentAPZTestData();
1949  [implicit_jscontext] jsval getCompositorAPZTestData();
1950
1951  /**
1952   * Posts an RestyleHint::RESTYLE_SELF restyle event for the given element.
1953   */
1954  void postRestyleSelfEvent(in Element aElement);
1955
1956  /**
1957   * This method doesn't do anything useful.  It was solely added for the
1958   * purpose of the test for bug 503926.
1959   */
1960  void xpconnectArgument(in nsISupports aObj);
1961
1962  /**
1963   * Helper for JS components that need to send permission requests with
1964   * e10s support properly.
1965   */
1966  void askPermission(in nsIContentPermissionRequest aRequest);
1967
1968  /**
1969   * Restyle generation for the current document.
1970   *
1971   * May throw NS_ERROR_NOT_AVAILABLE.
1972   */
1973  readonly attribute unsigned long long restyleGeneration;
1974
1975  /**
1976   * Number of frames constructed (excluding breaking) for the curent
1977   * document.
1978   *
1979   * May throw NS_ERROR_NOT_AVAILABLE.
1980   */
1981  readonly attribute unsigned long long framesConstructed;
1982
1983  /**
1984   * Number of frames reflowed for the curent document.
1985   *
1986   * May throw NS_ERROR_NOT_AVAILABLE.
1987   */
1988  readonly attribute unsigned long long framesReflowed;
1989
1990  /**
1991   * Indicates whether the current frame's refresh driver has a pending tick,
1992   * as reported by nsRefreshDriver::HasPendingTick.
1993   *
1994   * May throw NS_ERROR_NOT_AVAILABLE.
1995   */
1996  readonly attribute bool refreshDriverHasPendingTick;
1997
1998  /**
1999   * Controls the amount of chrome that should be visible on each side of
2000   * the window. Works like the chromemargin xul:window attribute.
2001   * This should only be used with non-XUL windows.
2002   */
2003  void setChromeMargin(in int32_t aTop,
2004                       in int32_t aRight,
2005                       in int32_t aBottom,
2006                       in int32_t aLeft);
2007
2008  /**
2009   * Controls the amount of space on each edge of the window that can be
2010   * dragged to resize the window in that direction.
2011   *
2012   * @param aResizeMargin  In CSS pixels, will apply to all four window sides.
2013   */
2014  void setResizeMargin(in int32_t aResizeMargin);
2015
2016  /**
2017   * Returns a JSObject which contains a list of frame uniformities
2018   * when the pref gfx.vsync.collect-scroll-data is enabled.
2019   * Every result contains a layer address and a frame uniformity for that layer.
2020   * A negative frame uniformity value indicates an invalid frame uniformity and an error has occured.
2021   */
2022  [implicit_jscontext] jsval getFrameUniformityTestData();
2023
2024  /*
2025   * Increase the chaos mode activation level. An equivalent number of
2026   * calls to leaveChaosMode must be made in order to restore the original
2027   * chaos mode state. If the activation level is nonzero all chaos mode
2028   * features are activated.
2029   */
2030  void enterChaosMode();
2031
2032  /**
2033   * Decrease the chaos mode activation level. See enterChaosMode().
2034   */
2035  void leaveChaosMode();
2036
2037  /**
2038   * Alerts Gecko of a device reset
2039   */
2040  void triggerDeviceReset();
2041
2042  /**
2043   * Returns whether the document's style set's rule processor for the
2044   * specified level of the cascade is shared by multiple style sets.
2045   * (Used by tests to ensure that certain optimizations do not regress.)
2046   *
2047   * @param aSheetType One of the nsIStyleSheetService.*_SHEET constants.
2048   */
2049  bool hasRuleProcessorUsedByMultipleStyleSets(in unsigned long aSheetType);
2050
2051  /**
2052   * Enable or disable displayport suppression. This is intended to be used by
2053   * testing code, to provide more deterministic behaviour over the displayport
2054   * suppression during tests. Note that this updates a flag, so whatever value
2055   * was last provided is what will be used.
2056   */
2057  void respectDisplayPortSuppression(in boolean aEnabled);
2058
2059  /**
2060   * Set a flag that forces the next reflow interrupt check to return true. This
2061   * can be used by tests to force execution of the interrupted reflow codepaths.
2062   */
2063  void forceReflowInterrupt();
2064
2065  /**
2066   * Terminate the GPU process. Used for testing GPU process restarts.
2067   */
2068  void terminateGPUProcess();
2069
2070  /**
2071    * Returns the GPU process pid, or -1 if there is no GPU process.
2072    */
2073  readonly attribute int32_t gpuProcessPid;
2074
2075  /**
2076   * Adds an EventStates bit to the element.
2077   *
2078   * The state string must be one of the following:
2079   *   * (none yet; but for example "higlighted" for NS_EVENT_STATE_HIGHLIGHTED)
2080   *
2081   * The supported state strings are defined in kManuallyManagedStates
2082   * in nsDOMWindowUtils.cpp.
2083   */
2084  void addManuallyManagedState(in Element element,
2085                               in AString state);
2086
2087  /**
2088   * Removes the specified EventStates bits from the element.
2089   *
2090   * See above for the strings that can be passed for |state|.
2091   */
2092  void removeManuallyManagedState(in Element element,
2093                                  in AString state);
2094
2095  /**
2096   * Returns usage data for a given storage object.
2097   *
2098   * @param aStorage
2099   *    The storage object to get usage data for.
2100   */
2101  int64_t getStorageUsage(in Storage aStorage);
2102
2103  /**
2104   * Returns the directionality of a string using the first-strong character
2105   * algorithm defined in http://unicode.org/reports/tr9/#P2.
2106   *
2107   * @param aString the string to retrieve the direction for.
2108   * @return one of DIRECTION_LTR, DIRECTION_RTL or DIRECTION_NOT_SET depending
2109   *         on the first-strong character found in the string.
2110   */
2111  long getDirectionFromText(in AString aString);
2112
2113  /**
2114   * Calls FrameNeedsReflow on that root frame so that a layout flush
2115   * will be necessary.
2116   *
2117   * This should only be used for testing.
2118   */
2119  void ensureDirtyRootFrame();
2120
2121  /**
2122   * Capture the contents of the current WebRender frame and
2123   * save them to a folder relative to the current working directory.
2124   */
2125  void wrCapture();
2126
2127  /**
2128   * Flag bits for use in |wrStartCaptureSequence|'s |aFlags| argument.
2129   */
2130  const uint32_t WR_CAPTURE_SCENE = 0x1;
2131  const uint32_t WR_CAPTURE_FRAME = 0x2;
2132  const uint32_t WR_CAPTURE_TILE_CACHE = 0x4;
2133  const uint32_t WR_CAPTURE_EXTERNAL_RESOURCES = 0x8;
2134
2135  /**
2136   * Start capturing each WebRender frame to disk.
2137   *
2138   * |aPath| is the name of a new directory to be created to hold the captures.
2139   * it is relative to:
2140   * - the |PUBLIC_STORAGE| environment variable, if set, else
2141   * - the |MOZ_UPLOAD_DIR| environment variable, if set, else
2142   * - the user's home directory, if known, else
2143   * the current directory.
2144   *
2145   * If there is already a directory with the given name, a numeric suffix is
2146   * added to ensure a fresh directory is created. This means that you can't
2147   * be sure your capture directory is actually named |aPath|.
2148   *
2149   * |aFlags| is a set of flags from |webrender::render_api::CaptureBits|.
2150   *
2151   * If there is already a sequence capture in progress, stop it and start a new
2152   * one, with the new path and flags.
2153   */
2154  void wrStartCaptureSequence(in ACString aPath, in uint32_t aFlags);
2155
2156  /**
2157   * Stop a capture begun with |wrStartCaptureSequence|.
2158   */
2159  void wrStopCaptureSequence();
2160
2161  /**
2162   * Toggle recording of composition on and off.
2163   *
2164   * This is equivalent to calling |startCompositionRecorder()| or
2165   * |stopCompositionRecorder(true)|.
2166   */
2167  Promise setCompositionRecording(in boolean aValue);
2168
2169  /**
2170   * Start the composition recorder.
2171   *
2172   * @return A promise that is resolved to true if the composion recorder was
2173   *         started successfully.
2174   */
2175  Promise startCompositionRecording();
2176
2177  /**
2178   * Stop the composition recorder.
2179   *
2180   * @param aWriteToDisk Whether or not the frames should be written to disk.
2181   *                     If false, they will be returned in the promise.
2182   * @return A promise that resolves when the frames have been collected.
2183   *         When |aWriteToDisk| is true, the promise will resolve to |undefined|.
2184   *         Otherwise, the promise will resolve to a |DOMCollectedFrames| dictionary,
2185   *         which contains the timestamps and contents of the captured frames.
2186   */
2187  Promise stopCompositionRecording(in boolean aWriteToDisk);
2188
2189  /**
2190   * Returns whether the document we're associated to has recorded a given CSS
2191   * property via the use counter mechanism.
2192   *
2193   * Throws if there's no document or the property is invalid.
2194   */
2195  bool isCssPropertyRecordedInUseCounter(in ACString aProperty);
2196
2197  /**
2198   * Calls SetInitialViewport on the MobileViewportManager, which effectively
2199   * causes it to refresh all of its internal state and update things that
2200   * need updating.
2201   */
2202  void resetMobileViewportManager();
2203
2204  /**
2205   * NOTE: Currently works only on GTK+.
2206   */
2207  attribute ACString systemFont;
2208
2209  /**
2210   * Returns the number of times this document for this window has
2211   * been painted to the screen.
2212   *
2213   * Use this instead of window.mozPaintCount
2214   */
2215  readonly attribute unsigned long long paintCount;
2216
2217  // These consts are only for testing purposes.
2218  const long DEFAULT_MOUSE_POINTER_ID = 0;
2219  const long DEFAULT_PEN_POINTER_ID   = 1;
2220  const long DEFAULT_TOUCH_POINTER_ID = 2;
2221
2222  // Match mozilla::MouseButton.
2223  const long MOUSE_BUTTON_LEFT_BUTTON   = 0;
2224  const long MOUSE_BUTTON_MIDDLE_BUTTON = 1;
2225  const long MOUSE_BUTTON_RIGHT_BUTTON  = 2;
2226
2227  // Match mozilla::MouseButtonsFlag.
2228  const long MOUSE_BUTTONS_NO_BUTTON = 0x00;
2229  const long MOUSE_BUTTONS_LEFT_BUTTON = 0x01;
2230  const long MOUSE_BUTTONS_RIGHT_BUTTON = 0x02;
2231  const long MOUSE_BUTTONS_MIDDLE_BUTTON = 0x04;
2232  // Typically, "back" button being left side of 5-button
2233  // mice, see "buttons" attribute document of DOM3 Events.
2234  const long MOUSE_BUTTONS_4TH_BUTTON = 0x08;
2235  // Typically, "forward" button being right side of 5-button
2236  // mice, see "buttons" attribute document of DOM3 Events.
2237  const long MOUSE_BUTTONS_5TH_BUTTON = 0x10;
2238  // Buttons are not specified, will be calculated from |aButton|.
2239  const long MOUSE_BUTTONS_NOT_SPECIFIED = -1;
2240
2241  // Return values for getDirectionFromText().
2242  const long DIRECTION_LTR = 0;
2243  const long DIRECTION_RTL = 1;
2244  const long DIRECTION_NOT_SET = 2;
2245
2246  void syncFlushCompositor();
2247
2248  unsigned long long getLayersId();
2249
2250  // Returns true if we are effectively throttling frame requests.
2251  readonly attribute bool effectivelyThrottlesFrameRequests;
2252
2253  // Returns the ID for the underlying window widget, which can
2254  // be compared against the rawId from a nsIMediaDevice to determine
2255  // if the window is being shared.
2256  //
2257  // Using this only makes sense in the parent process, and the function
2258  // will intentionally crash any non-parent process that tries to access
2259  // it.
2260  readonly attribute AString webrtcRawDeviceId;
2261
2262  // Used for testing to check the suspend status.
2263  readonly attribute bool suspendedByBrowsingContextGroup;
2264};
2265
2266[scriptable, uuid(c694e359-7227-4392-a138-33c0cc1f15a6)]
2267interface nsITranslationNodeList : nsISupports {
2268  readonly attribute unsigned long length;
2269  Node item(in unsigned long index);
2270
2271  // A translation root is a block element, or an inline element
2272  // which its parent is not a translation node.
2273  boolean isTranslationRootAtIndex(in unsigned long index);
2274};
2275
2276/**
2277 * JS doesn't do RAII very well. We can use this interface to make remembering
2278 * to destruct an object in a finally clause easier.
2279 */
2280[scriptable, uuid(52e5a996-d0a9-4efc-a6fa-24489c532b19)]
2281interface nsIJSRAIIHelper : nsISupports {
2282  void destruct();
2283};
2284