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 17 matching lines...) Expand all Loading... | |
28 event->touches[i].position.y += delta.y(); | 28 event->touches[i].position.y += delta.y(); |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 blink::WebGestureEvent DummyGestureScrollUpdate(double timeStampSeconds) { | 32 blink::WebGestureEvent DummyGestureScrollUpdate(double timeStampSeconds) { |
33 return blink::WebGestureEvent(blink::WebInputEvent::GestureScrollUpdate, | 33 return blink::WebGestureEvent(blink::WebInputEvent::GestureScrollUpdate, |
34 blink::WebInputEvent::NoModifiers, | 34 blink::WebInputEvent::NoModifiers, |
35 timeStampSeconds); | 35 timeStampSeconds); |
36 } | 36 } |
37 | 37 |
38 bool IsGesturePinchEvent(const blink::WebGestureEvent* event) { | |
39 return event->type() == blink::WebInputEvent::GesturePinchBegin || | |
40 event->type() == blink::WebInputEvent::GesturePinchUpdate || | |
41 event->type() == blink::WebInputEvent::GesturePinchEnd; | |
42 } | |
43 | |
38 } // anonymous namespace | 44 } // anonymous namespace |
39 | 45 |
40 namespace content { | 46 namespace content { |
41 | 47 |
42 void RenderWidgetHostInputEventRouter::OnRenderWidgetHostViewBaseDestroyed( | 48 void RenderWidgetHostInputEventRouter::OnRenderWidgetHostViewBaseDestroyed( |
43 RenderWidgetHostViewBase* view) { | 49 RenderWidgetHostViewBase* view) { |
44 view->RemoveObserver(this); | 50 view->RemoveObserver(this); |
45 | 51 |
46 // Remove this view from the owner_map. | 52 // Remove this view from the owner_map. |
47 for (auto entry : owner_map_) { | 53 for (auto entry : owner_map_) { |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
682 // should have been one. | 688 // should have been one. |
683 if (root_view != touchscreen_gesture_target_.target && | 689 if (root_view != touchscreen_gesture_target_.target && |
684 !rwhi->is_in_touchscreen_gesture_scroll()) { | 690 !rwhi->is_in_touchscreen_gesture_scroll()) { |
685 gesture_pinch_did_send_scroll_begin_ = true; | 691 gesture_pinch_did_send_scroll_begin_ = true; |
686 SendGestureScrollBegin(root_view, *event); | 692 SendGestureScrollBegin(root_view, *event); |
687 } | 693 } |
688 } | 694 } |
689 | 695 |
690 if (in_touchscreen_gesture_pinch_) { | 696 if (in_touchscreen_gesture_pinch_) { |
691 root_view->ProcessGestureEvent(*event, latency); | 697 root_view->ProcessGestureEvent(*event, latency); |
698 if (IsGesturePinchEvent(event)) { | |
699 // Broadcast the pinch events to all subframes so they can update their | |
700 // PageScales with the deltas in the events. We don't broadcast to | |
701 // RenderWidgetHostViewGuest as it has a separate mechanism for | |
702 // propagating page scaleg | |
kenrb
2017/01/24 17:13:27
nit: Typo.
wjmaclean
2017/01/24 18:24:26
Done.
| |
703 for (auto entry : owner_map_) { | |
704 if (entry.second != root_view && | |
705 !entry.second->IsRenderWidgetHostViewGuest()) { | |
706 entry.second->ProcessGestureEvent(*event, latency); | |
kenrb
2017/01/24 17:13:27
Will this eventually get removed? It feels weird t
wjmaclean
2017/01/24 18:24:26
Yes, this will disappear with Salamander.
kenrb
2017/01/24 18:47:30
This warrants a TODO, marking it as temporary, the
| |
707 } | |
708 } | |
709 } | |
692 if (event->type() == blink::WebInputEvent::GesturePinchEnd) { | 710 if (event->type() == blink::WebInputEvent::GesturePinchEnd) { |
693 in_touchscreen_gesture_pinch_ = false; | 711 in_touchscreen_gesture_pinch_ = false; |
694 // If the root view wasn't already receiving the gesture stream, then we | 712 // If the root view wasn't already receiving the gesture stream, then we |
695 // need to wrap the diverted pinch events in a GestureScrollBegin/End. | 713 // need to wrap the diverted pinch events in a GestureScrollBegin/End. |
696 auto rwhi = | 714 auto rwhi = |
697 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); | 715 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); |
698 if (root_view != touchscreen_gesture_target_.target && | 716 if (root_view != touchscreen_gesture_target_.target && |
699 gesture_pinch_did_send_scroll_begin_ && | 717 gesture_pinch_did_send_scroll_begin_ && |
700 rwhi->is_in_touchscreen_gesture_scroll()) { | 718 rwhi->is_in_touchscreen_gesture_scroll()) { |
701 SendGestureScrollEnd(root_view, *event); | 719 SendGestureScrollEnd(root_view, *event); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
779 if (!touchpad_gesture_target_.target) | 797 if (!touchpad_gesture_target_.target) |
780 return; | 798 return; |
781 | 799 |
782 // TODO(mohsen): Add tests to check event location. | 800 // TODO(mohsen): Add tests to check event location. |
783 event->x += touchpad_gesture_target_.delta.x(); | 801 event->x += touchpad_gesture_target_.delta.x(); |
784 event->y += touchpad_gesture_target_.delta.y(); | 802 event->y += touchpad_gesture_target_.delta.y(); |
785 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); | 803 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); |
786 } | 804 } |
787 | 805 |
788 } // namespace content | 806 } // namespace content |
OLD | NEW |