Commit 81a88382 authored by manukh's avatar manukh Committed by Commit Bot

[omnibox] [rich-autocompletion] Fix omnibox width when empty.

This CL fixes a typo introduced in crrev.com/c/2324212 that would
prevent the omnibox's width being updated in |LocationBarView::Layout()|
if:
- RichAutocompletionShowAdditionalText was enabled (default)
- RichAutocompletionTwoLineOmnibox was disabled (default)
- The omnibox was empty

This resulted in
- The hint 'Search Google or type a URL' when the omnibox is cleared and
blurred or when on the NTP.
- The cursor being misplaced when entering keyword mode which clears the
user text.

Bug: 1128094, 1062446
Change-Id: I073a9c75db1266d02a192675149211bad7615a8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410591Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807087}
parent 95abd54f
...@@ -650,33 +650,32 @@ void LocationBarView::Layout() { ...@@ -650,33 +650,32 @@ void LocationBarView::Layout() {
// If rich autocompletion is enabled, split |location_bounds| for the // If rich autocompletion is enabled, split |location_bounds| for the
// |omnibox_view_| and |omnibox_additional_text_view_|. // |omnibox_view_| and |omnibox_additional_text_view_|.
if (OmniboxFieldTrial::RichAutocompletionShowAdditionalText()) { if (OmniboxFieldTrial::RichAutocompletionShowAdditionalText() &&
if (OmniboxFieldTrial::RichAutocompletionTwoLineOmnibox()) { OmniboxFieldTrial::RichAutocompletionTwoLineOmnibox()) {
// Split vertically. // Split vertically.
auto omnibox_bounds = location_bounds; auto omnibox_bounds = location_bounds;
omnibox_bounds.set_height(location_bounds.height() / 2); omnibox_bounds.set_height(location_bounds.height() / 2);
omnibox_view_->SetBoundsRect(omnibox_bounds); omnibox_view_->SetBoundsRect(omnibox_bounds);
auto omnibox_additional_text_bounds = omnibox_bounds; auto omnibox_additional_text_bounds = omnibox_bounds;
omnibox_additional_text_bounds.set_x(location_bounds.x() + 3); omnibox_additional_text_bounds.set_x(location_bounds.x() + 3);
omnibox_additional_text_bounds.set_y(omnibox_bounds.bottom()); omnibox_additional_text_bounds.set_y(omnibox_bounds.bottom());
omnibox_additional_text_view_->SetBoundsRect( omnibox_additional_text_view_->SetBoundsRect(
omnibox_additional_text_bounds); omnibox_additional_text_bounds);
} else if (!omnibox_view_->GetText().empty()) { } else if (OmniboxFieldTrial::RichAutocompletionShowAdditionalText() &&
// Split horizontally. !omnibox_view_->GetText().empty()) {
auto omnibox_bounds = location_bounds; // Split horizontally.
omnibox_bounds.set_width(std::min( auto omnibox_bounds = location_bounds;
omnibox_view_->GetUnelidedTextWidth() + 10, location_bounds.width())); omnibox_bounds.set_width(std::min(
omnibox_view_->SetBoundsRect(omnibox_bounds); omnibox_view_->GetUnelidedTextWidth() + 10, location_bounds.width()));
auto omnibox_additional_text_bounds = location_bounds; omnibox_view_->SetBoundsRect(omnibox_bounds);
omnibox_additional_text_bounds.set_x(omnibox_bounds.x() + auto omnibox_additional_text_bounds = location_bounds;
omnibox_bounds.width()); omnibox_additional_text_bounds.set_x(omnibox_bounds.x() +
omnibox_additional_text_bounds.set_width( omnibox_bounds.width());
std::max(location_bounds.width() - omnibox_bounds.width(), 0)); omnibox_additional_text_bounds.set_width(
omnibox_additional_text_view_->SetBoundsRect( std::max(location_bounds.width() - omnibox_bounds.width(), 0));
omnibox_additional_text_bounds); omnibox_additional_text_view_->SetBoundsRect(
} omnibox_additional_text_bounds);
} else { } else {
omnibox_view_->SetBoundsRect(location_bounds); omnibox_view_->SetBoundsRect(location_bounds);
} }
......
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