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

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

Issue 2477893002: Clear last MouseMove root view in RWHIER if that view gets destroyed (Closed)
Patch Set: Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_input_event_router.h" 5 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // When a child iframe is destroyed, consider its parent to be to be the 82 // When a child iframe is destroyed, consider its parent to be to be the
83 // most recent target, if possible. In some cases the parent might already 83 // most recent target, if possible. In some cases the parent might already
84 // have been destroyed, in which case the last target is cleared. 84 // have been destroyed, in which case the last target is cleared.
85 if (view != last_mouse_move_root_view_) 85 if (view != last_mouse_move_root_view_)
86 last_mouse_move_target_ = 86 last_mouse_move_target_ =
87 static_cast<RenderWidgetHostViewChildFrame*>(last_mouse_move_target_) 87 static_cast<RenderWidgetHostViewChildFrame*>(last_mouse_move_target_)
88 ->GetParentView(); 88 ->GetParentView();
89 else 89 else
90 last_mouse_move_target_ = nullptr; 90 last_mouse_move_target_ = nullptr;
91 91
92 if (!last_mouse_move_target_) 92 if (!last_mouse_move_target_ || view == last_mouse_move_root_view_)
93 last_mouse_move_root_view_ = nullptr; 93 last_mouse_move_root_view_ = nullptr;
94 } 94 }
95 } 95 }
96 96
97 void RenderWidgetHostInputEventRouter::ClearAllObserverRegistrations() { 97 void RenderWidgetHostInputEventRouter::ClearAllObserverRegistrations() {
98 for (auto entry : owner_map_) 98 for (auto entry : owner_map_)
99 entry.second->RemoveObserver(this); 99 entry.second->RemoveObserver(this);
100 owner_map_.clear(); 100 owner_map_.clear();
101 } 101 }
102 102
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // space. 379 // space.
380 if (root_view != last_mouse_move_root_view_) 380 if (root_view != last_mouse_move_root_view_)
381 last_mouse_move_target_ = nullptr; 381 last_mouse_move_target_ = nullptr;
382 382
383 // Finding the LCA uses a standard approach. We build vectors of the 383 // Finding the LCA uses a standard approach. We build vectors of the
384 // ancestors of each node up to the root, and then remove common ancestors. 384 // ancestors of each node up to the root, and then remove common ancestors.
385 std::vector<RenderWidgetHostViewBase*> entered_views; 385 std::vector<RenderWidgetHostViewBase*> entered_views;
386 std::vector<RenderWidgetHostViewBase*> exited_views; 386 std::vector<RenderWidgetHostViewBase*> exited_views;
387 RenderWidgetHostViewBase* cur_view = target; 387 RenderWidgetHostViewBase* cur_view = target;
388 entered_views.push_back(cur_view); 388 entered_views.push_back(cur_view);
389 while (cur_view != root_view) { 389 while (cur_view->IsRenderWidgetHostViewChildFrame()) {
390 // Non-root RWHVs are guaranteed to be RenderWidgetHostViewChildFrames.
391 cur_view = 390 cur_view =
392 static_cast<RenderWidgetHostViewChildFrame*>(cur_view)->GetParentView(); 391 static_cast<RenderWidgetHostViewChildFrame*>(cur_view)->GetParentView();
393 // cur_view can possibly be nullptr for guestviews that are not currently 392 // cur_view can possibly be nullptr for guestviews that are not currently
394 // connected to the webcontents tree. 393 // connected to the webcontents tree.
395 if (!cur_view) 394 if (!cur_view) {
396 break; 395 last_mouse_move_target_ = target;
396 last_mouse_move_root_view_ = root_view;
397 return;
398 }
397 entered_views.push_back(cur_view); 399 entered_views.push_back(cur_view);
398 } 400 }
401 // Non-root RWHVs are guaranteed to be RenderWidgetHostViewChildFrames,
402 // as long as they are the only embeddable RWHVs.
403 DCHECK_EQ(cur_view, root_view);
399 404
400 cur_view = last_mouse_move_target_; 405 cur_view = last_mouse_move_target_;
401 if (cur_view) { 406 if (cur_view) {
402 exited_views.push_back(cur_view); 407 exited_views.push_back(cur_view);
403 while (cur_view != root_view) { 408 while (cur_view->IsRenderWidgetHostViewChildFrame()) {
404 cur_view = static_cast<RenderWidgetHostViewChildFrame*>(cur_view) 409 cur_view = static_cast<RenderWidgetHostViewChildFrame*>(cur_view)
405 ->GetParentView(); 410 ->GetParentView();
406 if (!cur_view) 411 if (!cur_view) {
407 break; 412 last_mouse_move_target_ = target;
413 last_mouse_move_root_view_ = root_view;
414 return;
415 }
408 exited_views.push_back(cur_view); 416 exited_views.push_back(cur_view);
409 } 417 }
418 DCHECK_EQ(cur_view, root_view);
410 } 419 }
411 420
412 // This removes common ancestors from the root downward. 421 // This removes common ancestors from the root downward.
413 RenderWidgetHostViewBase* common_ancestor = nullptr; 422 RenderWidgetHostViewBase* common_ancestor = nullptr;
414 while (entered_views.size() > 0 && exited_views.size() > 0 && 423 while (entered_views.size() > 0 && exited_views.size() > 0 &&
415 entered_views.back() == exited_views.back()) { 424 entered_views.back() == exited_views.back()) {
416 common_ancestor = entered_views.back(); 425 common_ancestor = entered_views.back();
417 entered_views.pop_back(); 426 entered_views.pop_back();
418 exited_views.pop_back(); 427 exited_views.pop_back();
419 } 428 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 if (!touchpad_gesture_target_.target) 735 if (!touchpad_gesture_target_.target)
727 return; 736 return;
728 737
729 // TODO(mohsen): Add tests to check event location. 738 // TODO(mohsen): Add tests to check event location.
730 event->x += touchpad_gesture_target_.delta.x(); 739 event->x += touchpad_gesture_target_.delta.x();
731 event->y += touchpad_gesture_target_.delta.y(); 740 event->y += touchpad_gesture_target_.delta.y();
732 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); 741 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency);
733 } 742 }
734 743
735 } // namespace content 744 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698