2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-01-29 01:24:29 +03:00
|
|
|
#ifndef nsScreen_h___
|
|
|
|
#define nsScreen_h___
|
|
|
|
|
2012-10-14 11:39:34 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-05-09 01:36:07 +04:00
|
|
|
#include "mozilla/dom/ScreenOrientation.h"
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2012-10-14 11:39:34 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
1999-01-29 01:24:29 +03:00
|
|
|
#include "nsIDOMScreen.h"
|
2003-07-03 06:49:06 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2012-10-14 11:40:11 +04:00
|
|
|
#include "nsRect.h"
|
2000-02-08 16:40:10 +03:00
|
|
|
|
2011-04-17 05:22:44 +04:00
|
|
|
class nsDeviceContext;
|
1999-01-29 01:24:29 +03:00
|
|
|
|
|
|
|
// Script "screen" object
|
2014-04-01 10:13:50 +04:00
|
|
|
class nsScreen : public mozilla::DOMEventTargetHelper
|
2012-03-14 14:10:48 +04:00
|
|
|
, public nsIDOMScreen
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
{
|
2012-10-14 11:39:34 +04:00
|
|
|
typedef mozilla::ErrorResult ErrorResult;
|
1999-01-29 01:24:29 +03:00
|
|
|
public:
|
2016-01-30 20:05:36 +03:00
|
|
|
static already_AddRefed<nsScreen> Create(nsPIDOMWindowInner* aWindow);
|
1999-01-29 01:24:29 +03:00
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2007-01-25 02:31:12 +03:00
|
|
|
NS_DECL_NSIDOMSCREEN
|
2015-08-19 00:55:21 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen, mozilla::DOMEventTargetHelper)
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(mozilla::DOMEventTargetHelper)
|
2012-03-14 14:10:48 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* GetParentObject() const
|
2012-10-14 11:40:11 +04:00
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowOuter* GetOuter() const;
|
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
int32_t GetTop(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
aRv = GetRect(rect);
|
|
|
|
return rect.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetLeft(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
aRv = GetRect(rect);
|
|
|
|
return rect.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetWidth(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
2013-11-07 17:40:23 +04:00
|
|
|
if (IsDeviceSizePageSize()) {
|
2016-01-30 20:05:36 +03:00
|
|
|
if (nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner()) {
|
2013-11-07 17:40:23 +04:00
|
|
|
int32_t innerWidth = 0;
|
|
|
|
aRv = owner->GetInnerWidth(&innerWidth);
|
|
|
|
return innerWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
aRv = GetRect(rect);
|
|
|
|
return rect.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetHeight(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
2013-11-07 17:40:23 +04:00
|
|
|
if (IsDeviceSizePageSize()) {
|
2016-01-30 20:05:36 +03:00
|
|
|
if (nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner()) {
|
2013-11-07 17:40:23 +04:00
|
|
|
int32_t innerHeight = 0;
|
|
|
|
aRv = owner->GetInnerHeight(&innerHeight);
|
|
|
|
return innerHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-14 11:40:11 +04:00
|
|
|
aRv = GetRect(rect);
|
|
|
|
return rect.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetPixelDepth(ErrorResult& aRv);
|
|
|
|
int32_t GetColorDepth(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
return GetPixelDepth(aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetAvailTop(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
aRv = GetAvailRect(rect);
|
|
|
|
return rect.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetAvailLeft(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
aRv = GetAvailRect(rect);
|
|
|
|
return rect.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetAvailWidth(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
aRv = GetAvailRect(rect);
|
|
|
|
return rect.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t GetAvailHeight(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
aRv = GetAvailRect(rect);
|
|
|
|
return rect.height;
|
|
|
|
}
|
|
|
|
|
2015-08-19 00:55:21 +03:00
|
|
|
// Deprecated
|
|
|
|
void GetMozOrientation(nsString& aOrientation) const;
|
2012-10-14 11:40:11 +04:00
|
|
|
|
2012-11-09 20:00:25 +04:00
|
|
|
IMPL_EVENT_HANDLER(mozorientationchange)
|
2012-10-14 11:40:11 +04:00
|
|
|
|
2012-10-14 11:39:34 +04:00
|
|
|
bool MozLockOrientation(const nsAString& aOrientation, ErrorResult& aRv);
|
|
|
|
bool MozLockOrientation(const mozilla::dom::Sequence<nsString>& aOrientations, ErrorResult& aRv);
|
2012-10-14 11:40:11 +04:00
|
|
|
void MozUnlockOrientation();
|
2012-10-14 11:39:34 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2012-10-14 11:40:11 +04:00
|
|
|
|
2015-08-19 00:55:21 +03:00
|
|
|
mozilla::dom::ScreenOrientation* Orientation() const;
|
2000-02-08 16:40:10 +03:00
|
|
|
|
1999-01-29 01:24:29 +03:00
|
|
|
protected:
|
2011-04-17 05:22:44 +04:00
|
|
|
nsDeviceContext* GetDeviceContext();
|
2003-09-20 01:06:52 +04:00
|
|
|
nsresult GetRect(nsRect& aRect);
|
|
|
|
nsresult GetAvailRect(nsRect& aRect);
|
2015-06-07 16:02:00 +03:00
|
|
|
nsresult GetWindowInnerRect(nsRect& aRect);
|
2003-09-20 01:06:52 +04:00
|
|
|
|
2011-12-04 21:07:00 +04:00
|
|
|
private:
|
2016-01-30 20:05:36 +03:00
|
|
|
explicit nsScreen(nsPIDOMWindowInner* aWindow);
|
2012-03-14 14:10:48 +04:00
|
|
|
virtual ~nsScreen();
|
|
|
|
|
2013-11-07 17:40:23 +04:00
|
|
|
bool IsDeviceSizePageSize();
|
|
|
|
|
2015-06-07 16:02:00 +03:00
|
|
|
bool ShouldResistFingerprinting() const;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::dom::ScreenOrientation> mScreenOrientation;
|
1999-01-29 01:24:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsScreen_h___ */
|