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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_win.cc

Issue 10824247: Remove GestureEvent interface, and rename GestureEventImpl to GestureEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_view_win.h" 5 #include "content/browser/renderer_host/render_widget_host_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <peninputpanel_i.c> 9 #include <peninputpanel_i.c>
10 #include <stack> 10 #include <stack>
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 last_pt.x = gi.ptsLocation.x; 264 last_pt.x = gi.ptsLocation.x;
265 last_pt.y = gi.ptsLocation.y; 265 last_pt.y = gi.ptsLocation.y;
266 *start = start_pt; 266 *start = start_pt;
267 return true; 267 return true;
268 } 268 }
269 269
270 WebKit::WebMouseWheelEvent MakeFakeScrollWheelEvent(HWND hwnd, 270 WebKit::WebMouseWheelEvent MakeFakeScrollWheelEvent(HWND hwnd,
271 POINT start, 271 POINT start,
272 POINT delta) { 272 POINT delta) {
273 WebKit::WebMouseWheelEvent result; 273 WebKit::WebMouseWheelEvent result;
274 result.type = WebInputEvent::MouseWheel; 274 result.type = WebInputEvent::MouseWheel;
275 result.timeStampSeconds = ::GetMessageTime() / 1000.0; 275 result.timeStampSeconds = ::GetMessageTime() / 1000.0;
276 result.button = WebMouseEvent::ButtonNone; 276 result.button = WebMouseEvent::ButtonNone;
277 result.globalX = start.x; 277 result.globalX = start.x;
278 result.globalY = start.y; 278 result.globalY = start.y;
279 // Map to window coordinates. 279 // Map to window coordinates.
280 POINT client_point = { result.globalX, result.globalY }; 280 POINT client_point = { result.globalX, result.globalY };
281 MapWindowPoints(0, hwnd, &client_point, 1); 281 MapWindowPoints(0, hwnd, &client_point, 1);
282 result.x = client_point.x; 282 result.x = client_point.x;
283 result.y = client_point.y; 283 result.y = client_point.y;
284 result.windowX = result.x; 284 result.windowX = result.x;
285 result.windowY = result.y; 285 result.windowY = result.y;
286 // Note that we support diagonal scrolling. 286 // Note that we support diagonal scrolling.
287 result.deltaX = static_cast<float>(delta.x); 287 result.deltaX = static_cast<float>(delta.x);
288 result.wheelTicksX = WHEEL_DELTA; 288 result.wheelTicksX = WHEEL_DELTA;
289 result.deltaY = static_cast<float>(delta.y); 289 result.deltaY = static_cast<float>(delta.y);
290 result.wheelTicksY = WHEEL_DELTA; 290 result.wheelTicksY = WHEEL_DELTA;
291 return result; 291 return result;
292 } 292 }
293 293
294 static const int kTouchMask = 0x7; 294 static const int kTouchMask = 0x7;
295 295
296 inline int GetTouchType(const TOUCHINPUT& point) { 296 inline int GetTouchType(const TOUCHINPUT& point) {
297 return point.dwFlags & kTouchMask; 297 return point.dwFlags & kTouchMask;
298 } 298 }
299 299
300 inline void SetTouchType(TOUCHINPUT* point, int type) { 300 inline void SetTouchType(TOUCHINPUT* point, int type) {
301 point->dwFlags = (point->dwFlags & kTouchMask) | type; 301 point->dwFlags = (point->dwFlags & kTouchMask) | type;
302 } 302 }
303 303
304 template <class IINTERFACE, class PAYLOAD>
305 class WrappedObject : public IINTERFACE {
306 public:
307 WrappedObject() {
308 }
309 const PAYLOAD& data() const {
310 return data_;
311 }
312 PAYLOAD& data() {
313 return data_;
314 }
315
316 private:
317 PAYLOAD data_;
318
319 typedef WrappedObject<IINTERFACE,PAYLOAD> Type;
320 DISALLOW_COPY_AND_ASSIGN(Type);
321 };
322
323 ui::EventType ConvertToUIEvent(WebKit::WebTouchPoint::State t) { 304 ui::EventType ConvertToUIEvent(WebKit::WebTouchPoint::State t) {
324 switch (t) { 305 switch (t) {
325 case WebKit::WebTouchPoint::StatePressed: 306 case WebKit::WebTouchPoint::StatePressed:
326 return ui::ET_TOUCH_PRESSED; 307 return ui::ET_TOUCH_PRESSED;
327 case WebKit::WebTouchPoint::StateMoved: 308 case WebKit::WebTouchPoint::StateMoved:
328 return ui::ET_TOUCH_MOVED; 309 return ui::ET_TOUCH_MOVED;
329 case WebKit::WebTouchPoint::StateStationary: 310 case WebKit::WebTouchPoint::StateStationary:
330 return ui::ET_TOUCH_STATIONARY; 311 return ui::ET_TOUCH_STATIONARY;
331 case WebKit::WebTouchPoint::StateReleased: 312 case WebKit::WebTouchPoint::StateReleased:
332 return ui::ET_TOUCH_RELEASED; 313 return ui::ET_TOUCH_RELEASED;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 case ui::ET_TOUCH_RELEASED: 365 case ui::ET_TOUCH_RELEASED:
385 return WebKit::WebInputEvent::TouchEnd; 366 return WebKit::WebInputEvent::TouchEnd;
386 case ui::ET_TOUCH_CANCELLED: 367 case ui::ET_TOUCH_CANCELLED:
387 return WebKit::WebInputEvent::TouchCancel; 368 return WebKit::WebInputEvent::TouchCancel;
388 default: 369 default:
389 DCHECK(false) << "Unexpected ui type. " << t; 370 DCHECK(false) << "Unexpected ui type. " << t;
390 return WebKit::WebInputEvent::Undefined; 371 return WebKit::WebInputEvent::Undefined;
391 } 372 }
392 } 373 }
393 374
394 class LocalGestureEvent : 375 class LocalGestureEvent : public ui::GestureEvent {
395 public WrappedObject<ui::GestureEvent, WebKit::WebGestureEvent> {
396 public: 376 public:
397 LocalGestureEvent( 377 LocalGestureEvent(HWND hwnd,
398 HWND hwnd, 378 const ui::GestureEventDetails& details,
399 const ui::GestureEventDetails& details, 379 const gfx::Point& location,
400 const gfx::Point& location, 380 int flags,
401 int flags, 381 base::Time time,
402 base::Time time, 382 unsigned int touch_id_bitfield)
403 unsigned int touch_id_bitfield) 383 : ui::GestureEvent(details.type(), location.x(), location.y(), flags,
404 : touch_ids_bitfield_(touch_id_bitfield), 384 time, details, touch_id_bitfield),
405 type_(details.type()) { 385 client_point_(location.ToPOINT()),
406 // location is given in window coordinates, based on the parent window. 386 screen_point_(location.ToPOINT()) {
407 // Map to the appropriate window's coordinates. For a root window the 387 MapWindowPoints(::GetParent(hwnd), hwnd, &client_point_, 1);
408 // coordinates won't change, because the parent shares our rect. 388 MapWindowPoints(hwnd, HWND_DESKTOP, &screen_point_, 1);
409 POINT client_point = { location.x(), location.y()}; 389 }
410 MapWindowPoints(::GetParent(hwnd), hwnd, &client_point, 1); 390
411 POINT screen_point = { location.x(), location.y()}; 391 virtual ~LocalGestureEvent() {}
412 MapWindowPoints(hwnd, HWND_DESKTOP, &screen_point, 1); 392
413 data().x = client_point.x; 393 WebKit::WebGestureEvent ToWebGestureEvent() {
414 data().y = client_point.y; 394 WebKit::WebGestureEvent gesture_event;
415 data().globalX = screen_point.x; 395 gesture_event.type = ConvertToWebInputEvent(type());
416 data().globalY = screen_point.y; 396 gesture_event.x = client_point_.x;
417 data().type = ConvertToWebInputEvent(type_); 397 gesture_event.y = client_point_.y;
418 data().boundingBox = details.bounding_box(); 398 gesture_event.globalX = screen_point_.x;
399 gesture_event.globalY = screen_point_.y;
400 gesture_event.boundingBox = details().bounding_box();
419 401
420 // Copy any event-type specific data. 402 // Copy any event-type specific data.
421 switch (type_) { 403 switch (type()) {
422 case ui::ET_GESTURE_TAP: 404 case ui::ET_GESTURE_TAP:
423 data().deltaX = details.tap_count(); 405 gesture_event.deltaX = details().tap_count();
424 break; 406 break;
425 case ui::ET_GESTURE_SCROLL_UPDATE: 407 case ui::ET_GESTURE_SCROLL_UPDATE:
426 data().deltaX = details.scroll_x(); 408 gesture_event.deltaX = details().scroll_x();
427 data().deltaY = details.scroll_y(); 409 gesture_event.deltaY = details().scroll_y();
428 break; 410 break;
429 case ui::ET_GESTURE_PINCH_UPDATE: 411 case ui::ET_GESTURE_PINCH_UPDATE:
430 data().deltaX = details.scale(); 412 gesture_event.deltaX = details().scale();
431 break; 413 break;
432 case ui::ET_SCROLL_FLING_START: 414 case ui::ET_SCROLL_FLING_START:
433 data().deltaX = details.velocity_x(); 415 gesture_event.deltaX = details().velocity_x();
434 data().deltaY = details.velocity_y(); 416 gesture_event.deltaY = details().velocity_y();
435 default: 417 default:
436 break; 418 break;
437 } 419 }
438 } 420 return gesture_event;
439
440 virtual int GetLowestTouchId() const OVERRIDE {
441 return LowestBit(touch_ids_bitfield_);
442 }
443
444 ui::EventType type() {
445 return type_;
446 } 421 }
447 422
448 private: 423 private:
449 // The set of indices of ones in the binary representation of 424 POINT client_point_;
450 // |touch_ids_bitfield_| is the set of touch_ids associate with this gesture. 425 POINT screen_point_;
451 // This value is stored as a bitfield because the number of touch ids varies,
452 // but we currently don't need more than 32 touches at a time.
453 const unsigned int touch_ids_bitfield_;
454
455 ui::EventType type_;
456 426
457 DISALLOW_COPY_AND_ASSIGN(LocalGestureEvent); 427 DISALLOW_COPY_AND_ASSIGN(LocalGestureEvent);
458 }; 428 };
459 429
460 class TouchEventFromWebTouchPoint : public ui::TouchEvent { 430 class TouchEventFromWebTouchPoint : public ui::TouchEvent {
461 public: 431 public:
462 TouchEventFromWebTouchPoint(const WebKit::WebTouchPoint& touch_point, 432 TouchEventFromWebTouchPoint(const WebKit::WebTouchPoint& touch_point,
463 base::TimeDelta& timestamp) 433 base::TimeDelta& timestamp)
464 : ui::TouchEvent(ConvertToUIEvent(touch_point.state), 434 : ui::TouchEvent(ConvertToUIEvent(touch_point.state),
465 touch_point.position, 435 touch_point.position,
(...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2821 ::DestroyWindow(tooltip_hwnd_); 2791 ::DestroyWindow(tooltip_hwnd_);
2822 tooltip_hwnd_ = NULL; 2792 tooltip_hwnd_ = NULL;
2823 } 2793 }
2824 2794
2825 bool RenderWidgetHostViewWin::ForwardGestureEventToRenderer( 2795 bool RenderWidgetHostViewWin::ForwardGestureEventToRenderer(
2826 ui::GestureEvent* gesture) { 2796 ui::GestureEvent* gesture) {
2827 if (!render_widget_host_) 2797 if (!render_widget_host_)
2828 return false; 2798 return false;
2829 2799
2830 LocalGestureEvent* local = static_cast<LocalGestureEvent*>(gesture); 2800 LocalGestureEvent* local = static_cast<LocalGestureEvent*>(gesture);
2831 if (local->data().type == WebKit::WebGestureEvent::Undefined) 2801 WebKit::WebGestureEvent gesture_event = local->ToWebGestureEvent();
2802 if (gesture_event.type == WebKit::WebGestureEvent::Undefined)
2832 return false; 2803 return false;
2833 const WebKit::WebGestureEvent& generatedEvent = local->data(); 2804 render_widget_host_->ForwardGestureEvent(gesture_event);
2834 render_widget_host_->ForwardGestureEvent(generatedEvent);
2835 return true; 2805 return true;
2836 } 2806 }
2837 2807
2838 void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, 2808 void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message,
2839 WPARAM wparam, 2809 WPARAM wparam,
2840 LPARAM lparam) { 2810 LPARAM lparam) {
2841 TRACE_EVENT0("browser", 2811 TRACE_EVENT0("browser",
2842 "RenderWidgetHostViewWin::ForwardMouseEventToRenderer"); 2812 "RenderWidgetHostViewWin::ForwardMouseEventToRenderer");
2843 if (!render_widget_host_) { 2813 if (!render_widget_host_) {
2844 TRACE_EVENT0("browser", "EarlyOut_NoRWH"); 2814 TRACE_EVENT0("browser", "EarlyOut_NoRWH");
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 // receive a focus change in the context of a pointer down message, it means 3084 // receive a focus change in the context of a pointer down message, it means
3115 // that the pointer down message occurred on the edit field and we should 3085 // that the pointer down message occurred on the edit field and we should
3116 // display the on screen keyboard 3086 // display the on screen keyboard
3117 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) 3087 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_)
3118 DisplayOnScreenKeyboardIfNeeded(); 3088 DisplayOnScreenKeyboardIfNeeded();
3119 received_focus_change_after_pointer_down_ = false; 3089 received_focus_change_after_pointer_down_ = false;
3120 pointer_down_context_ = false; 3090 pointer_down_context_ = false;
3121 } 3091 }
3122 3092
3123 } // namespace content 3093 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | content/browser/renderer_host/web_input_event_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698