• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2009, The Android Open Source Project
3  * Copyright (C) 2006 Zack Rusin <zack@kde.org>
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 #define LOG_TAG "WebCore"
27 
28 #include "config.h"
29 #include "EventHandler.h"
30 
31 #include "FocusController.h"
32 #include "Frame.h"
33 #include "KeyboardEvent.h"
34 #include "MouseEventWithHitTestResults.h"
35 #include "Page.h"
36 #include "PlatformKeyboardEvent.h"
37 #include "PlatformWheelEvent.h"
38 #include "RenderWidget.h"
39 
40 namespace WebCore {
41 
tabsToAllFormControls(KeyboardEvent *) const42 bool EventHandler::tabsToAllFormControls(KeyboardEvent*) const
43 {
44     return true;
45 }
46 
focusDocumentView()47 void EventHandler::focusDocumentView()
48 {
49     if (Page* page = m_frame->page())
50         page->focusController()->setFocusedFrame(m_frame);
51 }
52 
passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults & event)53 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
54 {
55     // Figure out which view to send the event to.
56     RenderObject* target = targetNode(event) ? targetNode(event)->renderer() : 0;
57     if (!target || !target->isWidget())
58         return false;
59     return passMouseDownEventToWidget(toRenderWidget(target)->widget());
60 }
61 
passWidgetMouseDownEventToWidget(RenderWidget * renderWidget)62 bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
63 {
64     return passMouseDownEventToWidget(renderWidget->widget());
65 }
66 
67 // This function is used to route the mouse down event to the native widgets, it seems like a
68 // work around for the Mac platform which does not support double clicks, but browsers do.
passMouseDownEventToWidget(Widget *)69 bool EventHandler::passMouseDownEventToWidget(Widget*)
70 {
71     // return false so the normal propogation handles the event
72     return false;
73 }
74 
eventActivatedView(const PlatformMouseEvent &) const75 bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const
76 {
77     notImplemented();
78     return false;
79 }
80 
81 // This is called to route wheel events to child widgets when they are RenderWidget
82 // as the parent usually gets wheel event. Don't have a mouse with a wheel to confirm
83 // the operation of this function.
passWheelEventToWidget(PlatformWheelEvent &,Widget *)84 bool EventHandler::passWheelEventToWidget(PlatformWheelEvent&, Widget*)
85 {
86     notImplemented();
87     return false;
88 }
89 
passMousePressEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)90 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
91 {
92     subframe->eventHandler()->handleMousePressEvent(mev.event());
93     return true;
94 }
95 
passMouseMoveEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe,HitTestResult * hoveredNode)96 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev,
97     Frame* subframe, HitTestResult* hoveredNode)
98 {
99     subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode);
100     return true;
101 }
102 
passMouseReleaseEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)103 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
104 {
105     subframe->eventHandler()->handleMouseReleaseEvent(mev.event());
106     return true;
107 }
108 
createDraggingClipboard() const109 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
110 {
111     return PassRefPtr<Clipboard>(0);
112 }
113 
accessKeyModifiers()114 unsigned EventHandler::accessKeyModifiers()
115 {
116     return PlatformKeyboardEvent::AltKey;
117 }
118 
119 const double EventHandler::TextDragDelay = 0.0;
120 
121 }  // namespace WebCore
122