1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007-2009 Torch Mobile, Inc.
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
27 #include "config.h"
28 #include "EventHandler.h"
29
30 #include "ClipboardWin.h"
31 #include "Cursor.h"
32 #include "FloatPoint.h"
33 #include "FocusController.h"
34 #include "FrameView.h"
35 #include "Frame.h"
36 #include "HitTestRequest.h"
37 #include "HitTestResult.h"
38 #include "MouseEventWithHitTestResults.h"
39 #include "Page.h"
40 #include "PlatformKeyboardEvent.h"
41 #include "PlatformWheelEvent.h"
42 #include "Scrollbar.h"
43 #include "SelectionController.h"
44 #include "WCDataObject.h"
45 #include "NotImplemented.h"
46
47 namespace WebCore {
48
49 const double EventHandler::TextDragDelay = 0.0;
50
passMousePressEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)51 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
52 {
53 subframe->eventHandler()->handleMousePressEvent(mev.event());
54 return true;
55 }
56
passMouseMoveEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe,HitTestResult * hoveredNode)57 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode)
58 {
59 if (m_mouseDownMayStartDrag && !m_mouseDownWasInSubframe)
60 return false;
61 subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode);
62 return true;
63 }
64
passMouseReleaseEventToSubframe(MouseEventWithHitTestResults & mev,Frame * subframe)65 bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
66 {
67 subframe->eventHandler()->handleMouseReleaseEvent(mev.event());
68 return true;
69 }
70
passWheelEventToWidget(PlatformWheelEvent & wheelEvent,Widget * widget)71 bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& wheelEvent, Widget* widget)
72 {
73 if (!widget->isFrameView())
74 return false;
75
76 return static_cast<FrameView*>(widget)->frame()->eventHandler()->handleWheelEvent(wheelEvent);
77 }
78
tabsToAllControls(KeyboardEvent *) const79 bool EventHandler::tabsToAllControls(KeyboardEvent*) const
80 {
81 return true;
82 }
83
eventActivatedView(const PlatformMouseEvent & event) const84 bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const
85 {
86 return event.activatedWebView();
87 }
88
createDraggingClipboard() const89 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
90 {
91 #if PLATFORM(WINCE)
92 return 0;
93 #else
94 COMPtr<WCDataObject> dataObject;
95 WCDataObject::createInstance(&dataObject);
96 return ClipboardWin::create(true, dataObject.get(), ClipboardWritable);
97 #endif
98 }
99
focusDocumentView()100 void EventHandler::focusDocumentView()
101 {
102 Page* page = m_frame->page();
103 if (!page)
104 return;
105 page->focusController()->setFocusedFrame(m_frame);
106 }
107
passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults &)108 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&)
109 {
110 notImplemented();
111 return false;
112 }
113
accessKeyModifiers()114 unsigned EventHandler::accessKeyModifiers()
115 {
116 return PlatformKeyboardEvent::AltKey;
117 }
118
119 }
120