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

Side by Side Diff: components/html_viewer/ui_setup_android.cc

Issue 1136743003: Plumbs through screen size and scale factor to html_viewer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/html_viewer/ui_setup_android.h" 5 #include "components/html_viewer/ui_setup_android.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "ui/events/gesture_detection/gesture_configuration.h" 8 #include "ui/events/gesture_detection/gesture_configuration.h"
9 #include "ui/gfx/geometry/size_conversions.h"
9 #include "ui/gfx/screen.h" 10 #include "ui/gfx/screen.h"
10 11
11 namespace html_viewer { 12 namespace html_viewer {
12 namespace { 13 namespace {
13 14
14 // TODO(sky): The values these serve up need to come from a service.
15 class ScreenMandoline : public gfx::Screen { 15 class ScreenMandoline : public gfx::Screen {
16 public: 16 public:
17 ScreenMandoline() {} 17 ScreenMandoline(const gfx::Size& screen_size_in_pixels,
18 float device_pixel_ratio)
19 : screen_size_in_pixels_(screen_size_in_pixels),
20 device_pixel_ratio_(device_pixel_ratio) {}
18 21
19 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); } 22 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
20 23
21 gfx::NativeWindow GetWindowUnderCursor() override { 24 gfx::NativeWindow GetWindowUnderCursor() override {
22 NOTIMPLEMENTED(); 25 NOTIMPLEMENTED();
23 return NULL; 26 return NULL;
24 } 27 }
25 28
26 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { 29 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
27 NOTIMPLEMENTED(); 30 NOTIMPLEMENTED();
28 return NULL; 31 return NULL;
29 } 32 }
30 33
31 gfx::Display GetPrimaryDisplay() const override { 34 gfx::Display GetPrimaryDisplay() const override {
32 NOTIMPLEMENTED(); 35 const gfx::Rect bounds_in_pixels(gfx::Point(), screen_size_in_pixels_);
33 gfx::Display display(0, gfx::Rect(0, 0, 1000, 1000)); 36 const gfx::Rect bounds_in_dip(gfx::ToCeiledSize(
34 display.set_device_scale_factor(2.0f); 37 gfx::ScaleSize(bounds_in_pixels.size(), 1.0f / device_pixel_ratio_)));
38 gfx::Display display(0, bounds_in_dip);
39 display.set_device_scale_factor(device_pixel_ratio_);
35 return display; 40 return display;
36 } 41 }
37 42
38 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override { 43 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override {
39 return GetPrimaryDisplay(); 44 return GetPrimaryDisplay();
40 } 45 }
41 46
42 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override { 47 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override {
43 return GetPrimaryDisplay(); 48 return GetPrimaryDisplay();
44 } 49 }
(...skipping 10 matching lines...) Expand all
55 60
56 void AddObserver(gfx::DisplayObserver* observer) override { 61 void AddObserver(gfx::DisplayObserver* observer) override {
57 // no display change on Android. 62 // no display change on Android.
58 } 63 }
59 64
60 void RemoveObserver(gfx::DisplayObserver* observer) override { 65 void RemoveObserver(gfx::DisplayObserver* observer) override {
61 // no display change on Android. 66 // no display change on Android.
62 } 67 }
63 68
64 private: 69 private:
70 const gfx::Size screen_size_in_pixels_;
71 const float device_pixel_ratio_;
72
65 DISALLOW_COPY_AND_ASSIGN(ScreenMandoline); 73 DISALLOW_COPY_AND_ASSIGN(ScreenMandoline);
66 }; 74 };
67 75
68 } // namespace 76 } // namespace
69 77
78 // TODO(sky): this needs to come from system.
70 class GestureConfigurationMandoline : public ui::GestureConfiguration { 79 class GestureConfigurationMandoline : public ui::GestureConfiguration {
71 public: 80 public:
72 GestureConfigurationMandoline() : GestureConfiguration() { 81 GestureConfigurationMandoline() : GestureConfiguration() {
73 set_double_tap_enabled(false); 82 set_double_tap_enabled(false);
74 set_double_tap_timeout_in_ms(semi_long_press_time_in_ms()); 83 set_double_tap_timeout_in_ms(semi_long_press_time_in_ms());
75 set_gesture_begin_end_types_enabled(true); 84 set_gesture_begin_end_types_enabled(true);
76 set_min_gesture_bounds_length(default_radius()); 85 set_min_gesture_bounds_length(default_radius());
77 set_min_pinch_update_span_delta(0); 86 set_min_pinch_update_span_delta(0);
78 set_min_scaling_touch_major(default_radius() * 2); 87 set_min_scaling_touch_major(default_radius() * 2);
79 set_velocity_tracker_strategy( 88 set_velocity_tracker_strategy(
80 ui::VelocityTracker::Strategy::LSQ2_RESTRICTED); 89 ui::VelocityTracker::Strategy::LSQ2_RESTRICTED);
81 set_span_slop(max_touch_move_in_pixels_for_click() * 2); 90 set_span_slop(max_touch_move_in_pixels_for_click() * 2);
82 set_swipe_enabled(true); 91 set_swipe_enabled(true);
83 set_two_finger_tap_enabled(true); 92 set_two_finger_tap_enabled(true);
84 } 93 }
85 94
86 ~GestureConfigurationMandoline() override {} 95 ~GestureConfigurationMandoline() override {}
87 96
88 private: 97 private:
89 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationMandoline); 98 DISALLOW_COPY_AND_ASSIGN(GestureConfigurationMandoline);
90 }; 99 };
91 100
92 UISetup::UISetup() 101 UISetup::UISetup(const gfx::Size& screen_size_in_pixels,
93 : screen_(new ScreenMandoline), 102 float device_pixel_ratio)
103 : screen_(new ScreenMandoline(screen_size_in_pixels, device_pixel_ratio)),
94 gesture_configuration_(new GestureConfigurationMandoline) { 104 gesture_configuration_(new GestureConfigurationMandoline) {
95 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, 105 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
96 screen_.get()); 106 screen_.get());
97 ui::GestureConfiguration::SetInstance(gesture_configuration_.get()); 107 ui::GestureConfiguration::SetInstance(gesture_configuration_.get());
98 } 108 }
99 109
100 UISetup::~UISetup() { 110 UISetup::~UISetup() {
101 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); 111 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr);
102 ui::GestureConfiguration::SetInstance(nullptr); 112 ui::GestureConfiguration::SetInstance(nullptr);
103 } 113 }
104 114
105 } // namespace html_viewer 115 } // namespace html_viewer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698