Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Unified Diff: headless/lib/browser/headless_screen.cc

Issue 1674263002: headless: Initial headless embedder API implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fine, no console logging Mr. Presubmit. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/lib/browser/headless_screen.h ('k') | headless/lib/browser/headless_url_request_context_getter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/browser/headless_screen.cc
diff --git a/ui/aura/test/test_screen.cc b/headless/lib/browser/headless_screen.cc
similarity index 61%
copy from ui/aura/test/test_screen.cc
copy to headless/lib/browser/headless_screen.cc
index 8a791571d05c39c7f949c87136c1abac067d7ccc..6d6f6074c7349e970873e6c6fe00a3fa274d553d 100644
--- a/ui/aura/test/test_screen.cc
+++ b/headless/lib/browser/headless_screen.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/aura/test/test_screen.h"
+#include "headless/lib/browser/headless_screen.h"
#include <stdint.h>
@@ -17,7 +17,7 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen.h"
-namespace aura {
+namespace headless {
namespace {
@@ -29,19 +29,16 @@ bool IsRotationPortrait(gfx::Display::Rotation rotation) {
} // namespace
// static
-TestScreen* TestScreen::Create(const gfx::Size& size) {
+HeadlessScreen* HeadlessScreen::Create(const gfx::Size& size) {
const gfx::Size kDefaultSize(800, 600);
- // Use (0,0) because the desktop aura tests are executed in
- // native environment where the display's origin is (0,0).
- return new TestScreen(gfx::Rect(size.IsEmpty() ? kDefaultSize : size));
+ return new HeadlessScreen(gfx::Rect(size.IsEmpty() ? kDefaultSize : size));
}
-TestScreen::~TestScreen() {
-}
+HeadlessScreen::~HeadlessScreen() {}
-WindowTreeHost* TestScreen::CreateHostForPrimaryDisplay() {
+aura::WindowTreeHost* HeadlessScreen::CreateHostForPrimaryDisplay() {
DCHECK(!host_);
- host_ = WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel()));
+ host_ = aura::WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel()));
// Some tests don't correctly manage window focus/activation states.
// Makes sure InputMethod is default focused so that IME basics can work.
host_->GetInputMethod()->OnFocus();
@@ -50,13 +47,12 @@ WindowTreeHost* TestScreen::CreateHostForPrimaryDisplay() {
return host_;
}
-void TestScreen::SetDeviceScaleFactor(float device_scale_factor) {
+void HeadlessScreen::SetDeviceScaleFactor(float device_scale_factor) {
gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
- host_->OnHostResized(bounds_in_pixel.size());
}
-void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) {
+void HeadlessScreen::SetDisplayRotation(gfx::Display::Rotation rotation) {
gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
gfx::Rect new_bounds(bounds_in_pixel);
if (IsRotationPortrait(rotation) != IsRotationPortrait(display_.rotation())) {
@@ -68,7 +64,7 @@ void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) {
host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform());
}
-void TestScreen::SetUIScale(float ui_scale) {
+void HeadlessScreen::SetUIScale(float ui_scale) {
ui_scale_ = ui_scale;
gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
gfx::Rect new_bounds = gfx::ToNearestRect(
@@ -77,11 +73,11 @@ void TestScreen::SetUIScale(float ui_scale) {
host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform());
}
-void TestScreen::SetWorkAreaInsets(const gfx::Insets& insets) {
+void HeadlessScreen::SetWorkAreaInsets(const gfx::Insets& insets) {
display_.UpdateWorkAreaFromInsets(insets);
}
-gfx::Transform TestScreen::GetRotationTransform() const {
+gfx::Transform HeadlessScreen::GetRotationTransform() const {
gfx::Transform rotate;
switch (display_.rotation()) {
case gfx::Display::ROTATE_0:
@@ -95,8 +91,7 @@ gfx::Transform TestScreen::GetRotationTransform() const {
rotate.Rotate(270);
break;
case gfx::Display::ROTATE_180:
- rotate.Translate(display_.bounds().width(),
- display_.bounds().height());
+ rotate.Translate(display_.bounds().width(), display_.bounds().height());
rotate.Rotate(180);
break;
}
@@ -104,75 +99,76 @@ gfx::Transform TestScreen::GetRotationTransform() const {
return rotate;
}
-gfx::Transform TestScreen::GetUIScaleTransform() const {
+gfx::Transform HeadlessScreen::GetUIScaleTransform() const {
gfx::Transform ui_scale;
ui_scale.Scale(1.0f / ui_scale_, 1.0f / ui_scale_);
return ui_scale;
}
-void TestScreen::OnWindowBoundsChanged(
- Window* window, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) {
+void HeadlessScreen::OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {
DCHECK_EQ(host_->window(), window);
display_.SetSize(gfx::ScaleToFlooredSize(new_bounds.size(),
display_.device_scale_factor()));
}
-void TestScreen::OnWindowDestroying(Window* window) {
+void HeadlessScreen::OnWindowDestroying(aura::Window* window) {
if (host_->window() == window)
host_ = NULL;
}
-gfx::Point TestScreen::GetCursorScreenPoint() {
- return Env::GetInstance()->last_mouse_location();
+gfx::Point HeadlessScreen::GetCursorScreenPoint() {
+ return aura::Env::GetInstance()->last_mouse_location();
}
-gfx::NativeWindow TestScreen::GetWindowUnderCursor() {
+gfx::NativeWindow HeadlessScreen::GetWindowUnderCursor() {
return GetWindowAtScreenPoint(GetCursorScreenPoint());
}
-gfx::NativeWindow TestScreen::GetWindowAtScreenPoint(const gfx::Point& point) {
+gfx::NativeWindow HeadlessScreen::GetWindowAtScreenPoint(
+ const gfx::Point& point) {
if (!host_ || !host_->window())
return nullptr;
return host_->window()->GetTopWindowContainingPoint(point);
}
-int TestScreen::GetNumDisplays() const {
+int HeadlessScreen::GetNumDisplays() const {
return 1;
}
-std::vector<gfx::Display> TestScreen::GetAllDisplays() const {
+std::vector<gfx::Display> HeadlessScreen::GetAllDisplays() const {
return std::vector<gfx::Display>(1, display_);
}
-gfx::Display TestScreen::GetDisplayNearestWindow(
+gfx::Display HeadlessScreen::GetDisplayNearestWindow(
gfx::NativeWindow window) const {
return display_;
}
-gfx::Display TestScreen::GetDisplayNearestPoint(const gfx::Point& point) const {
+gfx::Display HeadlessScreen::GetDisplayNearestPoint(
+ const gfx::Point& point) const {
return display_;
}
-gfx::Display TestScreen::GetDisplayMatching(const gfx::Rect& match_rect) const {
+gfx::Display HeadlessScreen::GetDisplayMatching(
+ const gfx::Rect& match_rect) const {
return display_;
}
-gfx::Display TestScreen::GetPrimaryDisplay() const {
+gfx::Display HeadlessScreen::GetPrimaryDisplay() const {
return display_;
}
-void TestScreen::AddObserver(gfx::DisplayObserver* observer) {
-}
+void HeadlessScreen::AddObserver(gfx::DisplayObserver* observer) {}
-void TestScreen::RemoveObserver(gfx::DisplayObserver* observer) {
-}
+void HeadlessScreen::RemoveObserver(gfx::DisplayObserver* observer) {}
-TestScreen::TestScreen(const gfx::Rect& screen_bounds)
- : host_(NULL),
- ui_scale_(1.0f) {
+HeadlessScreen::HeadlessScreen(const gfx::Rect& screen_bounds)
+ : host_(NULL), ui_scale_(1.0f) {
static int64_t synthesized_display_id = 2000;
display_.set_id(synthesized_display_id++);
display_.SetScaleAndBounds(1.0f, screen_bounds);
}
-} // namespace aura
+} // namespace headless
« no previous file with comments | « headless/lib/browser/headless_screen.h ('k') | headless/lib/browser/headless_url_request_context_getter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698