Bug 1665252 - remove allowpaymentrequest attribute from HTMLIFrameElement r=dom-worke...
[gecko.git] / dom / base / nsScreen.h
blobec5e29bf3ba3414ea55cb8bf2daffe9399fa6b7b
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/Attributes.h"
10 #include "mozilla/dom/ScreenBinding.h"
11 #include "mozilla/dom/ScreenLuminance.h"
12 #include "mozilla/dom/ScreenOrientation.h"
13 #include "mozilla/DOMEventTargetHelper.h"
14 #include "mozilla/ErrorResult.h"
15 #include "mozilla/StaticPrefs_media.h"
16 #include "nsCOMPtr.h"
17 #include "nsRect.h"
19 class nsDeviceContext;
21 // Script "screen" object
22 class nsScreen : public mozilla::DOMEventTargetHelper {
23 typedef mozilla::ErrorResult ErrorResult;
25 public:
26 static already_AddRefed<nsScreen> Create(nsPIDOMWindowInner* aWindow);
28 NS_DECL_ISUPPORTS_INHERITED
29 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen,
30 mozilla::DOMEventTargetHelper)
32 nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
34 nsPIDOMWindowOuter* GetOuter() const;
36 int32_t GetTop(ErrorResult& aRv) {
37 nsRect rect;
38 aRv = GetRect(rect);
39 return rect.y;
42 int32_t GetLeft(ErrorResult& aRv) {
43 nsRect rect;
44 aRv = GetRect(rect);
45 return rect.x;
48 int32_t GetWidth(ErrorResult& aRv) {
49 nsRect rect;
50 aRv = GetRect(rect);
51 return rect.Width();
54 int32_t GetHeight(ErrorResult& aRv) {
55 nsRect rect;
56 aRv = GetRect(rect);
57 return rect.Height();
60 int32_t GetPixelDepth(ErrorResult& aRv);
61 int32_t GetColorDepth(ErrorResult& aRv) { return GetPixelDepth(aRv); }
63 int32_t GetAvailTop(ErrorResult& aRv) {
64 nsRect rect;
65 aRv = GetAvailRect(rect);
66 return rect.y;
69 int32_t GetAvailLeft(ErrorResult& aRv) {
70 nsRect rect;
71 aRv = GetAvailRect(rect);
72 return rect.x;
75 int32_t GetAvailWidth(ErrorResult& aRv) {
76 nsRect rect;
77 aRv = GetAvailRect(rect);
78 return rect.Width();
81 int32_t GetAvailHeight(ErrorResult& aRv) {
82 nsRect rect;
83 aRv = GetAvailRect(rect);
84 return rect.Height();
87 // Media Capabilities extension
88 mozilla::dom::ScreenColorGamut ColorGamut() const {
89 return mozilla::dom::ScreenColorGamut::Srgb;
92 already_AddRefed<mozilla::dom::ScreenLuminance> GetLuminance() const {
93 return nullptr;
96 static bool MediaCapabilitiesEnabled(JSContext* aCx, JSObject* aGlobal) {
97 return mozilla::StaticPrefs::media_media_capabilities_screen_enabled();
100 IMPL_EVENT_HANDLER(change);
102 // Deprecated
103 void GetMozOrientation(nsString& aOrientation,
104 mozilla::dom::CallerType aCallerType) const;
106 IMPL_EVENT_HANDLER(mozorientationchange)
108 bool MozLockOrientation(const nsAString& aOrientation, ErrorResult& aRv);
109 bool MozLockOrientation(const mozilla::dom::Sequence<nsString>& aOrientations,
110 ErrorResult& aRv);
111 void MozUnlockOrientation();
113 virtual JSObject* WrapObject(JSContext* aCx,
114 JS::Handle<JSObject*> aGivenProto) override;
116 mozilla::dom::ScreenOrientation* Orientation() const;
118 protected:
119 nsDeviceContext* GetDeviceContext();
120 nsresult GetRect(nsRect& aRect);
121 nsresult GetAvailRect(nsRect& aRect);
122 nsresult GetWindowInnerRect(nsRect& aRect);
124 private:
125 explicit nsScreen(nsPIDOMWindowInner* aWindow);
126 virtual ~nsScreen();
128 bool ShouldResistFingerprinting() const;
130 mozilla::dom::Document* TopContentDocumentInRDMPane() const;
132 RefPtr<mozilla::dom::ScreenOrientation> mScreenOrientation;
135 #endif /* nsScreen_h___ */