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 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 static float MinWordFragmentWidthForBreakAll( | 1033 static float MinWordFragmentWidthForBreakAll( |
1034 LayoutText* layout_text, | 1034 LayoutText* layout_text, |
1035 const ComputedStyle& style, | 1035 const ComputedStyle& style, |
1036 const Font& font, | 1036 const Font& font, |
1037 TextDirection text_direction, | 1037 TextDirection text_direction, |
1038 int start, | 1038 int start, |
1039 int length, | 1039 int length, |
1040 EWordBreak break_all_or_break_word) { | 1040 EWordBreak break_all_or_break_word) { |
1041 DCHECK_GT(length, 0); | 1041 DCHECK_GT(length, 0); |
1042 LazyLineBreakIterator break_iterator(layout_text->GetText(), | 1042 LazyLineBreakIterator break_iterator(layout_text->GetText(), |
1043 LocaleForLineBreakIterator(style)); | 1043 style.LocaleForLineBreakIterator()); |
1044 int next_breakable = -1; | 1044 int next_breakable = -1; |
1045 float min = std::numeric_limits<float>::max(); | 1045 float min = std::numeric_limits<float>::max(); |
1046 int end = start + length; | 1046 int end = start + length; |
1047 for (int i = start; i < end;) { | 1047 for (int i = start; i < end;) { |
1048 int fragment_length; | 1048 int fragment_length; |
1049 if (break_all_or_break_word == EWordBreak::kBreakAllWordBreak) { | 1049 if (break_all_or_break_word == EWordBreak::kBreakAllWordBreak) { |
1050 break_iterator.IsBreakable(i + 1, next_breakable, | 1050 break_iterator.IsBreakable(i + 1, next_breakable, |
1051 LineBreakType::kBreakAll); | 1051 LineBreakType::kBreakAll); |
1052 fragment_length = (next_breakable > i ? next_breakable : length) - i; | 1052 fragment_length = (next_breakable > i ? next_breakable : length) - i; |
1053 } else { | 1053 } else { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 if (fragment_width <= minimum_fragment_width_to_consider) | 1103 if (fragment_width <= minimum_fragment_width_to_consider) |
1104 continue; | 1104 continue; |
1105 | 1105 |
1106 max_fragment_width = std::max(max_fragment_width, fragment_width); | 1106 max_fragment_width = std::max(max_fragment_width, fragment_width); |
1107 end = start; | 1107 end = start; |
1108 } | 1108 } |
1109 suffix_start = hyphen_locations.front(); | 1109 suffix_start = hyphen_locations.front(); |
1110 return max_fragment_width + layout_text->HyphenWidth(font, text_direction); | 1110 return max_fragment_width + layout_text->HyphenWidth(font, text_direction); |
1111 } | 1111 } |
1112 | 1112 |
1113 AtomicString LocaleForLineBreakIterator(const ComputedStyle& style) { | |
1114 LineBreakIteratorMode mode = LineBreakIteratorMode::kDefault; | |
1115 switch (style.GetLineBreak()) { | |
1116 default: | |
1117 NOTREACHED(); | |
1118 // Fall through. | |
1119 case kLineBreakAuto: | |
1120 case kLineBreakAfterWhiteSpace: | |
1121 return style.Locale(); | |
1122 case kLineBreakNormal: | |
1123 mode = LineBreakIteratorMode::kNormal; | |
1124 break; | |
1125 case kLineBreakStrict: | |
1126 mode = LineBreakIteratorMode::kStrict; | |
1127 break; | |
1128 case kLineBreakLoose: | |
1129 mode = LineBreakIteratorMode::kLoose; | |
1130 break; | |
1131 } | |
1132 if (const LayoutLocale* locale = style.GetFontDescription().Locale()) | |
1133 return locale->LocaleWithBreakKeyword(mode); | |
1134 return style.Locale(); | |
1135 } | |
1136 | |
1137 void LayoutText::ComputePreferredLogicalWidths( | 1113 void LayoutText::ComputePreferredLogicalWidths( |
1138 float lead_width, | 1114 float lead_width, |
1139 HashSet<const SimpleFontData*>& fallback_fonts, | 1115 HashSet<const SimpleFontData*>& fallback_fonts, |
1140 FloatRect& glyph_bounds) { | 1116 FloatRect& glyph_bounds) { |
1141 DCHECK(has_tab_ || PreferredLogicalWidthsDirty() || | 1117 DCHECK(has_tab_ || PreferredLogicalWidthsDirty() || |
1142 !known_to_have_no_overflow_and_no_fallback_fonts_); | 1118 !known_to_have_no_overflow_and_no_fallback_fonts_); |
1143 | 1119 |
1144 min_width_ = 0; | 1120 min_width_ = 0; |
1145 max_width_ = 0; | 1121 max_width_ = 0; |
1146 first_line_min_width_ = 0; | 1122 first_line_min_width_ = 0; |
1147 last_line_line_min_width_ = 0; | 1123 last_line_line_min_width_ = 0; |
1148 | 1124 |
1149 if (IsBR()) | 1125 if (IsBR()) |
1150 return; | 1126 return; |
1151 | 1127 |
1152 float curr_min_width = 0; | 1128 float curr_min_width = 0; |
1153 float curr_max_width = 0; | 1129 float curr_max_width = 0; |
1154 has_breakable_char_ = false; | 1130 has_breakable_char_ = false; |
1155 has_break_ = false; | 1131 has_break_ = false; |
1156 has_tab_ = false; | 1132 has_tab_ = false; |
1157 has_breakable_start_ = false; | 1133 has_breakable_start_ = false; |
1158 has_breakable_end_ = false; | 1134 has_breakable_end_ = false; |
1159 has_end_white_space_ = false; | 1135 has_end_white_space_ = false; |
1160 | 1136 |
1161 const ComputedStyle& style_to_use = StyleRef(); | 1137 const ComputedStyle& style_to_use = StyleRef(); |
1162 const Font& f = style_to_use.GetFont(); // FIXME: This ignores first-line. | 1138 const Font& f = style_to_use.GetFont(); // FIXME: This ignores first-line. |
1163 float word_spacing = style_to_use.WordSpacing(); | 1139 float word_spacing = style_to_use.WordSpacing(); |
1164 int len = TextLength(); | 1140 int len = TextLength(); |
1165 LazyLineBreakIterator break_iterator( | 1141 LazyLineBreakIterator break_iterator( |
1166 text_, LocaleForLineBreakIterator(style_to_use)); | 1142 text_, style_to_use.LocaleForLineBreakIterator()); |
1167 bool needs_word_spacing = false; | 1143 bool needs_word_spacing = false; |
1168 bool ignoring_spaces = false; | 1144 bool ignoring_spaces = false; |
1169 bool is_space = false; | 1145 bool is_space = false; |
1170 bool first_word = true; | 1146 bool first_word = true; |
1171 bool first_line = true; | 1147 bool first_line = true; |
1172 int next_breakable = -1; | 1148 int next_breakable = -1; |
1173 int last_word_boundary = 0; | 1149 int last_word_boundary = 0; |
1174 float cached_word_trailing_space_width[2] = {0, 0}; // LTR, RTL | 1150 float cached_word_trailing_space_width[2] = {0, 0}; // LTR, RTL |
1175 | 1151 |
1176 EWordBreak break_all_or_break_word = EWordBreak::kNormalWordBreak; | 1152 EWordBreak break_all_or_break_word = EWordBreak::kNormalWordBreak; |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 LayoutRect rect = LayoutRect( | 2100 LayoutRect rect = LayoutRect( |
2125 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height())); | 2101 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height())); |
2126 LayoutBlock* block = ContainingBlock(); | 2102 LayoutBlock* block = ContainingBlock(); |
2127 if (block && HasTextBoxes()) | 2103 if (block && HasTextBoxes()) |
2128 block->AdjustChildDebugRect(rect); | 2104 block->AdjustChildDebugRect(rect); |
2129 | 2105 |
2130 return rect; | 2106 return rect; |
2131 } | 2107 } |
2132 | 2108 |
2133 } // namespace blink | 2109 } // namespace blink |
OLD | NEW |