Chromium Code Reviews| Index: chrome/browser/android/compositor/layer/contextual_search_layer.cc |
| diff --git a/chrome/browser/android/compositor/layer/contextual_search_layer.cc b/chrome/browser/android/compositor/layer/contextual_search_layer.cc |
| index 248afa55b75c0d32dbefe24d755107cd879fe025..87a4c0897b9b3bbe9d5e6687b8bb94d3cebd916c 100644 |
| --- a/chrome/browser/android/compositor/layer/contextual_search_layer.cc |
| +++ b/chrome/browser/android/compositor/layer/contextual_search_layer.cc |
| @@ -241,16 +241,11 @@ void ContextualSearchLayer::SetProperties( |
| // --------------------------------------------------------------------------- |
| // Search Term, Context and Search Caption |
| // --------------------------------------------------------------------------- |
| - SetupTextLayer( |
| - search_bar_top, |
| - search_bar_height, |
| - search_text_layer_min_height, |
| - search_caption_resource_id, |
| - search_caption_visible, |
| - search_caption_animation_percentage, |
| - search_context_resource_id, |
| - search_context_opacity, |
| - search_term_caption_spacing); |
| + SetupTextLayer(search_bar_top, search_bar_height, |
|
mdjones
2016/11/22 16:37:49
Unless there was a reason not to, could we leave t
Donn Denman
2016/11/28 17:58:28
Done. I agree with you, but git CL format liked t
|
| + search_text_layer_min_height, search_caption_resource_id, |
| + search_caption_visible, search_caption_animation_percentage, |
| + search_term_opacity, search_context_resource_id, |
| + search_context_opacity, search_term_caption_spacing); |
| // --------------------------------------------------------------------------- |
| // Arrow Icon |
| @@ -533,21 +528,22 @@ void ContextualSearchLayer::SetStaticImageProperties( |
| gfx::PointF(side_margin, static_image_y_offset)); |
| } |
| -void ContextualSearchLayer::SetupTextLayer( |
| - float bar_top, |
| - float bar_height, |
| - float search_text_layer_min_height, |
| - int caption_resource_id, |
| - bool caption_visible, |
| - float animation_percentage, |
| - int context_resource_id, |
| - float context_opacity, |
| - float term_caption_spacing) { |
| +void ContextualSearchLayer::SetupTextLayer(float bar_top, |
| + float bar_height, |
| + float search_text_layer_min_height, |
| + int caption_resource_id, |
| + bool caption_visible, |
| + float animation_percentage, |
| + float search_term_opacity, |
| + int context_resource_id, |
| + float context_opacity, |
| + float term_caption_spacing) { |
| // --------------------------------------------------------------------------- |
| // Setup the Drawing Hierarchy |
| // --------------------------------------------------------------------------- |
| // Search Term |
| - if (bar_text_->parent() != text_layer_) |
| + bool has_bar_text = search_term_opacity > 0.0f; |
| + if (has_bar_text && bar_text_->parent() != text_layer_) |
| text_layer_->AddChild(bar_text_); |
| // Search Context |
| @@ -587,15 +583,20 @@ void ContextualSearchLayer::SetupTextLayer( |
| // We may not be able to fit these inside the ideal size as the user may have |
| // their Font Size set to large. |
| + // The Term might not be visible or initialized yet, so set up main_text with |
| + // whichever main bar text seems appropriate. |
| + scoped_refptr<cc::UIResourceLayer> main_text = |
| + (has_bar_text ? bar_text_ : search_context_); |
| + |
| // The search_caption_ may not have had it's resource set by this point, if so |
| // the bounds will be zero and everything will still work. |
| - float term_height = bar_text_->bounds().height(); |
| + float term_height = main_text->bounds().height(); |
| float caption_height = search_caption_->bounds().height(); |
| float layer_height = std::max(search_text_layer_min_height, |
| term_height + caption_height + term_caption_spacing); |
| - float layer_width = std::max(bar_text_->bounds().width(), |
| - search_caption_->bounds().width()); |
| + float layer_width = |
| + std::max(main_text->bounds().width(), search_caption_->bounds().width()); |
| float layer_top = bar_top + (bar_height - layer_height) / 2; |
| text_layer_->SetBounds(gfx::Size(layer_width, layer_height)); |
| @@ -624,14 +625,16 @@ void ContextualSearchLayer::SetupTextLayer( |
| // fade out and the Term will fade in. |
| search_context_->SetOpacity(context_opacity); |
| - bar_text_->SetOpacity(1.f - context_opacity); |
| + if (has_bar_text) |
|
mdjones
2016/11/22 16:37:49
The bar_text_ object always exists since it is cre
Donn Denman
2016/11/28 17:58:28
You're right, the checks earlier are the only ones
|
| + bar_text_->SetOpacity(1.f - context_opacity); |
| // If there is no caption, just vertically center the Search Term. |
| float term_top = (layer_height - term_height) / 2; |
| // If we aren't displaying the caption we're done. |
| if (!caption_visible || animation_percentage == 0.f || !caption_resource) { |
| - bar_text_->SetPosition(gfx::PointF(0.f, term_top)); |
| + if (has_bar_text) |
| + bar_text_->SetPosition(gfx::PointF(0.f, term_top)); |
| search_context_->SetPosition(gfx::PointF(0.f, term_top)); |
| return; |
| } |
| @@ -655,7 +658,8 @@ void ContextualSearchLayer::SetupTextLayer( |
| float caption_top = layer_height * (1.f - animation_percentage) |
| + caption_top_end * animation_percentage; |
| - bar_text_->SetPosition(gfx::PointF(0.f, term_top)); |
| + if (has_bar_text) |
| + bar_text_->SetPosition(gfx::PointF(0.f, term_top)); |
| search_context_->SetPosition(gfx::PointF(0.f, term_top)); |
| search_caption_->SetPosition(gfx::PointF(0.f, caption_top)); |
| } |