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

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

Issue 870073003: Remove mouse events from Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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
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 26 matching lines...) Expand all
37 #include "sky/engine/core/dom/Document.h" 37 #include "sky/engine/core/dom/Document.h"
38 #include "sky/engine/core/dom/DocumentMarkerController.h" 38 #include "sky/engine/core/dom/DocumentMarkerController.h"
39 #include "sky/engine/core/dom/NodeRenderingTraversal.h" 39 #include "sky/engine/core/dom/NodeRenderingTraversal.h"
40 #include "sky/engine/core/dom/Text.h" 40 #include "sky/engine/core/dom/Text.h"
41 #include "sky/engine/core/editing/Editor.h" 41 #include "sky/engine/core/editing/Editor.h"
42 #include "sky/engine/core/editing/FrameSelection.h" 42 #include "sky/engine/core/editing/FrameSelection.h"
43 #include "sky/engine/core/editing/HTMLInterchange.h" 43 #include "sky/engine/core/editing/HTMLInterchange.h"
44 #include "sky/engine/core/editing/InputMethodController.h" 44 #include "sky/engine/core/editing/InputMethodController.h"
45 #include "sky/engine/core/editing/TextIterator.h" 45 #include "sky/engine/core/editing/TextIterator.h"
46 #include "sky/engine/core/events/KeyboardEvent.h" 46 #include "sky/engine/core/events/KeyboardEvent.h"
47 #include "sky/engine/core/events/WheelEvent.h"
48 #include "sky/engine/core/frame/FrameHost.h" 47 #include "sky/engine/core/frame/FrameHost.h"
49 #include "sky/engine/core/frame/FrameView.h" 48 #include "sky/engine/core/frame/FrameView.h"
50 #include "sky/engine/core/frame/LocalFrame.h" 49 #include "sky/engine/core/frame/LocalFrame.h"
51 #include "sky/engine/core/frame/NewEventHandler.h" 50 #include "sky/engine/core/frame/NewEventHandler.h"
52 #include "sky/engine/core/frame/Settings.h" 51 #include "sky/engine/core/frame/Settings.h"
53 #include "sky/engine/core/html/HTMLImportElement.h" 52 #include "sky/engine/core/html/HTMLImportElement.h"
54 #include "sky/engine/core/html/ime/InputMethodContext.h" 53 #include "sky/engine/core/html/ime/InputMethodContext.h"
55 #include "sky/engine/core/loader/FrameLoader.h" 54 #include "sky/engine/core/loader/FrameLoader.h"
56 #include "sky/engine/core/loader/UniqueIdentifier.h" 55 #include "sky/engine/core/loader/UniqueIdentifier.h"
57 #include "sky/engine/core/page/AutoscrollController.h" 56 #include "sky/engine/core/page/AutoscrollController.h"
58 #include "sky/engine/core/page/Chrome.h" 57 #include "sky/engine/core/page/Chrome.h"
59 #include "sky/engine/core/page/EventHandler.h" 58 #include "sky/engine/core/page/EventHandler.h"
60 #include "sky/engine/core/page/EventWithHitTestResults.h" 59 #include "sky/engine/core/page/EventWithHitTestResults.h"
61 #include "sky/engine/core/page/FocusController.h" 60 #include "sky/engine/core/page/FocusController.h"
62 #include "sky/engine/core/page/Page.h" 61 #include "sky/engine/core/page/Page.h"
63 #include "sky/engine/core/rendering/RenderView.h" 62 #include "sky/engine/core/rendering/RenderView.h"
64 #include "sky/engine/platform/Cursor.h" 63 #include "sky/engine/platform/Cursor.h"
65 #include "sky/engine/platform/KeyboardCodes.h" 64 #include "sky/engine/platform/KeyboardCodes.h"
66 #include "sky/engine/platform/Logging.h" 65 #include "sky/engine/platform/Logging.h"
67 #include "sky/engine/platform/NotImplemented.h" 66 #include "sky/engine/platform/NotImplemented.h"
68 #include "sky/engine/platform/PlatformGestureEvent.h" 67 #include "sky/engine/platform/PlatformGestureEvent.h"
69 #include "sky/engine/platform/PlatformKeyboardEvent.h" 68 #include "sky/engine/platform/PlatformKeyboardEvent.h"
70 #include "sky/engine/platform/PlatformMouseEvent.h"
71 #include "sky/engine/platform/PlatformWheelEvent.h"
72 #include "sky/engine/platform/TraceEvent.h" 69 #include "sky/engine/platform/TraceEvent.h"
73 #include "sky/engine/platform/fonts/FontCache.h" 70 #include "sky/engine/platform/fonts/FontCache.h"
74 #include "sky/engine/platform/graphics/Color.h" 71 #include "sky/engine/platform/graphics/Color.h"
75 #include "sky/engine/platform/graphics/GraphicsContext.h" 72 #include "sky/engine/platform/graphics/GraphicsContext.h"
76 #include "sky/engine/platform/graphics/Image.h" 73 #include "sky/engine/platform/graphics/Image.h"
77 #include "sky/engine/platform/graphics/ImageBuffer.h" 74 #include "sky/engine/platform/graphics/ImageBuffer.h"
78 #include "sky/engine/platform/scroll/Scrollbar.h" 75 #include "sky/engine/platform/scroll/Scrollbar.h"
79 #include "sky/engine/public/platform/Platform.h" 76 #include "sky/engine/public/platform/Platform.h"
80 #include "sky/engine/public/platform/WebFloatPoint.h" 77 #include "sky/engine/public/platform/WebFloatPoint.h"
81 #include "sky/engine/public/platform/WebImage.h" 78 #include "sky/engine/public/platform/WebImage.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 WebViewImpl::~WebViewImpl() 162 WebViewImpl::~WebViewImpl()
166 { 163 {
167 ASSERT(!m_page); 164 ASSERT(!m_page);
168 } 165 }
169 166
170 WebLocalFrameImpl* WebViewImpl::mainFrameImpl() 167 WebLocalFrameImpl* WebViewImpl::mainFrameImpl()
171 { 168 {
172 return m_page ? WebLocalFrameImpl::fromFrame(m_page->mainFrame()) : 0; 169 return m_page ? WebLocalFrameImpl::fromFrame(m_page->mainFrame()) : 0;
173 } 170 }
174 171
175 void WebViewImpl::handleMouseLeave(LocalFrame& mainFrame, const WebMouseEvent& e vent)
176 {
177 m_client->setMouseOverURL(WebURL());
178 mainFrame.eventHandler().handleMouseLeaveEvent(PlatformMouseEventBuilder(mai nFrame.view(), event));
179 }
180
181 void WebViewImpl::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& ev ent)
182 {
183 mainFrame.eventHandler().handleMousePressEvent(PlatformMouseEventBuilder(mai nFrame.view(), event));
184 }
185
186 void WebViewImpl::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& even t)
187 {
188 mainFrame.eventHandler().handleMouseReleaseEvent(PlatformMouseEventBuilder(m ainFrame.view(), event));
189 }
190
191 bool WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const WebMouseWheelEve nt& event)
192 {
193 return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(m ainFrame.view(), event));
194 }
195
196 void WebViewImpl::handleMouseMove(LocalFrame& mainFrame, const WebMouseEvent& ev ent)
197 {
198 mainFrame.eventHandler().handleMouseMoveEvent(PlatformMouseEventBuilder(main Frame.view(), event));
199 }
200
201 bool WebViewImpl::handleTouchEvent(LocalFrame& mainFrame, const WebTouchEvent& e vent) 172 bool WebViewImpl::handleTouchEvent(LocalFrame& mainFrame, const WebTouchEvent& e vent)
202 { 173 {
203 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m ainFrame.view(), event)); 174 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m ainFrame.view(), event));
204 } 175 }
205 176
206 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) 177 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
207 { 178 {
208 bool eventSwallowed = false; 179 bool eventSwallowed = false;
209 bool eventCancelled = false; // for disambiguation 180 bool eventCancelled = false; // for disambiguation
210 181
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 gc.restore(); 518 gc.restore();
548 } 519 }
549 520
550 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0; 521 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0;
551 522
552 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha n 523 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha n
553 // the one-offs for subsets of these values. 524 // the one-offs for subsets of these values.
554 static String inputTypeToName(WebInputEvent::Type type) 525 static String inputTypeToName(WebInputEvent::Type type)
555 { 526 {
556 switch (type) { 527 switch (type) {
557 case WebInputEvent::MouseDown:
558 return EventTypeNames::mousedown;
559 case WebInputEvent::MouseUp:
560 return EventTypeNames::mouseup;
561 case WebInputEvent::MouseMove:
562 return EventTypeNames::mousemove;
563 case WebInputEvent::MouseEnter:
564 return EventTypeNames::mouseenter;
565 case WebInputEvent::MouseLeave:
566 return EventTypeNames::mouseleave;
567 case WebInputEvent::MouseWheel:
568 return EventTypeNames::mousewheel;
569 case WebInputEvent::KeyDown: 528 case WebInputEvent::KeyDown:
570 return EventTypeNames::keydown; 529 return EventTypeNames::keydown;
571 case WebInputEvent::KeyUp: 530 case WebInputEvent::KeyUp:
572 return EventTypeNames::keyup; 531 return EventTypeNames::keyup;
573 case WebInputEvent::GestureScrollBegin: 532 case WebInputEvent::GestureScrollBegin:
574 return EventTypeNames::gesturescrollstart; 533 return EventTypeNames::gesturescrollstart;
575 case WebInputEvent::GestureScrollEnd: 534 case WebInputEvent::GestureScrollEnd:
576 return EventTypeNames::gesturescrollend; 535 return EventTypeNames::gesturescrollend;
577 case WebInputEvent::GestureScrollUpdate: 536 case WebInputEvent::GestureScrollUpdate:
578 return EventTypeNames::gesturescrollupdate; 537 return EventTypeNames::gesturescrollupdate;
(...skipping 22 matching lines...) Expand all
601 { 560 {
602 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa me(inputEvent.type).ascii().data()); 561 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa me(inputEvent.type).ascii().data());
603 562
604 TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent , &inputEvent); 563 TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent , &inputEvent);
605 564
606 if (WebInputEvent::isPointerEventType(inputEvent.type)) { 565 if (WebInputEvent::isPointerEventType(inputEvent.type)) {
607 const WebPointerEvent& event = static_cast<const WebPointerEvent&>(input Event); 566 const WebPointerEvent& event = static_cast<const WebPointerEvent&>(input Event);
608 return m_page->mainFrame()->newEventHandler().handlePointerEvent(event); 567 return m_page->mainFrame()->newEventHandler().handlePointerEvent(event);
609 } 568 }
610 569
611 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) {
612 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type);
613 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it.
614 RefPtr<Node> node = m_mouseCaptureNode;
615
616 // Not all platforms call mouseCaptureLost() directly.
617 if (inputEvent.type == WebInputEvent::MouseUp)
618 mouseCaptureLost();
619
620 AtomicString eventType;
621 switch (inputEvent.type) {
622 case WebInputEvent::MouseMove:
623 eventType = EventTypeNames::mousemove;
624 break;
625 case WebInputEvent::MouseLeave:
626 eventType = EventTypeNames::mouseout;
627 break;
628 case WebInputEvent::MouseDown:
629 eventType = EventTypeNames::mousedown;
630 break;
631 case WebInputEvent::MouseUp:
632 eventType = EventTypeNames::mouseup;
633 break;
634 default:
635 ASSERT_NOT_REACHED();
636 }
637
638 node->dispatchMouseEvent(
639 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), static_cast< const WebMouseEvent&>(inputEvent)),
640 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount) ;
641 return true;
642 }
643
644 LocalFrame* frame = m_page ? m_page->mainFrame() : nullptr; 570 LocalFrame* frame = m_page ? m_page->mainFrame() : nullptr;
645 switch (inputEvent.type) { 571 switch (inputEvent.type) {
646
647 // FIXME: WebKit seems to always return false on mouse events processing
648 // methods. For now we'll assume it has processed them (as we are only
649 // interested in whether keyboard events are processed).
650 case WebInputEvent::MouseMove:
651 if (!frame || !frame->view())
652 return true;
653 handleMouseMove(*frame, static_cast<const WebMouseEvent&>(inputEvent));
654 return true;
655 case WebInputEvent::MouseLeave:
656 if (!frame || !frame->view())
657 return true;
658 handleMouseLeave(*frame, static_cast<const WebMouseEvent&>(inputEvent));
659 return true;
660 case WebInputEvent::MouseDown:
661 if (!frame || !frame->view())
662 return true;
663 handleMouseDown(*frame, static_cast<const WebMouseEvent&>(inputEvent));
664 return true;
665 case WebInputEvent::MouseUp:
666 if (!frame || !frame->view())
667 return true;
668 handleMouseUp(*frame, static_cast<const WebMouseEvent&>(inputEvent));
669 return true;
670
671 case WebInputEvent::MouseWheel:
672 if (!frame || !frame->view())
673 return false;
674 return handleMouseWheel(*frame, static_cast<const WebMouseWheelEvent&>(i nputEvent));
675
676 case WebInputEvent::RawKeyDown: 572 case WebInputEvent::RawKeyDown:
677 case WebInputEvent::KeyDown: 573 case WebInputEvent::KeyDown:
678 case WebInputEvent::KeyUp: 574 case WebInputEvent::KeyUp:
679 return handleKeyEvent(static_cast<const WebKeyboardEvent&>(inputEvent)); 575 return handleKeyEvent(static_cast<const WebKeyboardEvent&>(inputEvent));
680 576
681 case WebInputEvent::Char: 577 case WebInputEvent::Char:
682 return handleCharEvent(static_cast<const WebKeyboardEvent&>(inputEvent)) ; 578 return handleCharEvent(static_cast<const WebKeyboardEvent&>(inputEvent)) ;
683 case WebInputEvent::GestureScrollBegin: 579 case WebInputEvent::GestureScrollBegin:
684 case WebInputEvent::GestureScrollEnd: 580 case WebInputEvent::GestureScrollEnd:
685 case WebInputEvent::GestureScrollUpdate: 581 case WebInputEvent::GestureScrollUpdate:
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, 1174 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState,
1279 bool isInitialState) { 1175 bool isInitialState) {
1280 if (!page()) 1176 if (!page())
1281 return; 1177 return;
1282 1178
1283 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState = = WebPageVisibilityStateHidden); 1179 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState = = WebPageVisibilityStateHidden);
1284 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int> (visibilityState)), isInitialState); 1180 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int> (visibilityState)), isInitialState);
1285 } 1181 }
1286 1182
1287 } // namespace blink 1183 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698