1 // Copyright 2013 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 CC_INPUT_LAYER_SCROLL_OFFSET_DELEGATE_H_
6 #define CC_INPUT_LAYER_SCROLL_OFFSET_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "base/time/time.h"
11 #include "ui/gfx/geometry/scroll_offset.h"
12 #include "ui/gfx/geometry/size_f.h"
16 // The LayerScrollOffsetDelegate allows for the embedder to take ownership of
17 // the scroll offset of the root layer.
19 // The LayerScrollOffsetDelegate is only used on the impl thread.
20 class LayerScrollOffsetDelegate
{
22 // This is called by the compositor to query the current scroll offset of the
24 // There is no requirement that the return values of this method are
25 // stable in time (two subsequent calls may yield different results).
26 // The return value is not required to be related to the values passed in to
27 // the SetTotalScrollOffset method in any way however it is required to be no
28 // more than the value passed to the most recent SetMaxScrollOffset call.
29 virtual gfx::ScrollOffset
GetTotalScrollOffset() = 0;
31 // This is called by the compositor to notify the delegate of any change to
32 // the following parameters:
33 // |total_scroll_offset| current scroll offset of the root layer,
34 // |max_scroll_offset| total scroll offset upper bound for the root layer,
35 // |scrollable_size| root layer scrollable size,
36 // |page_scale_factor| current page scale,
37 // |min_page_scale_factor| page scale lower limit,
38 // |max_page_scale_factor| page scale upper limit.
39 virtual void UpdateRootLayerState(
40 const gfx::ScrollOffset
& total_scroll_offset
,
41 const gfx::ScrollOffset
& max_scroll_offset
,
42 const gfx::SizeF
& scrollable_size
,
43 float page_scale_factor
,
44 float min_page_scale_factor
,
45 float max_page_scale_factor
) = 0;
47 // This is called by the compositor to check whether a delegate-managed fling
49 // TODO(hush): Remove after WebView's smooth scrolling path is unified with
51 virtual bool IsExternalScrollActive() const = 0;
53 // This is called by the compositor when a fling hitting the root layer
54 // requires a scheduled animation update.
55 typedef base::Callback
<void(base::TimeTicks
)> AnimationCallback
;
56 virtual void SetNeedsAnimate(const AnimationCallback
& animation
) = 0;
59 LayerScrollOffsetDelegate() {}
60 virtual ~LayerScrollOffsetDelegate() {}
63 DISALLOW_COPY_AND_ASSIGN(LayerScrollOffsetDelegate
);
68 #endif // CC_INPUT_LAYER_SCROLL_OFFSET_DELEGATE_H_