summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/gfx/chrome_canvas.h4
-rw-r--r--chrome/common/gfx/chrome_canvas_win.cc2
-rw-r--r--chrome/views/controls/label.cc10
-rw-r--r--chrome/views/controls/label.h7
-rw-r--r--chrome/views/controls/message_box_view.cc1
5 files changed, 23 insertions, 1 deletions
diff --git a/chrome/common/gfx/chrome_canvas.h b/chrome/common/gfx/chrome_canvas.h
index dbf9466..a16f9da 100644
--- a/chrome/common/gfx/chrome_canvas.h
+++ b/chrome/common/gfx/chrome_canvas.h
@@ -59,6 +59,10 @@ class ChromeCanvas : public skia::PlatformCanvas {
// Prevent ellipsizing
NO_ELLIPSIS = 512,
+
+ // Specifies if words can be split by new lines.
+ // This only works with MULTI_LINE.
+ CHARACTER_BREAK = 1024,
};
// Creates an empty ChromeCanvas. Callers must use initialize before using
diff --git a/chrome/common/gfx/chrome_canvas_win.cc b/chrome/common/gfx/chrome_canvas_win.cc
index 38446ca..1f14703 100644
--- a/chrome/common/gfx/chrome_canvas_win.cc
+++ b/chrome/common/gfx/chrome_canvas_win.cc
@@ -54,6 +54,8 @@ int ComputeFormatFlags(int flags, const std::wstring& text) {
if (flags & ChromeCanvas::MULTI_LINE) {
f |= DT_WORDBREAK;
+ if (flags & ChromeCanvas::CHARACTER_BREAK)
+ f |= DT_EDITCONTROL;
} else {
f |= DT_SINGLELINE | DT_VCENTER;
if (!(flags & ChromeCanvas::NO_ELLIPSIS))
diff --git a/chrome/views/controls/label.cc b/chrome/views/controls/label.cc
index 7f1a886..f517686 100644
--- a/chrome/views/controls/label.cc
+++ b/chrome/views/controls/label.cc
@@ -45,6 +45,7 @@ void Label::Init(const std::wstring& text, const ChromeFont& font) {
color_ = kEnabledColor;
horiz_alignment_ = ALIGN_CENTER;
is_multi_line_ = false;
+ allow_character_break_ = false;
collapse_when_hidden_ = false;
rtl_alignment_mode_ = USE_UI_ALIGNMENT;
paint_as_focused_ = false;
@@ -80,6 +81,8 @@ gfx::Size Label::GetPreferredSize() {
int Label::ComputeMultiLineFlags() {
int flags = ChromeCanvas::MULTI_LINE;
+ if (allow_character_break_)
+ flags |= ChromeCanvas::CHARACTER_BREAK;
switch (horiz_alignment_) {
case ALIGN_LEFT:
flags |= ChromeCanvas::TEXT_ALIGN_LEFT;
@@ -282,6 +285,13 @@ void Label::SetMultiLine(bool f) {
}
}
+void Label::SetAllowCharacterBreak(bool f) {
+ if (f != allow_character_break_) {
+ allow_character_break_ = f;
+ SchedulePaint();
+ }
+}
+
bool Label::IsMultiLine() {
return is_multi_line_;
}
diff --git a/chrome/views/controls/label.h b/chrome/views/controls/label.h
index fc4f897..b2f1679 100644
--- a/chrome/views/controls/label.h
+++ b/chrome/views/controls/label.h
@@ -121,9 +121,13 @@ class Label : public View {
RTLAlignmentMode GetRTLAlignmentMode() const;
// Set whether the label text can wrap on multiple lines.
- // Default is false
+ // Default is false.
void SetMultiLine(bool f);
+ // Set whether the label text can be split on words.
+ // Default is false. This only works when is_multi_line is true.
+ void SetAllowCharacterBreak(bool f);
+
// Return whether the label text can wrap on multiple lines
bool IsMultiLine();
@@ -217,6 +221,7 @@ class Label : public View {
gfx::Size text_size_;
bool text_size_valid_;
bool is_multi_line_;
+ bool allow_character_break_;
bool url_set_;
Alignment horiz_alignment_;
std::wstring tooltip_text_;
diff --git a/chrome/views/controls/message_box_view.cc b/chrome/views/controls/message_box_view.cc
index 05bc6ac..afa2319 100644
--- a/chrome/views/controls/message_box_view.cc
+++ b/chrome/views/controls/message_box_view.cc
@@ -110,6 +110,7 @@ bool MessageBoxView::AcceleratorPressed(
void MessageBoxView::Init(int dialog_flags,
const std::wstring& default_prompt) {
message_label_->SetMultiLine(true);
+ message_label_->SetAllowCharacterBreak(true);
if (dialog_flags & MessageBoxFlags::kAutoDetectAlignment) {
// Determine the alignment and directionality based on the first character
// with strong directionality.