Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / cc / layers / viewport.h
blob25528af02a48b43706e6b9ccfa236ffa26e217b4
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 // Scrolls the viewport, applying the unique bubbling between the inner and
32 // outer viewport. Scrolls can be consumed by top controls.
33 ScrollResult ScrollBy(const gfx::Vector2dF& delta,
34 const gfx::Point& viewport_point,
35 bool is_wheel_scroll);
37 private:
38 explicit Viewport(LayerTreeHostImpl* host_impl);
40 bool ShouldTopControlsConsumeScroll(const gfx::Vector2dF& scroll_delta) const;
41 gfx::Vector2dF AdjustOverscroll(const gfx::Vector2dF& delta) const;
43 // Sends the delta to the top controls, returns the amount applied.
44 gfx::Vector2dF ScrollTopControls(const gfx::Vector2dF& delta);
46 gfx::ScrollOffset MaxTotalScrollOffset() const;
47 gfx::ScrollOffset TotalScrollOffset() const;
49 LayerImpl* InnerScrollLayer() const;
50 LayerImpl* OuterScrollLayer() const;
52 LayerTreeHostImpl* host_impl_;
54 DISALLOW_COPY_AND_ASSIGN(Viewport);
57 } // namespace cc
59 #endif // CC_LAYERS_VIEWPORT_H_