EventHandlerHaiku.cpp revision 231d4e3152a9c27a73b6ac7badbe6be673aa3ddf
1/* 2 * Copyright (C) 2006 Zack Rusin <zack@kde.org> 3 * Copyright (C) 2007 Ryan Leavengood <leavengood@gmail.com> 4 * Copyright (C) 2009 Maxime Simon <simon.maxime@gmail.com> 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 "ClipboardHaiku.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 "PlatformScrollBar.h" 43#include "PlatformWheelEvent.h" 44#include "RenderWidget.h" 45 46#include <interface/View.h> 47 48 49namespace WebCore { 50 51const double EventHandler::TextDragDelay = 0.0; 52 53static bool isKeyboardOptionTab(KeyboardEvent* event) 54{ 55 return event 56 && (event->type() == eventNames().keydownEvent 57 || event->type() == eventNames().keypressEvent) 58 && event->altKey() 59 && event->keyIdentifier() == "U+000009"; 60} 61 62bool EventHandler::invertSenseOfTabsToLinks(KeyboardEvent* event) const 63{ 64 return isKeyboardOptionTab(event); 65} 66 67bool EventHandler::tabsToAllControls(KeyboardEvent* event) const 68{ 69 bool handlingOptionTab = isKeyboardOptionTab(event); 70 71 return handlingOptionTab; 72} 73 74void EventHandler::focusDocumentView() 75{ 76 BView* view = m_frame->view()->platformWidget(); 77 if (view) 78 view->MakeFocus(); 79 80 Page* page = m_frame->page(); 81 if (page) 82 page->focusController()->setFocusedFrame(m_frame); 83} 84 85bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event) 86{ 87 // Figure out which view to send the event to. 88 RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : 0; 89 if (!target || !target->isWidget()) 90 return false; 91 return passMouseDownEventToWidget(toRenderWidget(target)->widget()); 92} 93 94bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget) 95{ 96 return passMouseDownEventToWidget(renderWidget->widget()); 97} 98 99bool EventHandler::passMouseDownEventToWidget(Widget* widget) 100{ 101 notImplemented(); 102 return false; 103} 104 105bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const 106{ 107 notImplemented(); 108 return false; 109} 110 111bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& event, Frame* subframe, HitTestResult*) 112{ 113 notImplemented(); 114 return true; 115} 116 117bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& event, Widget* widget) 118{ 119 if (!widget->isFrameView()) 120 return false; 121 122 return static_cast<FrameView*>(widget)->frame()->eventHandler()->handleWheelEvent(event); 123} 124 125PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const 126{ 127 return ClipboardHaiku::create(ClipboardWritable, true); 128} 129 130bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) 131{ 132 return passSubframeEventToSubframe(mev, subframe); 133} 134 135bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode) 136{ 137 return passSubframeEventToSubframe(mev, subframe, hoveredNode); 138} 139 140bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) 141{ 142 return passSubframeEventToSubframe(mev, subframe); 143} 144 145unsigned EventHandler::accessKeyModifiers() 146{ 147 return PlatformKeyboardEvent::AltKey; 148} 149 150} // namespace WebCore 151 152