| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 int length, | 1012 int length, |
| 1013 EWordBreak break_all_or_break_word) { | 1013 EWordBreak break_all_or_break_word) { |
| 1014 DCHECK_GT(length, 0); | 1014 DCHECK_GT(length, 0); |
| 1015 LazyLineBreakIterator break_iterator(layout_text->GetText(), | 1015 LazyLineBreakIterator break_iterator(layout_text->GetText(), |
| 1016 style.LocaleForLineBreakIterator()); | 1016 style.LocaleForLineBreakIterator()); |
| 1017 int next_breakable = -1; | 1017 int next_breakable = -1; |
| 1018 float min = std::numeric_limits<float>::max(); | 1018 float min = std::numeric_limits<float>::max(); |
| 1019 int end = start + length; | 1019 int end = start + length; |
| 1020 for (int i = start; i < end;) { | 1020 for (int i = start; i < end;) { |
| 1021 int fragment_length; | 1021 int fragment_length; |
| 1022 if (break_all_or_break_word == EWordBreak::kBreakAllWordBreak) { | 1022 if (break_all_or_break_word == EWordBreak::kBreakAll) { |
| 1023 break_iterator.IsBreakable(i + 1, next_breakable, | 1023 break_iterator.IsBreakable(i + 1, next_breakable, |
| 1024 LineBreakType::kBreakAll); | 1024 LineBreakType::kBreakAll); |
| 1025 fragment_length = (next_breakable > i ? next_breakable : length) - i; | 1025 fragment_length = (next_breakable > i ? next_breakable : length) - i; |
| 1026 } else { | 1026 } else { |
| 1027 fragment_length = U16_LENGTH(layout_text->CodepointAt(i)); | 1027 fragment_length = U16_LENGTH(layout_text->CodepointAt(i)); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 // Ensure that malformed surrogate pairs don't cause us to read | 1030 // Ensure that malformed surrogate pairs don't cause us to read |
| 1031 // past the end of the string. | 1031 // past the end of the string. |
| 1032 int text_length = layout_text->TextLength(); | 1032 int text_length = layout_text->TextLength(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 text_, style_to_use.LocaleForLineBreakIterator()); | 1115 text_, style_to_use.LocaleForLineBreakIterator()); |
| 1116 bool needs_word_spacing = false; | 1116 bool needs_word_spacing = false; |
| 1117 bool ignoring_spaces = false; | 1117 bool ignoring_spaces = false; |
| 1118 bool is_space = false; | 1118 bool is_space = false; |
| 1119 bool first_word = true; | 1119 bool first_word = true; |
| 1120 bool first_line = true; | 1120 bool first_line = true; |
| 1121 int next_breakable = -1; | 1121 int next_breakable = -1; |
| 1122 int last_word_boundary = 0; | 1122 int last_word_boundary = 0; |
| 1123 float cached_word_trailing_space_width[2] = {0, 0}; // LTR, RTL | 1123 float cached_word_trailing_space_width[2] = {0, 0}; // LTR, RTL |
| 1124 | 1124 |
| 1125 EWordBreak break_all_or_break_word = EWordBreak::kNormalWordBreak; | 1125 EWordBreak break_all_or_break_word = EWordBreak::kNormal; |
| 1126 LineBreakType line_break_type = LineBreakType::kNormal; | 1126 LineBreakType line_break_type = LineBreakType::kNormal; |
| 1127 if (style_to_use.AutoWrap()) { | 1127 if (style_to_use.AutoWrap()) { |
| 1128 if (style_to_use.WordBreak() == kBreakAllWordBreak || | 1128 if (style_to_use.WordBreak() == EWordBreak::kBreakAll || |
| 1129 style_to_use.WordBreak() == kBreakWordBreak) { | 1129 style_to_use.WordBreak() == EWordBreak::kBreakWord) { |
| 1130 break_all_or_break_word = style_to_use.WordBreak(); | 1130 break_all_or_break_word = style_to_use.WordBreak(); |
| 1131 } else if (style_to_use.WordBreak() == kKeepAllWordBreak) { | 1131 } else if (style_to_use.WordBreak() == EWordBreak::kKeepAll) { |
| 1132 line_break_type = LineBreakType::kKeepAll; | 1132 line_break_type = LineBreakType::kKeepAll; |
| 1133 } | 1133 } |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 Hyphenation* hyphenation = | 1136 Hyphenation* hyphenation = |
| 1137 style_to_use.AutoWrap() ? style_to_use.GetHyphenation() : nullptr; | 1137 style_to_use.AutoWrap() ? style_to_use.GetHyphenation() : nullptr; |
| 1138 bool disable_soft_hyphen = style_to_use.GetHyphens() == Hyphens::kNone; | 1138 bool disable_soft_hyphen = style_to_use.GetHyphens() == Hyphens::kNone; |
| 1139 float max_word_width = 0; | 1139 float max_word_width = 0; |
| 1140 if (!hyphenation) | 1140 if (!hyphenation) |
| 1141 max_word_width = std::numeric_limits<float>::infinity(); | 1141 max_word_width = std::numeric_limits<float>::infinity(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 f, i + suffix_start, word_len - suffix_start, lead_width, | 1300 f, i + suffix_start, word_len - suffix_start, lead_width, |
| 1301 curr_max_width, text_direction, &fallback_fonts, &glyph_bounds); | 1301 curr_max_width, text_direction, &fallback_fonts, &glyph_bounds); |
| 1302 max_fragment_width = std::max(max_fragment_width, suffix_width); | 1302 max_fragment_width = std::max(max_fragment_width, suffix_width); |
| 1303 curr_min_width += max_fragment_width - w; | 1303 curr_min_width += max_fragment_width - w; |
| 1304 max_word_width = std::max(max_word_width, max_fragment_width); | 1304 max_word_width = std::max(max_word_width, max_fragment_width); |
| 1305 } else { | 1305 } else { |
| 1306 max_word_width = w; | 1306 max_word_width = w; |
| 1307 } | 1307 } |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 if (break_all_or_break_word != EWordBreak::kNormalWordBreak) { | 1310 if (break_all_or_break_word != EWordBreak::kNormal) { |
| 1311 // Because sum of character widths may not be equal to the word width, | 1311 // Because sum of character widths may not be equal to the word width, |
| 1312 // we need to measure twice; once with normal break for max width, | 1312 // we need to measure twice; once with normal break for max width, |
| 1313 // another with break-all for min width. | 1313 // another with break-all for min width. |
| 1314 curr_min_width = MinWordFragmentWidthForBreakAll( | 1314 curr_min_width = MinWordFragmentWidthForBreakAll( |
| 1315 this, style_to_use, f, text_direction, i, word_len, | 1315 this, style_to_use, f, text_direction, i, word_len, |
| 1316 break_all_or_break_word); | 1316 break_all_or_break_word); |
| 1317 } else { | 1317 } else { |
| 1318 curr_min_width += w; | 1318 curr_min_width += w; |
| 1319 } | 1319 } |
| 1320 if (between_words) { | 1320 if (between_words) { |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 LayoutRect rect = LayoutRect( | 2049 LayoutRect rect = LayoutRect( |
| 2050 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height())); | 2050 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height())); |
| 2051 LayoutBlock* block = ContainingBlock(); | 2051 LayoutBlock* block = ContainingBlock(); |
| 2052 if (block && HasTextBoxes()) | 2052 if (block && HasTextBoxes()) |
| 2053 block->AdjustChildDebugRect(rect); | 2053 block->AdjustChildDebugRect(rect); |
| 2054 | 2054 |
| 2055 return rect; | 2055 return rect; |
| 2056 } | 2056 } |
| 2057 | 2057 |
| 2058 } // namespace blink | 2058 } // namespace blink |
| OLD | NEW |