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

Side by Side Diff: sky/engine/web/WebViewImpl.cpp

Issue 874823002: Move GestureEvent to NewEventDispatcher (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Build fixes Created 5 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
« no previous file with comments | « sky/engine/web/WebViewImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "sky/engine/core/page/Chrome.h" 57 #include "sky/engine/core/page/Chrome.h"
58 #include "sky/engine/core/page/EventHandler.h" 58 #include "sky/engine/core/page/EventHandler.h"
59 #include "sky/engine/core/page/EventWithHitTestResults.h" 59 #include "sky/engine/core/page/EventWithHitTestResults.h"
60 #include "sky/engine/core/page/FocusController.h" 60 #include "sky/engine/core/page/FocusController.h"
61 #include "sky/engine/core/page/Page.h" 61 #include "sky/engine/core/page/Page.h"
62 #include "sky/engine/core/rendering/RenderView.h" 62 #include "sky/engine/core/rendering/RenderView.h"
63 #include "sky/engine/platform/Cursor.h" 63 #include "sky/engine/platform/Cursor.h"
64 #include "sky/engine/platform/KeyboardCodes.h" 64 #include "sky/engine/platform/KeyboardCodes.h"
65 #include "sky/engine/platform/Logging.h" 65 #include "sky/engine/platform/Logging.h"
66 #include "sky/engine/platform/NotImplemented.h" 66 #include "sky/engine/platform/NotImplemented.h"
67 #include "sky/engine/platform/PlatformGestureEvent.h"
68 #include "sky/engine/platform/PlatformKeyboardEvent.h" 67 #include "sky/engine/platform/PlatformKeyboardEvent.h"
69 #include "sky/engine/platform/TraceEvent.h" 68 #include "sky/engine/platform/TraceEvent.h"
70 #include "sky/engine/platform/fonts/FontCache.h" 69 #include "sky/engine/platform/fonts/FontCache.h"
71 #include "sky/engine/platform/graphics/Color.h" 70 #include "sky/engine/platform/graphics/Color.h"
72 #include "sky/engine/platform/graphics/GraphicsContext.h" 71 #include "sky/engine/platform/graphics/GraphicsContext.h"
73 #include "sky/engine/platform/graphics/Image.h" 72 #include "sky/engine/platform/graphics/Image.h"
74 #include "sky/engine/platform/graphics/ImageBuffer.h" 73 #include "sky/engine/platform/graphics/ImageBuffer.h"
75 #include "sky/engine/platform/scroll/Scrollbar.h" 74 #include "sky/engine/platform/scroll/Scrollbar.h"
76 #include "sky/engine/public/platform/Platform.h" 75 #include "sky/engine/public/platform/Platform.h"
77 #include "sky/engine/public/platform/WebFloatPoint.h" 76 #include "sky/engine/public/platform/WebFloatPoint.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 WebViewImpl::~WebViewImpl() 161 WebViewImpl::~WebViewImpl()
163 { 162 {
164 ASSERT(!m_page); 163 ASSERT(!m_page);
165 } 164 }
166 165
167 WebLocalFrameImpl* WebViewImpl::mainFrameImpl() 166 WebLocalFrameImpl* WebViewImpl::mainFrameImpl()
168 { 167 {
169 return m_page ? WebLocalFrameImpl::fromFrame(m_page->mainFrame()) : 0; 168 return m_page ? WebLocalFrameImpl::fromFrame(m_page->mainFrame()) : 0;
170 } 169 }
171 170
172 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
173 {
174 bool eventSwallowed = false;
175 bool eventCancelled = false; // for disambiguation
176
177 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t);
178
179 // FIXME: Remove redundant hit tests by pushing the call to EventHandler::ta rgetGestureEvent
180 // up to this point and pass GestureEventWithHitTestResults around.
181
182 switch (event.type) {
183 case WebInputEvent::GestureTap: {
184 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
185 break;
186 }
187 case WebInputEvent::GestureTwoFingerTap:
188 case WebInputEvent::GestureLongPress:
189 case WebInputEvent::GestureLongTap: {
190 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
191 break;
192 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
193 break;
194 }
195 case WebInputEvent::GestureShowPress: {
196 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
197 break;
198 }
199 case WebInputEvent::GestureDoubleTap:
200 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore,
201 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here.
202 eventSwallowed = true;
203 break;
204 case WebInputEvent::GestureScrollBegin:
205 case WebInputEvent::GesturePinchBegin:
206 case WebInputEvent::GestureTapDown:
207 case WebInputEvent::GestureScrollEnd:
208 case WebInputEvent::GestureScrollUpdate:
209 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
210 case WebInputEvent::GestureTapCancel:
211 case WebInputEvent::GestureTapUnconfirmed:
212 case WebInputEvent::GesturePinchEnd:
213 case WebInputEvent::GesturePinchUpdate:
214 case WebInputEvent::GestureFlingStart: {
215 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
216 break;
217 }
218 default:
219 ASSERT_NOT_REACHED();
220 }
221 m_client->didHandleGestureEvent(event, eventCancelled);
222 return eventSwallowed;
223 }
224
225 void WebViewImpl::setShowPaintRects(bool show) 171 void WebViewImpl::setShowPaintRects(bool show)
226 { 172 {
227 m_showPaintRects = show; 173 m_showPaintRects = show;
228 } 174 }
229 175
230 void WebViewImpl::setShowDebugBorders(bool show) 176 void WebViewImpl::setShowDebugBorders(bool show)
231 { 177 {
232 m_showDebugBorders = show; 178 m_showDebugBorders = show;
233 } 179 }
234 180
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 FrameView* view = m_page->mainFrame()->view(); 452 FrameView* view = m_page->mainFrame()->view();
507 if (view) { 453 if (view) {
508 gc.clip(dirtyRect); 454 gc.clip(dirtyRect);
509 view->paint(&gc, dirtyRect); 455 view->paint(&gc, dirtyRect);
510 } else { 456 } else {
511 gc.fillRect(dirtyRect, Color::white); 457 gc.fillRect(dirtyRect, Color::white);
512 } 458 }
513 gc.restore(); 459 gc.restore();
514 } 460 }
515 461
516 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0;
517
518 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha n 462 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha n
519 // the one-offs for subsets of these values. 463 // the one-offs for subsets of these values.
520 static String inputTypeToName(WebInputEvent::Type type) 464 static String inputTypeToName(WebInputEvent::Type type)
521 { 465 {
522 switch (type) { 466 switch (type) {
523 case WebInputEvent::KeyDown: 467 case WebInputEvent::KeyDown:
524 return EventTypeNames::keydown; 468 return EventTypeNames::keydown;
525 case WebInputEvent::KeyUp: 469 case WebInputEvent::KeyUp:
526 return EventTypeNames::keyup; 470 return EventTypeNames::keyup;
527 case WebInputEvent::GestureScrollBegin: 471 case WebInputEvent::GestureScrollBegin:
(...skipping 12 matching lines...) Expand all
540 return EventTypeNames::gesturetapunconfirmed; 484 return EventTypeNames::gesturetapunconfirmed;
541 default: 485 default:
542 return String("unknown"); 486 return String("unknown");
543 } 487 }
544 } 488 }
545 489
546 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) 490 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
547 { 491 {
548 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa me(inputEvent.type).ascii().data()); 492 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa me(inputEvent.type).ascii().data());
549 493
550 TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent , &inputEvent);
551
552 if (WebInputEvent::isPointerEventType(inputEvent.type)) { 494 if (WebInputEvent::isPointerEventType(inputEvent.type)) {
553 const WebPointerEvent& event = static_cast<const WebPointerEvent&>(input Event); 495 const WebPointerEvent& event = static_cast<const WebPointerEvent&>(input Event);
554 return m_page->mainFrame()->newEventHandler().handlePointerEvent(event); 496 return m_page->mainFrame()->newEventHandler().handlePointerEvent(event);
555 } 497 }
556 498
499 if (WebInputEvent::isGestureEventType(inputEvent.type)) {
500 const WebGestureEvent& event = static_cast<const WebGestureEvent&>(input Event);
501 return m_page->mainFrame()->newEventHandler().handleGestureEvent(event);
502 }
503
557 switch (inputEvent.type) { 504 switch (inputEvent.type) {
558 case WebInputEvent::RawKeyDown: 505 case WebInputEvent::RawKeyDown:
559 case WebInputEvent::KeyDown: 506 case WebInputEvent::KeyDown:
560 case WebInputEvent::KeyUp: 507 case WebInputEvent::KeyUp:
561 return handleKeyEvent(static_cast<const WebKeyboardEvent&>(inputEvent)); 508 return handleKeyEvent(static_cast<const WebKeyboardEvent&>(inputEvent));
562
563 case WebInputEvent::Char: 509 case WebInputEvent::Char:
564 return handleCharEvent(static_cast<const WebKeyboardEvent&>(inputEvent)) ; 510 return handleCharEvent(static_cast<const WebKeyboardEvent&>(inputEvent)) ;
565 case WebInputEvent::GestureScrollBegin:
566 case WebInputEvent::GestureScrollEnd:
567 case WebInputEvent::GestureScrollUpdate:
568 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
569 case WebInputEvent::GestureFlingStart:
570 case WebInputEvent::GestureFlingCancel:
571 case WebInputEvent::GestureTap:
572 case WebInputEvent::GestureTapUnconfirmed:
573 case WebInputEvent::GestureTapDown:
574 case WebInputEvent::GestureShowPress:
575 case WebInputEvent::GestureTapCancel:
576 case WebInputEvent::GestureDoubleTap:
577 case WebInputEvent::GestureTwoFingerTap:
578 case WebInputEvent::GestureLongPress:
579 case WebInputEvent::GestureLongTap:
580 return handleGestureEvent(static_cast<const WebGestureEvent&>(inputEvent ));
581
582 case WebInputEvent::GesturePinchBegin:
583 case WebInputEvent::GesturePinchEnd:
584 case WebInputEvent::GesturePinchUpdate:
585 // FIXME: Once PlatformGestureEvent is updated to support pinch, this
586 // should call handleGestureEvent, just like it currently does for
587 // gesture scroll.
588 return false;
589
590 default: 511 default:
591 return false; 512 return false;
592 } 513 }
593 } 514 }
594 515
595 void WebViewImpl::mouseCaptureLost() 516 void WebViewImpl::mouseCaptureLost()
596 { 517 {
597 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); 518 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this);
598 m_mouseCaptureNode = nullptr; 519 m_mouseCaptureNode = nullptr;
599 } 520 }
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, 1073 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState,
1153 bool isInitialState) { 1074 bool isInitialState) {
1154 if (!page()) 1075 if (!page())
1155 return; 1076 return;
1156 1077
1157 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState = = WebPageVisibilityStateHidden); 1078 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState = = WebPageVisibilityStateHidden);
1158 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int> (visibilityState)), isInitialState); 1079 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int> (visibilityState)), isInitialState);
1159 } 1080 }
1160 1081
1161 } // namespace blink 1082 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698