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"
13 * The display type of nsIScreen belongs to.
15 enum class DisplayType
: int32_t
{
16 DISPLAY_PRIMARY
, // primary screen
17 DISPLAY_EXTERNAL
, // wired displays, such as HDMI, DisplayPort, etc.
18 DISPLAY_VIRTUAL
// wireless displays, such as Chromecast, WiFi-Display, etc.
22 [scriptable
, builtinclass
, uuid(826e80c8
-d70f
-42e2
-8aa9
-82c05f2a370a
)]
23 interface nsIScreen
: nsISupports
26 * These report screen dimensions in (screen-specific) device pixels
28 void GetRect
(out long left
, out long top
, out long width
, out long height
);
29 void GetAvailRect
(out long left
, out long top
, out long width
, out long height
);
32 mozilla
::LayoutDeviceIntRect GetRect
() {
33 int32_t left
= 0, top
= 0, width
= 0, height
= 0;
34 GetRect
(&left
, &top
, &width
, &height
);
35 return
{left
, top
, width
, height
};
38 mozilla
::LayoutDeviceIntRect GetAvailRect
() {
39 int32_t left
= 0, top
= 0, width
= 0, height
= 0;
40 GetAvailRect
(&left
, &top
, &width
, &height
);
41 return
{left
, top
, width
, height
};
46 * And these report in desktop pixels
48 void GetRectDisplayPix
(out long left
, out long top
, out long width
, out long height
);
49 void GetAvailRectDisplayPix
(out long left
, out long top
, out long width
, out long height
);
52 mozilla
::DesktopIntRect GetRectDisplayPix
() {
53 int32_t left
= 0, top
= 0, width
= 0, height
= 0;
54 GetRectDisplayPix
(&left
, &top
, &width
, &height
);
55 return
{left
, top
, width
, height
};
58 mozilla
::DesktopIntRect GetAvailRectDisplayPix
() {
59 int32_t left
= 0, top
= 0, width
= 0, height
= 0;
60 GetAvailRectDisplayPix
(&left
, &top
, &width
, &height
);
61 return
{left
, top
, width
, height
};
65 [infallible
] readonly attribute
long pixelDepth
;
66 [infallible
] readonly attribute
long colorDepth
;
69 * The number of device pixels per desktop pixel for this screen (for
70 * hidpi configurations where there may be multiple device pixels per
71 * desktop px and/or per CSS px).
73 * This seems poorly named (something like devicePixelsPerDesktopPixel
74 * would be more accurate/explicit), but given that it is exposed to
75 * front-end code and may also be used by add-ons, it's probably not
76 * worth the disruption of changing it.
78 * Returns 1.0 if HiDPI mode is disabled or unsupported, or if the
79 * host OS uses device pixels as its desktop pixel units (e.g. Windows 7 or
80 * GTK/X11). Per-monitor DPI is available in Windows 8.1+, GTK/Wayland or
83 [infallible
] readonly attribute
double contentsScaleFactor
;
86 * The default number of device pixels per unscaled CSS pixel for this
87 * screen. This is probably what contentsScaleFactor originally meant
88 * to be, prior to confusion between CSS pixels and desktop pixel units.
90 [infallible
] readonly attribute
double defaultCSSScaleFactor
;
94 mozilla
::DesktopToLayoutDeviceScale GetDesktopToLayoutDeviceScale
() {
95 return mozilla
::DesktopToLayoutDeviceScale
(GetContentsScaleFactor
());
98 mozilla
::CSSToLayoutDeviceScale GetCSSToLayoutDeviceScale
() {
99 return mozilla
::CSSToLayoutDeviceScale
(GetDefaultCSSScaleFactor
());
102 mozilla
::CSSToDesktopScale GetCSSToDesktopScale
() {
103 return GetCSSToLayoutDeviceScale
() / GetDesktopToLayoutDeviceScale
();
108 * The DPI of the screen.
110 [infallible
] readonly attribute
float dpi
;
112 /** The target screen refresh rate, in Hz, or 0 if unknown */
113 [infallible
] readonly attribute
long refreshRate
;
114 [infallible
] readonly attribute
boolean isPseudoDisplay
;