Bug 1826564 [wpt PR 39394] - Update mypy, a=testonly
[gecko.git] / widget / Screen.h
blobf3f8b4a628af24adbe89982bbf9e5249d8fbed26
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 /**
47 * Return default orientation type that angle is 0.
48 * This returns LandscapePrimary or PortraitPrimary.
50 hal::ScreenOrientation GetDefaultOrientationType() const;
52 float GetDPI() const { return mDPI; }
54 const LayoutDeviceIntRect& GetRect() const { return mRect; }
55 const LayoutDeviceIntRect& GetAvailRect() const { return mAvailRect; }
56 const DesktopToLayoutDeviceScale& GetContentsScaleFactor() const {
57 return mContentsScale;
60 enum class IncludeOSZoom : bool { No, Yes };
61 CSSToLayoutDeviceScale GetCSSToLayoutDeviceScale(IncludeOSZoom) const;
63 private:
64 virtual ~Screen() = default;
66 const LayoutDeviceIntRect mRect;
67 const LayoutDeviceIntRect mAvailRect;
68 const DesktopIntRect mRectDisplayPix;
69 const DesktopIntRect mAvailRectDisplayPix;
70 const uint32_t mPixelDepth;
71 const uint32_t mColorDepth;
72 const uint32_t mRefreshRate;
73 const DesktopToLayoutDeviceScale mContentsScale;
74 const CSSToLayoutDeviceScale mDefaultCssScale;
75 const float mDPI;
76 const hal::ScreenOrientation mScreenOrientation;
77 const OrientationAngle mOrientationAngle;
78 const bool mIsPseudoDisplay;
81 } // namespace widget
82 } // namespace mozilla
84 #endif