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