1 | /* |
2 | * Copyright (C) 2013 University of Washington. All rights reserved. |
3 | * Copyright (C) 2014 Apple Inc. All rights reserved. |
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 | * |
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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
16 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
17 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
18 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
19 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * THEORY 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 "UserInputBridge.h" |
30 | |
31 | #include "EventHandler.h" |
32 | #include "FocusController.h" |
33 | #include "Frame.h" |
34 | #include "FrameLoadRequest.h" |
35 | #include "FrameLoader.h" |
36 | #include "Page.h" |
37 | #include "PlatformKeyboardEvent.h" |
38 | #include "PlatformMouseEvent.h" |
39 | #include "PlatformWheelEvent.h" |
40 | |
41 | namespace WebCore { |
42 | |
43 | UserInputBridge::UserInputBridge(Page& page) |
44 | : m_page(page) |
45 | { |
46 | } |
47 | |
48 | #if ENABLE(CONTEXT_MENUS) |
49 | bool UserInputBridge::handleContextMenuEvent(const PlatformMouseEvent& mouseEvent, Frame& frame, InputSource) |
50 | { |
51 | return frame.eventHandler().sendContextMenuEvent(mouseEvent); |
52 | } |
53 | #endif |
54 | |
55 | bool UserInputBridge::handleMousePressEvent(const PlatformMouseEvent& mouseEvent, InputSource) |
56 | { |
57 | return m_page.mainFrame().eventHandler().handleMousePressEvent(mouseEvent); |
58 | } |
59 | |
60 | bool UserInputBridge::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent, InputSource) |
61 | { |
62 | return m_page.mainFrame().eventHandler().handleMouseReleaseEvent(mouseEvent); |
63 | } |
64 | |
65 | bool UserInputBridge::handleMouseMoveEvent(const PlatformMouseEvent& mouseEvent, InputSource) |
66 | { |
67 | return m_page.mainFrame().eventHandler().mouseMoved(mouseEvent); |
68 | } |
69 | |
70 | bool UserInputBridge::handleMouseMoveOnScrollbarEvent(const PlatformMouseEvent& mouseEvent, InputSource) |
71 | { |
72 | return m_page.mainFrame().eventHandler().passMouseMovedEventToScrollbars(mouseEvent); |
73 | } |
74 | |
75 | bool UserInputBridge::handleMouseForceEvent(const PlatformMouseEvent& mouseEvent, InputSource) |
76 | { |
77 | return m_page.mainFrame().eventHandler().handleMouseForceEvent(mouseEvent); |
78 | } |
79 | |
80 | bool UserInputBridge::handleKeyEvent(const PlatformKeyboardEvent& keyEvent, InputSource) |
81 | { |
82 | return m_page.focusController().focusedOrMainFrame().eventHandler().keyEvent(keyEvent); |
83 | } |
84 | |
85 | bool UserInputBridge::handleAccessKeyEvent(const PlatformKeyboardEvent& keyEvent, InputSource) |
86 | { |
87 | return m_page.focusController().focusedOrMainFrame().eventHandler().handleAccessKey(keyEvent); |
88 | } |
89 | |
90 | bool UserInputBridge::handleWheelEvent(const PlatformWheelEvent& wheelEvent, InputSource) |
91 | { |
92 | return m_page.mainFrame().eventHandler().handleWheelEvent(wheelEvent); |
93 | } |
94 | |
95 | void UserInputBridge::focusSetActive(bool active, InputSource) |
96 | { |
97 | m_page.focusController().setActive(active); |
98 | } |
99 | |
100 | void UserInputBridge::focusSetFocused(bool focused, InputSource) |
101 | { |
102 | m_page.focusController().setFocused(focused); |
103 | } |
104 | |
105 | bool UserInputBridge::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity, InputSource) |
106 | { |
107 | return m_page.focusController().focusedOrMainFrame().eventHandler().scrollRecursively(direction, granularity, nullptr); |
108 | } |
109 | |
110 | bool UserInputBridge::logicalScrollRecursively(ScrollLogicalDirection direction, ScrollGranularity granularity, InputSource) |
111 | { |
112 | return m_page.focusController().focusedOrMainFrame().eventHandler().logicalScrollRecursively(direction, granularity, nullptr); |
113 | } |
114 | |
115 | void UserInputBridge::loadRequest(FrameLoadRequest&& request, InputSource) |
116 | { |
117 | m_page.mainFrame().loader().load(WTFMove(request)); |
118 | } |
119 | |
120 | void UserInputBridge::reloadFrame(Frame* frame, OptionSet<ReloadOption> options, InputSource) |
121 | { |
122 | frame->loader().reload(options); |
123 | } |
124 | |
125 | void UserInputBridge::stopLoadingFrame(Frame* frame, InputSource) |
126 | { |
127 | frame->loader().stopForUserCancel(); |
128 | } |
129 | |
130 | bool UserInputBridge::tryClosePage(InputSource) |
131 | { |
132 | return m_page.mainFrame().loader().shouldClose(); |
133 | } |
134 | |
135 | } // namespace WebCore |
136 | |