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

Side by Side Diff: third_party/WebKit/Source/web/PageWidgetDelegate.cpp

Issue 1463823003: Return a enumeration of the state of handling of InputEvents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 { 107 {
108 paintInternal(page, canvas, rect, root, GlobalPaintNormalPhase); 108 paintInternal(page, canvas, rect, root, GlobalPaintNormalPhase);
109 } 109 }
110 110
111 void PageWidgetDelegate::paintIgnoringCompositing(Page& page, WebCanvas* canvas, 111 void PageWidgetDelegate::paintIgnoringCompositing(Page& page, WebCanvas* canvas,
112 const WebRect& rect, LocalFrame& root) 112 const WebRect& rect, LocalFrame& root)
113 { 113 {
114 paintInternal(page, canvas, rect, root, GlobalPaintFlattenCompositingLayers) ; 114 paintInternal(page, canvas, rect, root, GlobalPaintFlattenCompositingLayers) ;
115 } 115 }
116 116
117 bool PageWidgetDelegate::handleInputEvent(PageWidgetEventHandler& handler, const WebInputEvent& event, LocalFrame* root) 117 WebInputEventResult PageWidgetDelegate::handleInputEvent(PageWidgetEventHandler& handler, const WebInputEvent& event, LocalFrame* root)
118 { 118 {
119 switch (event.type) { 119 switch (event.type) {
120 120
121 // FIXME: WebKit seems to always return false on mouse events processing 121 // FIXME: WebKit seems to always return false on mouse events processing
122 // methods. For now we'll assume it has processed them (as we are only 122 // methods. For now we'll assume it has processed them (as we are only
123 // interested in whether keyboard events are processed). 123 // interested in whether keyboard events are processed).
124 // FIXME: Why do we return true when there is no root or the root is 124 // FIXME: Why do we return HandleSuppressed when there is no root or
125 // detached? 125 // the root is detached?
126 case WebInputEvent::MouseMove: 126 case WebInputEvent::MouseMove:
127 if (!root || !root->view()) 127 if (!root || !root->view())
128 return true; 128 return WebInputEventResult::HandledSuppressed;
129 handler.handleMouseMove(*root, static_cast<const WebMouseEvent&>(event)) ; 129 handler.handleMouseMove(*root, static_cast<const WebMouseEvent&>(event)) ;
130 return true; 130 return WebInputEventResult::HandledSystem;
131 case WebInputEvent::MouseLeave: 131 case WebInputEvent::MouseLeave:
132 if (!root || !root->view()) 132 if (!root || !root->view())
133 return true; 133 return WebInputEventResult::HandledSuppressed;
134 handler.handleMouseLeave(*root, static_cast<const WebMouseEvent&>(event) ); 134 handler.handleMouseLeave(*root, static_cast<const WebMouseEvent&>(event) );
135 return true; 135 return WebInputEventResult::HandledSystem;
136 case WebInputEvent::MouseDown: 136 case WebInputEvent::MouseDown:
137 if (!root || !root->view()) 137 if (!root || !root->view())
138 return true; 138 return WebInputEventResult::HandledSuppressed;
139 handler.handleMouseDown(*root, static_cast<const WebMouseEvent&>(event)) ; 139 handler.handleMouseDown(*root, static_cast<const WebMouseEvent&>(event)) ;
140 return true; 140 return WebInputEventResult::HandledSystem;
141 case WebInputEvent::MouseUp: 141 case WebInputEvent::MouseUp:
142 if (!root || !root->view()) 142 if (!root || !root->view())
143 return true; 143 return WebInputEventResult::HandledSuppressed;
144 handler.handleMouseUp(*root, static_cast<const WebMouseEvent&>(event)); 144 handler.handleMouseUp(*root, static_cast<const WebMouseEvent&>(event));
145 return true; 145 return WebInputEventResult::HandledSystem;
kotenkov 2016/01/12 20:55:00 It seems to me that there are a lot of changes in
dtapuska 2016/01/12 21:06:48 I agree the return values should be used. I wasn't
146
147 case WebInputEvent::MouseWheel: 146 case WebInputEvent::MouseWheel:
148 if (!root || !root->view()) 147 if (!root || !root->view())
149 return false; 148 return WebInputEventResult::NotHandled;
150 return handler.handleMouseWheel(*root, static_cast<const WebMouseWheelEv ent&>(event)); 149 return handler.handleMouseWheel(*root, static_cast<const WebMouseWheelEv ent&>(event));
151 150
152 case WebInputEvent::RawKeyDown: 151 case WebInputEvent::RawKeyDown:
153 case WebInputEvent::KeyDown: 152 case WebInputEvent::KeyDown:
154 case WebInputEvent::KeyUp: 153 case WebInputEvent::KeyUp:
155 return handler.handleKeyEvent(static_cast<const WebKeyboardEvent&>(event )); 154 return handler.handleKeyEvent(static_cast<const WebKeyboardEvent&>(event ));
156 155
157 case WebInputEvent::Char: 156 case WebInputEvent::Char:
158 return handler.handleCharEvent(static_cast<const WebKeyboardEvent&>(even t)); 157 return handler.handleCharEvent(static_cast<const WebKeyboardEvent&>(even t));
159 case WebInputEvent::GestureScrollBegin: 158 case WebInputEvent::GestureScrollBegin:
(...skipping 10 matching lines...) Expand all
170 case WebInputEvent::GestureTwoFingerTap: 169 case WebInputEvent::GestureTwoFingerTap:
171 case WebInputEvent::GestureLongPress: 170 case WebInputEvent::GestureLongPress:
172 case WebInputEvent::GestureLongTap: 171 case WebInputEvent::GestureLongTap:
173 return handler.handleGestureEvent(static_cast<const WebGestureEvent&>(ev ent)); 172 return handler.handleGestureEvent(static_cast<const WebGestureEvent&>(ev ent));
174 173
175 case WebInputEvent::TouchStart: 174 case WebInputEvent::TouchStart:
176 case WebInputEvent::TouchMove: 175 case WebInputEvent::TouchMove:
177 case WebInputEvent::TouchEnd: 176 case WebInputEvent::TouchEnd:
178 case WebInputEvent::TouchCancel: 177 case WebInputEvent::TouchCancel:
179 if (!root || !root->view()) 178 if (!root || !root->view())
180 return false; 179 return WebInputEventResult::NotHandled;
181 return handler.handleTouchEvent(*root, static_cast<const WebTouchEvent&> (event)); 180 return handler.handleTouchEvent(*root, static_cast<const WebTouchEvent&> (event));
182 case WebInputEvent::GesturePinchBegin: 181 case WebInputEvent::GesturePinchBegin:
183 case WebInputEvent::GesturePinchEnd: 182 case WebInputEvent::GesturePinchEnd:
184 case WebInputEvent::GesturePinchUpdate: 183 case WebInputEvent::GesturePinchUpdate:
185 // Touchscreen pinch events are currently not handled in main thread. On ce they are, 184 // Touchscreen pinch events are currently not handled in main thread. On ce they are,
186 // these should be passed to |handleGestureEvent| similar to gesture scr oll events. 185 // these should be passed to |handleGestureEvent| similar to gesture scr oll events.
187 return false; 186 return WebInputEventResult::NotHandled;
188 default: 187 default:
189 return false; 188 return WebInputEventResult::NotHandled;
190 } 189 }
191 } 190 }
192 191
193 // ---------------------------------------------------------------- 192 // ----------------------------------------------------------------
194 // Default handlers for PageWidgetEventHandler 193 // Default handlers for PageWidgetEventHandler
195 194
196 void PageWidgetEventHandler::handleMouseMove(LocalFrame& mainFrame, const WebMou seEvent& event) 195 void PageWidgetEventHandler::handleMouseMove(LocalFrame& mainFrame, const WebMou seEvent& event)
197 { 196 {
198 mainFrame.eventHandler().handleMouseMoveEvent(PlatformMouseEventBuilder(main Frame.view(), event)); 197 mainFrame.eventHandler().handleMouseMoveEvent(PlatformMouseEventBuilder(main Frame.view(), event));
199 } 198 }
200 199
201 void PageWidgetEventHandler::handleMouseLeave(LocalFrame& mainFrame, const WebMo useEvent& event) 200 void PageWidgetEventHandler::handleMouseLeave(LocalFrame& mainFrame, const WebMo useEvent& event)
202 { 201 {
203 mainFrame.eventHandler().handleMouseLeaveEvent(PlatformMouseEventBuilder(mai nFrame.view(), event)); 202 mainFrame.eventHandler().handleMouseLeaveEvent(PlatformMouseEventBuilder(mai nFrame.view(), event));
204 } 203 }
205 204
206 void PageWidgetEventHandler::handleMouseDown(LocalFrame& mainFrame, const WebMou seEvent& event) 205 void PageWidgetEventHandler::handleMouseDown(LocalFrame& mainFrame, const WebMou seEvent& event)
207 { 206 {
208 mainFrame.eventHandler().handleMousePressEvent(PlatformMouseEventBuilder(mai nFrame.view(), event)); 207 mainFrame.eventHandler().handleMousePressEvent(PlatformMouseEventBuilder(mai nFrame.view(), event));
209 } 208 }
210 209
211 void PageWidgetEventHandler::handleMouseUp(LocalFrame& mainFrame, const WebMouse Event& event) 210 void PageWidgetEventHandler::handleMouseUp(LocalFrame& mainFrame, const WebMouse Event& event)
212 { 211 {
213 mainFrame.eventHandler().handleMouseReleaseEvent(PlatformMouseEventBuilder(m ainFrame.view(), event)); 212 mainFrame.eventHandler().handleMouseReleaseEvent(PlatformMouseEventBuilder(m ainFrame.view(), event));
214 } 213 }
215 214
216 bool PageWidgetEventHandler::handleMouseWheel(LocalFrame& mainFrame, const WebMo useWheelEvent& event) 215 WebInputEventResult PageWidgetEventHandler::handleMouseWheel(LocalFrame& mainFra me, const WebMouseWheelEvent& event)
217 { 216 {
218 return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(m ainFrame.view(), event)); 217 return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(m ainFrame.view(), event));
219 } 218 }
220 219
221 bool PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFrame, const WebTo uchEvent& event) 220 WebInputEventResult PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFra me, const WebTouchEvent& event)
222 { 221 {
223 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m ainFrame.view(), event)); 222 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m ainFrame.view(), event));
224 } 223 }
225 224
226 #define WEBINPUT_EVENT_CASE(type) case WebInputEvent::type: return #type; 225 #define WEBINPUT_EVENT_CASE(type) case WebInputEvent::type: return #type;
227 226
228 const char* PageWidgetEventHandler::inputTypeToName(WebInputEvent::Type type) 227 const char* PageWidgetEventHandler::inputTypeToName(WebInputEvent::Type type)
229 { 228 {
230 switch (type) { 229 switch (type) {
231 WEBINPUT_EVENT_CASE(MouseDown) 230 WEBINPUT_EVENT_CASE(MouseDown)
(...skipping 28 matching lines...) Expand all
260 WEBINPUT_EVENT_CASE(TouchMove) 259 WEBINPUT_EVENT_CASE(TouchMove)
261 WEBINPUT_EVENT_CASE(TouchEnd) 260 WEBINPUT_EVENT_CASE(TouchEnd)
262 WEBINPUT_EVENT_CASE(TouchCancel) 261 WEBINPUT_EVENT_CASE(TouchCancel)
263 default: 262 default:
264 ASSERT_NOT_REACHED(); 263 ASSERT_NOT_REACHED();
265 return ""; 264 return "";
266 } 265 }
267 } 266 }
268 267
269 } // namespace blink 268 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698