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

Side by Side Diff: content/browser/renderer_host/input/touch_emulator.cc

Issue 859973003: Touch emulator: enables double tap support for pages similar to Chrome on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: frame_metadata_util Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/renderer_host/input/touch_emulator.h" 5 #include "content/browser/renderer_host/input/touch_emulator.h"
6 6
7 #include "content/browser/renderer_host/input/motion_event_web.h" 7 #include "content/browser/renderer_host/input/motion_event_web.h"
8 #include "content/browser/renderer_host/input/web_input_event_util.h" 8 #include "content/browser/renderer_host/input/web_input_event_util.h"
9 #include "content/common/input/web_touch_event_traits.h" 9 #include "content/common/input/web_touch_event_traits.h"
10 #include "content/grit/content_resources.h" 10 #include "content/grit/content_resources.h"
(...skipping 29 matching lines...) Expand all
40 // Time between two consecutive mouse moves, during which second mouse move 40 // Time between two consecutive mouse moves, during which second mouse move
41 // is not converted to touch. 41 // is not converted to touch.
42 const double kMouseMoveDropIntervalSeconds = 5.f / 1000; 42 const double kMouseMoveDropIntervalSeconds = 5.f / 1000;
43 43
44 } // namespace 44 } // namespace
45 45
46 TouchEmulator::TouchEmulator(TouchEmulatorClient* client) 46 TouchEmulator::TouchEmulator(TouchEmulatorClient* client)
47 : client_(client), 47 : client_(client),
48 gesture_provider_config_type_( 48 gesture_provider_config_type_(
49 ui::GestureProviderConfigType::CURRENT_PLATFORM), 49 ui::GestureProviderConfigType::CURRENT_PLATFORM),
50 double_tap_enabled_(true),
50 emulated_stream_active_sequence_count_(0), 51 emulated_stream_active_sequence_count_(0),
51 native_stream_active_sequence_count_(0) { 52 native_stream_active_sequence_count_(0) {
52 DCHECK(client_); 53 DCHECK(client_);
53 ResetState(); 54 ResetState();
54 55
55 bool use_2x = gfx::Screen::GetNativeScreen()-> 56 bool use_2x = gfx::Screen::GetNativeScreen()->
56 GetPrimaryDisplay().device_scale_factor() > 1.5f; 57 GetPrimaryDisplay().device_scale_factor() > 1.5f;
57 float cursor_scale_factor = use_2x ? 2.f : 1.f; 58 float cursor_scale_factor = use_2x ? 2.f : 1.f;
58 cursor_size_ = InitCursorFromResource(&touch_cursor_, 59 cursor_size_ = InitCursorFromResource(&touch_cursor_,
59 cursor_scale_factor, 60 cursor_scale_factor,
(...skipping 25 matching lines...) Expand all
85 pinch_gesture_active_ = false; 86 pinch_gesture_active_ = false;
86 } 87 }
87 88
88 void TouchEmulator::Enable(ui::GestureProviderConfigType config_type) { 89 void TouchEmulator::Enable(ui::GestureProviderConfigType config_type) {
89 if (!gesture_provider_ || gesture_provider_config_type_ != config_type) { 90 if (!gesture_provider_ || gesture_provider_config_type_ != config_type) {
90 gesture_provider_config_type_ = config_type; 91 gesture_provider_config_type_ = config_type;
91 gesture_provider_.reset(new ui::FilteredGestureProvider( 92 gesture_provider_.reset(new ui::FilteredGestureProvider(
92 GetEmulatorGestureProviderConfig(config_type), this)); 93 GetEmulatorGestureProviderConfig(config_type), this));
93 // TODO(dgozman): Use synthetic secondary touch to support multi-touch. 94 // TODO(dgozman): Use synthetic secondary touch to support multi-touch.
94 gesture_provider_->SetMultiTouchZoomSupportEnabled(false); 95 gesture_provider_->SetMultiTouchZoomSupportEnabled(false);
95 // TODO(dgozman): Enable double tap if requested by the renderer. 96 gesture_provider_->SetDoubleTapSupportForPageEnabled(double_tap_enabled_);
96 // TODO(dgozman): Don't break double-tap-based pinch with shift handling.
97 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false);
98 } 97 }
99 UpdateCursor(); 98 UpdateCursor();
100 } 99 }
101 100
102 void TouchEmulator::Disable() { 101 void TouchEmulator::Disable() {
103 if (!enabled()) 102 if (!enabled())
104 return; 103 return;
105 104
106 CancelTouch(); 105 CancelTouch();
107 gesture_provider_.reset(); 106 gesture_provider_.reset();
108 UpdateCursor(); 107 UpdateCursor();
109 ResetState(); 108 ResetState();
110 } 109 }
111 110
111 void TouchEmulator::SetDoubleTapSupportForPageEnabled(bool enabled) {
112 double_tap_enabled_ = enabled;
113 if (gesture_provider_)
114 gesture_provider_->SetDoubleTapSupportForPageEnabled(enabled);
115 }
116
112 gfx::SizeF TouchEmulator::InitCursorFromResource( 117 gfx::SizeF TouchEmulator::InitCursorFromResource(
113 WebCursor* cursor, float scale, int resource_id) { 118 WebCursor* cursor, float scale, int resource_id) {
114 gfx::Image& cursor_image = 119 gfx::Image& cursor_image =
115 content::GetContentClient()->GetNativeImageNamed(resource_id); 120 content::GetContentClient()->GetNativeImageNamed(resource_id);
116 WebCursor::CursorInfo cursor_info; 121 WebCursor::CursorInfo cursor_info;
117 cursor_info.type = blink::WebCursorInfo::TypeCustom; 122 cursor_info.type = blink::WebCursorInfo::TypeCustom;
118 cursor_info.image_scale_factor = scale; 123 cursor_info.image_scale_factor = scale;
119 cursor_info.custom_image = cursor_image.AsBitmap(); 124 cursor_info.custom_image = cursor_image.AsBitmap();
120 cursor_info.hotspot = 125 cursor_info.hotspot =
121 gfx::Point(cursor_image.Width() / 2, cursor_image.Height() / 2); 126 gfx::Point(cursor_image.Width() / 2, cursor_image.Height() / 2);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 point.screenPosition.x = mouse_event.globalX; 441 point.screenPosition.x = mouse_event.globalX;
437 point.position.y = mouse_event.y; 442 point.position.y = mouse_event.y;
438 point.screenPosition.y = mouse_event.globalY; 443 point.screenPosition.y = mouse_event.globalY;
439 } 444 }
440 445
441 bool TouchEmulator::InPinchGestureMode() const { 446 bool TouchEmulator::InPinchGestureMode() const {
442 return shift_pressed_; 447 return shift_pressed_;
443 } 448 }
444 449
445 } // namespace content 450 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_emulator.h ('k') | content/browser/renderer_host/input/touch_emulator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698