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 30 matching lines...) Expand all Loading... | |
| 41 #include "ui/gfx/paint_vector_icon.h" | 41 #include "ui/gfx/paint_vector_icon.h" |
| 42 #include "ui/gfx/range/range.h" | 42 #include "ui/gfx/range/range.h" |
| 43 #include "ui/gfx/render_text.h" | 43 #include "ui/gfx/render_text.h" |
| 44 #include "ui/gfx/text_utils.h" | 44 #include "ui/gfx/text_utils.h" |
| 45 #include "ui/native_theme/native_theme.h" | 45 #include "ui/native_theme/native_theme.h" |
| 46 | 46 |
| 47 using ui::NativeTheme; | 47 using ui::NativeTheme; |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 // The padding that should be placed between lines in a top and bottom layout. | |
|
Peter Kasting
2017/04/24 22:16:05
What is "a top and bottom layout"? Do you mean "W
Justin Donnelly
2017/04/25 16:52:30
"Top and bottom" is meant to distinguish a layout
| |
| 52 static const int kVerticalPadding = 3; | |
| 53 | |
| 51 // A mapping from OmniboxResultView's ResultViewState/ColorKind types to | 54 // A mapping from OmniboxResultView's ResultViewState/ColorKind types to |
| 52 // NativeTheme colors. | 55 // NativeTheme colors. |
| 53 struct TranslationTable { | 56 struct TranslationTable { |
| 54 ui::NativeTheme::ColorId id; | 57 ui::NativeTheme::ColorId id; |
| 55 OmniboxResultView::ResultViewState state; | 58 OmniboxResultView::ResultViewState state; |
| 56 OmniboxResultView::ColorKind kind; | 59 OmniboxResultView::ColorKind kind; |
| 57 } static const kTranslationTable[] = { | 60 } static const kTranslationTable[] = { |
| 58 { NativeTheme::kColorId_ResultsTableNormalBackground, | 61 { NativeTheme::kColorId_ResultsTableNormalBackground, |
| 59 OmniboxResultView::NORMAL, OmniboxResultView::BACKGROUND }, | 62 OmniboxResultView::NORMAL, OmniboxResultView::BACKGROUND }, |
| 60 { NativeTheme::kColorId_ResultsTableHoveredBackground, | 63 { NativeTheme::kColorId_ResultsTableHoveredBackground, |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 290 |
| 288 // Notify assistive technology when results with answers attached are | 291 // Notify assistive technology when results with answers attached are |
| 289 // selected. The non-answer text is already accessible as a consequence of | 292 // selected. The non-answer text is already accessible as a consequence of |
| 290 // updating the text in the omnibox but this alert and GetAccessibleNodeData | 293 // updating the text in the omnibox but this alert and GetAccessibleNodeData |
| 291 // below make the answer contents accessible. | 294 // below make the answer contents accessible. |
| 292 if (match_.answer) | 295 if (match_.answer) |
| 293 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 296 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 294 } | 297 } |
| 295 | 298 |
| 296 gfx::Size OmniboxResultView::GetPreferredSize() const { | 299 gfx::Size OmniboxResultView::GetPreferredSize() const { |
| 297 if (!match_.answer) | 300 int height = GetTextHeight() + (2 * GetVerticalMargin()); |
| 298 return gfx::Size(0, GetContentLineHeight()); | 301 if (match_.answer) |
| 299 if (match_.answer->second_line().num_text_lines() == 1) | 302 height += GetAnswerLineHeight() + kVerticalPadding; |
| 300 return gfx::Size(0, GetContentLineHeight() + GetAnswerLineHeight()); | 303 return gfx::Size(0, height); |
| 301 if (!description_rendertext_) { | |
| 302 description_rendertext_ = | |
| 303 CreateAnswerLine(match_.answer->second_line(), GetAnswerLineFont()); | |
| 304 } | |
| 305 description_rendertext_->SetDisplayRect( | |
| 306 gfx::Rect(text_bounds_.width(), 0)); | |
| 307 description_rendertext_->GetStringSize(); | |
| 308 return gfx::Size( | |
| 309 0, GetContentLineHeight() + | |
| 310 GetAnswerLineHeight() * description_rendertext_->GetNumLines()); | |
| 311 } | 304 } |
| 312 | 305 |
| 313 void OmniboxResultView::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 306 void OmniboxResultView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 314 node_data->SetName(match_.answer | 307 node_data->SetName(match_.answer |
| 315 ? l10n_util::GetStringFUTF16( | 308 ? l10n_util::GetStringFUTF16( |
| 316 IDS_OMNIBOX_ACCESSIBLE_ANSWER, match_.contents, | 309 IDS_OMNIBOX_ACCESSIBLE_ANSWER, match_.contents, |
| 317 match_.answer->second_line().AccessibleText()) | 310 match_.answer->second_line().AccessibleText()) |
| 318 : match_.contents); | 311 : match_.contents); |
| 319 } | 312 } |
| 320 | 313 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 334 | 327 |
| 335 int OmniboxResultView::GetTextHeight() const { | 328 int OmniboxResultView::GetTextHeight() const { |
| 336 return font_height_; | 329 return font_height_; |
| 337 } | 330 } |
| 338 | 331 |
| 339 void OmniboxResultView::PaintMatch(const AutocompleteMatch& match, | 332 void OmniboxResultView::PaintMatch(const AutocompleteMatch& match, |
| 340 gfx::RenderText* contents, | 333 gfx::RenderText* contents, |
| 341 gfx::RenderText* description, | 334 gfx::RenderText* description, |
| 342 gfx::Canvas* canvas, | 335 gfx::Canvas* canvas, |
| 343 int x) const { | 336 int x) const { |
| 344 int y = text_bounds_.y(); | 337 int y = text_bounds_.y() + GetVerticalMargin(); |
| 345 | 338 |
| 346 if (!separator_rendertext_) { | 339 if (!separator_rendertext_) { |
| 347 const base::string16& separator = | 340 const base::string16& separator = |
| 348 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); | 341 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); |
| 349 separator_rendertext_ = CreateRenderText(separator); | 342 separator_rendertext_ = CreateRenderText(separator); |
| 350 separator_rendertext_->SetColor(GetColor(GetState(), DIMMED_TEXT)); | 343 separator_rendertext_->SetColor(GetColor(GetState(), DIMMED_TEXT)); |
| 351 separator_width_ = separator_rendertext_->GetContentWidth(); | 344 separator_width_ = separator_rendertext_->GetContentWidth(); |
| 352 } | 345 } |
| 353 | 346 |
| 354 contents->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); | 347 contents->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); |
| 355 if (description) | 348 if (description) |
| 356 description->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); | 349 description->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); |
| 357 int contents_max_width, description_max_width; | 350 int contents_max_width, description_max_width; |
| 358 OmniboxPopupModel::ComputeMatchMaxWidths( | 351 OmniboxPopupModel::ComputeMatchMaxWidths( |
| 359 contents->GetContentWidth(), | 352 contents->GetContentWidth(), |
| 360 separator_width_, | 353 separator_width_, |
| 361 description ? description->GetContentWidth() : 0, | 354 description ? description->GetContentWidth() : 0, |
| 362 mirroring_context_->remaining_width(x), | 355 mirroring_context_->remaining_width(x), |
| 363 match.answer != nullptr, | 356 match.answer != nullptr, |
| 364 !AutocompleteMatch::IsSearchType(match.type), | 357 !AutocompleteMatch::IsSearchType(match.type), |
| 365 &contents_max_width, | 358 &contents_max_width, |
| 366 &description_max_width); | 359 &description_max_width); |
| 367 | 360 |
| 368 int after_contents_x = DrawRenderText(match, contents, CONTENTS, canvas, | 361 int after_contents_x = DrawRenderText(match, contents, CONTENTS, canvas, |
| 369 x, y, contents_max_width); | 362 x, y, contents_max_width); |
| 370 | 363 |
| 371 if (description_max_width != 0) { | 364 if (description_max_width != 0) { |
| 372 if (match.answer) { | 365 if (match.answer) { |
| 373 y += GetContentLineHeight(); | 366 y += GetTextHeight() + kVerticalPadding; |
| 374 if (!answer_image_.isNull()) { | 367 if (!answer_image_.isNull()) { |
| 375 int answer_icon_size = GetAnswerLineHeight(); | 368 int answer_icon_size = GetAnswerLineHeight(); |
|
Peter Kasting
2017/04/24 22:16:05
This will vertically center the icon against (howe
Justin Donnelly
2017/04/25 16:52:30
Yes, that's what I want. With multiple lines of te
| |
| 376 canvas->DrawImageInt( | 369 canvas->DrawImageInt( |
| 377 answer_image_, | 370 answer_image_, |
| 378 0, 0, answer_image_.width(), answer_image_.height(), | 371 0, 0, answer_image_.width(), answer_image_.height(), |
| 379 GetMirroredXInView(x), y, answer_icon_size, answer_icon_size, true); | 372 GetMirroredXInView(x), y, answer_icon_size, answer_icon_size, true); |
| 380 // TODO(dschuyler): Perhaps this should be based on the font size | 373 // TODO(dschuyler): Perhaps this should be based on the font size |
| 381 // instead of hardcoded to 2 dp (e.g. by adding a space in an | 374 // instead of hardcoded to 2 dp (e.g. by adding a space in an |
| 382 // appropriate font to the beginning of the description, then reducing | 375 // appropriate font to the beginning of the description, then reducing |
| 383 // the additional padding here to zero). | 376 // the additional padding here to zero). |
| 384 const int kAnswerIconToTextPadding = 2; | 377 const int kAnswerIconToTextPadding = 2; |
| 385 x += answer_icon_size + kAnswerIconToTextPadding; | 378 x += answer_icon_size + kAnswerIconToTextPadding; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 x += start_offset; | 446 x += start_offset; |
| 454 prefix_x = x - prefix_width; | 447 prefix_x = x - prefix_width; |
| 455 } | 448 } |
| 456 prefix_render_text->SetDirectionalityMode(is_match_contents_rtl ? | 449 prefix_render_text->SetDirectionalityMode(is_match_contents_rtl ? |
| 457 gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR); | 450 gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR); |
| 458 prefix_render_text->SetHorizontalAlignment( | 451 prefix_render_text->SetHorizontalAlignment( |
| 459 is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT); | 452 is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT); |
| 460 prefix_render_text->SetDisplayRect( | 453 prefix_render_text->SetDisplayRect( |
| 461 gfx::Rect(mirroring_context_->mirrored_left_coord( | 454 gfx::Rect(mirroring_context_->mirrored_left_coord( |
| 462 prefix_x, prefix_x + prefix_width), | 455 prefix_x, prefix_x + prefix_width), |
| 463 y, prefix_width, GetContentLineHeight())); | 456 y, prefix_width, GetTextHeight())); |
| 464 prefix_render_text->Draw(canvas); | 457 prefix_render_text->Draw(canvas); |
| 465 } | 458 } |
| 466 | 459 |
| 467 // Set the display rect to trigger elision. | 460 // Set the display rect to trigger elision. |
| 468 const int final_width = right_x - x; | 461 int height = (render_text_type == DESCRIPTION && match.answer) |
| 469 int height = GetContentLineHeight(); | 462 ? GetAnswerLineHeight() |
| 470 if (render_text_type == DESCRIPTION && match.answer) { | 463 : GetTextHeight(); |
| 471 render_text->SetDisplayRect(gfx::Rect(gfx::Size(final_width, 0))); | |
| 472 render_text->GetStringSize(); | |
| 473 height = GetAnswerLineHeight() * render_text->GetNumLines(); | |
| 474 } | |
| 475 render_text->SetDisplayRect( | 464 render_text->SetDisplayRect( |
| 476 gfx::Rect(mirroring_context_->mirrored_left_coord(x, right_x), y, | 465 gfx::Rect(mirroring_context_->mirrored_left_coord(x, right_x), y, |
| 477 final_width, height)); | 466 right_x - x, height)); |
| 478 render_text->Draw(canvas); | 467 render_text->Draw(canvas); |
| 479 return right_x; | 468 return right_x; |
| 480 } | 469 } |
| 481 | 470 |
| 482 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateRenderText( | 471 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateRenderText( |
| 483 const base::string16& text) const { | 472 const base::string16& text) const { |
| 484 std::unique_ptr<gfx::RenderText> render_text( | 473 std::unique_ptr<gfx::RenderText> render_text( |
| 485 gfx::RenderText::CreateInstance()); | 474 gfx::RenderText::CreateInstance()); |
| 486 render_text->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); | 475 render_text->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); |
| 487 render_text->SetCursorEnabled(false); | 476 render_text->SetCursorEnabled(false); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING) + | 607 GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING) + |
| 619 LocationBarView::kIconInteriorPadding; | 608 LocationBarView::kIconInteriorPadding; |
| 620 // The horizontal bounds we're given are the outside bounds, so we can match | 609 // The horizontal bounds we're given are the outside bounds, so we can match |
| 621 // the omnibox border outline shape exactly in OnPaint(). We have to inset | 610 // the omnibox border outline shape exactly in OnPaint(). We have to inset |
| 622 // here to keep the icons lined up. | 611 // here to keep the icons lined up. |
| 623 const int start_x = BackgroundWith1PxBorder::kLocationBarBorderThicknessDip + | 612 const int start_x = BackgroundWith1PxBorder::kLocationBarBorderThicknessDip + |
| 624 horizontal_padding; | 613 horizontal_padding; |
| 625 const int end_x = width() - start_x; | 614 const int end_x = width() - start_x; |
| 626 | 615 |
| 627 const gfx::ImageSkia icon = GetIcon(); | 616 const gfx::ImageSkia icon = GetIcon(); |
| 628 icon_bounds_.SetRect(start_x, (GetContentLineHeight() - icon.height()) / 2, | 617 const int icon_y = |
| 629 icon.width(), icon.height()); | 618 GetVerticalMargin() + (GetTextHeight() - icon.height()) / 2; |
| 619 icon_bounds_.SetRect(start_x, icon_y, icon.width(), icon.height()); | |
| 630 | 620 |
| 631 const int text_x = start_x + LocationBarView::kIconWidth + horizontal_padding; | 621 const int text_x = start_x + LocationBarView::kIconWidth + horizontal_padding; |
| 632 int text_width = end_x - text_x; | 622 int text_width = end_x - text_x; |
| 633 | 623 |
| 634 if (match_.associated_keyword.get()) { | 624 if (match_.associated_keyword.get()) { |
| 635 const int max_kw_x = end_x - keyword_icon_->width(); | 625 const int max_kw_x = end_x - keyword_icon_->width(); |
| 636 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); | 626 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); |
| 637 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; | 627 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; |
| 638 | 628 |
| 639 text_width = kw_x - text_x - horizontal_padding; | 629 text_width = kw_x - text_x - horizontal_padding; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 658 if (!ShowOnlyKeywordMatch()) { | 648 if (!ShowOnlyKeywordMatch()) { |
| 659 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_), | 649 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_), |
| 660 icon_bounds_.y()); | 650 icon_bounds_.y()); |
| 661 int x = GetMirroredXForRect(text_bounds_); | 651 int x = GetMirroredXForRect(text_bounds_); |
| 662 mirroring_context_->Initialize(x, text_bounds_.width()); | 652 mirroring_context_->Initialize(x, text_bounds_.width()); |
| 663 InitContentsRenderTextIfNecessary(); | 653 InitContentsRenderTextIfNecessary(); |
| 664 | 654 |
| 665 if (!description_rendertext_) { | 655 if (!description_rendertext_) { |
| 666 if (match_.answer) { | 656 if (match_.answer) { |
| 667 description_rendertext_ = | 657 description_rendertext_ = |
| 668 CreateAnswerLine(match_.answer->second_line(), GetAnswerLineFont()); | 658 CreateAnswerLine(match_.answer->second_line(), GetAnswerFont()); |
| 669 } else if (!match_.description.empty()) { | 659 } else if (!match_.description.empty()) { |
| 670 description_rendertext_ = CreateClassifiedRenderText( | 660 description_rendertext_ = CreateClassifiedRenderText( |
| 671 match_.description, match_.description_class, true); | 661 match_.description, match_.description_class, true); |
| 672 } | 662 } |
| 673 } | 663 } |
| 674 PaintMatch(match_, contents_rendertext_.get(), | 664 PaintMatch(match_, contents_rendertext_.get(), |
| 675 description_rendertext_.get(), canvas, x); | 665 description_rendertext_.get(), canvas, x); |
| 676 } | 666 } |
| 677 | 667 |
| 678 AutocompleteMatch* keyword_match = match_.associated_keyword.get(); | 668 AutocompleteMatch* keyword_match = match_.associated_keyword.get(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 691 PaintMatch(*keyword_match, keyword_contents_rendertext_.get(), | 681 PaintMatch(*keyword_match, keyword_contents_rendertext_.get(), |
| 692 keyword_description_rendertext_.get(), canvas, x); | 682 keyword_description_rendertext_.get(), canvas, x); |
| 693 } | 683 } |
| 694 } | 684 } |
| 695 | 685 |
| 696 void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) { | 686 void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) { |
| 697 Layout(); | 687 Layout(); |
| 698 SchedulePaint(); | 688 SchedulePaint(); |
| 699 } | 689 } |
| 700 | 690 |
| 701 const gfx::FontList& OmniboxResultView::GetAnswerLineFont() const { | 691 const gfx::FontList& OmniboxResultView::GetAnswerFont() const { |
| 702 // This assumes that the first text type in the second answer line can be used | 692 // This assumes that the first text type in the second answer line can be used |
| 703 // to specify the font for all the text fields in the line. For now this works | 693 // to specify the font for all the text fields in the line. For now this works |
| 704 // but eventually it will be necessary to get RenderText to support multiple | 694 // but eventually it will be necessary to get RenderText to support multiple |
| 705 // font sizes or use multiple RenderTexts. | 695 // font sizes or use multiple RenderTexts. |
| 706 int text_type = | 696 int text_type = |
| 707 match_.answer && !match_.answer->second_line().text_fields().empty() | 697 match_.answer && !match_.answer->second_line().text_fields().empty() |
| 708 ? match_.answer->second_line().text_fields()[0].type() | 698 ? match_.answer->second_line().text_fields()[0].type() |
| 709 : SuggestionAnswer::SUGGESTION; | 699 : SuggestionAnswer::SUGGESTION; |
| 710 return ui::ResourceBundle::GetSharedInstance().GetFontList( | 700 return ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 711 GetTextStyle(text_type).font); | 701 GetTextStyle(text_type).font); |
| 712 } | 702 } |
| 713 | 703 |
| 714 int OmniboxResultView::GetAnswerLineHeight() const { | 704 int OmniboxResultView::GetAnswerLineHeight() const { |
|
Peter Kasting
2017/04/24 22:16:05
Nit: Seems like GetAnswerHeight() would be better
Justin Donnelly
2017/04/25 16:52:30
Good point, done. Also changed CreateAnswerLine()
| |
| 715 return GetAnswerLineFont().GetHeight(); | 705 // If the answer specifies a maximum of 1 line we can simply return the answer |
| 706 // font height. | |
| 707 if (match_.answer->second_line().num_text_lines() == 1) | |
| 708 return GetAnswerFont().GetHeight(); | |
| 709 | |
| 710 // Multi-line answers require layout in order to determine the number of lines | |
| 711 // the RenderText will use. | |
| 712 if (!description_rendertext_) { | |
| 713 description_rendertext_ = | |
| 714 CreateAnswerLine(match_.answer->second_line(), GetAnswerFont()); | |
| 715 } | |
| 716 description_rendertext_->SetDisplayRect(gfx::Rect(text_bounds_.width(), 0)); | |
| 717 description_rendertext_->GetStringSize(); | |
| 718 return GetAnswerFont().GetHeight() * description_rendertext_->GetNumLines(); | |
| 716 } | 719 } |
| 717 | 720 |
| 718 int OmniboxResultView::GetContentLineHeight() const { | 721 int OmniboxResultView::GetVerticalMargin() const { |
| 722 // Regardless of the text size, we ensure a minimum size for the content line | |
|
Justin Donnelly
2017/04/21 16:57:08
This is my understanding of what this logic is try
| |
| 723 // here. This minimum is larger for hybrid mouse/touch devices to ensure an | |
| 724 // adequately sized touch target. | |
| 719 using Md = ui::MaterialDesignController; | 725 using Md = ui::MaterialDesignController; |
| 720 const int kIconVerticalPad = Md::GetMode() == Md::MATERIAL_HYBRID ? 8 : 4; | 726 const int kIconVerticalPad = Md::GetMode() == Md::MATERIAL_HYBRID ? 8 : 4; |
| 721 const int kTextVerticalPad = 3; | 727 const int min_height = LocationBarView::kIconWidth + 2 * kIconVerticalPad; |
| 722 return std::max( | 728 |
| 723 LocationBarView::kIconWidth + 2 * kIconVerticalPad, | 729 return std::max(kVerticalPadding, (min_height - GetTextHeight()) / 2); |
| 724 GetTextHeight() + 2 * kTextVerticalPad); | |
| 725 } | 730 } |
| 726 | 731 |
| 727 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerLine( | 732 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerLine( |
| 728 const SuggestionAnswer::ImageLine& line, | 733 const SuggestionAnswer::ImageLine& line, |
| 729 const gfx::FontList& font_list) const { | 734 const gfx::FontList& font_list) const { |
| 730 std::unique_ptr<gfx::RenderText> destination = | 735 std::unique_ptr<gfx::RenderText> destination = |
| 731 CreateRenderText(base::string16()); | 736 CreateRenderText(base::string16()); |
| 732 destination->SetFontList(font_list); | 737 destination->SetFontList(font_list); |
| 733 | 738 |
| 734 for (const SuggestionAnswer::TextField& text_field : line.text_fields()) | 739 for (const SuggestionAnswer::TextField& text_field : line.text_fields()) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 destination->AppendText(text); | 801 destination->AppendText(text); |
| 797 const TextStyle& text_style = GetTextStyle(text_type); | 802 const TextStyle& text_style = GetTextStyle(text_type); |
| 798 // TODO(dschuyler): follow up on the problem of different font sizes within | 803 // TODO(dschuyler): follow up on the problem of different font sizes within |
| 799 // one RenderText. Maybe with destination->SetFontList(...). | 804 // one RenderText. Maybe with destination->SetFontList(...). |
| 800 destination->ApplyWeight( | 805 destination->ApplyWeight( |
| 801 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); | 806 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); |
| 802 destination->ApplyColor( | 807 destination->ApplyColor( |
| 803 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 808 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
| 804 destination->ApplyBaselineStyle(text_style.baseline, range); | 809 destination->ApplyBaselineStyle(text_style.baseline, range); |
| 805 } | 810 } |
| OLD | NEW |