| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "headless/lib/browser/headless_screen.h" | 5 #include "headless/lib/browser/headless_screen.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 bool IsRotationPortrait(display::Display::Rotation rotation) { | 24 bool IsRotationPortrait(display::Display::Rotation rotation) { |
| 25 return rotation == display::Display::ROTATE_90 || | 25 return rotation == display::Display::ROTATE_90 || |
| 26 rotation == display::Display::ROTATE_270; | 26 rotation == display::Display::ROTATE_270; |
| 27 } | 27 } |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 HeadlessScreen* HeadlessScreen::Create(const gfx::Size& size) { | 32 HeadlessScreen* HeadlessScreen::Create(const gfx::Size& size) { |
| 33 const gfx::Size kDefaultSize(800, 600); | 33 return new HeadlessScreen(gfx::Rect(size)); |
| 34 return new HeadlessScreen(gfx::Rect(size.IsEmpty() ? kDefaultSize : size)); | |
| 35 } | 34 } |
| 36 | 35 |
| 37 HeadlessScreen::~HeadlessScreen() {} | 36 HeadlessScreen::~HeadlessScreen() {} |
| 38 | 37 |
| 39 aura::WindowTreeHost* HeadlessScreen::CreateHostForPrimaryDisplay() { | 38 aura::WindowTreeHost* HeadlessScreen::CreateHostForPrimaryDisplay() { |
| 40 DCHECK(!host_); | 39 DCHECK(!host_); |
| 41 host_ = aura::WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel())); | 40 host_ = aura::WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel())); |
| 42 // Some tests don't correctly manage window focus/activation states. | 41 // Some tests don't correctly manage window focus/activation states. |
| 43 // Makes sure InputMethod is default focused so that IME basics can work. | 42 // Makes sure InputMethod is default focused so that IME basics can work. |
| 44 host_->GetInputMethod()->OnFocus(); | 43 host_->GetInputMethod()->OnFocus(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 void HeadlessScreen::RemoveObserver(display::DisplayObserver* observer) {} | 164 void HeadlessScreen::RemoveObserver(display::DisplayObserver* observer) {} |
| 166 | 165 |
| 167 HeadlessScreen::HeadlessScreen(const gfx::Rect& screen_bounds) | 166 HeadlessScreen::HeadlessScreen(const gfx::Rect& screen_bounds) |
| 168 : host_(NULL), ui_scale_(1.0f) { | 167 : host_(NULL), ui_scale_(1.0f) { |
| 169 static int64_t synthesized_display_id = 2000; | 168 static int64_t synthesized_display_id = 2000; |
| 170 display_.set_id(synthesized_display_id++); | 169 display_.set_id(synthesized_display_id++); |
| 171 display_.SetScaleAndBounds(1.0f, screen_bounds); | 170 display_.SetScaleAndBounds(1.0f, screen_bounds); |
| 172 } | 171 } |
| 173 | 172 |
| 174 } // namespace headless | 173 } // namespace headless |
| OLD | NEW |