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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2386103004: Ensure that we don't report huge mouse movement deltas for mouse enter and leave events. (Closed)
Patch Set: Don't update the location for mouse move events originating from the mouse enter and leave events. Created 4 years, 2 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 window_->ReleaseCapture(); 1310 window_->ReleaseCapture();
1311 1311
1312 #if defined(OS_WIN) 1312 #if defined(OS_WIN)
1313 ::ClipCursor(NULL); 1313 ::ClipCursor(NULL);
1314 #endif 1314 #endif
1315 1315
1316 // Ensure that the global mouse position is updated here to its original 1316 // Ensure that the global mouse position is updated here to its original
1317 // value. If we don't do this then the synthesized mouse move which is posted 1317 // value. If we don't do this then the synthesized mouse move which is posted
1318 // after the cursor is moved ends up getting a large movement delta which is 1318 // after the cursor is moved ends up getting a large movement delta which is
1319 // not what sites expect. The delta is computed in the 1319 // not what sites expect. The delta is computed in the
1320 // ModifyEventMovementAndCoords function. 1320 // ModifyEventMovementAndCoords function.
sky 2016/10/05 15:49:55 If you update aura::Env and nuke global_mouse_posi
ananta 2016/10/05 21:42:17 It looks like the mouse events sent to blink requi
1321 global_mouse_position_ = unlocked_global_mouse_position_; 1321 global_mouse_position_ = unlocked_global_mouse_position_;
1322 window_->MoveCursorTo(unlocked_mouse_position_); 1322 window_->MoveCursorTo(unlocked_mouse_position_);
1323 1323
1324 aura::client::CursorClient* cursor_client = 1324 aura::client::CursorClient* cursor_client =
1325 aura::client::GetCursorClient(root_window); 1325 aura::client::GetCursorClient(root_window);
1326 if (cursor_client) { 1326 if (cursor_client) {
1327 cursor_client->UnlockCursor(); 1327 cursor_client->UnlockCursor();
1328 cursor_client->ShowCursor(); 1328 cursor_client->ShowCursor();
1329 } 1329 }
1330 1330
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 IsFractionalScaleFactor(current_device_scale_factor_)) { 1868 IsFractionalScaleFactor(current_device_scale_factor_)) {
1869 if (event->type() == ui::ET_MOUSE_MOVED || 1869 if (event->type() == ui::ET_MOUSE_MOVED ||
1870 event->type() == ui::ET_MOUSE_DRAGGED) { 1870 event->type() == ui::ET_MOUSE_DRAGGED) {
1871 if ((abs(mouse_event.x - center.x()) <= 2) && 1871 if ((abs(mouse_event.x - center.x()) <= 2) &&
1872 (abs(mouse_event.y - center.y()) <= 2)) { 1872 (abs(mouse_event.y - center.y()) <= 2)) {
1873 is_move_to_center_event = true; 1873 is_move_to_center_event = true;
1874 } 1874 }
1875 } 1875 }
1876 } 1876 }
1877 1877
1878 ModifyEventMovementAndCoords(&mouse_event); 1878 ModifyEventMovementAndCoords(&mouse_event, event);
1879 1879
1880 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; 1880 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_;
1881 if (should_not_forward) { 1881 if (should_not_forward) {
1882 synthetic_move_sent_ = false; 1882 synthetic_move_sent_ = false;
1883 } else { 1883 } else {
1884 // Check if the mouse has reached the border and needs to be centered. 1884 // Check if the mouse has reached the border and needs to be centered.
1885 if (ShouldMoveToCenter()) { 1885 if (ShouldMoveToCenter()) {
1886 synthetic_move_sent_ = true; 1886 synthetic_move_sent_ = true;
1887 window_->MoveCursorTo(center); 1887 window_->MoveCursorTo(center);
1888 } 1888 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); 1947 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab();
1948 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && 1948 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
1949 !(event->flags() & ui::EF_FROM_TOUCH)) { 1949 !(event->flags() & ui::EF_FROM_TOUCH)) {
1950 // Confirm existing composition text on mouse press, to make sure 1950 // Confirm existing composition text on mouse press, to make sure
1951 // the input caret won't be moved with an ongoing composition text. 1951 // the input caret won't be moved with an ongoing composition text.
1952 if (event->type() == ui::ET_MOUSE_PRESSED) 1952 if (event->type() == ui::ET_MOUSE_PRESSED)
1953 FinishImeCompositionSession(); 1953 FinishImeCompositionSession();
1954 1954
1955 blink::WebMouseEvent mouse_event = ui::MakeWebMouseEvent( 1955 blink::WebMouseEvent mouse_event = ui::MakeWebMouseEvent(
1956 *event, base::Bind(&GetScreenLocationFromEvent)); 1956 *event, base::Bind(&GetScreenLocationFromEvent));
1957 ModifyEventMovementAndCoords(&mouse_event); 1957 ModifyEventMovementAndCoords(&mouse_event, event);
1958 if (ShouldRouteEvent(event)) { 1958 if (ShouldRouteEvent(event)) {
1959 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( 1959 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(
1960 this, &mouse_event, *event->latency()); 1960 this, &mouse_event, *event->latency());
1961 } else { 1961 } else {
1962 ProcessMouseEvent(mouse_event, *event->latency()); 1962 ProcessMouseEvent(mouse_event, *event->latency());
1963 } 1963 }
1964 1964
1965 // Ensure that we get keyboard focus on mouse down as a plugin window may 1965 // Ensure that we get keyboard focus on mouse down as a plugin window may
1966 // have grabbed keyboard focus. 1966 // have grabbed keyboard focus.
1967 if (event->type() == ui::ET_MOUSE_PRESSED) 1967 if (event->type() == ui::ET_MOUSE_PRESSED)
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 if (!has_composition_text_) 2493 if (!has_composition_text_)
2494 return; 2494 return;
2495 2495
2496 if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) { 2496 if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) {
2497 text_input_manager_->GetActiveWidget()->ImeFinishComposingText(false); 2497 text_input_manager_->GetActiveWidget()->ImeFinishComposingText(false);
2498 } 2498 }
2499 ImeCancelComposition(); 2499 ImeCancelComposition();
2500 } 2500 }
2501 2501
2502 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( 2502 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords(
2503 blink::WebMouseEvent* event) { 2503 blink::WebMouseEvent* event,
2504 ui::MouseEvent* ui_mouse_event) {
sky 2016/10/06 16:33:36 Make this take a const&, in fact can both args be
ananta 2016/10/06 21:15:18 Changed ui_mouse_event to be a const ref. The othe
2504 // If the mouse has just entered, we must report zero movementX/Y. Hence we 2505 // If the mouse has just entered, we must report zero movementX/Y. Hence we
2505 // reset any global_mouse_position set previously. 2506 // reset any global_mouse_position set previously.
2506 if (event->type == blink::WebInputEvent::MouseEnter || 2507 if (ui_mouse_event->type() == ui::ET_MOUSE_ENTERED ||
2507 event->type == blink::WebInputEvent::MouseLeave) 2508 ui_mouse_event->type() == ui::ET_MOUSE_EXITED) {
2508 global_mouse_position_.SetPoint(event->globalX, event->globalY); 2509 global_mouse_position_.SetPoint(event->globalX, event->globalY);
sky 2016/10/04 18:17:55 This is the first I've seen of ModifyEventMovement
ananta 2016/10/04 19:44:52 The global_mouse_position technically can be possi
2510 }
2509 2511
2510 // Movement is computed by taking the difference of the new cursor position 2512 // Movement is computed by taking the difference of the new cursor position
2511 // and the previous. Under mouse lock the cursor will be warped back to the 2513 // and the previous. Under mouse lock the cursor will be warped back to the
2512 // center so that we are not limited by clipping boundaries. 2514 // center so that we are not limited by clipping boundaries.
2513 // We do not measure movement as the delta from cursor to center because 2515 // We do not measure movement as the delta from cursor to center because
2514 // we may receive more mouse movement events before our warp has taken 2516 // we may receive more mouse movement events before our warp has taken
2515 // effect. 2517 // effect.
2516 event->movementX = event->globalX - global_mouse_position_.x(); 2518 event->movementX = event->globalX - global_mouse_position_.x();
2517 event->movementY = event->globalY - global_mouse_position_.y(); 2519 event->movementY = event->globalY - global_mouse_position_.y();
2518 2520
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 ->GetTextSelection(focused_view) 3044 ->GetTextSelection(focused_view)
3043 ->GetSelectedText(&selected_text)) { 3045 ->GetSelectedText(&selected_text)) {
3044 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 3046 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
3045 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 3047 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
3046 clipboard_writer.WriteText(selected_text); 3048 clipboard_writer.WriteText(selected_text);
3047 } 3049 }
3048 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 3050 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
3049 } 3051 }
3050 3052
3051 } // namespace content 3053 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698