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

Side by Side Diff: ui/gfx/render_text_harfbuzz.cc

Issue 993153003: Prevent infinite loop about itemizing text in RenderTextHarfBuzz. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text_harfbuzz.h" 5 #include "ui/gfx/render_text_harfbuzz.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/i18n/bidi_line_iterator.h" 9 #include "base/i18n/bidi_line_iterator.h"
10 #include "base/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 internal::TextRunHarfBuzz* run = new internal::TextRunHarfBuzz; 1158 internal::TextRunHarfBuzz* run = new internal::TextRunHarfBuzz;
1159 run->range.set_start(run_break); 1159 run->range.set_start(run_break);
1160 run->font_style = (style.style(BOLD) ? Font::BOLD : 0) | 1160 run->font_style = (style.style(BOLD) ? Font::BOLD : 0) |
1161 (style.style(ITALIC) ? Font::ITALIC : 0); 1161 (style.style(ITALIC) ? Font::ITALIC : 0);
1162 run->baseline_type = style.baseline(); 1162 run->baseline_type = style.baseline();
1163 run->strike = style.style(STRIKE); 1163 run->strike = style.style(STRIKE);
1164 run->diagonal_strike = style.style(DIAGONAL_STRIKE); 1164 run->diagonal_strike = style.style(DIAGONAL_STRIKE);
1165 run->underline = style.style(UNDERLINE); 1165 run->underline = style.style(UNDERLINE);
1166 int32 script_item_break = 0; 1166 int32 script_item_break = 0;
1167 bidi_iterator.GetLogicalRun(run_break, &script_item_break, &run->level); 1167 bidi_iterator.GetLogicalRun(run_break, &script_item_break, &run->level);
1168
1168 // Odd BiDi embedding levels correspond to RTL runs. 1169 // Odd BiDi embedding levels correspond to RTL runs.
1169 run->is_rtl = (run->level % 2) == 1; 1170 run->is_rtl = (run->level % 2) == 1;
1170 // Find the length and script of this script run. 1171 // Find the length and script of this script run.
1171 script_item_break = ScriptInterval(text, run_break, 1172 script_item_break = ScriptInterval(text, run_break,
1172 script_item_break - run_break, &run->script) + run_break; 1173 script_item_break - run_break, &run->script) + run_break;
1173 1174
1174 // Find the next break and advance the iterators as needed. 1175 // Find the next break and advance the iterators as needed.
1175 run_break = std::min( 1176 run_break = std::min(
1176 static_cast<size_t>(script_item_break), 1177 static_cast<size_t>(script_item_break),
1177 TextIndexToGivenTextIndex(text, style.GetRange().end())); 1178 TextIndexToGivenTextIndex(text, style.GetRange().end()));
1178 1179
1179 // Break runs at certain characters that need to be rendered separately to 1180 // Break runs at certain characters that need to be rendered separately to
1180 // prevent either an unusual character from forcing a fallback font on the 1181 // prevent either an unusual character from forcing a fallback font on the
1181 // entire run, or brackets from being affected by a fallback font. 1182 // entire run, or brackets from being affected by a fallback font.
1182 // http://crbug.com/278913, http://crbug.com/396776 1183 // http://crbug.com/278913, http://crbug.com/396776
1183 if (run_break > run->range.start()) 1184 if (run_break > run->range.start())
1184 run_break = FindRunBreakingCharacter(text, run->range.start(), run_break); 1185 run_break = FindRunBreakingCharacter(text, run->range.start(), run_break);
1185 1186
1187 if (run_break <= run->range.start())
msw 2015/03/18 16:21:36 Why does this ever happen? Can we fix the actual d
Jun Mukai 2015/03/23 23:14:06 It's still unclear why it happens on the reported
1188 run_break = std::max(script_item_break, run_break + 1);
1189
1186 DCHECK(IsValidCodePointIndex(text, run_break)); 1190 DCHECK(IsValidCodePointIndex(text, run_break));
1187 style.UpdatePosition(DisplayIndexToTextIndex(run_break)); 1191 style.UpdatePosition(DisplayIndexToTextIndex(run_break));
1188 run->range.set_end(run_break); 1192 run->range.set_end(run_break);
1189 1193
1190 run_list_out->add(run); 1194 run_list_out->add(run);
1191 } 1195 }
1192 1196
1193 // Undo the temporarily applied composition underlines and selection colors. 1197 // Undo the temporarily applied composition underlines and selection colors.
1194 UndoCompositionAndSelectionStyles(); 1198 UndoCompositionAndSelectionStyles();
1195 1199
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 DCHECK(!update_layout_run_list_); 1496 DCHECK(!update_layout_run_list_);
1493 DCHECK(!update_display_run_list_); 1497 DCHECK(!update_display_run_list_);
1494 return text_elided() ? display_run_list_.get() : &layout_run_list_; 1498 return text_elided() ? display_run_list_.get() : &layout_run_list_;
1495 } 1499 }
1496 1500
1497 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { 1501 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const {
1498 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); 1502 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList();
1499 } 1503 }
1500 1504
1501 } // namespace gfx 1505 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698