Chromium Code Reviews| 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 // 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 Loading... | |
| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 if (text_start >= text_length) | 490 if (text_start >= text_length) |
| 491 break; | 491 break; |
| 492 | 492 |
| 493 const size_t text_end = (i < (classifications.size() - 1)) ? | 493 const size_t text_end = (i < (classifications.size() - 1)) ? |
| 494 std::min(classifications[i + 1].offset, text_length) : | 494 std::min(classifications[i + 1].offset, text_length) : |
| 495 text_length; | 495 text_length; |
| 496 const gfx::Range current_range(text_start, text_end); | 496 const gfx::Range current_range(text_start, text_end); |
| 497 | 497 |
| 498 // Calculate style-related data. | 498 // Calculate style-related data. |
| 499 if (classifications[i].style & ACMatchClassification::MATCH) | 499 if (classifications[i].style & ACMatchClassification::MATCH) |
| 500 render_text->ApplyStyle(gfx::BOLD, true, current_range); | 500 render_text->ApplyWeight(gfx::Font::Weight::BOLD, current_range); |
| 501 | 501 |
| 502 ColorKind color_kind = TEXT; | 502 ColorKind color_kind = TEXT; |
| 503 if (classifications[i].style & ACMatchClassification::URL) { | 503 if (classifications[i].style & ACMatchClassification::URL) { |
| 504 color_kind = URL; | 504 color_kind = URL; |
| 505 // Consider logical string for domain "ABC.comי/hello" where ABC are | 505 // Consider logical string for domain "ABC.comי/hello" where ABC are |
| 506 // Hebrew (RTL) characters. This string should ideally show as | 506 // Hebrew (RTL) characters. This string should ideally show as |
| 507 // "CBA.com/hello". If we do not force LTR on URL, it will appear as | 507 // "CBA.com/hello". If we do not force LTR on URL, it will appear as |
| 508 // "com/hello.CBA". | 508 // "com/hello.CBA". |
| 509 // With IDN and RTL TLDs, it might be okay to allow RTL rendering of URLs, | 509 // With IDN and RTL TLDs, it might be okay to allow RTL rendering of URLs, |
| 510 // but it still has some pitfalls like : | 510 // but it still has some pitfalls like : |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 808 int text_type, | 808 int text_type, |
| 809 bool is_bold) { | 809 bool is_bold) { |
| 810 if (text.empty()) | 810 if (text.empty()) |
| 811 return; | 811 return; |
| 812 int offset = destination->text().length(); | 812 int offset = destination->text().length(); |
| 813 gfx::Range range(offset, offset + text.length()); | 813 gfx::Range range(offset, offset + text.length()); |
| 814 destination->AppendText(text); | 814 destination->AppendText(text); |
| 815 const TextStyle& text_style = GetTextStyle(text_type); | 815 const TextStyle& text_style = GetTextStyle(text_type); |
| 816 // TODO(dschuyler): follow up on the problem of different font sizes within | 816 // TODO(dschuyler): follow up on the problem of different font sizes within |
| 817 // one RenderText. Maybe with destination->SetFontList(...). | 817 // one RenderText. Maybe with destination->SetFontList(...). |
| 818 destination->ApplyStyle(gfx::BOLD, is_bold, range); | 818 destination->ApplyWeight(gfx::Font::Weight::BOLD, range); |
|
Peter Kasting
2016/03/26 00:56:51
This looks wrong. Should this be something like:
Mikus
2016/03/29 10:55:38
Done.
| |
| 819 destination->ApplyColor( | 819 destination->ApplyColor( |
| 820 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 820 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
| 821 destination->ApplyBaselineStyle(text_style.baseline, range); | 821 destination->ApplyBaselineStyle(text_style.baseline, range); |
| 822 } | 822 } |
| 823 | 823 |
| 824 int OmniboxResultView::StartMargin() const { | 824 int OmniboxResultView::StartMargin() const { |
| 825 return ui::MaterialDesignController::IsModeMaterial() ? | 825 return ui::MaterialDesignController::IsModeMaterial() ? |
| 826 model_->start_margin() : 0; | 826 model_->start_margin() : 0; |
| 827 } | 827 } |
| 828 | 828 |
| 829 int OmniboxResultView::EndMargin() const { | 829 int OmniboxResultView::EndMargin() const { |
| 830 return ui::MaterialDesignController::IsModeMaterial() ? | 830 return ui::MaterialDesignController::IsModeMaterial() ? |
| 831 model_->end_margin() : 0; | 831 model_->end_margin() : 0; |
| 832 } | 832 } |
| OLD | NEW |