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

Side by Side Diff: chrome/renderer/render_widget.cc

Issue 3388013: Forward touch events to a RenderWidget's associated WebWidget (Closed)
Patch Set: removed commented-out include Created 10 years, 2 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/renderer/render_widget.h" 5 #include "chrome/renderer/render_widget.h"
6 6
7 #include "app/surface/transport_dib.h" 7 #include "app/surface/transport_dib.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 18 matching lines...) Expand all
29 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" 29 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
30 #include "webkit/glue/plugins/webplugin.h" 30 #include "webkit/glue/plugins/webplugin.h"
31 #include "webkit/glue/webkit_glue.h" 31 #include "webkit/glue/webkit_glue.h"
32 32
33 #if defined(OS_POSIX) 33 #if defined(OS_POSIX)
34 #include "ipc/ipc_channel_posix.h" 34 #include "ipc/ipc_channel_posix.h"
35 #include "third_party/skia/include/core/SkPixelRef.h" 35 #include "third_party/skia/include/core/SkPixelRef.h"
36 #include "third_party/skia/include/core/SkMallocPixelRef.h" 36 #include "third_party/skia/include/core/SkMallocPixelRef.h"
37 #endif // defined(OS_POSIX) 37 #endif // defined(OS_POSIX)
38 38
39 #if defined(TOUCH_UI)
40 #include "chrome/renderer/gesture_manager.h"
41 #endif
42
39 #include "third_party/WebKit/WebKit/chromium/public/WebWidget.h" 43 #include "third_party/WebKit/WebKit/chromium/public/WebWidget.h"
40 44
41 using WebKit::WebCompositionUnderline; 45 using WebKit::WebCompositionUnderline;
42 using WebKit::WebCursorInfo; 46 using WebKit::WebCursorInfo;
43 using WebKit::WebInputEvent; 47 using WebKit::WebInputEvent;
44 using WebKit::WebMouseEvent; 48 using WebKit::WebMouseEvent;
45 using WebKit::WebNavigationPolicy; 49 using WebKit::WebNavigationPolicy;
46 using WebKit::WebPopupMenu; 50 using WebKit::WebPopupMenu;
47 using WebKit::WebPopupMenuInfo; 51 using WebKit::WebPopupMenuInfo;
48 using WebKit::WebPopupType; 52 using WebKit::WebPopupType;
49 using WebKit::WebRect; 53 using WebKit::WebRect;
50 using WebKit::WebScreenInfo; 54 using WebKit::WebScreenInfo;
51 using WebKit::WebSize; 55 using WebKit::WebSize;
52 using WebKit::WebTextDirection; 56 using WebKit::WebTextDirection;
53 using WebKit::WebTextInputType; 57 using WebKit::WebTextInputType;
54 using WebKit::WebVector; 58 using WebKit::WebVector;
55 using WebKit::WebWidget; 59 using WebKit::WebWidget;
56 60
61 #if defined(TOUCH_UI)
62 using WebKit::WebTouchEvent;
63 #endif
64
57 RenderWidget::RenderWidget(RenderThreadBase* render_thread, 65 RenderWidget::RenderWidget(RenderThreadBase* render_thread,
58 WebKit::WebPopupType popup_type) 66 WebKit::WebPopupType popup_type)
59 : routing_id_(MSG_ROUTING_NONE), 67 : routing_id_(MSG_ROUTING_NONE),
60 webwidget_(NULL), 68 webwidget_(NULL),
61 opener_id_(MSG_ROUTING_NONE), 69 opener_id_(MSG_ROUTING_NONE),
62 render_thread_(render_thread), 70 render_thread_(render_thread),
63 host_window_(0), 71 host_window_(0),
64 current_paint_buf_(NULL), 72 current_paint_buf_(NULL),
65 next_paint_flags_(0), 73 next_paint_flags_(0),
66 update_reply_pending_(false), 74 update_reply_pending_(false),
67 did_show_(false), 75 did_show_(false),
68 is_hidden_(false), 76 is_hidden_(false),
69 needs_repainting_on_restore_(false), 77 needs_repainting_on_restore_(false),
70 has_focus_(false), 78 has_focus_(false),
71 handling_input_event_(false), 79 handling_input_event_(false),
72 closing_(false), 80 closing_(false),
73 input_method_is_active_(false), 81 input_method_is_active_(false),
74 text_input_type_(WebKit::WebTextInputTypeNone), 82 text_input_type_(WebKit::WebTextInputTypeNone),
75 popup_type_(popup_type), 83 popup_type_(popup_type),
76 pending_window_rect_count_(0), 84 pending_window_rect_count_(0),
77 suppress_next_char_events_(false), 85 suppress_next_char_events_(false),
78 is_gpu_rendering_active_(false) { 86 is_gpu_rendering_active_(false)
87 #if defined(TOUCH_UI)
88 ,
89 gesture_manager_(GestureManager::Get())
90 #endif
91 {
79 RenderProcess::current()->AddRefProcess(); 92 RenderProcess::current()->AddRefProcess();
80 DCHECK(render_thread_); 93 DCHECK(render_thread_);
81 } 94 }
82 95
83 RenderWidget::~RenderWidget() { 96 RenderWidget::~RenderWidget() {
84 DCHECK(!webwidget_) << "Leaking our WebWidget!"; 97 DCHECK(!webwidget_) << "Leaking our WebWidget!";
85 if (current_paint_buf_) { 98 if (current_paint_buf_) {
86 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); 99 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
87 current_paint_buf_ = NULL; 100 current_paint_buf_ = NULL;
88 } 101 }
89 RenderProcess::current()->ReleaseProcess(); 102 RenderProcess::current()->ReleaseProcess();
90 } 103 }
91 104
92 // static 105 // static
93 RenderWidget* RenderWidget::Create(int32 opener_id, 106 RenderWidget* RenderWidget::Create(int32 opener_id,
94 RenderThreadBase* render_thread, 107 RenderThreadBase* render_thread,
95 WebKit::WebPopupType popup_type) { 108 WebKit::WebPopupType popup_type) {
96 DCHECK(opener_id != MSG_ROUTING_NONE); 109 DCHECK(opener_id != MSG_ROUTING_NONE);
97 scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread, 110 scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread,
98 popup_type); 111 popup_type);
99 widget->Init(opener_id); // adds reference 112 widget->Init(opener_id); // adds reference
100 return widget; 113 return widget;
101 } 114 }
102 115
103 // static 116 // static
104 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { 117 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) {
105 switch (render_widget->popup_type_) { 118 switch (render_widget->popup_type_) {
106 case WebKit::WebPopupTypeNone: // Nothing to create. 119 case WebKit::WebPopupTypeNone: // Nothing to create.
107 break; 120 break;
108 case WebKit::WebPopupTypeSelect: 121 case WebKit::WebPopupTypeSelect:
109 case WebKit::WebPopupTypeSuggestion: 122 case WebKit::WebPopupTypeSuggestion:
110 return WebPopupMenu::create(render_widget); 123 return WebPopupMenu::create(render_widget);
111 default: 124 default:
112 NOTREACHED(); 125 NOTREACHED();
113 } 126 }
114 return NULL; 127 return NULL;
115 } 128 }
116 129
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 reinterpret_cast<const WebInputEvent*>(data); 347 reinterpret_cast<const WebInputEvent*>(data);
335 348
336 bool is_keyboard_shortcut = false; 349 bool is_keyboard_shortcut = false;
337 // is_keyboard_shortcut flag is only available for RawKeyDown events. 350 // is_keyboard_shortcut flag is only available for RawKeyDown events.
338 if (input_event->type == WebInputEvent::RawKeyDown) 351 if (input_event->type == WebInputEvent::RawKeyDown)
339 message.ReadBool(&iter, &is_keyboard_shortcut); 352 message.ReadBool(&iter, &is_keyboard_shortcut);
340 353
341 bool processed = false; 354 bool processed = false;
342 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { 355 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
343 suppress_next_char_events_ = false; 356 suppress_next_char_events_ = false;
344 if (webwidget_) 357 if (webwidget_) {
345 processed = webwidget_->handleInputEvent(*input_event); 358 processed = webwidget_->handleInputEvent(*input_event);
359 #if defined(TOUCH_UI)
360 if (WebInputEvent::isTouchEventType(input_event->type)) {
darin (slow to review) 2010/09/25 15:21:06 why is this code here instead of inside the WebVie
361 processed = gesture_manager_->ProcessTouchEventForGesture(
362 *static_cast<const WebTouchEvent*>(input_event),
363 this,
364 processed);
365 }
366 #endif
367 }
346 } 368 }
347 369
348 // If this RawKeyDown event corresponds to a browser keyboard shortcut and 370 // If this RawKeyDown event corresponds to a browser keyboard shortcut and
349 // it's not processed by webkit, then we need to suppress the upcoming Char 371 // it's not processed by webkit, then we need to suppress the upcoming Char
350 // events. 372 // events.
351 if (!processed && is_keyboard_shortcut) 373 if (!processed && is_keyboard_shortcut)
352 suppress_next_char_events_ = true; 374 suppress_next_char_events_ = true;
353 375
354 IPC::Message* response = new ViewHostMsg_HandleInputEvent_ACK(routing_id_); 376 IPC::Message* response = new ViewHostMsg_HandleInputEvent_ACK(routing_id_);
355 response->WriteInt(input_event->type); 377 response->WriteInt(input_event->type);
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 970
949 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { 971 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
950 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); 972 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin();
951 i != plugin_window_moves_.end(); ++i) { 973 i != plugin_window_moves_.end(); ++i) {
952 if (i->window == window) { 974 if (i->window == window) {
953 plugin_window_moves_.erase(i); 975 plugin_window_moves_.erase(i);
954 break; 976 break;
955 } 977 }
956 } 978 }
957 } 979 }
OLDNEW
« chrome/renderer/render_widget.h ('K') | « chrome/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698