Reland "Non-SFI mode: Switch to newlib. (patchset #4 id:60001 of https://codereview...
[chromium-blink-merge.git] / cc / layers / viewport.h
blob794df21be679cb513065dc609601f663b5892b58
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 CC_LAYERS_VIEWPORT_H_
6 #define CC_LAYERS_VIEWPORT_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/layers/layer_impl.h"
10 #include "ui/gfx/geometry/vector2d_f.h"
12 namespace cc {
14 class LayerTreeHostImpl;
16 // Encapsulates gesture handling logic on the viewport layers. The "viewport"
17 // is made up of two scrolling layers, the inner viewport (visual) and the
18 // outer viewport (layout) scroll layers. These layers have different scroll
19 // bubbling behavior from the rest of the layer tree which is encoded in this
20 // class.
21 class CC_EXPORT Viewport {
22 public:
23 struct ScrollResult {
24 gfx::Vector2dF applied_delta;
25 gfx::Vector2dF unused_scroll_delta;
26 gfx::Vector2dF top_controls_applied_delta;
29 static scoped_ptr<Viewport> Create(LayerTreeHostImpl* host_impl);
31 // Differs from scrolling in that only the visual viewport is moved, without
32 // affecting the top controls or outer viewport.
33 void Pan(const gfx::Vector2dF& delta);
35 // Scrolls the viewport, applying the unique bubbling between the inner and
36 // outer viewport. Scrolls can be consumed by top controls.
37 ScrollResult ScrollBy(const gfx::Vector2dF& delta,
38 const gfx::Point& viewport_point,
39 bool is_wheel_scroll,
40 bool affect_top_controls);
42 private:
43 explicit Viewport(LayerTreeHostImpl* host_impl);
45 bool ShouldTopControlsConsumeScroll(const gfx::Vector2dF& scroll_delta) const;
46 gfx::Vector2dF AdjustOverscroll(const gfx::Vector2dF& delta) const;
48 // Sends the delta to the top controls, returns the amount applied.
49 gfx::Vector2dF ScrollTopControls(const gfx::Vector2dF& delta);
51 gfx::ScrollOffset MaxTotalScrollOffset() const;
52 gfx::ScrollOffset TotalScrollOffset() const;
54 LayerImpl* InnerScrollLayer() const;
55 LayerImpl* OuterScrollLayer() const;
57 LayerTreeHostImpl* host_impl_;
59 DISALLOW_COPY_AND_ASSIGN(Viewport);
62 } // namespace cc
64 #endif // CC_LAYERS_VIEWPORT_H_