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 "Page.h"
47 #include "PlatformKeyboardEvent.h"
48 #include "PlatformWheelEvent.h"
49 #include "RenderWidget.h"
50 #include "Scrollbar.h"
51 #include "NotImplemented.h"
52
53 QT_BEGIN_NAMESPACE
54 extern Q_GUI_EXPORT bool qt_tab_all_widgets; // from qapplication.cpp
55 QT_END_NAMESPACE
56
57 namespace WebCore {
58
59 const double EventHandler::TextDragDelay = 0.0;
60
isKeyboardOptionTab(KeyboardEvent * event)61 static bool isKeyboardOptionTab(KeyboardEvent* event)
62 {
63 return event
64 && (event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent)
65 && event->altKey()
66 && event->keyIdentifier() == "U+0009";
67 }
68
invertSenseOfTabsToLinks(KeyboardEvent * event) const69 bool EventHandler::invertSenseOfTabsToLinks(KeyboardEvent* event) const
70 {
71 return isKeyboardOptionTab(event);
72 }
73
tabsToAllControls(KeyboardEvent * event) const74 bool EventHandler::tabsToAllControls(KeyboardEvent* event) const
75 {
76 return (isKeyboardOptionTab(event) ? !qt_tab_all_widgets : qt_tab_all_widgets);
77 }
78
focusDocumentView()79 void EventHandler::focusDocumentView()
80 {
81 Page* page = m_frame->page();
82 if (!page)
83 return;
84 page->focusController()->setFocusedFrame(m_frame);
85 }
86
passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults &)87 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&)
88 {
89 notImplemented();
90 return false;
91 }
92
eventActivatedView(const PlatformMouseEvent &) const93 bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const
94 {
95 //Qt has an activation event which is sent independently
96 // of mouse event so this thing will be a snafu to implement
97 // correctly
98 return false;
99 }
100
passWheelEventToWidget(PlatformWheelEvent & event,Widget * widget)101 bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& event, Widget* widget)
102 {
103 Q_ASSERT(widget);
104 if (!widget->isFrameView())
105 return false;
106
107 return static_cast<FrameView*>(widget)->frame()->eventHandler()->handleWheelEvent(event);
108 }
109
createDraggingClipboard() const110 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
111 {
112 return ClipboardQt::create(ClipboardWritable, true);
113 }
114
passMousePressEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)115 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
116 {
117 subframe->eventHandler()->handleMousePressEvent(mev.event());
118 return true;
119 }
120
passMouseMoveEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe,HitTestResult * hoveredNode)121 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode)
122 {
123 subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode);
124 return true;
125 }
126
passMouseReleaseEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)127 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
128 {
129 subframe->eventHandler()->handleMouseReleaseEvent(mev.event());
130 return true;
131 }
132
accessKeyModifiers()133 unsigned EventHandler::accessKeyModifiers()
134 {
135 return PlatformKeyboardEvent::CtrlKey;
136 }
137
138 }
139