Commit 2350bafa authored by David Black's avatar David Black Committed by Commit Bot

Fixes UI jank caused by footer visibility change.

By adding a parent container to |footer_|, we will reserve the same
amount of layout space whether or not that view is visible. This is
because the parent container uses a FillLayout which does not factor
visibility in when measuring.

Bug: b:113871610
Change-Id: I4810368f5de3af4c3b8152e080acf7c2249304fc
Reviewed-on: https://chromium-review.googlesource.com/1219899Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#590467}
parent ca70be0f
...@@ -82,8 +82,6 @@ void AssistantFooterView::InitLayout() { ...@@ -82,8 +82,6 @@ void AssistantFooterView::InitLayout() {
const bool setup_completed = const bool setup_completed =
Shell::Get()->voice_interaction_controller()->setup_completed(); Shell::Get()->voice_interaction_controller()->setup_completed();
LOG(ERROR) << "eyor: setup_completed: " << setup_completed;
// Suggestion container. // Suggestion container.
suggestion_container_ = new SuggestionContainerView(assistant_controller_); suggestion_container_ = new SuggestionContainerView(assistant_controller_);
suggestion_container_->set_can_process_events_within_subtree(setup_completed); suggestion_container_->set_can_process_events_within_subtree(setup_completed);
...@@ -115,8 +113,6 @@ void AssistantFooterView::OnVoiceInteractionSetupCompleted(bool completed) { ...@@ -115,8 +113,6 @@ void AssistantFooterView::OnVoiceInteractionSetupCompleted(bool completed) {
using assistant::util::CreateOpacityElement; using assistant::util::CreateOpacityElement;
using assistant::util::StartLayerAnimationSequence; using assistant::util::StartLayerAnimationSequence;
LOG(ERROR) << "eyor: completed: " << completed;
// When the consent state changes, we need to hide/show the appropriate views. // When the consent state changes, we need to hide/show the appropriate views.
views::View* hide_view = views::View* hide_view =
completed ? static_cast<views::View*>(opt_in_view_) completed ? static_cast<views::View*>(opt_in_view_)
...@@ -134,6 +130,7 @@ void AssistantFooterView::OnVoiceInteractionSetupCompleted(bool completed) { ...@@ -134,6 +130,7 @@ void AssistantFooterView::OnVoiceInteractionSetupCompleted(bool completed) {
StartLayerAnimationSequence(hide_view->layer()->GetAnimator(), StartLayerAnimationSequence(hide_view->layer()->GetAnimator(),
CreateLayerAnimationSequence(CreateOpacityElement( CreateLayerAnimationSequence(CreateOpacityElement(
0.f, kAnimationFadeOutDuration)), 0.f, kAnimationFadeOutDuration)),
// Observe the animation.
animation_observer_.get()); animation_observer_.get());
// Show the view for the next consent state by fading to 100% opacity with // Show the view for the next consent state by fading to 100% opacity with
......
...@@ -254,6 +254,13 @@ void AssistantMainStage::InitContentLayoutContainer() { ...@@ -254,6 +254,13 @@ void AssistantMainStage::InitContentLayoutContainer() {
layout_manager->SetFlexForView(ui_element_container_, 1); layout_manager->SetFlexForView(ui_element_container_, 1);
// Footer. // Footer.
// Note that the |footer_| is placed within its own view container so that as
// its visibility changes, its parent container will still reserve the same
// layout space. This prevents jank that would otherwise occur due to
// |ui_element_container_| claiming that empty space.
views::View* footer_container = new views::View();
footer_container->SetLayoutManager(std::make_unique<views::FillLayout>());
footer_ = new AssistantFooterView(assistant_controller_); footer_ = new AssistantFooterView(assistant_controller_);
footer_->AddObserver(this); footer_->AddObserver(this);
...@@ -261,7 +268,8 @@ void AssistantMainStage::InitContentLayoutContainer() { ...@@ -261,7 +268,8 @@ void AssistantMainStage::InitContentLayoutContainer() {
footer_->SetPaintToLayer(); footer_->SetPaintToLayer();
footer_->layer()->SetFillsBoundsOpaquely(false); footer_->layer()->SetFillsBoundsOpaquely(false);
content_layout_container_->AddChildView(footer_); footer_container->AddChildView(footer_);
content_layout_container_->AddChildView(footer_container);
AddChildView(content_layout_container_); AddChildView(content_layout_container_);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment