/src/mozilla-central/widget/headless/HeadlessScreenHelper.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
7 | | #include "HeadlessScreenHelper.h" |
8 | | |
9 | | #include "prenv.h" |
10 | | #include "mozilla/RefPtr.h" |
11 | | #include "nsTArray.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace widget { |
15 | | |
16 | | /* static */ LayoutDeviceIntRect |
17 | | HeadlessScreenHelper::GetScreenRect() |
18 | 0 | { |
19 | 0 | char *ev = PR_GetEnv("MOZ_HEADLESS_WIDTH"); |
20 | 0 | int width = 1366; |
21 | 0 | if (ev) { |
22 | 0 | width = atoi(ev); |
23 | 0 | } |
24 | 0 | ev = PR_GetEnv("MOZ_HEADLESS_HEIGHT"); |
25 | 0 | int height = 768; |
26 | 0 | if (ev) { |
27 | 0 | height = atoi(ev); |
28 | 0 | } |
29 | 0 | return LayoutDeviceIntRect(0, 0, width, height); |
30 | 0 | } |
31 | | |
32 | | HeadlessScreenHelper::HeadlessScreenHelper() |
33 | 0 | { |
34 | 0 | AutoTArray<RefPtr<Screen>, 1> screenList; |
35 | 0 | LayoutDeviceIntRect rect = GetScreenRect(); |
36 | 0 | RefPtr<Screen> ret = new Screen(rect, rect, |
37 | 0 | 24, 24, |
38 | 0 | DesktopToLayoutDeviceScale(), |
39 | 0 | CSSToLayoutDeviceScale(), |
40 | 0 | 96.0f); |
41 | 0 | screenList.AppendElement(ret.forget()); |
42 | 0 | ScreenManager& screenManager = ScreenManager::GetSingleton(); |
43 | 0 | screenManager.Refresh(std::move(screenList)); |
44 | 0 | } |
45 | | |
46 | | } // namespace widget |
47 | | } // namespace mozilla |