blob: 43b6b80687a66900e1d6ce386e39ae5af40d62e4 [file] [log] [blame]
kjk6287cbc2007-02-07 21:53:30 +00001/*
2 * Copyright (C) 2006 Zack Rusin <zack@kde.org>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "EventHandler.h"
28
29#include "EventNames.h"
30#include "FloatPoint.h"
31#include "FocusController.h"
32#include "Frame.h"
33#include "FrameView.h"
34#include "KeyboardEvent.h"
35#include "MouseEventWithHitTestResults.h"
kevino64ee95c2007-05-28 00:39:59 +000036#include "NotImplemented.h"
kjk6287cbc2007-02-07 21:53:30 +000037#include "Page.h"
38#include "PlatformScrollBar.h"
39#include "PlatformWheelEvent.h"
40#include "RenderWidget.h"
41
42namespace WebCore {
43
44using namespace EventNames;
45
kjk6287cbc2007-02-07 21:53:30 +000046static bool isKeyboardOptionTab(KeyboardEvent* event)
47{
48 return event
49 && (event->type() == keydownEvent || event->type() == keypressEvent)
50 && event->altKey()
rwlbuis8457ad52007-05-13 14:00:18 +000051 && event->keyIdentifier() == "U+0009";
kjk6287cbc2007-02-07 21:53:30 +000052}
53
kjk6287cbc2007-02-07 21:53:30 +000054bool EventHandler::tabsToAllControls(KeyboardEvent* event) const
55{
56 bool handlingOptionTab = isKeyboardOptionTab(event);
57
58 return handlingOptionTab;
59}
60
61void EventHandler::focusDocumentView()
62{
63 if (Page* page = m_frame->page())
64 page->focusController()->setFocusedFrame(m_frame);
65}
66
67bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
68{
69 // Figure out which view to send the event to.
70 RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : 0;
71 if (!target || !target->isWidget())
72 return false;
73
74 return passMouseDownEventToWidget(static_cast<RenderWidget*>(target)->widget());
75}
76
77bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
78{
79 return passMouseDownEventToWidget(renderWidget->widget());
80}
81
82bool EventHandler::passMouseDownEventToWidget(Widget* widget)
83{
kevino64ee95c2007-05-28 00:39:59 +000084 notImplemented();
kjk6287cbc2007-02-07 21:53:30 +000085 return false;
86}
87
kjk6287cbc2007-02-07 21:53:30 +000088bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const
89{
kevino64ee95c2007-05-28 00:39:59 +000090 notImplemented();
kjk6287cbc2007-02-07 21:53:30 +000091 return false;
92}
93
arobenfa828ec2007-07-05 05:21:28 +000094bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& event, Frame* subframe, HitTestResult*)
kjk6287cbc2007-02-07 21:53:30 +000095{
kevino64ee95c2007-05-28 00:39:59 +000096 notImplemented();
kjk6287cbc2007-02-07 21:53:30 +000097 return false;
98}
99
bdashb3ab2f82007-04-24 00:59:44 +0000100bool EventHandler::passWheelEventToWidget(PlatformWheelEvent&, Widget* widget)
kjk6287cbc2007-02-07 21:53:30 +0000101{
kevino64ee95c2007-05-28 00:39:59 +0000102 notImplemented();
kjk6287cbc2007-02-07 21:53:30 +0000103 return false;
104}
105
kjk781540c2007-02-20 21:21:21 +0000106Clipboard* EventHandler::createDraggingClipboard() const
107{
kevino64ee95c2007-05-28 00:39:59 +0000108 notImplemented();
kjk781540c2007-02-20 21:21:21 +0000109 return 0;
110}
111
kjk6287cbc2007-02-07 21:53:30 +0000112bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
113{
114 return passSubframeEventToSubframe(mev, subframe);
115}
116
arobena6e57ef2007-07-05 03:23:48 +0000117bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode)
kjk6287cbc2007-02-07 21:53:30 +0000118{
arobena6e57ef2007-07-05 03:23:48 +0000119 return passSubframeEventToSubframe(mev, subframe, hoveredNode);
kjk6287cbc2007-02-07 21:53:30 +0000120}
121
122bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
123{
124 return passSubframeEventToSubframe(mev, subframe);
125}
126
kjk6287cbc2007-02-07 21:53:30 +0000127bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults&, PlatformScrollbar* scrollbar)
128{
weinig61c4ecc2007-05-28 01:46:32 +0000129 notImplemented();
bdashb3ab2f82007-04-24 00:59:44 +0000130 return false;
kjk6287cbc2007-02-07 21:53:30 +0000131}
132
133}