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

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

Issue 2633233002: Add the pointer type of pen to the synthetic WebMousEvent (Closed)
Patch Set: pen type Created 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/synthetic_gesture_target_aura.h" 5 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "content/browser/renderer_host/render_widget_host_impl.h" 9 #include "content/browser/renderer_host/render_widget_host_impl.h"
10 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 10 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 case blink::WebMouseEvent::Button::Right: 123 case blink::WebMouseEvent::Button::Right:
124 return ui::EF_RIGHT_MOUSE_BUTTON; 124 return ui::EF_RIGHT_MOUSE_BUTTON;
125 125
126 default: 126 default:
127 NOTREACHED(); 127 NOTREACHED();
128 } 128 }
129 129
130 return 0; 130 return 0;
131 } 131 }
132 132
133 ui::EventPointerType WebPointerTypeToEventPointerType(
134 blink::WebPointerProperties::PointerType type) {
135 switch (type) {
136 case blink::WebPointerProperties::PointerType::Touch:
137 return ui::EventPointerType::POINTER_TYPE_TOUCH;
138 case blink::WebPointerProperties::PointerType::Mouse:
139 return ui::EventPointerType::POINTER_TYPE_MOUSE;
140 case blink::WebPointerProperties::PointerType::Pen:
141 return ui::EventPointerType::POINTER_TYPE_PEN;
142 case blink::WebPointerProperties::PointerType::Eraser:
143 return ui::EventPointerType::POINTER_TYPE_ERASER;
144 case blink::WebPointerProperties::PointerType::Unknown:
145 return ui::EventPointerType::POINTER_TYPE_UNKNOWN;
146 }
147 NOTREACHED() << "Unexpected EventPointerType";
148 return ui::EventPointerType::POINTER_TYPE_UNKNOWN;
149 }
150
133 } // namespace 151 } // namespace
134 152
135 void SyntheticGestureTargetAura::DispatchWebMouseEventToPlatform( 153 void SyntheticGestureTargetAura::DispatchWebMouseEventToPlatform(
136 const blink::WebMouseEvent& web_mouse, 154 const blink::WebMouseEvent& web_mouse,
137 const ui::LatencyInfo& latency_info) { 155 const ui::LatencyInfo& latency_info) {
138 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type()); 156 ui::EventType event_type = WebMouseEventTypeToEventType(web_mouse.type());
139 int flags = WebMouseEventButtonToFlags(web_mouse.button); 157 int flags = WebMouseEventButtonToFlags(web_mouse.button);
140 ui::MouseEvent mouse_event(event_type, gfx::Point(), gfx::Point(), 158 ui::MouseEvent mouse_event(event_type, gfx::Point(), gfx::Point(),
141 ui::EventTimeForNow(), flags, flags); 159 ui::EventTimeForNow(), flags, flags);
142 gfx::PointF location(web_mouse.x * device_scale_factor_, 160 gfx::PointF location(web_mouse.x * device_scale_factor_,
143 web_mouse.y * device_scale_factor_); 161 web_mouse.y * device_scale_factor_);
144 mouse_event.set_location_f(location); 162 mouse_event.set_location_f(location);
145 mouse_event.set_root_location_f(location); 163 mouse_event.set_root_location_f(location);
164 ui::PointerDetails pointer_details = mouse_event.pointer_details();
165 pointer_details.pointer_type =
166 WebPointerTypeToEventPointerType(web_mouse.pointerType);
167 mouse_event.set_pointer_details(pointer_details);
146 168
147 aura::Window* window = GetWindow(); 169 aura::Window* window = GetWindow();
148 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); 170 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow());
149 ui::EventDispatchDetails details = 171 ui::EventDispatchDetails details =
150 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event); 172 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event);
151 if (details.dispatcher_destroyed) 173 if (details.dispatcher_destroyed)
152 return; 174 return;
153 } 175 }
154 176
155 SyntheticGestureParams::GestureSourceType 177 SyntheticGestureParams::GestureSourceType
(...skipping 14 matching lines...) Expand all
170 ->min_distance_for_pinch_scroll_in_pixels(); 192 ->min_distance_for_pinch_scroll_in_pixels();
171 } 193 }
172 194
173 aura::Window* SyntheticGestureTargetAura::GetWindow() const { 195 aura::Window* SyntheticGestureTargetAura::GetWindow() const {
174 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); 196 aura::Window* window = render_widget_host()->GetView()->GetNativeView();
175 DCHECK(window); 197 DCHECK(window);
176 return window; 198 return window;
177 } 199 }
178 200
179 } // namespace content 201 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698