1/* 2 * Copyright (C) 2006 Zack Rusin <zack@kde.org> 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 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 "Clipboard.h" 32#include "Cursor.h" 33#include "Document.h" 34#include "EventNames.h" 35#include "FloatPoint.h" 36#include "FocusController.h" 37#include "Frame.h" 38#include "FrameLoader.h" 39#include "FrameTree.h" 40#include "FrameView.h" 41#include "HTMLFrameSetElement.h" 42#include "HitTestRequest.h" 43#include "HitTestResult.h" 44#include "KeyboardEvent.h" 45#include "MouseEventWithHitTestResults.h" 46#include "NotImplemented.h" 47#include "Page.h" 48#include "PlatformKeyboardEvent.h" 49#include "PlatformWheelEvent.h" 50#include "RenderWidget.h" 51#include "Scrollbar.h" 52 53namespace WebCore { 54 55#if defined(Q_WS_MAC) 56const double EventHandler::TextDragDelay = 0.15; 57#else 58const double EventHandler::TextDragDelay = 0.0; 59#endif 60 61bool EventHandler::tabsToAllFormControls(KeyboardEvent* event) const 62{ 63 return !isKeyboardOptionTab(event); 64} 65 66void EventHandler::focusDocumentView() 67{ 68 Page* page = m_frame->page(); 69 if (!page) 70 return; 71 page->focusController()->setFocusedFrame(m_frame); 72} 73 74bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&) 75{ 76 notImplemented(); 77 return false; 78} 79 80bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const 81{ 82 // Qt has an activation event which is sent independently 83 // of mouse event so this thing will be a snafu to implement 84 // correctly 85 return false; 86} 87 88bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& event, Widget* widget) 89{ 90 Q_ASSERT(widget); 91 if (!widget->isFrameView()) 92 return false; 93 94 return toFrameView(widget)->frame()->eventHandler()->handleWheelEvent(event); 95} 96 97PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const 98{ 99 return Clipboard::createForDragAndDrop(); 100} 101 102bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) 103{ 104 subframe->eventHandler()->handleMousePressEvent(mev.event()); 105 return true; 106} 107 108bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode) 109{ 110 subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode); 111 return true; 112} 113 114bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) 115{ 116 subframe->eventHandler()->handleMouseReleaseEvent(mev.event()); 117 return true; 118} 119 120unsigned EventHandler::accessKeyModifiers() 121{ 122#if OS(DARWIN) 123 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 124#else 125 return PlatformEvent::AltKey; 126#endif 127} 128 129} 130