diff options
author | aelias <aelias@chromium.org> | 2015-02-07 13:43:01 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-07 21:43:29 +0000 |
commit | 6004fe0188ac900b02b843a9bff3ad8e569d616a (patch) | |
tree | a9b4d1eafd984be567b19f03c95801b3b719aaf3 /cc/trees/layer_tree_impl.h | |
parent | aafbad78096f681d9677df4134e333dc3e11a90e (diff) | |
download | chromium_src-6004fe0188ac900b02b843a9bff3ad8e569d616a.zip chromium_src-6004fe0188ac900b02b843a9bff3ad8e569d616a.tar.gz chromium_src-6004fe0188ac900b02b843a9bff3ad8e569d616a.tar.bz2 |
Normalize top controls offset to (0, 1), Chromium-side.
Since top controls height can now be changed, storing top controls
offset as an absolute value causes problems. Normalizing its format to
(0, 1) means we we don't need to adjust it when the height changes. It
also improves readability and means TopControlsManager will compute
correctly even when the height is currently 0.
This patch also switches top controls to use SyncedProperty.
See also Blink-side patch: https://codereview.chromium.org/882683003
BUG=430635
Review URL: https://codereview.chromium.org/901813002
Cr-Commit-Position: refs/heads/master@{#315216}
Diffstat (limited to 'cc/trees/layer_tree_impl.h')
-rw-r--r-- | cc/trees/layer_tree_impl.h | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index 2329139..19bba86 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -55,6 +55,7 @@ struct RendererCapabilities; struct SelectionHandle; typedef std::vector<UIResourceRequest> UIResourceRequestQueue; +typedef SyncedProperty<AdditionGroup<float>> SyncedTopControls; typedef SyncedProperty<AdditionGroup<gfx::Vector2dF>> SyncedElasticOverscroll; class CC_EXPORT LayerTreeImpl { @@ -62,9 +63,11 @@ class CC_EXPORT LayerTreeImpl { static scoped_ptr<LayerTreeImpl> create( LayerTreeHostImpl* layer_tree_host_impl, scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, + scoped_refptr<SyncedTopControls> top_controls_shown_ratio, scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) { - return make_scoped_ptr(new LayerTreeImpl( - layer_tree_host_impl, page_scale_factor, elastic_overscroll)); + return make_scoped_ptr( + new LayerTreeImpl(layer_tree_host_impl, page_scale_factor, + top_controls_shown_ratio, elastic_overscroll)); } virtual ~LayerTreeImpl(); @@ -192,6 +195,13 @@ class CC_EXPORT LayerTreeImpl { return elastic_overscroll_.get(); } + SyncedTopControls* top_controls_shown_ratio() { + return top_controls_shown_ratio_.get(); + } + const SyncedTopControls* top_controls_shown_ratio() const { + return top_controls_shown_ratio_.get(); + } + // Updates draw properties and render surface layer list, as well as tile // priorities. Returns false if it was unable to update. bool UpdateDrawProperties(); @@ -303,36 +313,17 @@ class CC_EXPORT LayerTreeImpl { void RegisterPictureLayerImpl(PictureLayerImpl* layer); void UnregisterPictureLayerImpl(PictureLayerImpl* layer); - void set_top_controls_shrink_blink_size(bool shrink) { - top_controls_shrink_blink_size_ = shrink; - } - void set_top_controls_height(float height) { top_controls_height_ = height; } - void set_top_controls_content_offset(float offset) { - top_controls_content_offset_ = offset; - } - void set_top_controls_delta(float delta) { - top_controls_delta_ = delta; - } - void set_sent_top_controls_delta(float sent_delta) { - sent_top_controls_delta_ = sent_delta; - } - + void set_top_controls_shrink_blink_size(bool shrink); bool top_controls_shrink_blink_size() const { return top_controls_shrink_blink_size_; } - float top_controls_height() const { return top_controls_height_; } - float top_controls_content_offset() const { - return top_controls_content_offset_; - } - float top_controls_delta() const { - return top_controls_delta_; - } - float sent_top_controls_delta() const { - return sent_top_controls_delta_; - } - float total_top_controls_content_offset() const { - return top_controls_content_offset_ + top_controls_delta_; + bool SetCurrentTopControlsShownRatio(float ratio); + float CurrentTopControlsShownRatio() const { + return top_controls_shown_ratio_->Current(IsActiveTree()); } + void set_top_controls_height(float top_controls_height); + float top_controls_height() const { return top_controls_height_; } + void PushTopControlsFromMainThread(float top_controls_shown_ratio); void SetPendingPageScaleAnimation( scoped_ptr<PendingPageScaleAnimation> pending_animation); @@ -342,6 +333,7 @@ class CC_EXPORT LayerTreeImpl { explicit LayerTreeImpl( LayerTreeHostImpl* layer_tree_host_impl, scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, + scoped_refptr<SyncedTopControls> top_controls_shown_ratio, scoped_refptr<SyncedElasticOverscroll> elastic_overscroll); void ProcessLayersRecursive(LayerImpl* current, void (LayerImpl::*function)()); @@ -353,7 +345,7 @@ class CC_EXPORT LayerTreeImpl { float max_page_scale_factor); void DidUpdatePageScale(); void HideInnerViewportScrollbarsIfNearMinimumScale(); - + void PushTopControls(const float* top_controls_shown_ratio); LayerTreeHostImpl* layer_tree_host_impl_; int source_frame_number_; scoped_ptr<LayerImpl> root_layer_; @@ -416,11 +408,9 @@ class CC_EXPORT LayerTreeImpl { float top_controls_height_; - // The up-to-date content offset of the top controls, i.e. the amount that the - // web contents have been shifted down from the top of the device viewport. - float top_controls_content_offset_; - float top_controls_delta_; - float sent_top_controls_delta_; + // The amount that the top controls are shown from 0 (hidden) to 1 (fully + // shown). + scoped_refptr<SyncedTopControls> top_controls_shown_ratio_; scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |