1/*
2 * Copyright (C) 2011-2013 University of Washington.
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 * 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
15 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY 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
29#if ENABLE(WEB_REPLAY)
30
31#include "AllReplayInputs.h"
32#include "MainFrame.h"
33#include "NavigationScheduler.h"
34#include "Page.h"
35#include "ReplayController.h"
36#include "URL.h"
37#include "UserInputBridge.h"
38
39namespace WebCore {
40
41// Sentinel inputs.
42void BeginSegmentSentinel::dispatch(ReplayController&)
43{
44}
45
46void EndSegmentSentinel::dispatch(ReplayController&)
47{
48}
49
50// Navigation inputs.
51void InitialNavigation::dispatch(ReplayController& controller)
52{
53    controller.page().mainFrame().navigationScheduler().scheduleLocationChange(m_securityOrigin.get(), m_url, m_referrer);
54}
55
56void HandleKeyPress::dispatch(ReplayController& controller)
57{
58    controller.page().userInputBridge().handleKeyEvent(platformEvent(), InputSource::Synthetic);
59}
60
61// User interaction inputs.
62void HandleMouseMove::dispatch(ReplayController& controller)
63{
64    if (m_scrollbarTargeted)
65        controller.page().userInputBridge().handleMouseMoveOnScrollbarEvent(platformEvent(), InputSource::Synthetic);
66    else
67        controller.page().userInputBridge().handleMouseMoveEvent(platformEvent(), InputSource::Synthetic);
68}
69
70void HandleMousePress::dispatch(ReplayController& controller)
71{
72    controller.page().userInputBridge().handleMousePressEvent(platformEvent(), InputSource::Synthetic);
73}
74
75void HandleMouseRelease::dispatch(ReplayController& controller)
76{
77    controller.page().userInputBridge().handleMouseReleaseEvent(platformEvent(), InputSource::Synthetic);
78}
79
80void HandleWheelEvent::dispatch(ReplayController& controller)
81{
82    controller.page().userInputBridge().handleWheelEvent(platformEvent(), InputSource::Synthetic);
83}
84
85void LogicalScrollPage::dispatch(ReplayController& controller)
86{
87    controller.page().userInputBridge().logicalScrollRecursively(direction(), granularity(), InputSource::Synthetic);
88}
89
90void ScrollPage::dispatch(ReplayController& controller)
91{
92    controller.page().userInputBridge().scrollRecursively(direction(), granularity(), InputSource::Synthetic);
93}
94
95} // namespace WebCore
96
97#endif // ENABLE(WEB_REPLAY)
98