| 1 | /* |
| 2 | * Copyright (C) 2012, 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 | #pragma once |
| 29 | |
| 30 | #include "FrameLoaderTypes.h" |
| 31 | #include "ScrollTypes.h" |
| 32 | #include <wtf/Forward.h> |
| 33 | #include <wtf/Noncopyable.h> |
| 34 | |
| 35 | namespace WebCore { |
| 36 | |
| 37 | class Frame; |
| 38 | class FrameLoadRequest; |
| 39 | class Page; |
| 40 | class PlatformKeyboardEvent; |
| 41 | class PlatformMouseEvent; |
| 42 | class PlatformWheelEvent; |
| 43 | |
| 44 | // Real user inputs come from WebKit or WebKit2. |
| 45 | // Synthetic inputs come from within WebCore (i.e., from web replay or fake mouse moves). |
| 46 | enum class InputSource { |
| 47 | User, |
| 48 | Synthetic |
| 49 | }; |
| 50 | |
| 51 | class UserInputBridge { |
| 52 | WTF_MAKE_NONCOPYABLE(UserInputBridge); |
| 53 | public: |
| 54 | UserInputBridge(Page&); |
| 55 | |
| 56 | // User input APIs. |
| 57 | #if ENABLE(CONTEXT_MENUS) |
| 58 | WEBCORE_EXPORT bool handleContextMenuEvent(const PlatformMouseEvent&, Frame&, InputSource = InputSource::User); |
| 59 | #endif |
| 60 | WEBCORE_EXPORT bool handleMousePressEvent(const PlatformMouseEvent&, InputSource source = InputSource::User); |
| 61 | WEBCORE_EXPORT bool handleMouseReleaseEvent(const PlatformMouseEvent&, InputSource source = InputSource::User); |
| 62 | WEBCORE_EXPORT bool handleMouseMoveEvent(const PlatformMouseEvent&, InputSource source = InputSource::User); |
| 63 | WEBCORE_EXPORT bool handleMouseMoveOnScrollbarEvent(const PlatformMouseEvent&, InputSource source = InputSource::User); |
| 64 | WEBCORE_EXPORT bool handleMouseForceEvent(const PlatformMouseEvent&, InputSource = InputSource::User); |
| 65 | WEBCORE_EXPORT bool handleWheelEvent(const PlatformWheelEvent&, InputSource source = InputSource::User); |
| 66 | WEBCORE_EXPORT bool handleKeyEvent(const PlatformKeyboardEvent&, InputSource source = InputSource::User); |
| 67 | WEBCORE_EXPORT bool handleAccessKeyEvent(const PlatformKeyboardEvent&, InputSource source = InputSource::User); |
| 68 | void focusSetActive(bool active, InputSource source = InputSource::User); |
| 69 | void focusSetFocused(bool focused, InputSource source = InputSource::User); |
| 70 | WEBCORE_EXPORT bool scrollRecursively(ScrollDirection, ScrollGranularity, InputSource source = InputSource::User); |
| 71 | WEBCORE_EXPORT bool logicalScrollRecursively(ScrollLogicalDirection, ScrollGranularity, InputSource source = InputSource::User); |
| 72 | |
| 73 | // Navigation APIs. |
| 74 | WEBCORE_EXPORT void loadRequest(FrameLoadRequest&&, InputSource = InputSource::User); |
| 75 | WEBCORE_EXPORT void reloadFrame(Frame*, OptionSet<ReloadOption>, InputSource = InputSource::User); |
| 76 | WEBCORE_EXPORT void stopLoadingFrame(Frame*, InputSource source = InputSource::User); |
| 77 | WEBCORE_EXPORT bool tryClosePage(InputSource source = InputSource::User); |
| 78 | |
| 79 | private: |
| 80 | Page& m_page; |
| 81 | }; |
| 82 | |
| 83 | } // namespace WebCore |
| 84 | |