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

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: Created 4 years, 9 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 }; 215 };
216 216
217 OmniboxResultView::OmniboxResultView(OmniboxPopupContentsView* model, 217 OmniboxResultView::OmniboxResultView(OmniboxPopupContentsView* model,
218 int model_index, 218 int model_index,
219 LocationBarView* location_bar_view, 219 LocationBarView* location_bar_view,
220 const gfx::FontList& font_list) 220 const gfx::FontList& font_list)
221 : model_(model), 221 : model_(model),
222 model_index_(model_index), 222 model_index_(model_index),
223 location_bar_view_(location_bar_view), 223 location_bar_view_(location_bar_view),
224 font_list_(font_list), 224 font_list_(font_list),
225 font_height_( 225 font_height_(std::max(
226 std::max(font_list.GetHeight(), 226 font_list.GetHeight(),
227 font_list.DeriveWithStyle(gfx::Font::BOLD).GetHeight())), 227 font_list.DeriveWithWeight(gfx::Font::WEIGHT_BOLD).GetHeight())),
228 mirroring_context_(new MirroringContext()), 228 mirroring_context_(new MirroringContext()),
229 keyword_icon_(new views::ImageView()), 229 keyword_icon_(new views::ImageView()),
230 animation_(new gfx::SlideAnimation(this)) { 230 animation_(new gfx::SlideAnimation(this)) {
231 CHECK_GE(model_index, 0); 231 CHECK_GE(model_index, 0);
232 if (default_icon_size_ == 0) { 232 if (default_icon_size_ == 0) {
233 default_icon_size_ = 233 default_icon_size_ =
234 location_bar_view_->GetThemeProvider()->GetImageSkiaNamed( 234 location_bar_view_->GetThemeProvider()->GetImageSkiaNamed(
235 AutocompleteMatch::TypeToIcon( 235 AutocompleteMatch::TypeToIcon(
236 AutocompleteMatchType::URL_WHAT_YOU_TYPED))->width(); 236 AutocompleteMatchType::URL_WHAT_YOU_TYPED))->width();
237 } 237 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (text_start >= text_length) 489 if (text_start >= text_length)
490 break; 490 break;
491 491
492 const size_t text_end = (i < (classifications.size() - 1)) ? 492 const size_t text_end = (i < (classifications.size() - 1)) ?
493 std::min(classifications[i + 1].offset, text_length) : 493 std::min(classifications[i + 1].offset, text_length) :
494 text_length; 494 text_length;
495 const gfx::Range current_range(text_start, text_end); 495 const gfx::Range current_range(text_start, text_end);
496 496
497 // Calculate style-related data. 497 // Calculate style-related data.
498 if (classifications[i].style & ACMatchClassification::MATCH) 498 if (classifications[i].style & ACMatchClassification::MATCH)
499 render_text->ApplyStyle(gfx::BOLD, true, current_range); 499 render_text->ApplyWeight(gfx::Font::WEIGHT_BOLD, current_range);
500 500
501 ColorKind color_kind = TEXT; 501 ColorKind color_kind = TEXT;
502 if (classifications[i].style & ACMatchClassification::URL) { 502 if (classifications[i].style & ACMatchClassification::URL) {
503 color_kind = URL; 503 color_kind = URL;
504 // Consider logical string for domain "ABC.comי/hello" where ABC are 504 // Consider logical string for domain "ABC.comי/hello" where ABC are
505 // Hebrew (RTL) characters. This string should ideally show as 505 // Hebrew (RTL) characters. This string should ideally show as
506 // "CBA.com/hello". If we do not force LTR on URL, it will appear as 506 // "CBA.com/hello". If we do not force LTR on URL, it will appear as
507 // "com/hello.CBA". 507 // "com/hello.CBA".
508 // With IDN and RTL TLDs, it might be okay to allow RTL rendering of URLs, 508 // With IDN and RTL TLDs, it might be okay to allow RTL rendering of URLs,
509 // but it still has some pitfalls like : 509 // but it still has some pitfalls like :
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 int text_type, 807 int text_type,
808 bool is_bold) { 808 bool is_bold) {
809 if (text.empty()) 809 if (text.empty())
810 return; 810 return;
811 int offset = destination->text().length(); 811 int offset = destination->text().length();
812 gfx::Range range(offset, offset + text.length()); 812 gfx::Range range(offset, offset + text.length());
813 destination->AppendText(text); 813 destination->AppendText(text);
814 const TextStyle& text_style = GetTextStyle(text_type); 814 const TextStyle& text_style = GetTextStyle(text_type);
815 // TODO(dschuyler): follow up on the problem of different font sizes within 815 // TODO(dschuyler): follow up on the problem of different font sizes within
816 // one RenderText. Maybe with destination->SetFontList(...). 816 // one RenderText. Maybe with destination->SetFontList(...).
817 destination->ApplyStyle(gfx::BOLD, is_bold, range); 817 destination->ApplyWeight(gfx::Font::WEIGHT_BOLD, range);
818 destination->ApplyColor( 818 destination->ApplyColor(
819 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); 819 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range);
820 destination->ApplyBaselineStyle(text_style.baseline, range); 820 destination->ApplyBaselineStyle(text_style.baseline, range);
821 } 821 }
822 822
823 int OmniboxResultView::StartMargin() const { 823 int OmniboxResultView::StartMargin() const {
824 return ui::MaterialDesignController::IsModeMaterial() ? 824 return ui::MaterialDesignController::IsModeMaterial() ?
825 model_->start_margin() : 0; 825 model_->start_margin() : 0;
826 } 826 }
827 827
828 int OmniboxResultView::EndMargin() const { 828 int OmniboxResultView::EndMargin() const {
829 return ui::MaterialDesignController::IsModeMaterial() ? 829 return ui::MaterialDesignController::IsModeMaterial() ?
830 model_->end_margin() : 0; 830 model_->end_margin() : 0;
831 } 831 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698