• 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 
tabsToAllControls(KeyboardEvent *) const42 bool EventHandler::tabsToAllControls(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 = event.targetNode() ? event.targetNode()->renderer() : 0;
57     if (!target || !target->isWidget())
58         return false;
59 
60     return passMouseDownEventToWidget(static_cast<RenderWidget*>(target)->widget());
61 }
62 
passWidgetMouseDownEventToWidget(RenderWidget * renderWidget)63 bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
64 {
65     return passMouseDownEventToWidget(renderWidget->widget());
66 }
67 
68 // This function is used to route the mouse down event to the native widgets, it seems like a
69 // work around for the Mac platform which does not support double clicks, but browsers do.
passMouseDownEventToWidget(Widget *)70 bool EventHandler::passMouseDownEventToWidget(Widget*)
71 {
72     // return false so the normal propogation handles the event
73     return false;
74 }
75 
eventActivatedView(const PlatformMouseEvent &) const76 bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const
77 {
78     notImplemented();
79     return false;
80 }
81 
82 // This function is called for mouse events by FrameView::handleMousePressEvent().
83 // It is used to ensure that events are sync'ed correctly between frames. For example
84 // if the user presses down in one frame and up in another frame, this function will
85 // returns true, and pass the event to the correct frame.
passSubframeEventToSubframe(MouseEventWithHitTestResults &,Frame *,HitTestResult *)86 bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults&, Frame*, HitTestResult*)
87 {
88     notImplemented();
89     return false;
90 }
91 
92 // This is called to route wheel events to child widgets when they are RenderWidget
93 // as the parent usually gets wheel event. Don't have a mouse with a wheel to confirm
94 // the operation of this function.
passWheelEventToWidget(PlatformWheelEvent &,Widget *)95 bool EventHandler::passWheelEventToWidget(PlatformWheelEvent&, Widget*)
96 {
97     notImplemented();
98     return false;
99 }
100 
passMousePressEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)101 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
102 {
103     return passSubframeEventToSubframe(mev, subframe);
104 }
105 
passMouseMoveEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe,HitTestResult *)106 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev,
107     Frame* subframe, HitTestResult*)
108 {
109     return passSubframeEventToSubframe(mev, subframe);
110 }
111 
passMouseReleaseEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)112 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
113 {
114     return passSubframeEventToSubframe(mev, subframe);
115 }
116 
117 class Clipboard : public RefCounted<Clipboard> {
118 };
119 
createDraggingClipboard() const120 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
121 {
122     return PassRefPtr<Clipboard>(0);
123 }
124 
accessKeyModifiers()125 unsigned EventHandler::accessKeyModifiers()
126 {
127     return PlatformKeyboardEvent::AltKey;
128 }
129 
130 const double EventHandler::TextDragDelay = 0.0;
131 
132 }  // namespace WebCore
133