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

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

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 227 }
228 overlayMainFrame()->view()->updateAllLifecyclePhases(); 228 overlayMainFrame()->view()->updateAllLifecyclePhases();
229 } 229 }
230 230
231 bool InspectorOverlay::handleInputEvent(const WebInputEvent& inputEvent) { 231 bool InspectorOverlay::handleInputEvent(const WebInputEvent& inputEvent) {
232 bool handled = false; 232 bool handled = false;
233 233
234 if (isEmpty()) 234 if (isEmpty())
235 return false; 235 return false;
236 236
237 if (WebInputEvent::isGestureEventType(inputEvent.type) && 237 if (inputEvent.type() == WebInputEvent::GestureTap) {
238 inputEvent.type == WebInputEvent::GestureTap) {
239 // We only have a use for gesture tap. 238 // We only have a use for gesture tap.
240 WebGestureEvent transformedEvent = TransformWebGestureEvent( 239 WebGestureEvent transformedEvent = TransformWebGestureEvent(
241 m_frameImpl->frameView(), 240 m_frameImpl->frameView(),
242 static_cast<const WebGestureEvent&>(inputEvent)); 241 static_cast<const WebGestureEvent&>(inputEvent));
243 handled = handleGestureEvent(transformedEvent); 242 handled = handleGestureEvent(transformedEvent);
244 if (handled) 243 if (handled)
245 return true; 244 return true;
246 245
247 overlayMainFrame()->eventHandler().handleGestureEvent(transformedEvent); 246 overlayMainFrame()->eventHandler().handleGestureEvent(transformedEvent);
248 } 247 }
249 if (WebInputEvent::isMouseEventType(inputEvent.type) && 248 if (WebInputEvent::isMouseEventType(inputEvent.type()) &&
250 inputEvent.type != WebInputEvent::MouseEnter) { 249 inputEvent.type() != WebInputEvent::MouseEnter) {
251 // PlatformMouseEventBuilder does not work with MouseEnter type, so we 250 // PlatformMouseEventBuilder does not work with MouseEnter type, so we
252 // filter it out manually. 251 // filter it out manually.
253 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder( 252 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(
254 m_frameImpl->frameView(), 253 m_frameImpl->frameView(),
255 static_cast<const WebMouseEvent&>(inputEvent)); 254 static_cast<const WebMouseEvent&>(inputEvent));
256 255
257 if (mouseEvent.type() == PlatformEvent::MouseMoved) 256 if (mouseEvent.type() == PlatformEvent::MouseMoved)
258 handled = handleMouseMove(mouseEvent); 257 handled = handleMouseMove(mouseEvent);
259 else if (mouseEvent.type() == PlatformEvent::MousePressed) 258 else if (mouseEvent.type() == PlatformEvent::MousePressed)
260 handled = handleMousePress(); 259 handled = handleMousePress();
261 260
262 if (handled) 261 if (handled)
263 return true; 262 return true;
264 263
265 if (mouseEvent.type() == PlatformEvent::MouseMoved) { 264 if (mouseEvent.type() == PlatformEvent::MouseMoved) {
266 handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent( 265 handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent(
267 mouseEvent, createPlatformMouseEventVector( 266 mouseEvent, createPlatformMouseEventVector(
268 m_frameImpl->frameView(), 267 m_frameImpl->frameView(),
269 std::vector<const WebInputEvent*>())) != 268 std::vector<const WebInputEvent*>())) !=
270 WebInputEventResult::NotHandled; 269 WebInputEventResult::NotHandled;
271 } 270 }
272 if (mouseEvent.type() == PlatformEvent::MousePressed) 271 if (mouseEvent.type() == PlatformEvent::MousePressed)
273 handled = overlayMainFrame()->eventHandler().handleMousePressEvent( 272 handled = overlayMainFrame()->eventHandler().handleMousePressEvent(
274 mouseEvent) != WebInputEventResult::NotHandled; 273 mouseEvent) != WebInputEventResult::NotHandled;
275 if (mouseEvent.type() == PlatformEvent::MouseReleased) 274 if (mouseEvent.type() == PlatformEvent::MouseReleased)
276 handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent( 275 handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent(
277 mouseEvent) != WebInputEventResult::NotHandled; 276 mouseEvent) != WebInputEventResult::NotHandled;
278 } 277 }
279 278
280 if (WebInputEvent::isTouchEventType(inputEvent.type)) { 279 if (WebInputEvent::isTouchEventType(inputEvent.type())) {
281 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder( 280 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(
282 m_frameImpl->frameView(), 281 m_frameImpl->frameView(),
283 static_cast<const WebTouchEvent&>(inputEvent)); 282 static_cast<const WebTouchEvent&>(inputEvent));
284 handled = handleTouchEvent(touchEvent); 283 handled = handleTouchEvent(touchEvent);
285 if (handled) 284 if (handled)
286 return true; 285 return true;
287 overlayMainFrame()->eventHandler().handleTouchEvent( 286 overlayMainFrame()->eventHandler().handleTouchEvent(
288 touchEvent, 287 touchEvent,
289 createPlatformTouchEventVector(m_frameImpl->frameView(), 288 createPlatformTouchEventVector(m_frameImpl->frameView(),
290 std::vector<const WebInputEvent*>())); 289 std::vector<const WebInputEvent*>()));
291 } 290 }
292 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { 291 if (WebInputEvent::isKeyboardEventType(inputEvent.type())) {
293 overlayMainFrame()->eventHandler().keyEvent( 292 overlayMainFrame()->eventHandler().keyEvent(
294 static_cast<const WebKeyboardEvent&>(inputEvent)); 293 static_cast<const WebKeyboardEvent&>(inputEvent));
295 } 294 }
296 295
297 if (inputEvent.type == WebInputEvent::MouseWheel) { 296 if (inputEvent.type() == WebInputEvent::MouseWheel) {
298 WebMouseWheelEvent transformedEvent = TransformWebMouseWheelEvent( 297 WebMouseWheelEvent transformedEvent = TransformWebMouseWheelEvent(
299 m_frameImpl->frameView(), 298 m_frameImpl->frameView(),
300 static_cast<const WebMouseWheelEvent&>(inputEvent)); 299 static_cast<const WebMouseWheelEvent&>(inputEvent));
301 handled = overlayMainFrame()->eventHandler().handleWheelEvent( 300 handled = overlayMainFrame()->eventHandler().handleWheelEvent(
302 transformedEvent) != WebInputEventResult::NotHandled; 301 transformedEvent) != WebInputEventResult::NotHandled;
303 } 302 }
304 303
305 return handled; 304 return handled;
306 } 305 }
307 306
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 752
754 if (m_hoveredNodeForInspectMode) { 753 if (m_hoveredNodeForInspectMode) {
755 inspect(m_hoveredNodeForInspectMode.get()); 754 inspect(m_hoveredNodeForInspectMode.get());
756 m_hoveredNodeForInspectMode.clear(); 755 m_hoveredNodeForInspectMode.clear();
757 return true; 756 return true;
758 } 757 }
759 return false; 758 return false;
760 } 759 }
761 760
762 bool InspectorOverlay::handleGestureEvent(const WebGestureEvent& event) { 761 bool InspectorOverlay::handleGestureEvent(const WebGestureEvent& event) {
763 if (!shouldSearchForNode() || event.type != WebInputEvent::GestureTap) 762 if (!shouldSearchForNode() || event.type() != WebInputEvent::GestureTap)
764 return false; 763 return false;
765 Node* node = hoveredNodeForEvent(m_frameImpl->frame(), event, false); 764 Node* node = hoveredNodeForEvent(m_frameImpl->frame(), event, false);
766 if (node && m_inspectModeHighlightConfig) { 765 if (node && m_inspectModeHighlightConfig) {
767 highlightNode(node, *m_inspectModeHighlightConfig, false); 766 highlightNode(node, *m_inspectModeHighlightConfig, false);
768 inspect(node); 767 inspect(node);
769 return true; 768 return true;
770 } 769 }
771 return false; 770 return false;
772 } 771 }
773 772
(...skipping 12 matching lines...) Expand all
786 bool InspectorOverlay::shouldSearchForNode() { 785 bool InspectorOverlay::shouldSearchForNode() {
787 return m_inspectMode != InspectorDOMAgent::NotSearching; 786 return m_inspectMode != InspectorDOMAgent::NotSearching;
788 } 787 }
789 788
790 void InspectorOverlay::inspect(Node* node) { 789 void InspectorOverlay::inspect(Node* node) {
791 if (m_domAgent) 790 if (m_domAgent)
792 m_domAgent->inspect(node); 791 m_domAgent->inspect(node);
793 } 792 }
794 793
795 } // namespace blink 794 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp ('k') | third_party/WebKit/Source/web/PageWidgetDelegate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698