Chromium Code Reviews| Index: ui/views/controls/styled_label.cc |
| diff --git a/ui/views/controls/styled_label.cc b/ui/views/controls/styled_label.cc |
| index 1b4cf1c93aaa038342e0949d9ce75ff1a78478d3..d157b507a69d338ec38cf1bae008b437e078ea21 100644 |
| --- a/ui/views/controls/styled_label.cc |
| +++ b/ui/views/controls/styled_label.cc |
| @@ -259,11 +259,17 @@ gfx::Size StyledLabel::CalculateAndDoLayout(int width, bool dry_run) { |
| // Iterate over the text, creating a bunch of labels and links and laying them |
| // out in the appropriate positions. |
| while (!remaining_string.empty()) { |
| - // Don't put whitespace at beginning of a line with an exception for the |
| - // first line (so the text's leading whitespace is respected). |
| if (x == 0 && line > 0) { |
| - base::TrimWhitespace(remaining_string, base::TRIM_LEADING, |
| - &remaining_string); |
| + if (remaining_string.front() == L'\n') { |
| + // wrapped to the next line on \n, remove it. Other whitespaces, |
|
Evan Stade
2016/12/06 17:04:47
nit: capitalization
nit: s/whitespaces/whitespace
|
| + // eg, spaces to indent next line, are preserved. |
| + remaining_string.erase(0, 1); |
| + } else { |
| + // wrapped on whitespace character or characters in the middle of the |
|
Evan Stade
2016/12/06 17:04:47
nit: capitalization
|
| + // line - none of them are needed at the beginning of the next line |
|
Evan Stade
2016/12/06 17:04:47
nit: final punctuation
|
| + base::TrimWhitespace(remaining_string, base::TRIM_LEADING, |
| + &remaining_string); |
|
Evan Stade
2016/12/06 17:04:47
nit: indentation
|
| + } |
| } |
| gfx::Range range(gfx::Range::InvalidRange()); |
| @@ -293,13 +299,17 @@ gfx::Size StyledLabel::CalculateAndDoLayout(int width, bool dry_run) { |
| if (substrings.empty() || substrings[0].empty()) { |
| // Nothing fits on this line. Start a new line. |
| // If x is 0, first line may have leading whitespace that doesn't fit in a |
| - // single line, so try trimming those. Otherwise there is no room for |
| - // anything; abort. |
| + // single line, so try trimming those. When first remaining char is \n, |
| + // otput it as empty line. Otherwise there is no room for anything; abort. |
|
Evan Stade
2016/12/06 17:04:47
nit: spelling
nit: "...an empty line"
|
| if (x == 0) { |
| if (line == 0) { |
| base::TrimWhitespace(remaining_string, base::TRIM_LEADING, |
| &remaining_string); |
| continue; |
| + } else if (!remaining_string.empty() && |
| + remaining_string.front() == L'\n') { |
| + line++; |
|
Evan Stade
2016/12/06 17:04:47
nit: ++line (I don't know why we mix line++ and ++
|
| + continue; |
| } |
| break; |
| } |