Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 2713253002: Adjust ellision strategy for omnibox search chip. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 568
569 // Perform layout. 569 // Perform layout.
570 int full_width = width() - (2 * edge_thickness); 570 int full_width = width() - (2 * edge_thickness);
571 571
572 int entry_width = full_width; 572 int entry_width = full_width;
573 leading_decorations.LayoutPass1(&entry_width); 573 leading_decorations.LayoutPass1(&entry_width);
574 trailing_decorations.LayoutPass1(&entry_width); 574 trailing_decorations.LayoutPass1(&entry_width);
575 leading_decorations.LayoutPass2(&entry_width); 575 leading_decorations.LayoutPass2(&entry_width);
576 trailing_decorations.LayoutPass2(&entry_width); 576 trailing_decorations.LayoutPass2(&entry_width);
577 577
578 int location_needed_width = omnibox_view_->GetTextWidth(); 578 int location_desired_width = omnibox_view_->GetTextWidth();
579 int available_width = entry_width - location_needed_width; 579 int available_width = entry_width - location_desired_width;
580 // The bounds must be wide enough for all the decorations to fit. 580 // The bounds must be wide enough for all the decorations to fit.
581 gfx::Rect location_bounds(edge_thickness, vertical_padding, 581 gfx::Rect location_bounds(edge_thickness, vertical_padding,
582 std::max(full_width, full_width - entry_width), 582 std::max(full_width, full_width - entry_width),
583 location_height); 583 location_height);
584 leading_decorations.LayoutPass3(&location_bounds, &available_width); 584 leading_decorations.LayoutPass3(&location_bounds, &available_width, false);
585 trailing_decorations.LayoutPass3(&location_bounds, &available_width); 585 trailing_decorations.LayoutPass3(&location_bounds, &available_width, true);
586 586
587 // Layout |ime_inline_autocomplete_view_| next to the user input. 587 // Layout |ime_inline_autocomplete_view_| next to the user input.
588 if (ime_inline_autocomplete_view_->visible()) { 588 if (ime_inline_autocomplete_view_->visible()) {
589 int width = 589 int width =
590 gfx::GetStringWidth(ime_inline_autocomplete_view_->text(), 590 gfx::GetStringWidth(ime_inline_autocomplete_view_->text(),
591 ime_inline_autocomplete_view_->font_list()) + 591 ime_inline_autocomplete_view_->font_list()) +
592 ime_inline_autocomplete_view_->GetInsets().width(); 592 ime_inline_autocomplete_view_->GetInsets().width();
593 // All the target languages (IMEs) are LTR, and we do not need to support 593 // All the target languages (IMEs) are LTR, and we do not need to support
594 // RTL so far. In other words, no testable RTL environment so far. 594 // RTL so far. In other words, no testable RTL environment so far.
595 int x = location_needed_width; 595 int x = location_desired_width;
596 if (width > entry_width) 596 if (width > entry_width)
597 x = 0; 597 x = 0;
598 else if (location_needed_width + width > entry_width) 598 else if (location_desired_width + width > entry_width)
599 x = entry_width - width; 599 x = entry_width - width;
600 location_bounds.set_width(x); 600 location_bounds.set_width(x);
601 ime_inline_autocomplete_view_->SetBounds( 601 ime_inline_autocomplete_view_->SetBounds(
602 location_bounds.right(), location_bounds.y(), 602 location_bounds.right(), location_bounds.y(),
603 std::min(width, entry_width), location_bounds.height()); 603 std::min(width, entry_width), location_bounds.height());
604 } 604 }
605 omnibox_view_->SetBoundsRect(location_bounds); 605 omnibox_view_->SetBoundsRect(location_bounds);
606 } 606 }
607 607
608 bool LocationBarView::OnMousePressed(const ui::MouseEvent& event) {
609 return static_cast<views::View*>(omnibox_view_)->OnMousePressed(event);
Peter Kasting 2017/02/25 06:17:11 I don't like forwarding these. It seems strange g
Evan Stade 2017/03/07 18:10:22 well the location icon is usually a security indic
610 }
611
612 void LocationBarView::OnMouseReleased(const ui::MouseEvent& event) {
613 static_cast<views::View*>(omnibox_view_)->OnMouseReleased(event);
614 }
615
608 void LocationBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { 616 void LocationBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
609 RefreshLocationIcon(); 617 RefreshLocationIcon();
610 if (is_popup_mode_) { 618 if (is_popup_mode_) {
611 set_background( 619 set_background(
612 views::Background::CreateSolidBackground(GetColor(BACKGROUND))); 620 views::Background::CreateSolidBackground(GetColor(BACKGROUND)));
613 } else { 621 } else {
614 // This border color will be blended on top of the toolbar (which may use an 622 // This border color will be blended on top of the toolbar (which may use an
615 // image in the case of themes). 623 // image in the case of themes).
616 set_background( 624 set_background(
617 new BackgroundWith1PxBorder(GetColor(BACKGROUND), GetBorderColor())); 625 new BackgroundWith1PxBorder(GetColor(BACKGROUND), GetBorderColor()));
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 // LocationBarView, private TemplateURLServiceObserver implementation: 1215 // LocationBarView, private TemplateURLServiceObserver implementation:
1208 1216
1209 void LocationBarView::OnTemplateURLServiceChanged() { 1217 void LocationBarView::OnTemplateURLServiceChanged() {
1210 template_url_service_->RemoveObserver(this); 1218 template_url_service_->RemoveObserver(this);
1211 template_url_service_ = nullptr; 1219 template_url_service_ = nullptr;
1212 // If the browser is no longer active, let's not show the info bubble, as this 1220 // If the browser is no longer active, let's not show the info bubble, as this
1213 // would make the browser the active window again. 1221 // would make the browser the active window again.
1214 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1222 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1215 ShowFirstRunBubble(); 1223 ShowFirstRunBubble();
1216 } 1224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698