|
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 |
|
65 static bool isKeyboardOptionTab(KeyboardEvent* event) |
|
66 { |
|
67 return event |
|
68 && (event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent) |
|
69 && event->altKey() |
|
70 && event->keyIdentifier() == "U+0009"; |
|
71 } |
|
72 |
|
73 bool EventHandler::invertSenseOfTabsToLinks(KeyboardEvent* event) const |
|
74 { |
|
75 return isKeyboardOptionTab(event); |
|
76 } |
|
77 |
|
78 bool EventHandler::tabsToAllControls(KeyboardEvent* event) const |
|
79 { |
|
80 return (isKeyboardOptionTab(event) ? !qt_tab_all_widgets : qt_tab_all_widgets); |
|
81 } |
|
82 |
|
83 void EventHandler::focusDocumentView() |
|
84 { |
|
85 Page* page = m_frame->page(); |
|
86 if (!page) |
|
87 return; |
|
88 page->focusController()->setFocusedFrame(m_frame); |
|
89 } |
|
90 |
|
91 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&) |
|
92 { |
|
93 notImplemented(); |
|
94 return false; |
|
95 } |
|
96 |
|
97 bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const |
|
98 { |
|
99 // Qt has an activation event which is sent independently |
|
100 // of mouse event so this thing will be a snafu to implement |
|
101 // correctly |
|
102 return false; |
|
103 } |
|
104 |
|
105 bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& event, Widget* widget) |
|
106 { |
|
107 Q_ASSERT(widget); |
|
108 if (!widget->isFrameView()) |
|
109 return false; |
|
110 |
|
111 return static_cast<FrameView*>(widget)->frame()->eventHandler()->handleWheelEvent(event); |
|
112 } |
|
113 |
|
114 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const |
|
115 { |
|
116 return ClipboardQt::create(ClipboardWritable, true); |
|
117 } |
|
118 |
|
119 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) |
|
120 { |
|
121 subframe->eventHandler()->handleMousePressEvent(mev.event()); |
|
122 return true; |
|
123 } |
|
124 |
|
125 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode) |
|
126 { |
|
127 subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode); |
|
128 return true; |
|
129 } |
|
130 |
|
131 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) |
|
132 { |
|
133 subframe->eventHandler()->handleMouseReleaseEvent(mev.event()); |
|
134 return true; |
|
135 } |
|
136 |
|
137 unsigned EventHandler::accessKeyModifiers() |
|
138 { |
|
139 #if OS(DARWIN) |
|
140 return PlatformKeyboardEvent::CtrlKey | PlatformKeyboardEvent::AltKey; |
|
141 #else |
|
142 return PlatformKeyboardEvent::AltKey; |
|
143 #endif |
|
144 } |
|
145 |
|
146 } |