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

Unified Diff: content/browser/renderer_host/render_widget_host_view_event_handler.cc

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Fixed compile failures. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_event_handler.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_event_handler.cc b/content/browser/renderer_host/render_widget_host_view_event_handler.cc
index 7c01ba9e7ffaa0cbb81d3d29feb08c20983b0754..2aa68a80fa9e89f9ead8609b7eae7f8a0f7f4c6d 100644
--- a/content/browser/renderer_host/render_widget_host_view_event_handler.cc
+++ b/content/browser/renderer_host/render_widget_host_view_event_handler.cc
@@ -721,8 +721,8 @@ void RenderWidgetHostViewEventHandler::HandleMouseEventWhileLocked(
bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED ||
event->type() == ui::ET_MOUSE_DRAGGED) &&
- mouse_event.x == center.x() &&
- mouse_event.y == center.y();
+ mouse_event.position.x == center.x() &&
+ mouse_event.position.y == center.y();
// For fractional scale factors, the conversion from pixels to dip and
// vice versa could result in off by 1 or 2 errors which hurts us because
@@ -736,8 +736,8 @@ void RenderWidgetHostViewEventHandler::HandleMouseEventWhileLocked(
IsFractionalScaleFactor(host_view_->current_device_scale_factor())) {
if (event->type() == ui::ET_MOUSE_MOVED ||
event->type() == ui::ET_MOUSE_DRAGGED) {
- if ((abs(mouse_event.x - center.x()) <= 2) &&
- (abs(mouse_event.y - center.y()) <= 2)) {
+ if ((std::abs(mouse_event.position.x - center.x()) <= 2) &&
+ (std::abs(mouse_event.position.y - center.y()) <= 2)) {
is_move_to_center_event = true;
}
}
@@ -779,7 +779,8 @@ void RenderWidgetHostViewEventHandler::ModifyEventMovementAndCoords(
// reset any global_mouse_position set previously.
if (ui_mouse_event.type() == ui::ET_MOUSE_ENTERED ||
ui_mouse_event.type() == ui::ET_MOUSE_EXITED) {
- global_mouse_position_.SetPoint(event->globalX, event->globalY);
+ global_mouse_position_.SetPoint(event->screenPosition.x,
+ event->screenPosition.y);
}
// Movement is computed by taking the difference of the new cursor position
@@ -788,21 +789,23 @@ void RenderWidgetHostViewEventHandler::ModifyEventMovementAndCoords(
// We do not measure movement as the delta from cursor to center because
// we may receive more mouse movement events before our warp has taken
// effect.
- event->movementX = event->globalX - global_mouse_position_.x();
- event->movementY = event->globalY - global_mouse_position_.y();
+ event->movementX = event->screenPosition.x - global_mouse_position_.x();
+ event->movementY = event->screenPosition.y - global_mouse_position_.y();
- global_mouse_position_.SetPoint(event->globalX, event->globalY);
+ global_mouse_position_.SetPoint(event->screenPosition.x,
+ event->screenPosition.y);
// Under mouse lock, coordinates of mouse are locked to what they were when
// mouse lock was entered.
if (mouse_locked_) {
- event->x = unlocked_mouse_position_.x();
- event->y = unlocked_mouse_position_.y();
- event->globalX = unlocked_global_mouse_position_.x();
- event->globalY = unlocked_global_mouse_position_.y();
+ event->position.x = unlocked_mouse_position_.x();
+ event->position.y = unlocked_mouse_position_.y();
+ event->screenPosition.x = unlocked_global_mouse_position_.x();
+ event->screenPosition.y = unlocked_global_mouse_position_.y();
} else {
- unlocked_mouse_position_.SetPoint(event->x, event->y);
- unlocked_global_mouse_position_.SetPoint(event->globalX, event->globalY);
+ unlocked_mouse_position_.SetPoint(event->position.x, event->position.y);
+ unlocked_global_mouse_position_.SetPoint(event->screenPosition.x,
+ event->screenPosition.y);
}
}

Powered by Google App Engine
This is Rietveld 408576698