Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / input / synchronous_input_handler_proxy.h
blob438f41ced8f6825dbcc030a5e7b273ec7e2373c0
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_INPUT_SYNCHRONOUS_INPUT_HANDLER_PROXY_H_
6 #define CONTENT_RENDERER_INPUT_SYNCHRONOUS_INPUT_HANDLER_PROXY_H_
8 #include "base/time/time.h"
10 namespace gfx {
11 class ScrollOffset;
12 class SizeF;
15 namespace content {
17 class CONTENT_EXPORT SynchronousInputHandler {
18 public:
19 // Informs the Android WebView embedder that a fling animation is running, and
20 // that it should call SynchronouslyAnimate() if it wants to execute that
21 // animation. The embedder/app may choose to override and ignore the
22 // request for animation.
23 virtual void SetNeedsSynchronousAnimateInput() = 0;
25 // Informs the Android WebView embedder of the current root scroll and page
26 // scale state.
27 virtual void UpdateRootLayerState(
28 const gfx::ScrollOffset& total_scroll_offset,
29 const gfx::ScrollOffset& max_scroll_offset,
30 const gfx::SizeF& scrollable_size,
31 float page_scale_factor,
32 float min_page_scale_factor,
33 float max_page_scale_factor) = 0;
36 // Android WebView requires synchronous scrolling from the WebView application.
37 // This interface provides support for that behaviour. The WebView embedder will
38 // act as the InputHandler for controlling the timing of input (fling)
39 // animations.
40 class CONTENT_EXPORT SynchronousInputHandlerProxy {
41 public:
42 // Tell the proxy that we will control the timing of root fling animations
43 // from the SynchronousInputHandler. Once this is set, the InputHandler is
44 // not requested to Animate() the InputHandlerProxy for root layer flings.
45 // Instead, requests for animation will go to the SynchronousInputHandler and
46 // animation ticks will only come back through SynchronouslyAnimate().
47 // Non-root flings are not affected.
48 virtual void SetOnlySynchronouslyAnimateRootFlings(
49 SynchronousInputHandler* synchronous_input_handler) = 0;
51 // Tick input (fling) animations. This may happen out of phase with the frame
52 // timing, or not at all, as it is controlled by the WebView application. When
53 // it returns, it expects the animation scroll offsets to be visible to the
54 // application.
55 virtual void SynchronouslyAnimate(base::TimeTicks time) = 0;
57 // Called when the synchronous input handler wants to change the root scroll
58 // offset. Since it has the final say, this overrides values from compositor-
59 // controlled behaviour. After the offset is applied, the
60 // SynchronousInputHandler should be given back the result in case it differs
61 // from what was sent.
62 virtual void SynchronouslySetRootScrollOffset(
63 const gfx::ScrollOffset& root_offset) = 0;
66 } // namespace content
68 #endif // CONTENT_RENDERER_INPUT_SYNCHRONOUS_INPUT_HANDLER_PROXY_H_