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

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

Issue 2480203002: ui: Cleanup class/struct forward declarations (Closed)
Patch Set: Sync CL to position 430550 Created 4 years, 1 month 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') | infra/config/recipes.cfg » ('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/headless/lib/browser/headless_screen.cc b/headless/lib/browser/headless_screen.cc
index c8be18bfdb1804dab9c759e8c04d70a924dcdd2b..be86924d2e3fc81ed7801995640ee6e9ee0ea726 100644
--- a/headless/lib/browser/headless_screen.cc
+++ b/headless/lib/browser/headless_screen.cc
@@ -12,7 +12,6 @@
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/input_method.h"
-#include "ui/display/screen.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/native_widget_types.h"
@@ -37,7 +36,8 @@ HeadlessScreen::~HeadlessScreen() {}
aura::WindowTreeHost* HeadlessScreen::CreateHostForPrimaryDisplay() {
DCHECK(!host_);
- host_ = aura::WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel()));
+ host_ = aura::WindowTreeHost::Create(
+ gfx::Rect(GetPrimaryDisplay().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();
@@ -47,50 +47,59 @@ aura::WindowTreeHost* HeadlessScreen::CreateHostForPrimaryDisplay() {
}
void HeadlessScreen::SetDeviceScaleFactor(float device_scale_factor) {
- gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
- display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
+ display::Display display(GetPrimaryDisplay());
+ gfx::Rect bounds_in_pixel(display.GetSizeInPixel());
+ display.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
+ display_list().UpdateDisplay(display);
}
void HeadlessScreen::SetDisplayRotation(display::Display::Rotation rotation) {
- gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
+ display::Display display(GetPrimaryDisplay());
+ gfx::Rect bounds_in_pixel(display.GetSizeInPixel());
gfx::Rect new_bounds(bounds_in_pixel);
- if (IsRotationPortrait(rotation) != IsRotationPortrait(display_.rotation())) {
+ if (IsRotationPortrait(rotation) != IsRotationPortrait(display.rotation())) {
new_bounds.set_width(bounds_in_pixel.height());
new_bounds.set_height(bounds_in_pixel.width());
}
- display_.set_rotation(rotation);
- display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds);
+ display.set_rotation(rotation);
+ display.SetScaleAndBounds(display.device_scale_factor(), new_bounds);
+ display_list().UpdateDisplay(display);
host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform());
}
void HeadlessScreen::SetUIScale(float ui_scale) {
ui_scale_ = ui_scale;
- gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
+ display::Display display(GetPrimaryDisplay());
+ gfx::Rect bounds_in_pixel(display.GetSizeInPixel());
gfx::Rect new_bounds = gfx::ToNearestRect(
gfx::ScaleRect(gfx::RectF(bounds_in_pixel), 1.0f / ui_scale));
- display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds);
+ display.SetScaleAndBounds(display.device_scale_factor(), new_bounds);
+ display_list().UpdateDisplay(display);
host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform());
}
void HeadlessScreen::SetWorkAreaInsets(const gfx::Insets& insets) {
- display_.UpdateWorkAreaFromInsets(insets);
+ display::Display display(GetPrimaryDisplay());
+ display.UpdateWorkAreaFromInsets(insets);
+ display_list().UpdateDisplay(display);
}
gfx::Transform HeadlessScreen::GetRotationTransform() const {
gfx::Transform rotate;
- switch (display_.rotation()) {
+ display::Display display(GetPrimaryDisplay());
+ switch (display.rotation()) {
case display::Display::ROTATE_0:
break;
case display::Display::ROTATE_90:
- rotate.Translate(display_.bounds().height(), 0);
+ rotate.Translate(display.bounds().height(), 0);
rotate.Rotate(90);
break;
case display::Display::ROTATE_270:
- rotate.Translate(0, display_.bounds().width());
+ rotate.Translate(0, display.bounds().width());
rotate.Rotate(270);
break;
case display::Display::ROTATE_180:
- rotate.Translate(display_.bounds().width(), display_.bounds().height());
+ rotate.Translate(display.bounds().width(), display.bounds().height());
rotate.Rotate(180);
break;
}
@@ -108,8 +117,10 @@ 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()));
+ display::Display display(GetPrimaryDisplay());
+ display.SetSize(gfx::ScaleToFlooredSize(new_bounds.size(),
+ display.device_scale_factor()));
+ display_list().UpdateDisplay(display);
}
void HeadlessScreen::OnWindowDestroying(aura::Window* window) {
@@ -132,42 +143,17 @@ gfx::NativeWindow HeadlessScreen::GetWindowAtScreenPoint(
return host_->window()->GetTopWindowContainingPoint(point);
}
-int HeadlessScreen::GetNumDisplays() const {
- return 1;
-}
-
-std::vector<display::Display> HeadlessScreen::GetAllDisplays() const {
- return std::vector<display::Display>(1, display_);
-}
-
display::Display HeadlessScreen::GetDisplayNearestWindow(
gfx::NativeWindow window) const {
- return display_;
-}
-
-display::Display HeadlessScreen::GetDisplayNearestPoint(
- const gfx::Point& point) const {
- return display_;
+ return GetPrimaryDisplay();
}
-display::Display HeadlessScreen::GetDisplayMatching(
- const gfx::Rect& match_rect) const {
- return display_;
-}
-
-display::Display HeadlessScreen::GetPrimaryDisplay() const {
- return display_;
-}
-
-void HeadlessScreen::AddObserver(display::DisplayObserver* observer) {}
-
-void HeadlessScreen::RemoveObserver(display::DisplayObserver* observer) {}
-
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);
+ display::Display display(synthesized_display_id++);
+ display.SetScaleAndBounds(1.0f, screen_bounds);
+ ProcessDisplayChanged(display, true /* is_primary */);
}
} // namespace headless
« no previous file with comments | « headless/lib/browser/headless_screen.h ('k') | infra/config/recipes.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698