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,8 +650,8 @@ void LocationBarView::Layout() { ...@@ -650,8 +650,8 @@ 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);
...@@ -662,7 +662,8 @@ void LocationBarView::Layout() { ...@@ -662,7 +662,8 @@ void LocationBarView::Layout() {
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() &&
!omnibox_view_->GetText().empty()) {
// Split horizontally. // Split horizontally.
auto omnibox_bounds = location_bounds; auto omnibox_bounds = location_bounds;
omnibox_bounds.set_width(std::min( omnibox_bounds.set_width(std::min(
...@@ -675,8 +676,6 @@ void LocationBarView::Layout() { ...@@ -675,8 +676,6 @@ void LocationBarView::Layout() {
std::max(location_bounds.width() - omnibox_bounds.width(), 0)); std::max(location_bounds.width() - omnibox_bounds.width(), 0));
omnibox_additional_text_view_->SetBoundsRect( omnibox_additional_text_view_->SetBoundsRect(
omnibox_additional_text_bounds); 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