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

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

Issue 23731010: Move text_elider to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update3 Created 7 years, 3 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 | Annotate | Revision Log
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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <atlbase.h> // NOLINT 8 #include <atlbase.h> // NOLINT
9 #include <atlwin.h> // NOLINT 9 #include <atlwin.h> // NOLINT
10 #endif 10 #endif
11 11
12 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" 12 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h"
13 13
14 #include <algorithm> // NOLINT 14 #include <algorithm> // NOLINT
15 15
16 #include "base/i18n/bidi_line_iterator.h" 16 #include "base/i18n/bidi_line_iterator.h"
17 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
18 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 18 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
19 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 19 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
20 #include "chrome/browser/ui/views/omnibox/omnibox_result_view_model.h" 20 #include "chrome/browser/ui/views/omnibox/omnibox_result_view_model.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
23 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/text/text_elider.h"
25 #include "ui/base/theme_provider.h" 24 #include "ui/base/theme_provider.h"
26 #include "ui/gfx/canvas.h" 25 #include "ui/gfx/canvas.h"
27 #include "ui/gfx/color_utils.h" 26 #include "ui/gfx/color_utils.h"
28 #include "ui/gfx/image/image.h" 27 #include "ui/gfx/image/image.h"
29 #include "ui/gfx/render_text.h" 28 #include "ui/gfx/render_text.h"
29 #include "ui/gfx/text_elider.h"
30 #include "ui/native_theme/native_theme.h" 30 #include "ui/native_theme/native_theme.h"
31 31
32 #if defined(OS_WIN) 32 #if defined(OS_WIN)
33 #include "ui/native_theme/native_theme_win.h" 33 #include "ui/native_theme/native_theme_win.h"
34 #endif 34 #endif
35 35
36 #if defined(USE_AURA) 36 #if defined(USE_AURA)
37 #include "ui/native_theme/native_theme_aura.h" 37 #include "ui/native_theme/native_theme_aura.h"
38 #endif 38 #endif
39 39
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // classification. 510 // classification.
511 (*j)->SetText((*j)->text() + kEllipsis); 511 (*j)->SetText((*j)->text() + kEllipsis);
512 } 512 }
513 first_classification = false; 513 first_classification = false;
514 514
515 // Can we fit at least an ellipsis? 515 // Can we fit at least an ellipsis?
516 gfx::Font font((*j)->GetStyle(gfx::BOLD) ? 516 gfx::Font font((*j)->GetStyle(gfx::BOLD) ?
517 (*j)->GetPrimaryFont().DeriveFont(0, gfx::Font::BOLD) : 517 (*j)->GetPrimaryFont().DeriveFont(0, gfx::Font::BOLD) :
518 (*j)->GetPrimaryFont()); 518 (*j)->GetPrimaryFont());
519 string16 elided_text( 519 string16 elided_text(
520 ui::ElideText((*j)->text(), font, remaining_width, ui::ELIDE_AT_END)); 520 gfx::ElideText((*j)->text(), font, remaining_width, gfx::ELIDE_AT_END) );
521 Classifications::reverse_iterator prior(j + 1); 521 Classifications::reverse_iterator prior(j + 1);
522 const bool on_first_classification = (prior == i->classifications.rend()); 522 const bool on_first_classification = (prior == i->classifications.rend());
523 if (elided_text.empty() && (remaining_width >= ellipsis_width_) && 523 if (elided_text.empty() && (remaining_width >= ellipsis_width_) &&
524 on_first_classification) { 524 on_first_classification) {
525 // Edge case: This classification is bold, we can't fit a bold ellipsis 525 // Edge case: This classification is bold, we can't fit a bold ellipsis
526 // but we can fit a normal one, and this is the first classification in 526 // but we can fit a normal one, and this is the first classification in
527 // the run. We should display a lone normal ellipsis, because appending 527 // the run. We should display a lone normal ellipsis, because appending
528 // one to the end of the previous run might put it in the wrong visual 528 // one to the end of the previous run might put it in the wrong visual
529 // location (if the previous run is reversed from the normal visual 529 // location (if the previous run is reversed from the normal visual
530 // order). 530 // order).
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 int x = GetMirroredXForRect(keyword_text_bounds_); 624 int x = GetMirroredXForRect(keyword_text_bounds_);
625 mirroring_context_->Initialize(x, keyword_text_bounds_.width()); 625 mirroring_context_->Initialize(x, keyword_text_bounds_.width());
626 PaintMatch(canvas, *match_.associated_keyword.get(), x); 626 PaintMatch(canvas, *match_.associated_keyword.get(), x);
627 } 627 }
628 } 628 }
629 629
630 void OmniboxResultView::AnimationProgressed(const ui::Animation* animation) { 630 void OmniboxResultView::AnimationProgressed(const ui::Animation* animation) {
631 Layout(); 631 Layout();
632 SchedulePaint(); 632 SchedulePaint();
633 } 633 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/global_menu_bar_x11.cc ('k') | chrome/browser/ui/views/status_bubble_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698