Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5012)

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 511253003: Made Blink aware of top controls offset (Chromium-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added top_controls_content_offset Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index e8d9142d8e8f160e054b87ca530c4f21ac75c7fa..2c4aaeed1cde600230738bfbda7b243d366a8879 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -249,7 +249,6 @@ LayerTreeHostImpl::LayerTreeHostImpl(
zero_budget_(false),
device_scale_factor_(1.f),
overhang_ui_resource_id_(0),
- top_controls_layout_height_(0.f),
resourceless_software_draw_(false),
begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()),
animation_registrar_(AnimationRegistrar::Create()),
@@ -1465,9 +1464,9 @@ CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const {
metadata.max_page_scale_factor = active_tree_->max_page_scale_factor();
if (top_controls_manager_) {
metadata.location_bar_offset =
- gfx::Vector2dF(0.f, top_controls_manager_->controls_top_offset());
+ gfx::Vector2dF(0.f, top_controls_manager_->ControlsTopOffset());
metadata.location_bar_content_translation =
- gfx::Vector2dF(0.f, top_controls_manager_->content_top_offset());
+ gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset());
}
active_tree_->GetViewportSelection(&metadata.selection_start,
@@ -1678,11 +1677,11 @@ void LayerTreeHostImpl::UpdateInnerViewportContainerSize() {
if (!container_layer)
return;
- if (top_controls_manager_)
+ if (top_controls_manager_) {
container_layer->SetBoundsDelta(
- gfx::Vector2dF(0,
- top_controls_layout_height_ -
- top_controls_manager_->content_top_offset()));
+ gfx::Vector2dF(0, active_tree_->top_controls_layout_height() -
+ active_tree_->total_top_controls_content_offset()));
+ }
}
void LayerTreeHostImpl::DidLoseOutputSurface() {
@@ -1747,8 +1746,12 @@ void LayerTreeHostImpl::CreatePendingTree() {
// Update the delta from the active tree, which may have
// adjusted its delta prior to the pending tree being created.
DCHECK_EQ(1.f, pending_tree_->sent_page_scale_delta());
+ DCHECK_EQ(1.f, pending_tree_->sent_top_controls_delta());
pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() /
active_tree_->sent_page_scale_delta());
+ pending_tree_->set_top_controls_delta(
+ active_tree_->top_controls_delta() /
+ active_tree_->sent_top_controls_delta());
client_->OnCanDrawStateChanged(CanDraw());
TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get());
@@ -1791,6 +1794,11 @@ void LayerTreeHostImpl::ActivateSyncTree() {
active_tree_->SetRootLayerScrollOffsetDelegate(
root_layer_scroll_offset_delegate_);
+
+ top_controls_manager_->SetControlsTopOffset(
+ active_tree_->total_top_controls_content_offset()
+ - top_controls_manager_->top_controls_height());
+
UpdateInnerViewportContainerSize();
} else {
active_tree_->ProcessUIResourceRequestQueue();
@@ -2146,16 +2154,6 @@ void LayerTreeHostImpl::SetViewportSize(const gfx::Size& device_viewport_size) {
active_tree_->set_needs_update_draw_properties();
}
-void LayerTreeHostImpl::SetTopControlsLayoutHeight(
- float top_controls_layout_height) {
- if (top_controls_layout_height_ == top_controls_layout_height)
- return;
- top_controls_layout_height_ = top_controls_layout_height;
-
- UpdateInnerViewportContainerSize();
- SetFullRootLayerDamage();
-}
-
void LayerTreeHostImpl::SetOverhangUIResource(
UIResourceId overhang_ui_resource_id,
const gfx::Size& overhang_ui_resource_size) {
@@ -2208,6 +2206,19 @@ void LayerTreeHostImpl::DidChangeTopControlsPosition() {
SetFullRootLayerDamage();
}
+void LayerTreeHostImpl::SetControlsTopOffset(float offset) {
+ float target_content_top =
+ offset + top_controls_manager_->controls_height();
+
+ active_tree_->set_top_controls_delta(
+ target_content_top - active_tree_->top_controls_content_offset());
+}
+
+float LayerTreeHostImpl::ControlsTopOffset() const {
+ return active_tree_->total_top_controls_content_offset() -
+ top_controls_manager_->controls_height();
+}
+
void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) {
DCHECK(input_handler_client_ == NULL);
input_handler_client_ = client;
@@ -2908,6 +2919,8 @@ scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() {
scroll_info->page_scale_delta = active_tree_->page_scale_delta();
active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta);
scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_);
+ scroll_info->top_controls_delta = active_tree()->top_controls_delta();
+ active_tree_->set_sent_top_controls_delta(scroll_info->top_controls_delta);
return scroll_info.Pass();
}

Powered by Google App Engine
This is Rietveld 408576698