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 "ClipboardQt.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
53 QT_BEGIN_NAMESPACE
54 Q_GUI_EXPORT extern bool qt_tab_all_widgets; // from qapplication.cpp
55 QT_END_NAMESPACE
56
57 namespace WebCore {
58
59 #if defined(Q_WS_MAC)
60 const double EventHandler::TextDragDelay = 0.15;
61 #else
62 const double EventHandler::TextDragDelay = 0.0;
63 #endif
64
tabsToAllFormControls(KeyboardEvent * event) const65 bool EventHandler::tabsToAllFormControls(KeyboardEvent* event) const
66 {
67 return (isKeyboardOptionTab(event) ? !qt_tab_all_widgets : qt_tab_all_widgets);
68 }
69
focusDocumentView()70 void EventHandler::focusDocumentView()
71 {
72 Page* page = m_frame->page();
73 if (!page)
74 return;
75 page->focusController()->setFocusedFrame(m_frame);
76 }
77
passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults &)78 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&)
79 {
80 notImplemented();
81 return false;
82 }
83
eventActivatedView(const PlatformMouseEvent &) const84 bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const
85 {
86 // Qt has an activation event which is sent independently
87 // of mouse event so this thing will be a snafu to implement
88 // correctly
89 return false;
90 }
91
passWheelEventToWidget(PlatformWheelEvent & event,Widget * widget)92 bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& event, Widget* widget)
93 {
94 Q_ASSERT(widget);
95 if (!widget->isFrameView())
96 return false;
97
98 return static_cast<FrameView*>(widget)->frame()->eventHandler()->handleWheelEvent(event);
99 }
100
createDraggingClipboard() const101 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
102 {
103 return ClipboardQt::create(ClipboardWritable, Clipboard::DragAndDrop);
104 }
105
passMousePressEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)106 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
107 {
108 subframe->eventHandler()->handleMousePressEvent(mev.event());
109 return true;
110 }
111
passMouseMoveEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe,HitTestResult * hoveredNode)112 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode)
113 {
114 subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode);
115 return true;
116 }
117
passMouseReleaseEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)118 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
119 {
120 subframe->eventHandler()->handleMouseReleaseEvent(mev.event());
121 return true;
122 }
123
accessKeyModifiers()124 unsigned EventHandler::accessKeyModifiers()
125 {
126 #if OS(DARWIN)
127 return PlatformKeyboardEvent::CtrlKey | PlatformKeyboardEvent::AltKey;
128 #else
129 return PlatformKeyboardEvent::AltKey;
130 #endif
131 }
132
133 }
134