Commit 0830cdf0 authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

Omnibox UI Refresh: Align Omnibox text to new Suggestion text

The goal of the CL is to re-align the Omnibox text to match the new
Refresh spec.

In the new Refresh spec, the text has a different indentation depending
on whether or not the popup is open, so this CL resets the insets
of the OmniboxViewViews whenever the popup opens or closes.

It also updates LocationBarView to no longer ignore the left-inset
value of the OmniboxViewViews. We used to also ignore the right-inset
value, but we stopped doing that recently [1].

After no longer ignoring the left-inset value, we update the
non-Refresh value to the correct value of 0 (to keep things looking
the same), and update the Refresh value to 2, which matches mocks.

We are updating the inset of the OmniboxViewViews textfield instead of
the bounds of the textfield because we want the whole area to remain a
clickable I-beam, even if we indent the text a bit.

[1] https://codereview.chromium.org/2642893002/diff/100001/chrome/browser/ui/views/location_bar/location_bar_view.cc

Bug: 849779, 823535
Change-Id: I8c2a9e4934a78efec0d3d6cd60c63181be2d92c4
Reviewed-on: https://chromium-review.googlesource.com/1096491Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566834}
parent 7a6c1aee
......@@ -47,8 +47,10 @@ ChromeLayoutProvider::CreateLayoutProvider() {
gfx::Insets ChromeLayoutProvider::GetInsetsMetric(int metric) const {
switch (metric) {
case ChromeInsetsMetric::INSETS_OMNIBOX:
return gfx::Insets(3);
case ChromeInsetsMetric::INSETS_OMNIBOX: {
int left_inset = ui::MaterialDesignController::IsRefreshUi() ? 2 : 0;
return gfx::Insets(3, left_inset, 3, 3);
}
case ChromeInsetsMetric::INSETS_TOAST:
return gfx::Insets(0, 8);
case INSETS_BOOKMARKS_BAR_BUTTON:
......
......@@ -476,10 +476,8 @@ void LocationBarView::Layout() {
keyword_hint_view_->SetVisible(false);
const int item_padding = GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING);
LocationBarLayout leading_decorations(
LocationBarLayout::LEFT_EDGE, item_padding,
item_padding - omnibox_view_->GetInsets().left());
LocationBarLayout leading_decorations(LocationBarLayout::LEFT_EDGE,
item_padding, item_padding);
LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE,
item_padding, item_padding);
......@@ -1234,6 +1232,9 @@ void LocationBarView::OnPopupVisibilityChanged() {
// The focus ring may be hidden or shown when the popup visibility changes.
if (focus_ring_)
focus_ring_->SchedulePaint();
if (ui::MaterialDesignController::IsRefreshUi())
omnibox_view_->UpdateTextIndent();
}
const ToolbarModel* LocationBarView::GetToolbarModel() const {
......
......@@ -236,6 +236,20 @@ void OmniboxViewViews::InstallPlaceholderText() {
set_placeholder_text_hidden_on_focus(true);
}
void OmniboxViewViews::UpdateTextIndent() {
DCHECK(ui::MaterialDesignController::IsRefreshUi());
gfx::Insets insets =
ChromeLayoutProvider::Get()->GetInsetsMetric(INSETS_OMNIBOX);
if (model()->popup_model()->IsOpen())
insets += gfx::Insets(0, 8 /* left */, 0, 0);
SetBorder(views::CreateEmptyBorder(insets));
// This is necessary to reposition the internal RenderText.
OnBoundsChanged(gfx::Rect());
}
void OmniboxViewViews::EmphasizeURLComponents() {
if (!location_bar_view_)
return;
......
......@@ -91,6 +91,10 @@ class OmniboxViewViews : public OmniboxView,
// "Search Google or type a URL" when the Omnibox is empty and unfocused.
void InstallPlaceholderText();
// If the Omnibox popup is open, updates the text indent to match the popup.
// Otherwise, resets the text indent to default.
void UpdateTextIndent();
// OmniboxView:
void EmphasizeURLComponents() override;
void Update() override;
......
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