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

Unified Diff: content/browser/renderer_host/render_widget_host_view_win.cc

Issue 10834269: gestures: Some more event cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 8 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_win.h ('k') | ui/aura/root_window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_win.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
index ea249f22fa91e5efc34c990f7c225f48c5ff0acb..5e607625b50dbd6c5dd5a50d43324138723f3ac2 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.cc
+++ b/content/browser/renderer_host/render_widget_host_view_win.cc
@@ -372,60 +372,41 @@ WebKit::WebInputEvent::Type ConvertToWebInputEvent(ui::EventType t) {
}
}
-class LocalGestureEvent : public ui::GestureEvent {
- public:
- LocalGestureEvent(HWND hwnd,
- const ui::GestureEventDetails& details,
- const gfx::Point& location,
- int flags,
- base::Time time,
- unsigned int touch_id_bitfield)
- : ui::GestureEvent(details.type(), location.x(), location.y(), flags,
- time, details, touch_id_bitfield),
- client_point_(location.ToPOINT()),
- screen_point_(location.ToPOINT()) {
- MapWindowPoints(::GetParent(hwnd), hwnd, &client_point_, 1);
- MapWindowPoints(hwnd, HWND_DESKTOP, &screen_point_, 1);
- }
-
- virtual ~LocalGestureEvent() {}
-
- WebKit::WebGestureEvent ToWebGestureEvent() {
- WebKit::WebGestureEvent gesture_event;
- gesture_event.type = ConvertToWebInputEvent(type());
- gesture_event.x = client_point_.x;
- gesture_event.y = client_point_.y;
- gesture_event.globalX = screen_point_.x;
- gesture_event.globalY = screen_point_.y;
- gesture_event.boundingBox = details().bounding_box();
-
- // Copy any event-type specific data.
- switch (type()) {
- case ui::ET_GESTURE_TAP:
- gesture_event.deltaX = details().tap_count();
- break;
- case ui::ET_GESTURE_SCROLL_UPDATE:
- gesture_event.deltaX = details().scroll_x();
- gesture_event.deltaY = details().scroll_y();
- break;
- case ui::ET_GESTURE_PINCH_UPDATE:
- gesture_event.deltaX = details().scale();
- break;
- case ui::ET_SCROLL_FLING_START:
- gesture_event.deltaX = details().velocity_x();
- gesture_event.deltaY = details().velocity_y();
- default:
- break;
- }
- return gesture_event;
+WebKit::WebGestureEvent CreateWebGestureEvent(HWND hwnd,
+ const ui::GestureEvent& gesture) {
+ POINT client_point = gesture.location().ToPOINT();
+ POINT screen_point = gesture.location().ToPOINT();
+ MapWindowPoints(::GetParent(hwnd), hwnd, &client_point, 1);
+ MapWindowPoints(hwnd, HWND_DESKTOP, &screen_point, 1);
+
+ WebKit::WebGestureEvent gesture_event;
+ gesture_event.type = ConvertToWebInputEvent(gesture.type());
+ gesture_event.x = client_point.x;
+ gesture_event.y = client_point.y;
+ gesture_event.globalX = screen_point.x;
+ gesture_event.globalY = screen_point.y;
+ gesture_event.boundingBox = gesture.details().bounding_box();
+
+ // Copy any event-type specific data.
+ switch (gesture.type()) {
+ case ui::ET_GESTURE_TAP:
+ gesture_event.deltaX = gesture.details().tap_count();
+ break;
+ case ui::ET_GESTURE_SCROLL_UPDATE:
+ gesture_event.deltaX = gesture.details().scroll_x();
+ gesture_event.deltaY = gesture.details().scroll_y();
+ break;
+ case ui::ET_GESTURE_PINCH_UPDATE:
+ gesture_event.deltaX = gesture.details().scale();
+ break;
+ case ui::ET_SCROLL_FLING_START:
+ gesture_event.deltaX = gesture.details().velocity_x();
+ gesture_event.deltaY = gesture.details().velocity_y();
+ default:
+ break;
}
-
- private:
- POINT client_point_;
- POINT screen_point_;
-
- DISALLOW_COPY_AND_ASSIGN(LocalGestureEvent);
-};
+ return gesture_event;
+}
class TouchEventFromWebTouchPoint : public ui::TouchEvent {
public:
@@ -1214,24 +1195,6 @@ void RenderWidgetHostViewWin::UpdateDesiredTouchMode(bool touch_mode) {
}
}
-ui::GestureEvent* RenderWidgetHostViewWin::CreateGestureEvent(
- const ui::GestureEventDetails& details,
- const gfx::Point& location,
- int flags,
- base::Time time,
- unsigned int touch_id_bitfield) {
- return new LocalGestureEvent(m_hWnd, details, location, flags, time,
- touch_id_bitfield);
-}
-
-ui::TouchEvent* RenderWidgetHostViewWin::CreateTouchEvent(
- ui::EventType type,
- const gfx::Point& location,
- int touch_id,
- base::TimeDelta time_stamp) {
- return new ui::TouchEvent(type, location, touch_id, time_stamp);
-}
-
bool RenderWidgetHostViewWin::DispatchLongPressGestureEvent(
ui::GestureEvent* event) {
return ForwardGestureEventToRenderer(event);
@@ -2797,11 +2760,10 @@ bool RenderWidgetHostViewWin::ForwardGestureEventToRenderer(
if (!render_widget_host_)
return false;
- LocalGestureEvent* local = static_cast<LocalGestureEvent*>(gesture);
- WebKit::WebGestureEvent gesture_event = local->ToWebGestureEvent();
- if (gesture_event.type == WebKit::WebGestureEvent::Undefined)
+ WebKit::WebGestureEvent web_gesture = CreateWebGestureEvent(m_hWnd, *gesture);
+ if (web_gesture.type == WebKit::WebGestureEvent::Undefined)
return false;
- render_widget_host_->ForwardGestureEvent(gesture_event);
+ render_widget_host_->ForwardGestureEvent(web_gesture);
return true;
}
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_win.h ('k') | ui/aura/root_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698