| OLD | NEW |
| 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_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 } | 744 } |
| 745 | 745 |
| 746 void RenderWidgetHostImpl::EnableFullAccessibilityMode() { | 746 void RenderWidgetHostImpl::EnableFullAccessibilityMode() { |
| 747 SetAccessibilityMode(AccessibilityModeComplete); | 747 SetAccessibilityMode(AccessibilityModeComplete); |
| 748 } | 748 } |
| 749 | 749 |
| 750 static WebGestureEvent MakeGestureEvent(WebInputEvent::Type type, | 750 static WebGestureEvent MakeGestureEvent(WebInputEvent::Type type, |
| 751 double timestamp_seconds, | 751 double timestamp_seconds, |
| 752 int x, | 752 int x, |
| 753 int y, | 753 int y, |
| 754 float delta_x, | |
| 755 float delta_y, | |
| 756 int modifiers) { | 754 int modifiers) { |
| 757 WebGestureEvent result; | 755 WebGestureEvent result; |
| 758 | 756 |
| 759 result.type = type; | 757 result.type = type; |
| 760 result.x = x; | 758 result.x = x; |
| 761 result.y = y; | 759 result.y = y; |
| 762 result.deltaX = delta_x; | |
| 763 result.deltaY = delta_y; | |
| 764 result.timeStampSeconds = timestamp_seconds; | 760 result.timeStampSeconds = timestamp_seconds; |
| 765 result.modifiers = modifiers; | 761 result.modifiers = modifiers; |
| 766 | 762 |
| 767 return result; | 763 return result; |
| 768 } | 764 } |
| 769 | 765 |
| 770 void RenderWidgetHostImpl::SimulateTouchGestureWithMouse( | 766 void RenderWidgetHostImpl::SimulateTouchGestureWithMouse( |
| 771 const WebMouseEvent& mouse_event) { | 767 const WebMouseEvent& mouse_event) { |
| 772 int x = mouse_event.x, y = mouse_event.y; | 768 int x = mouse_event.x, y = mouse_event.y; |
| 773 float dx = mouse_event.movementX, dy = mouse_event.movementY; | 769 float dx = mouse_event.movementX, dy = mouse_event.movementY; |
| 774 static int startX = 0, startY = 0; | 770 static int startX = 0, startY = 0; |
| 775 | 771 |
| 776 switch (mouse_event.button) { | 772 switch (mouse_event.button) { |
| 777 case WebMouseEvent::ButtonLeft: | 773 case WebMouseEvent::ButtonLeft: |
| 778 if (mouse_event.type == WebInputEvent::MouseDown) { | 774 if (mouse_event.type == WebInputEvent::MouseDown) { |
| 779 startX = x; | 775 startX = x; |
| 780 startY = y; | 776 startY = y; |
| 781 ForwardGestureEvent(MakeGestureEvent( | 777 ForwardGestureEvent(MakeGestureEvent( |
| 782 WebInputEvent::GestureScrollBegin, mouse_event.timeStampSeconds, | 778 WebInputEvent::GestureScrollBegin, mouse_event.timeStampSeconds, |
| 783 x, y, 0, 0, 0)); | 779 x, y, 0)); |
| 784 } | 780 } |
| 785 if (dx != 0 || dy != 0) { | 781 if (dx != 0 || dy != 0) { |
| 786 ForwardGestureEvent(MakeGestureEvent( | 782 WebGestureEvent event = MakeGestureEvent( |
| 787 WebInputEvent::GestureScrollUpdate, mouse_event.timeStampSeconds, | 783 WebInputEvent::GestureScrollUpdate, mouse_event.timeStampSeconds, |
| 788 x, y, dx, dy, 0)); | 784 x, y, 0); |
| 785 event.data.scrollUpdate.deltaX = dx; |
| 786 event.data.scrollUpdate.deltaY = dy; |
| 787 // TODO(rbyers): deltaX/deltaY fields going away. crbug.com/143237 |
| 788 event.deltaX = dx; |
| 789 event.deltaY = dy; |
| 790 ForwardGestureEvent(event); |
| 789 } | 791 } |
| 790 if (mouse_event.type == WebInputEvent::MouseUp) { | 792 if (mouse_event.type == WebInputEvent::MouseUp) { |
| 791 ForwardGestureEvent(MakeGestureEvent( | 793 ForwardGestureEvent(MakeGestureEvent( |
| 792 WebInputEvent::GestureScrollEnd, mouse_event.timeStampSeconds, | 794 WebInputEvent::GestureScrollEnd, mouse_event.timeStampSeconds, |
| 793 x, y, dx, dy, 0)); | 795 x, y, 0)); |
| 794 } | 796 } |
| 795 break; | 797 break; |
| 796 case WebMouseEvent::ButtonMiddle: | 798 case WebMouseEvent::ButtonMiddle: |
| 797 if (mouse_event.type == WebInputEvent::MouseDown) { | 799 if (mouse_event.type == WebInputEvent::MouseDown) { |
| 798 startX = x; | 800 startX = x; |
| 799 startY = y; | 801 startY = y; |
| 800 ForwardGestureEvent(MakeGestureEvent( | 802 ForwardGestureEvent(MakeGestureEvent( |
| 801 WebInputEvent::GestureTapDown, mouse_event.timeStampSeconds, | 803 WebInputEvent::GestureTapDown, mouse_event.timeStampSeconds, |
| 802 x, y, 0, 0, 0)); | 804 x, y, 0)); |
| 803 } | 805 } |
| 804 if (mouse_event.type == WebInputEvent::MouseUp) { | 806 if (mouse_event.type == WebInputEvent::MouseUp) { |
| 805 ForwardGestureEvent(MakeGestureEvent( | 807 ForwardGestureEvent(MakeGestureEvent( |
| 806 WebInputEvent::GestureTap, mouse_event.timeStampSeconds, | 808 WebInputEvent::GestureTap, mouse_event.timeStampSeconds, |
| 807 x, y, dx, dy, 0)); | 809 x, y, 0)); |
| 808 } | 810 } |
| 809 break; | 811 break; |
| 810 case WebMouseEvent::ButtonRight: | 812 case WebMouseEvent::ButtonRight: |
| 811 if (mouse_event.type == WebInputEvent::MouseDown) { | 813 if (mouse_event.type == WebInputEvent::MouseDown) { |
| 812 startX = x; | 814 startX = x; |
| 813 startY = y; | 815 startY = y; |
| 814 ForwardGestureEvent(MakeGestureEvent( | 816 ForwardGestureEvent(MakeGestureEvent( |
| 815 WebInputEvent::GesturePinchBegin, mouse_event.timeStampSeconds, | 817 WebInputEvent::GesturePinchBegin, mouse_event.timeStampSeconds, |
| 816 x, y, 1, 1, 0)); | 818 x, y, 0)); |
| 817 } | 819 } |
| 818 if (dx != 0 || dy != 0) { | 820 if (dx != 0 || dy != 0) { |
| 819 dx = pow(dy < 0 ? 0.998f : 1.002f, fabs(dy)); | 821 dx = pow(dy < 0 ? 0.998f : 1.002f, fabs(dy)); |
| 820 dy = dx; | 822 WebGestureEvent event = MakeGestureEvent( |
| 821 ForwardGestureEvent(MakeGestureEvent( | |
| 822 WebInputEvent::GesturePinchUpdate, mouse_event.timeStampSeconds, | 823 WebInputEvent::GesturePinchUpdate, mouse_event.timeStampSeconds, |
| 823 startX, startY, dx, dy, 0)); | 824 startX, startY, 0); |
| 825 event.data.pinchUpdate.scale = dx; |
| 826 event.deltaX = dx; |
| 827 ForwardGestureEvent(event); |
| 824 } | 828 } |
| 825 if (mouse_event.type == WebInputEvent::MouseUp) { | 829 if (mouse_event.type == WebInputEvent::MouseUp) { |
| 826 ForwardGestureEvent(MakeGestureEvent( | 830 ForwardGestureEvent(MakeGestureEvent( |
| 827 WebInputEvent::GesturePinchEnd, mouse_event.timeStampSeconds, | 831 WebInputEvent::GesturePinchEnd, mouse_event.timeStampSeconds, |
| 828 x, y, dx, dy, 0)); | 832 x, y, 0)); |
| 829 } | 833 } |
| 830 break; | 834 break; |
| 831 case WebMouseEvent::ButtonNone: | 835 case WebMouseEvent::ButtonNone: |
| 832 break; | 836 break; |
| 833 } | 837 } |
| 834 } | 838 } |
| 835 | 839 |
| 836 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 840 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
| 837 TRACE_EVENT2("renderer_host", "RenderWidgetHostImpl::ForwardMouseEvent", | 841 TRACE_EVENT2("renderer_host", "RenderWidgetHostImpl::ForwardMouseEvent", |
| 838 "x", mouse_event.x, "y", mouse_event.y); | 842 "x", mouse_event.x, "y", mouse_event.y); |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 // indicate that no callback is in progress (i.e. without this line | 2042 // indicate that no callback is in progress (i.e. without this line |
| 2039 // DelayedAutoResized will not get called again). | 2043 // DelayedAutoResized will not get called again). |
| 2040 new_auto_size_.SetSize(0, 0); | 2044 new_auto_size_.SetSize(0, 0); |
| 2041 if (!should_auto_resize_) | 2045 if (!should_auto_resize_) |
| 2042 return; | 2046 return; |
| 2043 | 2047 |
| 2044 OnRenderAutoResized(new_size); | 2048 OnRenderAutoResized(new_size); |
| 2045 } | 2049 } |
| 2046 | 2050 |
| 2047 } // namespace content | 2051 } // namespace content |
| OLD | NEW |