| OLD | NEW |
| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // When a child iframe is destroyed, consider its parent to be to be the | 83 // When a child iframe is destroyed, consider its parent to be to be the |
| 84 // most recent target, if possible. In some cases the parent might already | 84 // most recent target, if possible. In some cases the parent might already |
| 85 // have been destroyed, in which case the last target is cleared. | 85 // have been destroyed, in which case the last target is cleared. |
| 86 if (view != last_mouse_move_root_view_) | 86 if (view != last_mouse_move_root_view_) |
| 87 last_mouse_move_target_ = | 87 last_mouse_move_target_ = |
| 88 static_cast<RenderWidgetHostViewChildFrame*>(last_mouse_move_target_) | 88 static_cast<RenderWidgetHostViewChildFrame*>(last_mouse_move_target_) |
| 89 ->GetParentView(); | 89 ->GetParentView(); |
| 90 else | 90 else |
| 91 last_mouse_move_target_ = nullptr; | 91 last_mouse_move_target_ = nullptr; |
| 92 | 92 |
| 93 if (!last_mouse_move_target_) | 93 if (!last_mouse_move_target_ || view == last_mouse_move_root_view_) |
| 94 last_mouse_move_root_view_ = nullptr; | 94 last_mouse_move_root_view_ = nullptr; |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 void RenderWidgetHostInputEventRouter::ClearAllObserverRegistrations() { | 98 void RenderWidgetHostInputEventRouter::ClearAllObserverRegistrations() { |
| 99 for (auto entry : owner_map_) | 99 for (auto entry : owner_map_) |
| 100 entry.second->RemoveObserver(this); | 100 entry.second->RemoveObserver(this); |
| 101 owner_map_.clear(); | 101 owner_map_.clear(); |
| 102 } | 102 } |
| 103 | 103 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // space. | 375 // space. |
| 376 if (root_view != last_mouse_move_root_view_) | 376 if (root_view != last_mouse_move_root_view_) |
| 377 last_mouse_move_target_ = nullptr; | 377 last_mouse_move_target_ = nullptr; |
| 378 | 378 |
| 379 // Finding the LCA uses a standard approach. We build vectors of the | 379 // Finding the LCA uses a standard approach. We build vectors of the |
| 380 // ancestors of each node up to the root, and then remove common ancestors. | 380 // ancestors of each node up to the root, and then remove common ancestors. |
| 381 std::vector<RenderWidgetHostViewBase*> entered_views; | 381 std::vector<RenderWidgetHostViewBase*> entered_views; |
| 382 std::vector<RenderWidgetHostViewBase*> exited_views; | 382 std::vector<RenderWidgetHostViewBase*> exited_views; |
| 383 RenderWidgetHostViewBase* cur_view = target; | 383 RenderWidgetHostViewBase* cur_view = target; |
| 384 entered_views.push_back(cur_view); | 384 entered_views.push_back(cur_view); |
| 385 while (cur_view != root_view) { | 385 while (cur_view->IsRenderWidgetHostViewChildFrame()) { |
| 386 // Non-root RWHVs are guaranteed to be RenderWidgetHostViewChildFrames. | |
| 387 cur_view = | 386 cur_view = |
| 388 static_cast<RenderWidgetHostViewChildFrame*>(cur_view)->GetParentView(); | 387 static_cast<RenderWidgetHostViewChildFrame*>(cur_view)->GetParentView(); |
| 389 // cur_view can possibly be nullptr for guestviews that are not currently | 388 // cur_view can possibly be nullptr for guestviews that are not currently |
| 390 // connected to the webcontents tree. | 389 // connected to the webcontents tree. |
| 391 if (!cur_view) | 390 if (!cur_view) { |
| 392 break; | 391 last_mouse_move_target_ = target; |
| 392 last_mouse_move_root_view_ = root_view; |
| 393 return; |
| 394 } |
| 393 entered_views.push_back(cur_view); | 395 entered_views.push_back(cur_view); |
| 394 } | 396 } |
| 397 // Non-root RWHVs are guaranteed to be RenderWidgetHostViewChildFrames, |
| 398 // as long as they are the only embeddable RWHVs. |
| 399 DCHECK_EQ(cur_view, root_view); |
| 395 | 400 |
| 396 cur_view = last_mouse_move_target_; | 401 cur_view = last_mouse_move_target_; |
| 397 if (cur_view) { | 402 if (cur_view) { |
| 398 exited_views.push_back(cur_view); | 403 exited_views.push_back(cur_view); |
| 399 while (cur_view != root_view) { | 404 while (cur_view->IsRenderWidgetHostViewChildFrame()) { |
| 400 cur_view = static_cast<RenderWidgetHostViewChildFrame*>(cur_view) | 405 cur_view = static_cast<RenderWidgetHostViewChildFrame*>(cur_view) |
| 401 ->GetParentView(); | 406 ->GetParentView(); |
| 402 if (!cur_view) | 407 if (!cur_view) { |
| 403 break; | 408 last_mouse_move_target_ = target; |
| 409 last_mouse_move_root_view_ = root_view; |
| 410 return; |
| 411 } |
| 404 exited_views.push_back(cur_view); | 412 exited_views.push_back(cur_view); |
| 405 } | 413 } |
| 414 DCHECK_EQ(cur_view, root_view); |
| 406 } | 415 } |
| 407 | 416 |
| 408 // This removes common ancestors from the root downward. | 417 // This removes common ancestors from the root downward. |
| 409 RenderWidgetHostViewBase* common_ancestor = nullptr; | 418 RenderWidgetHostViewBase* common_ancestor = nullptr; |
| 410 while (entered_views.size() > 0 && exited_views.size() > 0 && | 419 while (entered_views.size() > 0 && exited_views.size() > 0 && |
| 411 entered_views.back() == exited_views.back()) { | 420 entered_views.back() == exited_views.back()) { |
| 412 common_ancestor = entered_views.back(); | 421 common_ancestor = entered_views.back(); |
| 413 entered_views.pop_back(); | 422 entered_views.pop_back(); |
| 414 exited_views.pop_back(); | 423 exited_views.pop_back(); |
| 415 } | 424 } |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 if (!touchpad_gesture_target_.target) | 738 if (!touchpad_gesture_target_.target) |
| 730 return; | 739 return; |
| 731 | 740 |
| 732 // TODO(mohsen): Add tests to check event location. | 741 // TODO(mohsen): Add tests to check event location. |
| 733 event->x += touchpad_gesture_target_.delta.x(); | 742 event->x += touchpad_gesture_target_.delta.x(); |
| 734 event->y += touchpad_gesture_target_.delta.y(); | 743 event->y += touchpad_gesture_target_.delta.y(); |
| 735 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); | 744 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); |
| 736 } | 745 } |
| 737 | 746 |
| 738 } // namespace content | 747 } // namespace content |
| OLD | NEW |