Move viewport scrolling logic into separate class
The viewport is made up of two scrolling layers now, the inner
and outer viewport scroll layers. These layers do not follow the
usual scroll bubbling logic since they're supposed to appear as
one viewport to the user (i.e. we should rail). Forcing it to
be scrolled via LayerTreeHostImpl::ScrollBy caused that method to
become increasingly complex.
This patch creates a Viewport class that allows LTHI::ScrollBy to
call Viewport::ScrollBy and scroll the viewport as a unit. I've
tried to simplify the logic in both these methods as much as I
could without changing behavior.
BUG=443724
Review URL: https://codereview.chromium.org/986443003
Cr-Commit-Position: refs/heads/master@{#322268}
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index 2efe2dab..388de5e 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -73,6 +73,7 @@
class UIResourceBitmap;
class UIResourceRequest;
struct ScrollAndScaleSet;
+class Viewport;
enum class GpuRasterizationStatus {
ON,
@@ -524,6 +525,11 @@
return frame_timing_tracker_.get();
}
+ gfx::Vector2dF ScrollLayer(LayerImpl* layer_impl,
+ const gfx::Vector2dF& delta,
+ const gfx::Point& viewport_point,
+ bool is_wheel_scroll);
+
protected:
LayerTreeHostImpl(
const LayerTreeSettings& settings,
@@ -546,6 +552,11 @@
Proxy* proxy_;
private:
+ gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
+ LayerImpl* layer_impl,
+ const gfx::PointF& viewport_point,
+ const gfx::Vector2dF& viewport_delta);
+
void CreateAndSetRenderer();
void CreateAndSetTileManager();
void DestroyTileManager();
@@ -555,6 +566,8 @@
bool IsSynchronousSingleThreaded() const;
+ Viewport* viewport() { return viewport_.get(); }
+
// Scroll by preferring to move the outer viewport first, only moving the
// inner if the outer is at its scroll extents.
void ScrollViewportBy(gfx::Vector2dF scroll_delta);
@@ -565,14 +578,6 @@
void AnimateScrollbars(base::TimeTicks monotonic_time);
void AnimateTopControls(base::TimeTicks monotonic_time);
- bool ShouldTopControlsConsumeScroll(const gfx::Vector2dF& scroll_delta) const;
-
- gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
- LayerImpl* layer_impl,
- float scale_from_viewport_to_screen_space,
- const gfx::PointF& viewport_point,
- const gfx::Vector2dF& viewport_delta);
-
void TrackDamageForAllSurfaces(
LayerImpl* root_draw_layer,
const LayerImplList& render_surface_layer_list);
@@ -747,6 +752,8 @@
scoped_ptr<FrameTimingTracker> frame_timing_tracker_;
+ scoped_ptr<Viewport> viewport_;
+
DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
};