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