1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include
"nsISupports.idl"
12 namespace mozilla
::dom
{
13 // TODO(zrhoffman, bug 1444515): ScreenColorGamut should be forward-declared
14 // using `webidl` once the webidl identifier supports enums.
15 enum class ScreenColorGamut
: uint8_t
;
16 } // namespace mozilla::dom
19 * The display type of nsIScreen belongs to.
21 enum class DisplayType
: int32_t
{
22 DISPLAY_PRIMARY
, // primary screen
23 DISPLAY_EXTERNAL
, // wired displays, such as HDMI, DisplayPort, etc.
24 DISPLAY_VIRTUAL
// wireless displays, such as Chromecast, WiFi-Display, etc.
28 native ScreenColorGamut
(mozilla
::dom
::ScreenColorGamut
);
30 [scriptable
, builtinclass
, uuid(826e80c8
-d70f
-42e2
-8aa9
-82c05f2a370a
)]
31 interface nsIScreen
: nsISupports
34 * These report screen dimensions in (screen-specific) device pixels
36 void GetRect
(out long left
, out long top
, out long width
, out long height
);
37 void GetAvailRect
(out long left
, out long top
, out long width
, out long height
);
40 mozilla
::LayoutDeviceIntRect GetRect
() {
41 int32_t left
= 0, top
= 0, width
= 0, height
= 0;
42 GetRect
(&left
, &top
, &width
, &height
);
43 return
{left
, top
, width
, height
};
46 mozilla
::LayoutDeviceIntRect GetAvailRect
() {
47 int32_t left
= 0, top
= 0, width
= 0, height
= 0;
48 GetAvailRect
(&left
, &top
, &width
, &height
);
49 return
{left
, top
, width
, height
};
54 * And these report in desktop pixels
56 void GetRectDisplayPix
(out long left
, out long top
, out long width
, out long height
);
57 void GetAvailRectDisplayPix
(out long left
, out long top
, out long width
, out long height
);
60 mozilla
::DesktopIntRect GetRectDisplayPix
() {
61 int32_t left
= 0, top
= 0, width
= 0, height
= 0;
62 GetRectDisplayPix
(&left
, &top
, &width
, &height
);
63 return
{left
, top
, width
, height
};
66 mozilla
::DesktopIntRect GetAvailRectDisplayPix
() {
67 int32_t left
= 0, top
= 0, width
= 0, height
= 0;
68 GetAvailRectDisplayPix
(&left
, &top
, &width
, &height
);
69 return
{left
, top
, width
, height
};
73 [infallible
] readonly attribute
long pixelDepth
;
74 [infallible
] readonly attribute
long colorDepth
;
76 * ScreenColorGamut is native type, which cannot be declared [infallible].
78 readonly attribute ScreenColorGamut colorGamut
;
81 * The number of device pixels per desktop pixel for this screen (for
82 * hidpi configurations where there may be multiple device pixels per
83 * desktop px and/or per CSS px).
85 * This seems poorly named (something like devicePixelsPerDesktopPixel
86 * would be more accurate/explicit), but given that it is exposed to
87 * front-end code and may also be used by add-ons, it's probably not
88 * worth the disruption of changing it.
90 * Returns 1.0 if HiDPI mode is disabled or unsupported, or if the
91 * host OS uses device pixels as its desktop pixel units (e.g. Windows 7 or
92 * GTK/X11). Per-monitor DPI is available in Windows 8.1+, GTK/Wayland or
95 [infallible
] readonly attribute
double contentsScaleFactor
;
98 * The default number of device pixels per unscaled CSS pixel for this
99 * screen. This is probably what contentsScaleFactor originally meant
100 * to be, prior to confusion between CSS pixels and desktop pixel units.
102 [infallible
] readonly attribute
double defaultCSSScaleFactor
;
106 mozilla
::DesktopToLayoutDeviceScale GetDesktopToLayoutDeviceScale
() {
107 return mozilla
::DesktopToLayoutDeviceScale
(GetContentsScaleFactor
());
110 mozilla
::CSSToLayoutDeviceScale GetCSSToLayoutDeviceScale
() {
111 return mozilla
::CSSToLayoutDeviceScale
(GetDefaultCSSScaleFactor
());
114 mozilla
::CSSToDesktopScale GetCSSToDesktopScale
() {
115 return GetCSSToLayoutDeviceScale
() / GetDesktopToLayoutDeviceScale
();
120 * The DPI of the screen.
122 [infallible
] readonly attribute
float dpi
;
124 /** The target screen refresh rate, in Hz, or 0 if unknown */
125 [infallible
] readonly attribute
long refreshRate
;
126 [infallible
] readonly attribute
boolean isPseudoDisplay
;