Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/widget/Screen.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */
2
/* vim: set sw=4 ts=8 et 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
#include "Screen.h"
8
9
#include "mozilla/dom/DOMTypes.h"
10
11
namespace mozilla {
12
namespace widget {
13
14
NS_IMPL_ISUPPORTS(Screen, nsIScreen)
15
16
Screen::Screen(LayoutDeviceIntRect aRect, LayoutDeviceIntRect aAvailRect,
17
               uint32_t aPixelDepth, uint32_t aColorDepth,
18
               DesktopToLayoutDeviceScale aContentsScale,
19
               CSSToLayoutDeviceScale aDefaultCssScale,
20
               float aDPI)
21
  : mRect(aRect)
22
  , mAvailRect(aAvailRect)
23
  , mRectDisplayPix(RoundedToInt(aRect / aContentsScale))
24
  , mAvailRectDisplayPix(RoundedToInt(aAvailRect / aContentsScale))
25
  , mPixelDepth(aPixelDepth)
26
  , mColorDepth(aColorDepth)
27
  , mContentsScale(aContentsScale)
28
  , mDefaultCssScale(aDefaultCssScale)
29
  , mDPI(aDPI)
30
0
{
31
0
}
32
33
Screen::Screen(const mozilla::dom::ScreenDetails& aScreen)
34
  : mRect(aScreen.rect())
35
  , mAvailRect(aScreen.availRect())
36
  , mRectDisplayPix(aScreen.rectDisplayPix())
37
  , mAvailRectDisplayPix(aScreen.availRectDisplayPix())
38
  , mPixelDepth(aScreen.pixelDepth())
39
  , mColorDepth(aScreen.colorDepth())
40
  , mContentsScale(aScreen.contentsScaleFactor())
41
  , mDefaultCssScale(aScreen.defaultCSSScaleFactor())
42
  , mDPI(aScreen.dpi())
43
0
{
44
0
}
45
46
Screen::Screen(const Screen& aOther)
47
  : mRect(aOther.mRect)
48
  , mAvailRect(aOther.mAvailRect)
49
  , mRectDisplayPix(aOther.mRectDisplayPix)
50
  , mAvailRectDisplayPix(aOther.mAvailRectDisplayPix)
51
  , mPixelDepth(aOther.mPixelDepth)
52
  , mColorDepth(aOther.mColorDepth)
53
  , mContentsScale(aOther.mContentsScale)
54
  , mDefaultCssScale(aOther.mDefaultCssScale)
55
  , mDPI(aOther.mDPI)
56
0
{
57
0
}
58
59
mozilla::dom::ScreenDetails
60
Screen::ToScreenDetails()
61
0
{
62
0
  return mozilla::dom::ScreenDetails(
63
0
    mRect, mRectDisplayPix, mAvailRect, mAvailRectDisplayPix,
64
0
    mPixelDepth, mColorDepth, mContentsScale, mDefaultCssScale, mDPI);
65
0
}
66
67
NS_IMETHODIMP
68
Screen::GetRect(int32_t* aOutLeft,
69
                int32_t* aOutTop,
70
                int32_t* aOutWidth,
71
                int32_t* aOutHeight)
72
0
{
73
0
  mRect.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight);
74
0
  return NS_OK;
75
0
}
76
77
NS_IMETHODIMP
78
Screen::GetRectDisplayPix(int32_t* aOutLeft,
79
                          int32_t* aOutTop,
80
                          int32_t* aOutWidth,
81
                          int32_t* aOutHeight)
82
0
{
83
0
  mRectDisplayPix.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight);
84
0
  return NS_OK;
85
0
}
86
87
NS_IMETHODIMP
88
Screen::GetAvailRect(int32_t* aOutLeft,
89
                     int32_t* aOutTop,
90
                     int32_t* aOutWidth,
91
                     int32_t* aOutHeight)
92
0
{
93
0
  mAvailRect.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight);
94
0
  return NS_OK;
95
0
}
96
97
NS_IMETHODIMP
98
Screen::GetAvailRectDisplayPix(int32_t* aOutLeft,
99
                               int32_t* aOutTop,
100
                               int32_t* aOutWidth,
101
                               int32_t* aOutHeight)
102
0
{
103
0
  mAvailRectDisplayPix.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight);
104
0
  return NS_OK;
105
0
}
106
107
NS_IMETHODIMP
108
Screen::GetPixelDepth(int32_t* aPixelDepth)
109
0
{
110
0
  *aPixelDepth = mPixelDepth;
111
0
  return NS_OK;
112
0
}
113
114
NS_IMETHODIMP
115
Screen::GetColorDepth(int32_t* aColorDepth)
116
0
{
117
0
  *aColorDepth = mColorDepth;
118
0
  return NS_OK;
119
0
}
120
121
NS_IMETHODIMP
122
Screen::GetContentsScaleFactor(double *aOutScale)
123
0
{
124
0
  *aOutScale = mContentsScale.scale;
125
0
  return NS_OK;
126
0
}
127
128
NS_IMETHODIMP
129
Screen::GetDefaultCSSScaleFactor(double *aOutScale)
130
0
{
131
0
  double scale = nsIWidget::DefaultScaleOverride();
132
0
  if (scale > 0.0) {
133
0
    *aOutScale = scale;
134
0
  } else {
135
0
    *aOutScale = mDefaultCssScale.scale;
136
0
  }
137
0
  return NS_OK;
138
0
}
139
140
NS_IMETHODIMP
141
Screen::GetDpi(float* aDPI)
142
0
{
143
0
  *aDPI = mDPI;
144
0
  return NS_OK;
145
0
}
146
147
} // namespace widget
148
} // namespace mozilla