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

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

Issue 2836453002: Standardizing on the name "tail suggestions" (in comments) (Closed)
Patch Set: Created 3 years, 8 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 RenderTextType render_text_type, 400 RenderTextType render_text_type,
401 gfx::Canvas* canvas, 401 gfx::Canvas* canvas,
402 int x, 402 int x,
403 int y, 403 int y,
404 int max_width) const { 404 int max_width) const {
405 DCHECK(!render_text->text().empty()); 405 DCHECK(!render_text->text().empty());
406 406
407 const int remaining_width = mirroring_context_->remaining_width(x); 407 const int remaining_width = mirroring_context_->remaining_width(x);
408 int right_x = x + max_width; 408 int right_x = x + max_width;
409 409
410 // Infinite suggestions should appear with the leading ellipses vertically 410 // Tail suggestions should appear with the leading ellipses vertically
411 // stacked. 411 // stacked.
412 if (render_text_type == CONTENTS && 412 if (render_text_type == CONTENTS &&
413 match.type == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { 413 match.type == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) {
414 // When the directionality of suggestion doesn't match the UI, we try to 414 // When the directionality of suggestion doesn't match the UI, we try to
415 // vertically stack the ellipsis by restricting the end edge (right_x). 415 // vertically stack the ellipsis by restricting the end edge (right_x).
416 const bool is_ui_rtl = base::i18n::IsRTL(); 416 const bool is_ui_rtl = base::i18n::IsRTL();
417 const bool is_match_contents_rtl = 417 const bool is_match_contents_rtl =
418 (render_text->GetDisplayTextDirection() == base::i18n::RIGHT_TO_LEFT); 418 (render_text->GetDisplayTextDirection() == base::i18n::RIGHT_TO_LEFT);
419 const int offset = 419 const int offset =
420 GetDisplayOffset(match, is_ui_rtl, is_match_contents_rtl); 420 GetDisplayOffset(match, is_ui_rtl, is_match_contents_rtl);
421 421
422 std::unique_ptr<gfx::RenderText> prefix_render_text( 422 std::unique_ptr<gfx::RenderText> prefix_render_text(
423 CreateRenderText(base::UTF8ToUTF16( 423 CreateRenderText(base::UTF8ToUTF16(
424 match.GetAdditionalInfo(kACMatchPropertyContentsPrefix)))); 424 match.GetAdditionalInfo(kACMatchPropertyContentsPrefix))));
425 const int prefix_width = prefix_render_text->GetContentWidth(); 425 const int prefix_width = prefix_render_text->GetContentWidth();
426 int prefix_x = x; 426 int prefix_x = x;
427 427
428 const int max_match_contents_width = model_->max_match_contents_width(); 428 const int max_match_contents_width = model_->max_match_contents_width();
429 429
430 if (is_ui_rtl != is_match_contents_rtl) { 430 if (is_ui_rtl != is_match_contents_rtl) {
431 // RTL infinite suggestions appear near the left edge in LTR UI, while LTR 431 // RTL tail suggestions appear near the left edge in LTR UI, while LTR
432 // infinite suggestions appear near the right edge in RTL UI. This is 432 // tail suggestions appear near the right edge in RTL UI. This is
433 // against the natural horizontal alignment of the text. We reduce the 433 // against the natural horizontal alignment of the text. We reduce the
434 // width of the box for suggestion display, so that the suggestions appear 434 // width of the box for suggestion display, so that the suggestions appear
435 // in correct confines. This reduced width allows us to modify the text 435 // in correct confines. This reduced width allows us to modify the text
436 // alignment (see below). 436 // alignment (see below).
437 right_x = x + std::min(remaining_width - prefix_width, 437 right_x = x + std::min(remaining_width - prefix_width,
438 std::max(offset, max_match_contents_width)); 438 std::max(offset, max_match_contents_width));
439 prefix_x = right_x; 439 prefix_x = right_x;
440 // We explicitly set the horizontal alignment so that when LTR suggestions 440 // We explicitly set the horizontal alignment so that when LTR suggestions
441 // show in RTL UI (or vice versa), their ellipses appear stacked in a 441 // show in RTL UI (or vice versa), their ellipses appear stacked in a
442 // single column. 442 // single column.
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 destination->AppendText(text); 796 destination->AppendText(text);
797 const TextStyle& text_style = GetTextStyle(text_type); 797 const TextStyle& text_style = GetTextStyle(text_type);
798 // TODO(dschuyler): follow up on the problem of different font sizes within 798 // TODO(dschuyler): follow up on the problem of different font sizes within
799 // one RenderText. Maybe with destination->SetFontList(...). 799 // one RenderText. Maybe with destination->SetFontList(...).
800 destination->ApplyWeight( 800 destination->ApplyWeight(
801 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); 801 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range);
802 destination->ApplyColor( 802 destination->ApplyColor(
803 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); 803 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range);
804 destination->ApplyBaselineStyle(text_style.baseline, range); 804 destination->ApplyBaselineStyle(text_style.baseline, range);
805 } 805 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_result_view.h ('k') | components/omnibox/browser/search_suggestion_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698