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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_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 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "content/public/common/page_transition_types.h" 61 #include "content/public/common/page_transition_types.h"
62 #include "grit/generated_resources.h" 62 #include "grit/generated_resources.h"
63 #include "grit/theme_resources.h" 63 #include "grit/theme_resources.h"
64 #include "grit/ui_resources.h" 64 #include "grit/ui_resources.h"
65 #include "ui/base/accessibility/accessible_view_state.h" 65 #include "ui/base/accessibility/accessible_view_state.h"
66 #include "ui/base/animation/slide_animation.h" 66 #include "ui/base/animation/slide_animation.h"
67 #include "ui/base/dragdrop/drag_utils.h" 67 #include "ui/base/dragdrop/drag_utils.h"
68 #include "ui/base/dragdrop/os_exchange_data.h" 68 #include "ui/base/dragdrop/os_exchange_data.h"
69 #include "ui/base/l10n/l10n_util.h" 69 #include "ui/base/l10n/l10n_util.h"
70 #include "ui/base/resource/resource_bundle.h" 70 #include "ui/base/resource/resource_bundle.h"
71 #include "ui/base/text/text_elider.h"
72 #include "ui/base/theme_provider.h" 71 #include "ui/base/theme_provider.h"
73 #include "ui/base/window_open_disposition.h" 72 #include "ui/base/window_open_disposition.h"
74 #include "ui/gfx/canvas.h" 73 #include "ui/gfx/canvas.h"
74 #include "ui/gfx/text_elider.h"
75 #include "ui/views/button_drag_utils.h" 75 #include "ui/views/button_drag_utils.h"
76 #include "ui/views/controls/button/menu_button.h" 76 #include "ui/views/controls/button/menu_button.h"
77 #include "ui/views/controls/label.h" 77 #include "ui/views/controls/label.h"
78 #include "ui/views/controls/menu/menu_item_view.h" 78 #include "ui/views/controls/menu/menu_item_view.h"
79 #include "ui/views/drag_utils.h" 79 #include "ui/views/drag_utils.h"
80 #include "ui/views/metrics.h" 80 #include "ui/views/metrics.h"
81 #include "ui/views/view_constants.h" 81 #include "ui/views/view_constants.h"
82 #include "ui/views/widget/tooltip_manager.h" 82 #include "ui/views/widget/tooltip_manager.h"
83 #include "ui/views/widget/widget.h" 83 #include "ui/views/widget/widget.h"
84 #include "ui/views/window/non_client_view.h" 84 #include "ui/views/window/non_client_view.h"
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 int max_width = views::TooltipManager::GetMaxWidth(screen_loc.x(), 609 int max_width = views::TooltipManager::GetMaxWidth(screen_loc.x(),
610 screen_loc.y(), 610 screen_loc.y(),
611 context); 611 context);
612 const gfx::FontList& tt_fonts = views::TooltipManager::GetDefaultFontList(); 612 const gfx::FontList& tt_fonts = views::TooltipManager::GetDefaultFontList();
613 string16 result; 613 string16 result;
614 614
615 // First the title. 615 // First the title.
616 if (!title.empty()) { 616 if (!title.empty()) {
617 string16 localized_title = title; 617 string16 localized_title = title;
618 base::i18n::AdjustStringForLocaleDirection(&localized_title); 618 base::i18n::AdjustStringForLocaleDirection(&localized_title);
619 result.append(ui::ElideText(localized_title, tt_fonts, max_width, 619 result.append(gfx::ElideText(localized_title, tt_fonts, max_width,
620 ui::ELIDE_AT_END)); 620 gfx::ELIDE_AT_END));
621 } 621 }
622 622
623 // Only show the URL if the url and title differ. 623 // Only show the URL if the url and title differ.
624 if (title != UTF8ToUTF16(url.spec())) { 624 if (title != UTF8ToUTF16(url.spec())) {
625 if (!result.empty()) 625 if (!result.empty())
626 result.push_back('\n'); 626 result.push_back('\n');
627 627
628 // We need to explicitly specify the directionality of the URL's text to 628 // We need to explicitly specify the directionality of the URL's text to
629 // make sure it is treated as an LTR string when the context is RTL. For 629 // make sure it is treated as an LTR string when the context is RTL. For
630 // example, the URL "http://www.yahoo.com/" appears as 630 // example, the URL "http://www.yahoo.com/" appears as
631 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since 631 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since
632 // the Unicode BiDi algorithm puts certain characters on the left by 632 // the Unicode BiDi algorithm puts certain characters on the left by
633 // default. 633 // default.
634 std::string languages = profile->GetPrefs()->GetString( 634 std::string languages = profile->GetPrefs()->GetString(
635 prefs::kAcceptLanguages); 635 prefs::kAcceptLanguages);
636 string16 elided_url(ui::ElideUrl(url, tt_fonts, max_width, languages)); 636 string16 elided_url(gfx::ElideUrl(url, tt_fonts, max_width, languages));
637 elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url); 637 elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url);
638 result.append(elided_url); 638 result.append(elided_url);
639 } 639 }
640 return result; 640 return result;
641 } 641 }
642 642
643 bool BookmarkBarView::IsDetached() const { 643 bool BookmarkBarView::IsDetached() const {
644 return (bookmark_bar_state_ == BookmarkBar::DETACHED) || 644 return (bookmark_bar_state_ == BookmarkBar::DETACHED) ||
645 (animating_detached_ && size_animation_->is_animating()); 645 (animating_detached_ && size_animation_->is_animating());
646 } 646 }
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 DCHECK(apps_page_shortcut_); 1858 DCHECK(apps_page_shortcut_);
1859 // Only perform layout if required. 1859 // Only perform layout if required.
1860 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( 1860 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar(
1861 browser_->profile()); 1861 browser_->profile());
1862 if (apps_page_shortcut_->visible() == visible) 1862 if (apps_page_shortcut_->visible() == visible)
1863 return; 1863 return;
1864 apps_page_shortcut_->SetVisible(visible); 1864 apps_page_shortcut_->SetVisible(visible);
1865 UpdateBookmarksSeparatorVisibility(); 1865 UpdateBookmarksSeparatorVisibility();
1866 Layout(); 1866 Layout();
1867 } 1867 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/back_forward_menu_model.cc ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698