Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / base / nsScreen.h
blobaa4158e94e81cc0c412926e93989f1c56640b026
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 #ifndef nsScreen_h___
7 #define nsScreen_h___
9 #include "mozilla/dom/ScreenBinding.h"
10 #include "mozilla/dom/ScreenLuminance.h"
11 #include "mozilla/dom/ScreenOrientation.h"
12 #include "mozilla/DOMEventTargetHelper.h"
13 #include "mozilla/StaticPrefs_media.h"
14 #include "Units.h"
16 class nsDeviceContext;
18 namespace mozilla {
19 enum class RFPTarget : uint64_t;
22 // Script "screen" object
23 class nsScreen : public mozilla::DOMEventTargetHelper {
24 public:
25 explicit nsScreen(nsPIDOMWindowInner* aWindow);
27 NS_DECL_ISUPPORTS_INHERITED
28 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen,
29 mozilla::DOMEventTargetHelper)
31 nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
33 nsPIDOMWindowOuter* GetOuter() const;
35 int32_t Top() { return GetRect().y; }
36 int32_t Left() { return GetRect().x; }
37 int32_t Width() { return GetRect().Width(); }
38 int32_t Height() { return GetRect().Height(); }
40 int32_t AvailTop() { return GetAvailRect().y; }
41 int32_t AvailLeft() { return GetAvailRect().x; }
42 int32_t AvailWidth() { return GetAvailRect().Width(); }
43 int32_t AvailHeight() { return GetAvailRect().Height(); }
45 int32_t PixelDepth();
46 int32_t ColorDepth() { return PixelDepth(); }
48 // Media Capabilities extension
49 mozilla::dom::ScreenColorGamut ColorGamut() const {
50 return mozilla::dom::ScreenColorGamut::Srgb;
53 already_AddRefed<mozilla::dom::ScreenLuminance> GetLuminance() const {
54 return nullptr;
57 static bool MediaCapabilitiesEnabled(JSContext* aCx, JSObject* aGlobal) {
58 return mozilla::StaticPrefs::media_media_capabilities_screen_enabled();
61 IMPL_EVENT_HANDLER(change);
63 uint16_t GetOrientationAngle() const;
64 mozilla::hal::ScreenOrientation GetOrientationType() const;
66 // Deprecated
67 void GetMozOrientation(nsString& aOrientation,
68 mozilla::dom::CallerType aCallerType) const;
70 IMPL_EVENT_HANDLER(mozorientationchange)
72 // This function is deprecated, use ScreenOrientation API instead.
73 bool MozLockOrientation(const nsAString&) { return false; };
74 bool MozLockOrientation(const mozilla::dom::Sequence<nsString>&) {
75 return false;
77 void MozUnlockOrientation() {}
79 virtual JSObject* WrapObject(JSContext* aCx,
80 JS::Handle<JSObject*> aGivenProto) override;
82 mozilla::dom::ScreenOrientation* Orientation() const;
83 mozilla::dom::ScreenOrientation* GetOrientationIfExists() const {
84 return mScreenOrientation.get();
87 protected:
88 nsDeviceContext* GetDeviceContext() const;
89 mozilla::CSSIntRect GetRect();
90 mozilla::CSSIntRect GetAvailRect();
91 mozilla::CSSIntRect GetWindowInnerRect();
93 private:
94 virtual ~nsScreen();
96 bool ShouldResistFingerprinting(mozilla::RFPTarget aTarget) const;
98 mozilla::dom::Document* TopContentDocumentInRDMPane() const;
100 RefPtr<mozilla::dom::ScreenOrientation> mScreenOrientation;
103 #endif /* nsScreen_h___ */