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

Unified Diff: content/browser/renderer_host/render_widget_host_view_event_handler.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 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..d687d6e68d53c0d787c4836be1eb6ff03cb4b853 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
@@ -719,10 +719,11 @@ void RenderWidgetHostViewEventHandler::HandleMouseEventWhileLocked(
blink::WebMouseEvent mouse_event =
ui::MakeWebMouseEvent(*event, base::Bind(&GetScreenLocationFromEvent));
- 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();
+ bool is_move_to_center_event =
+ (event->type() == ui::ET_MOUSE_MOVED ||
+ event->type() == ui::ET_MOUSE_DRAGGED) &&
+ mouse_event.positionInWidget().x == center.x() &&
+ mouse_event.positionInWidget().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 +737,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.positionInWidget().x - center.x()) <= 2) &&
+ (std::abs(mouse_event.positionInWidget().y - center.y()) <= 2)) {
is_move_to_center_event = true;
}
}
@@ -779,7 +780,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->positionInScreen().x,
+ event->positionInScreen().y);
}
// Movement is computed by taking the difference of the new cursor position
@@ -788,21 +790,24 @@ 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->positionInScreen().x - global_mouse_position_.x();
+ event->movementY = event->positionInScreen().y - global_mouse_position_.y();
- global_mouse_position_.SetPoint(event->globalX, event->globalY);
+ global_mouse_position_.SetPoint(event->positionInScreen().x,
+ event->positionInScreen().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->setPositionInWidget(unlocked_mouse_position_.x(),
+ unlocked_mouse_position_.y());
+ event->setPositionInScreen(unlocked_global_mouse_position_.x(),
+ 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->positionInWidget().x,
+ event->positionInWidget().y);
+ unlocked_global_mouse_position_.SetPoint(event->positionInScreen().x,
+ event->positionInScreen().y);
}
}

Powered by Google App Engine
This is Rietveld 408576698