OLD | NEW |
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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 // Initialize the Omnibox view. | 282 // Initialize the Omnibox view. |
283 location_entry_.reset(CreateOmniboxView(this, model_, profile_, | 283 location_entry_.reset(CreateOmniboxView(this, model_, profile_, |
284 command_updater_, is_popup_mode_, this, font_list, font_y_offset)); | 284 command_updater_, is_popup_mode_, this, font_list, font_y_offset)); |
285 SetLocationEntryFocusable(true); | 285 SetLocationEntryFocusable(true); |
286 location_entry_view_ = location_entry_->AddToView(this); | 286 location_entry_view_ = location_entry_->AddToView(this); |
287 | 287 |
288 // Initialize the inline autocomplete view which is visible only when IME is | 288 // Initialize the inline autocomplete view which is visible only when IME is |
289 // turned on. Use the same font with the omnibox and highlighted background. | 289 // turned on. Use the same font with the omnibox and highlighted background. |
290 ime_inline_autocomplete_view_ = new views::Label(string16(), font); | 290 ime_inline_autocomplete_view_ = new views::Label(string16(), font); |
291 ime_inline_autocomplete_view_->set_border( | 291 { |
292 views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0)); | 292 // views::Label (|ime_inline_autocomplete_view_|) supports only gfx::Font |
| 293 // and ignores the rest of fonts but the first in |font_list| while |
| 294 // views::Textfield (|location_entry_view_|) supports gfx::FontList and |
| 295 // layouts text based on all fonts in the list. Thus the font height and |
| 296 // baseline can be different between them. We add padding to align them |
| 297 // on the same baseline. |
| 298 // TODO(yukishiino): Remove this hack once views::Label supports |
| 299 // gfx::FontList. |
| 300 const int baseline_diff = location_entry_view_->GetBaseline() - |
| 301 ime_inline_autocomplete_view_->GetBaseline(); |
| 302 ime_inline_autocomplete_view_->set_border( |
| 303 views::Border::CreateEmptyBorder( |
| 304 font_y_offset + baseline_diff, 0, 0, 0)); |
| 305 } |
293 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 306 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
294 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); | 307 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); |
295 ime_inline_autocomplete_view_->set_background( | 308 ime_inline_autocomplete_view_->set_background( |
296 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( | 309 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( |
297 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); | 310 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); |
298 ime_inline_autocomplete_view_->SetEnabledColor( | 311 ime_inline_autocomplete_view_->SetEnabledColor( |
299 GetNativeTheme()->GetSystemColor( | 312 GetNativeTheme()->GetSystemColor( |
300 ui::NativeTheme::kColorId_TextfieldSelectionColor)); | 313 ui::NativeTheme::kColorId_TextfieldSelectionColor)); |
301 ime_inline_autocomplete_view_->SetVisible(false); | 314 ime_inline_autocomplete_view_->SetVisible(false); |
302 AddChildView(ime_inline_autocomplete_view_); | 315 AddChildView(ime_inline_autocomplete_view_); |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1541 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
1529 int total_height = | 1542 int total_height = |
1530 use_preferred_size ? GetPreferredSize().height() : height(); | 1543 use_preferred_size ? GetPreferredSize().height() : height(); |
1531 return std::max(total_height - (vertical_edge_thickness() * 2), 0); | 1544 return std::max(total_height - (vertical_edge_thickness() * 2), 0); |
1532 } | 1545 } |
1533 | 1546 |
1534 bool LocationBarView::HasValidSuggestText() const { | 1547 bool LocationBarView::HasValidSuggestText() const { |
1535 return suggested_text_view_->visible() && | 1548 return suggested_text_view_->visible() && |
1536 !suggested_text_view_->size().IsEmpty(); | 1549 !suggested_text_view_->size().IsEmpty(); |
1537 } | 1550 } |
OLD | NEW |