Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsScreen_h___
6 #define nsScreen_h___
8 #include "mozilla/Attributes.h"
9 #include "mozilla/dom/ScreenOrientation.h"
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/ErrorResult.h"
12 #include "mozilla/HalScreenConfiguration.h"
13 #include "nsIDOMScreen.h"
14 #include "nsCOMPtr.h"
15 #include "nsRect.h"
17 class nsDeviceContext;
19 // Script "screen" object
20 class nsScreen : public mozilla::DOMEventTargetHelper
21 , public nsIDOMScreen
22 , public mozilla::hal::ScreenConfigurationObserver
23 {
24 typedef mozilla::ErrorResult ErrorResult;
25 public:
26 static already_AddRefed<nsScreen> Create(nsPIDOMWindow* aWindow);
28 NS_DECL_ISUPPORTS_INHERITED
29 NS_DECL_NSIDOMSCREEN
30 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(mozilla::DOMEventTargetHelper)
32 nsPIDOMWindow* GetParentObject() const
33 {
34 return GetOwner();
35 }
37 int32_t GetTop(ErrorResult& aRv)
38 {
39 nsRect rect;
40 aRv = GetRect(rect);
41 return rect.y;
42 }
44 int32_t GetLeft(ErrorResult& aRv)
45 {
46 nsRect rect;
47 aRv = GetRect(rect);
48 return rect.x;
49 }
51 int32_t GetWidth(ErrorResult& aRv)
52 {
53 nsRect rect;
54 if (IsDeviceSizePageSize()) {
55 nsCOMPtr<nsPIDOMWindow> owner = GetOwner();
56 if (owner) {
57 int32_t innerWidth = 0;
58 aRv = owner->GetInnerWidth(&innerWidth);
59 return innerWidth;
60 }
61 }
63 aRv = GetRect(rect);
64 return rect.width;
65 }
67 int32_t GetHeight(ErrorResult& aRv)
68 {
69 nsRect rect;
70 if (IsDeviceSizePageSize()) {
71 nsCOMPtr<nsPIDOMWindow> owner = GetOwner();
72 if (owner) {
73 int32_t innerHeight = 0;
74 aRv = owner->GetInnerHeight(&innerHeight);
75 return innerHeight;
76 }
77 }
79 aRv = GetRect(rect);
80 return rect.height;
81 }
83 int32_t GetPixelDepth(ErrorResult& aRv);
84 int32_t GetColorDepth(ErrorResult& aRv)
85 {
86 return GetPixelDepth(aRv);
87 }
89 int32_t GetAvailTop(ErrorResult& aRv)
90 {
91 nsRect rect;
92 aRv = GetAvailRect(rect);
93 return rect.y;
94 }
96 int32_t GetAvailLeft(ErrorResult& aRv)
97 {
98 nsRect rect;
99 aRv = GetAvailRect(rect);
100 return rect.x;
101 }
103 int32_t GetAvailWidth(ErrorResult& aRv)
104 {
105 nsRect rect;
106 aRv = GetAvailRect(rect);
107 return rect.width;
108 }
110 int32_t GetAvailHeight(ErrorResult& aRv)
111 {
112 nsRect rect;
113 aRv = GetAvailRect(rect);
114 return rect.height;
115 }
117 void GetMozOrientation(nsString& aOrientation);
119 IMPL_EVENT_HANDLER(mozorientationchange)
121 bool MozLockOrientation(const nsAString& aOrientation, ErrorResult& aRv);
122 bool MozLockOrientation(const mozilla::dom::Sequence<nsString>& aOrientations, ErrorResult& aRv);
123 void MozUnlockOrientation();
125 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
127 void Notify(const mozilla::hal::ScreenConfiguration& aConfiguration);
129 protected:
130 nsDeviceContext* GetDeviceContext();
131 nsresult GetRect(nsRect& aRect);
132 nsresult GetAvailRect(nsRect& aRect);
133 bool IsChrome();
134 nsresult GetDOMWindow(nsIDOMWindow **aResult);
135 nsresult GetWindowInnerRect(nsRect& aRect);
137 mozilla::dom::ScreenOrientation mOrientation;
139 private:
140 class FullScreenEventListener MOZ_FINAL : public nsIDOMEventListener
141 {
142 public:
143 FullScreenEventListener() {};
145 NS_DECL_ISUPPORTS
146 NS_DECL_NSIDOMEVENTLISTENER
147 };
149 nsScreen(nsPIDOMWindow* aWindow);
150 virtual ~nsScreen();
152 enum LockPermission {
153 LOCK_DENIED,
154 FULLSCREEN_LOCK_ALLOWED,
155 LOCK_ALLOWED
156 };
158 LockPermission GetLockOrientationPermission() const;
160 bool IsDeviceSizePageSize();
162 nsRefPtr<FullScreenEventListener> mEventListener;
163 };
165 #endif /* nsScreen_h___ */