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/. */ 6 7 #ifndef mozilla_widget_Screen_h 8 #define mozilla_widget_Screen_h 9 10 #include "nsIScreen.h" 11 12 #include "Units.h" 13 #include "mozilla/HalScreenConfiguration.h" // For hal::ScreenOrientation 14 15 namespace mozilla { 16 namespace dom { 17 class ScreenDetails; 18 } // namespace dom 19 20 namespace widget { 21 22 class Screen final : public nsIScreen { 23 public: 24 NS_DECL_ISUPPORTS 25 NS_DECL_NSISCREEN 26 27 using OrientationAngle = uint16_t; 28 29 Screen(LayoutDeviceIntRect aRect, LayoutDeviceIntRect aAvailRect, 30 uint32_t aPixelDepth, uint32_t aColorDepth, 31 DesktopToLayoutDeviceScale aContentsScale, 32 CSSToLayoutDeviceScale aDefaultCssScale, float aDpi, 33 hal::ScreenOrientation = hal::ScreenOrientation::None, 34 OrientationAngle = 0); 35 explicit Screen(const dom::ScreenDetails& aScreenDetails); 36 Screen(const Screen& aOther); 37 38 dom::ScreenDetails ToScreenDetails() const; 39 GetOrientationAngle()40 OrientationAngle GetOrientationAngle() const { return mOrientationAngle; } GetOrientationType()41 hal::ScreenOrientation GetOrientationType() const { 42 return mScreenOrientation; 43 } 44 GetDPI()45 float GetDPI() const { return mDPI; } 46 47 private: 48 virtual ~Screen() = default; 49 50 const LayoutDeviceIntRect mRect; 51 const LayoutDeviceIntRect mAvailRect; 52 const DesktopIntRect mRectDisplayPix; 53 const DesktopIntRect mAvailRectDisplayPix; 54 const uint32_t mPixelDepth; 55 const uint32_t mColorDepth; 56 const DesktopToLayoutDeviceScale mContentsScale; 57 const CSSToLayoutDeviceScale mDefaultCssScale; 58 const float mDPI; 59 const hal::ScreenOrientation mScreenOrientation; 60 const OrientationAngle mOrientationAngle; 61 }; 62 63 } // namespace widget 64 } // namespace mozilla 65 66 #endif 67