OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/render_widget_host_view_views.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 return WebKit::WebInputEvent::TouchEnd; | 100 return WebKit::WebInputEvent::TouchEnd; |
101 case ui::ET_TOUCH_MOVED: | 101 case ui::ET_TOUCH_MOVED: |
102 return WebKit::WebInputEvent::TouchMove; | 102 return WebKit::WebInputEvent::TouchMove; |
103 case ui::ET_TOUCH_CANCELLED: | 103 case ui::ET_TOUCH_CANCELLED: |
104 return WebKit::WebInputEvent::TouchCancel; | 104 return WebKit::WebInputEvent::TouchCancel; |
105 default: | 105 default: |
106 return WebKit::WebInputEvent::Undefined; | 106 return WebKit::WebInputEvent::Undefined; |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
| 110 inline void UpdateTouchParams(const views::TouchEvent& event, |
| 111 WebKit::WebTouchPoint* tpoint) { |
| 112 tpoint->radiusX = event.radius_x(); |
| 113 tpoint->radiusY = event.radius_y(); |
| 114 tpoint->rotationAngle = event.angle(); |
| 115 } |
| 116 |
110 void UpdateTouchPointPosition(const views::TouchEvent* event, | 117 void UpdateTouchPointPosition(const views::TouchEvent* event, |
111 const gfx::Point& origin, | 118 const gfx::Point& origin, |
112 WebKit::WebTouchPoint* tpoint) { | 119 WebKit::WebTouchPoint* tpoint) { |
113 tpoint->position.x = event->x(); | 120 tpoint->position.x = event->x(); |
114 tpoint->position.y = event->y(); | 121 tpoint->position.y = event->y(); |
115 | 122 |
116 tpoint->screenPosition.x = tpoint->position.x + origin.x(); | 123 tpoint->screenPosition.x = tpoint->position.x + origin.x(); |
117 tpoint->screenPosition.y = tpoint->position.y + origin.y(); | 124 tpoint->screenPosition.y = tpoint->position.y + origin.y(); |
118 } | 125 } |
119 | 126 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 DLOG(WARNING) << "Unknown touch event " << event.type(); | 563 DLOG(WARNING) << "Unknown touch event " << event.type(); |
557 break; | 564 break; |
558 } | 565 } |
559 | 566 |
560 if (!point) | 567 if (!point) |
561 return TOUCH_STATUS_UNKNOWN; | 568 return TOUCH_STATUS_UNKNOWN; |
562 | 569 |
563 if (status != TOUCH_STATUS_START) | 570 if (status != TOUCH_STATUS_START) |
564 status = TOUCH_STATUS_CONTINUE; | 571 status = TOUCH_STATUS_CONTINUE; |
565 | 572 |
| 573 UpdateTouchParams(event, point); |
| 574 |
566 // Update the location and state of the point. | 575 // Update the location and state of the point. |
567 point->state = TouchPointStateFromEvent(&event); | 576 point->state = TouchPointStateFromEvent(&event); |
568 if (point->state == WebKit::WebTouchPoint::StateMoved) { | 577 if (point->state == WebKit::WebTouchPoint::StateMoved) { |
569 // It is possible for badly written touch drivers to emit Move events even | 578 // It is possible for badly written touch drivers to emit Move events even |
570 // when the touch location hasn't changed. In such cases, consume the event | 579 // when the touch location hasn't changed. In such cases, consume the event |
571 // and pretend nothing happened. | 580 // and pretend nothing happened. |
572 if (point->position.x == event.x() && point->position.y == event.y()) { | 581 if (point->position.x == event.x() && point->position.y == event.y()) { |
573 return status; | 582 return status; |
574 } | 583 } |
575 } | 584 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 } | 947 } |
939 | 948 |
940 // static | 949 // static |
941 RenderWidgetHostView* | 950 RenderWidgetHostView* |
942 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 951 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
943 gfx::NativeView widget) { | 952 gfx::NativeView widget) { |
944 gpointer user_data = g_object_get_data(G_OBJECT(widget), | 953 gpointer user_data = g_object_get_data(G_OBJECT(widget), |
945 kRenderWidgetHostViewKey); | 954 kRenderWidgetHostViewKey); |
946 return reinterpret_cast<RenderWidgetHostView*>(user_data); | 955 return reinterpret_cast<RenderWidgetHostView*>(user_data); |
947 } | 956 } |
OLD | NEW |