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

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: Address sky review comments 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 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 IsFractionalScaleFactor(current_device_scale_factor_)) { 1890 IsFractionalScaleFactor(current_device_scale_factor_)) {
1891 if (event->type() == ui::ET_MOUSE_MOVED || 1891 if (event->type() == ui::ET_MOUSE_MOVED ||
1892 event->type() == ui::ET_MOUSE_DRAGGED) { 1892 event->type() == ui::ET_MOUSE_DRAGGED) {
1893 if ((abs(mouse_event.x - center.x()) <= 2) && 1893 if ((abs(mouse_event.x - center.x()) <= 2) &&
1894 (abs(mouse_event.y - center.y()) <= 2)) { 1894 (abs(mouse_event.y - center.y()) <= 2)) {
1895 is_move_to_center_event = true; 1895 is_move_to_center_event = true;
1896 } 1896 }
1897 } 1897 }
1898 } 1898 }
1899 1899
1900 ModifyEventMovementAndCoords(&mouse_event); 1900 ModifyEventMovementAndCoords(*event, &mouse_event);
1901 1901
1902 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; 1902 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_;
1903 if (should_not_forward) { 1903 if (should_not_forward) {
1904 synthetic_move_sent_ = false; 1904 synthetic_move_sent_ = false;
1905 } else { 1905 } else {
1906 // Check if the mouse has reached the border and needs to be centered. 1906 // Check if the mouse has reached the border and needs to be centered.
1907 if (ShouldMoveToCenter()) { 1907 if (ShouldMoveToCenter()) {
1908 synthetic_move_sent_ = true; 1908 synthetic_move_sent_ = true;
1909 window_->MoveCursorTo(center); 1909 window_->MoveCursorTo(center);
1910 } 1910 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); 1969 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab();
1970 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && 1970 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
1971 !(event->flags() & ui::EF_FROM_TOUCH)) { 1971 !(event->flags() & ui::EF_FROM_TOUCH)) {
1972 // Confirm existing composition text on mouse press, to make sure 1972 // Confirm existing composition text on mouse press, to make sure
1973 // the input caret won't be moved with an ongoing composition text. 1973 // the input caret won't be moved with an ongoing composition text.
1974 if (event->type() == ui::ET_MOUSE_PRESSED) 1974 if (event->type() == ui::ET_MOUSE_PRESSED)
1975 FinishImeCompositionSession(); 1975 FinishImeCompositionSession();
1976 1976
1977 blink::WebMouseEvent mouse_event = ui::MakeWebMouseEvent( 1977 blink::WebMouseEvent mouse_event = ui::MakeWebMouseEvent(
1978 *event, base::Bind(&GetScreenLocationFromEvent)); 1978 *event, base::Bind(&GetScreenLocationFromEvent));
1979 ModifyEventMovementAndCoords(&mouse_event); 1979 ModifyEventMovementAndCoords(*event, &mouse_event);
1980 if (ShouldRouteEvent(event)) { 1980 if (ShouldRouteEvent(event)) {
1981 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, 1981 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this,
1982 &mouse_event); 1982 &mouse_event);
1983 } else { 1983 } else {
1984 ProcessMouseEvent(mouse_event, *event->latency()); 1984 ProcessMouseEvent(mouse_event, *event->latency());
1985 } 1985 }
1986 1986
1987 // Ensure that we get keyboard focus on mouse down as a plugin window may 1987 // Ensure that we get keyboard focus on mouse down as a plugin window may
1988 // have grabbed keyboard focus. 1988 // have grabbed keyboard focus.
1989 if (event->type() == ui::ET_MOUSE_PRESSED) 1989 if (event->type() == ui::ET_MOUSE_PRESSED)
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 if (!has_composition_text_) 2515 if (!has_composition_text_)
2516 return; 2516 return;
2517 2517
2518 if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) { 2518 if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) {
2519 text_input_manager_->GetActiveWidget()->ImeFinishComposingText(false); 2519 text_input_manager_->GetActiveWidget()->ImeFinishComposingText(false);
2520 } 2520 }
2521 ImeCancelComposition(); 2521 ImeCancelComposition();
2522 } 2522 }
2523 2523
2524 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( 2524 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords(
2525 const ui::MouseEvent& ui_mouse_event,
2525 blink::WebMouseEvent* event) { 2526 blink::WebMouseEvent* event) {
2526 // If the mouse has just entered, we must report zero movementX/Y. Hence we 2527 // If the mouse has just entered, we must report zero movementX/Y. Hence we
2527 // reset any global_mouse_position set previously. 2528 // reset any global_mouse_position set previously.
2528 if (event->type == blink::WebInputEvent::MouseEnter || 2529 if (ui_mouse_event.type() == ui::ET_MOUSE_ENTERED ||
2529 event->type == blink::WebInputEvent::MouseLeave) 2530 ui_mouse_event.type() == ui::ET_MOUSE_EXITED) {
2530 global_mouse_position_.SetPoint(event->globalX, event->globalY); 2531 global_mouse_position_.SetPoint(event->globalX, event->globalY);
2532 }
2531 2533
2532 // Movement is computed by taking the difference of the new cursor position 2534 // Movement is computed by taking the difference of the new cursor position
2533 // and the previous. Under mouse lock the cursor will be warped back to the 2535 // and the previous. Under mouse lock the cursor will be warped back to the
2534 // center so that we are not limited by clipping boundaries. 2536 // center so that we are not limited by clipping boundaries.
2535 // We do not measure movement as the delta from cursor to center because 2537 // We do not measure movement as the delta from cursor to center because
2536 // we may receive more mouse movement events before our warp has taken 2538 // we may receive more mouse movement events before our warp has taken
2537 // effect. 2539 // effect.
2538 event->movementX = event->globalX - global_mouse_position_.x(); 2540 event->movementX = event->globalX - global_mouse_position_.x();
2539 event->movementY = event->globalY - global_mouse_position_.y(); 2541 event->movementY = event->globalY - global_mouse_position_.y();
2540 2542
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 ->GetTextSelection(focused_view) 3066 ->GetTextSelection(focused_view)
3065 ->GetSelectedText(&selected_text)) { 3067 ->GetSelectedText(&selected_text)) {
3066 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 3068 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
3067 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 3069 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
3068 clipboard_writer.WriteText(selected_text); 3070 clipboard_writer.WriteText(selected_text);
3069 } 3071 }
3070 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 3072 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
3071 } 3073 }
3072 3074
3073 } // namespace content 3075 } // 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