Bug 1769628 [wpt PR 34081] - Update wpt metadata, a=testonly
[gecko.git] / widget / Screen.h
blobc29c15c01fb12667538ae3477b171628d206531b
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 #ifndef mozilla_widget_Screen_h
8 #define mozilla_widget_Screen_h
10 #include "nsIScreen.h"
12 #include "Units.h"
13 #include "mozilla/HalScreenConfiguration.h" // For hal::ScreenOrientation
15 namespace mozilla {
16 namespace dom {
17 class ScreenDetails;
18 } // namespace dom
20 namespace widget {
22 class Screen final : public nsIScreen {
23 public:
24 NS_DECL_ISUPPORTS
25 NS_DECL_NSISCREEN
27 using OrientationAngle = uint16_t;
28 enum class IsPseudoDisplay : bool { No, Yes };
30 Screen(LayoutDeviceIntRect aRect, LayoutDeviceIntRect aAvailRect,
31 uint32_t aPixelDepth, uint32_t aColorDepth, uint32_t aRefreshRate,
32 DesktopToLayoutDeviceScale aContentsScale,
33 CSSToLayoutDeviceScale aDefaultCssScale, float aDpi, IsPseudoDisplay,
34 hal::ScreenOrientation = hal::ScreenOrientation::None,
35 OrientationAngle = 0);
36 explicit Screen(const dom::ScreenDetails& aScreenDetails);
37 Screen(const Screen& aOther);
39 dom::ScreenDetails ToScreenDetails() const;
41 OrientationAngle GetOrientationAngle() const { return mOrientationAngle; }
42 hal::ScreenOrientation GetOrientationType() const {
43 return mScreenOrientation;
46 float GetDPI() const { return mDPI; }
48 const LayoutDeviceIntRect& GetRect() const { return mRect; }
49 const LayoutDeviceIntRect& GetAvailRect() const { return mAvailRect; }
50 const DesktopToLayoutDeviceScale& GetContentsScaleFactor() const {
51 return mContentsScale;
53 const CSSToLayoutDeviceScale& GetDefaultCSSScaleFactor() const {
54 return mDefaultCssScale;
57 private:
58 virtual ~Screen() = default;
60 const LayoutDeviceIntRect mRect;
61 const LayoutDeviceIntRect mAvailRect;
62 const DesktopIntRect mRectDisplayPix;
63 const DesktopIntRect mAvailRectDisplayPix;
64 const uint32_t mPixelDepth;
65 const uint32_t mColorDepth;
66 const uint32_t mRefreshRate;
67 const DesktopToLayoutDeviceScale mContentsScale;
68 const CSSToLayoutDeviceScale mDefaultCssScale;
69 const float mDPI;
70 const hal::ScreenOrientation mScreenOrientation;
71 const OrientationAngle mOrientationAngle;
72 const bool mIsPseudoDisplay;
75 } // namespace widget
76 } // namespace mozilla
78 #endif