1 /* 2 * Copyright (C) 2010 Company 100, Inc. 3 * Copyright 2009, The Android Open Source Project 4 * Copyright (C) 2006 Zack Rusin <zack (at) kde.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #include "config.h" 29 #include "EventHandler.h" 30 31 #include "ClipboardBrew.h" 32 #include "EventNames.h" 33 #include "FocusController.h" 34 #include "Frame.h" 35 #include "FrameView.h" 36 #include "HitTestResult.h" 37 #include "KeyboardEvent.h" 38 #include "MouseEventWithHitTestResults.h" 39 #include "NotImplemented.h" 40 #include "Page.h" 41 #include "PlatformKeyboardEvent.h" 42 #include "PlatformWheelEvent.h" 43 #include "RenderWidget.h" 44 45 namespace WebCore { 46 47 bool EventHandler::tabsToAllFormControls(KeyboardEvent* event) const 48 { 49 return true; 50 } 51 52 void EventHandler::focusDocumentView() 53 { 54 Page* page = m_frame->page(); 55 if (page) 56 page->focusController()->setFocusedFrame(m_frame); 57 } 58 59 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event) 60 { 61 // Figure out which view to send the event to. 62 RenderObject* target = targetNode(event) ? targetNode(event)->renderer() : 0; 63 if (!target || !target->isWidget()) 64 return false; 65 return passMouseDownEventToWidget(toRenderWidget(target)->widget()); 66 } 67 68 bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget) 69 { 70 return passMouseDownEventToWidget(renderWidget->widget()); 71 } 72 73 // This function is used to route the mouse down event to the native widgets, it seems like a 74 // work around for the Mac platform which does not support double clicks, but browsers do. 75 bool EventHandler::passMouseDownEventToWidget(Widget* widget) 76 { 77 notImplemented(); 78 return false; 79 } 80 81 bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const 82 { 83 notImplemented(); 84 return false; 85 } 86 87 // This function is called for mouse events by FrameView::handleMousePressEvent(). 88 // It is used to ensure that events are sync'ed correctly between frames. For example 89 // if the user presses down in one frame and up in another frame, this function will 90 // returns true, and pass the event to the correct frame. 91 bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& event, Frame* subframe, HitTestResult*) 92 { 93 notImplemented(); 94 return false; 95 } 96 97 // This is called to route wheel events to child widgets when they are RenderWidget 98 // as the parent usually gets wheel event. Don't have a mouse with a wheel to confirm 99 // the operation of this function. 100 bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& event, Widget* widget) 101 { 102 notImplemented(); 103 return false; 104 } 105 106 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) 107 { 108 return passSubframeEventToSubframe(mev, subframe); 109 } 110 111 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode) 112 { 113 return passSubframeEventToSubframe(mev, subframe, hoveredNode); 114 } 115 116 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) 117 { 118 return passSubframeEventToSubframe(mev, subframe); 119 } 120 121 unsigned EventHandler::accessKeyModifiers() 122 { 123 return PlatformKeyboardEvent::AltKey; 124 } 125 126 } // namespace WebCore 127 128