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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_result_view.cc

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a lost comment and modify a render text unittest to not test black because of test env font con… Created 4 years, 6 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 // For WinDDK ATL compatibility, these ATL headers must come first. 5 // For WinDDK ATL compatibility, these ATL headers must come first.
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 7
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include <atlbase.h> // NOLINT 9 #include <atlbase.h> // NOLINT
10 #include <atlwin.h> // NOLINT 10 #include <atlwin.h> // NOLINT
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 }; 184 };
185 185
186 OmniboxResultView::OmniboxResultView(OmniboxPopupContentsView* model, 186 OmniboxResultView::OmniboxResultView(OmniboxPopupContentsView* model,
187 int model_index, 187 int model_index,
188 LocationBarView* location_bar_view, 188 LocationBarView* location_bar_view,
189 const gfx::FontList& font_list) 189 const gfx::FontList& font_list)
190 : model_(model), 190 : model_(model),
191 model_index_(model_index), 191 model_index_(model_index),
192 location_bar_view_(location_bar_view), 192 location_bar_view_(location_bar_view),
193 font_list_(font_list), 193 font_list_(font_list),
194 font_height_( 194 font_height_(std::max(
195 std::max(font_list.GetHeight(), 195 font_list.GetHeight(),
196 font_list.DeriveWithStyle(gfx::Font::BOLD).GetHeight())), 196 font_list.DeriveWithWeight(gfx::Font::Weight::BOLD).GetHeight())),
197 mirroring_context_(new MirroringContext()), 197 mirroring_context_(new MirroringContext()),
198 keyword_icon_(new views::ImageView()), 198 keyword_icon_(new views::ImageView()),
199 animation_(new gfx::SlideAnimation(this)) { 199 animation_(new gfx::SlideAnimation(this)) {
200 CHECK_GE(model_index, 0); 200 CHECK_GE(model_index, 0);
201 if (default_icon_size_ == 0) { 201 if (default_icon_size_ == 0) {
202 default_icon_size_ = 202 default_icon_size_ =
203 location_bar_view_->GetThemeProvider()->GetImageSkiaNamed( 203 location_bar_view_->GetThemeProvider()->GetImageSkiaNamed(
204 AutocompleteMatch::TypeToIcon( 204 AutocompleteMatch::TypeToIcon(
205 AutocompleteMatchType::URL_WHAT_YOU_TYPED))->width(); 205 AutocompleteMatchType::URL_WHAT_YOU_TYPED))->width();
206 } 206 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 if (text_start >= text_length) 463 if (text_start >= text_length)
464 break; 464 break;
465 465
466 const size_t text_end = (i < (classifications.size() - 1)) ? 466 const size_t text_end = (i < (classifications.size() - 1)) ?
467 std::min(classifications[i + 1].offset, text_length) : 467 std::min(classifications[i + 1].offset, text_length) :
468 text_length; 468 text_length;
469 const gfx::Range current_range(text_start, text_end); 469 const gfx::Range current_range(text_start, text_end);
470 470
471 // Calculate style-related data. 471 // Calculate style-related data.
472 if (classifications[i].style & ACMatchClassification::MATCH) 472 if (classifications[i].style & ACMatchClassification::MATCH)
473 render_text->ApplyStyle(gfx::BOLD, true, current_range); 473 render_text->ApplyWeight(gfx::Font::Weight::BOLD, current_range);
474 474
475 ColorKind color_kind = TEXT; 475 ColorKind color_kind = TEXT;
476 if (classifications[i].style & ACMatchClassification::URL) { 476 if (classifications[i].style & ACMatchClassification::URL) {
477 color_kind = URL; 477 color_kind = URL;
478 // Consider logical string for domain "ABC.comי/hello" where ABC are 478 // Consider logical string for domain "ABC.comי/hello" where ABC are
479 // Hebrew (RTL) characters. This string should ideally show as 479 // Hebrew (RTL) characters. This string should ideally show as
480 // "CBA.com/hello". If we do not force LTR on URL, it will appear as 480 // "CBA.com/hello". If we do not force LTR on URL, it will appear as
481 // "com/hello.CBA". 481 // "com/hello.CBA".
482 // With IDN and RTL TLDs, it might be okay to allow RTL rendering of URLs, 482 // With IDN and RTL TLDs, it might be okay to allow RTL rendering of URLs,
483 // but it still has some pitfalls like : 483 // but it still has some pitfalls like :
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 int text_type, 791 int text_type,
792 bool is_bold) { 792 bool is_bold) {
793 if (text.empty()) 793 if (text.empty())
794 return; 794 return;
795 int offset = destination->text().length(); 795 int offset = destination->text().length();
796 gfx::Range range(offset, offset + text.length()); 796 gfx::Range range(offset, offset + text.length());
797 destination->AppendText(text); 797 destination->AppendText(text);
798 const TextStyle& text_style = GetTextStyle(text_type); 798 const TextStyle& text_style = GetTextStyle(text_type);
799 // TODO(dschuyler): follow up on the problem of different font sizes within 799 // TODO(dschuyler): follow up on the problem of different font sizes within
800 // one RenderText. Maybe with destination->SetFontList(...). 800 // one RenderText. Maybe with destination->SetFontList(...).
801 destination->ApplyStyle(gfx::BOLD, is_bold, range); 801 destination->ApplyWeight(
802 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range);
802 destination->ApplyColor( 803 destination->ApplyColor(
803 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); 804 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range);
804 destination->ApplyBaselineStyle(text_style.baseline, range); 805 destination->ApplyBaselineStyle(text_style.baseline, range);
805 } 806 }
806 807
807 int OmniboxResultView::StartMargin() const { 808 int OmniboxResultView::StartMargin() const {
808 return ui::MaterialDesignController::IsModeMaterial() ? 809 return ui::MaterialDesignController::IsModeMaterial() ?
809 model_->start_margin() : 0; 810 model_->start_margin() : 0;
810 } 811 }
811 812
812 int OmniboxResultView::EndMargin() const { 813 int OmniboxResultView::EndMargin() const {
813 return ui::MaterialDesignController::IsModeMaterial() ? 814 return ui::MaterialDesignController::IsModeMaterial() ?
814 model_->end_margin() : 0; 815 model_->end_margin() : 0;
815 } 816 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/first_run_bubble.cc ('k') | chrome/browser/ui/views/platform_keys_certificate_selector_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698