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

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

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Rebased, fixed a comment in web_input_event_builders_mac.mm Created 3 years, 8 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 "build/build_config.h" 7 #include "build/build_config.h"
8 #include "content/browser/renderer_host/input/motion_event_web.h" 8 #include "content/browser/renderer_host/input/motion_event_web.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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 cursor->InitFromCursorInfo(cursor_info); 152 cursor->InitFromCursorInfo(cursor_info);
153 return gfx::ScaleSize(gfx::SizeF(cursor_image.Size()), 1.f / scale); 153 return gfx::ScaleSize(gfx::SizeF(cursor_image.Size()), 1.f / scale);
154 } 154 }
155 155
156 bool TouchEmulator::HandleMouseEvent(const WebMouseEvent& mouse_event) { 156 bool TouchEmulator::HandleMouseEvent(const WebMouseEvent& mouse_event) {
157 if (!enabled()) 157 if (!enabled())
158 return false; 158 return false;
159 159
160 if (mouse_event.button == WebMouseEvent::Button::Right && 160 if (mouse_event.button == WebMouseEvent::Button::Right &&
161 mouse_event.type() == WebInputEvent::MouseDown) { 161 mouse_event.type() == WebInputEvent::MouseDown) {
162 client_->ShowContextMenuAtPoint(gfx::Point(mouse_event.x, mouse_event.y)); 162 client_->ShowContextMenuAtPoint(gfx::Point(
163 mouse_event.positionInWidget().x, mouse_event.positionInWidget().y));
163 } 164 }
164 165
165 if (mouse_event.button != WebMouseEvent::Button::Left) 166 if (mouse_event.button != WebMouseEvent::Button::Left)
166 return true; 167 return true;
167 168
168 if (mouse_event.type() == WebInputEvent::MouseMove) { 169 if (mouse_event.type() == WebInputEvent::MouseMove) {
169 if (last_mouse_event_was_move_ && 170 if (last_mouse_event_was_move_ &&
170 mouse_event.timeStampSeconds() < 171 mouse_event.timeStampSeconds() <
171 last_mouse_move_timestamp_ + kMouseMoveDropIntervalSeconds) 172 last_mouse_move_timestamp_ + kMouseMoveDropIntervalSeconds)
172 return true; 173 return true;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 touch_event_.touchesLength = 1; 457 touch_event_.touchesLength = 1;
457 touch_event_.setModifiers(ModifiersWithoutMouseButtons(mouse_event)); 458 touch_event_.setModifiers(ModifiersWithoutMouseButtons(mouse_event));
458 WebTouchEventTraits::ResetTypeAndTouchStates( 459 WebTouchEventTraits::ResetTypeAndTouchStates(
459 eventType, mouse_event.timeStampSeconds(), &touch_event_); 460 eventType, mouse_event.timeStampSeconds(), &touch_event_);
460 WebTouchPoint& point = touch_event_.touches[0]; 461 WebTouchPoint& point = touch_event_.touches[0];
461 point.id = 0; 462 point.id = 0;
462 point.radiusX = 0.5f * cursor_size_.width(); 463 point.radiusX = 0.5f * cursor_size_.width();
463 point.radiusY = 0.5f * cursor_size_.height(); 464 point.radiusY = 0.5f * cursor_size_.height();
464 point.force = eventType == WebInputEvent::TouchEnd ? 0.f : 1.f; 465 point.force = eventType == WebInputEvent::TouchEnd ? 0.f : 1.f;
465 point.rotationAngle = 0.f; 466 point.rotationAngle = 0.f;
466 point.position.x = mouse_event.x; 467 point.position.x = mouse_event.positionInWidget().x;
467 point.screenPosition.x = mouse_event.globalX; 468 point.screenPosition.x = mouse_event.positionInScreen().x;
468 point.position.y = mouse_event.y; 469 point.position.y = mouse_event.positionInWidget().y;
469 point.screenPosition.y = mouse_event.globalY; 470 point.screenPosition.y = mouse_event.positionInScreen().y;
470 point.tiltX = 0; 471 point.tiltX = 0;
471 point.tiltY = 0; 472 point.tiltY = 0;
472 point.pointerType = blink::WebPointerProperties::PointerType::Touch; 473 point.pointerType = blink::WebPointerProperties::PointerType::Touch;
473 } 474 }
474 475
475 bool TouchEmulator::InPinchGestureMode() const { 476 bool TouchEmulator::InPinchGestureMode() const {
476 return shift_pressed_; 477 return shift_pressed_;
477 } 478 }
478 479
479 } // namespace content 480 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698