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

Unified Diff: ui/views/controls/message_box_view.cc

Issue 327273005: Revert of Use labels to display views tab titles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/message_box_view.cc
diff --git a/ui/views/controls/message_box_view.cc b/ui/views/controls/message_box_view.cc
index 671ca6194ec432baa908efb7eabbc6a81f50f297..20caaa89a025badcdf3b0d1bd513f25d9c310dd4 100644
--- a/ui/views/controls/message_box_view.cc
+++ b/ui/views/controls/message_box_view.cc
@@ -177,13 +177,21 @@
if (params.options & DETECT_DIRECTIONALITY) {
std::vector<base::string16> texts;
SplitStringIntoParagraphs(params.message, &texts);
+ // If the text originates from a web page, its alignment is based on its
+ // first character with strong directionality.
+ base::i18n::TextDirection message_direction =
+ base::i18n::GetFirstStrongCharacterDirection(params.message);
+ gfx::HorizontalAlignment alignment =
+ (message_direction == base::i18n::RIGHT_TO_LEFT) ?
+ gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT;
for (size_t i = 0; i < texts.size(); ++i) {
Label* message_label = new Label(texts[i]);
- // Avoid empty multi-line labels, which have a height of 0.
+ // Don't set multi-line to true if the text is empty, else the label will
+ // have a height of 0.
message_label->SetMultiLine(!texts[i].empty());
message_label->SetAllowCharacterBreak(true);
- message_label->set_directionality_mode(gfx::DIRECTIONALITY_FROM_TEXT);
- message_label->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD);
+ message_label->set_directionality_mode(Label::AUTO_DETECT_DIRECTIONALITY);
+ message_label->SetHorizontalAlignment(alignment);
message_labels_.push_back(message_label);
}
} else {
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698