Line data Source code
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 0 : HeadlessScreenHelper::GetScreenRect()
18 : {
19 0 : char *ev = PR_GetEnv("MOZ_HEADLESS_WIDTH");
20 0 : int width = 1366;
21 0 : if (ev) {
22 0 : width = atoi(ev);
23 : }
24 0 : ev = PR_GetEnv("MOZ_HEADLESS_HEIGHT");
25 0 : int height = 768;
26 0 : if (ev) {
27 0 : height = atoi(ev);
28 : }
29 0 : return LayoutDeviceIntRect(0, 0, width, height);
30 : }
31 :
32 0 : HeadlessScreenHelper::HeadlessScreenHelper()
33 : {
34 0 : AutoTArray<RefPtr<Screen>, 1> screenList;
35 0 : LayoutDeviceIntRect rect = GetScreenRect();
36 : RefPtr<Screen> ret = new Screen(rect, rect,
37 : 24, 24,
38 0 : DesktopToLayoutDeviceScale(),
39 0 : CSSToLayoutDeviceScale());
40 0 : screenList.AppendElement(ret.forget());
41 0 : ScreenManager& screenManager = ScreenManager::GetSingleton();
42 0 : screenManager.Refresh(Move(screenList));
43 0 : }
44 :
45 : } // namespace widget
46 : } // namespace mozilla
|