OLD | NEW |
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 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/i18n/bidi_line_iterator.h" | 10 #include "base/i18n/bidi_line_iterator.h" |
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 internal::TextRunHarfBuzz* run = new internal::TextRunHarfBuzz; | 1259 internal::TextRunHarfBuzz* run = new internal::TextRunHarfBuzz; |
1260 run->range.set_start(run_break); | 1260 run->range.set_start(run_break); |
1261 run->font_style = (style.style(BOLD) ? Font::BOLD : 0) | | 1261 run->font_style = (style.style(BOLD) ? Font::BOLD : 0) | |
1262 (style.style(ITALIC) ? Font::ITALIC : 0); | 1262 (style.style(ITALIC) ? Font::ITALIC : 0); |
1263 run->baseline_type = style.baseline(); | 1263 run->baseline_type = style.baseline(); |
1264 run->strike = style.style(STRIKE); | 1264 run->strike = style.style(STRIKE); |
1265 run->diagonal_strike = style.style(DIAGONAL_STRIKE); | 1265 run->diagonal_strike = style.style(DIAGONAL_STRIKE); |
1266 run->underline = style.style(UNDERLINE); | 1266 run->underline = style.style(UNDERLINE); |
1267 int32 script_item_break = 0; | 1267 int32 script_item_break = 0; |
1268 bidi_iterator.GetLogicalRun(run_break, &script_item_break, &run->level); | 1268 bidi_iterator.GetLogicalRun(run_break, &script_item_break, &run->level); |
| 1269 CHECK_GT(static_cast<size_t>(script_item_break), run_break); |
1269 // Odd BiDi embedding levels correspond to RTL runs. | 1270 // Odd BiDi embedding levels correspond to RTL runs. |
1270 run->is_rtl = (run->level % 2) == 1; | 1271 run->is_rtl = (run->level % 2) == 1; |
1271 // Find the length and script of this script run. | 1272 // Find the length and script of this script run. |
1272 script_item_break = ScriptInterval(text, run_break, | 1273 script_item_break = ScriptInterval(text, run_break, |
1273 script_item_break - run_break, &run->script) + run_break; | 1274 script_item_break - run_break, &run->script) + run_break; |
1274 | 1275 |
1275 // Find the next break and advance the iterators as needed. | 1276 // Find the next break and advance the iterators as needed. |
1276 const size_t new_run_break = std::min( | 1277 const size_t new_run_break = std::min( |
1277 static_cast<size_t>(script_item_break), | 1278 static_cast<size_t>(script_item_break), |
1278 TextIndexToGivenTextIndex(text, style.GetRange().end())); | 1279 TextIndexToGivenTextIndex(text, style.GetRange().end())); |
1279 CHECK_NE(new_run_break, run_break) | 1280 CHECK_GT(new_run_break, run_break) |
1280 << "It must proceed! " << text << " " << run_break; | 1281 << "It must proceed! " << text << " " << run_break; |
1281 run_break = new_run_break; | 1282 run_break = new_run_break; |
1282 | 1283 |
1283 // Break runs at certain characters that need to be rendered separately to | 1284 // Break runs at certain characters that need to be rendered separately to |
1284 // prevent either an unusual character from forcing a fallback font on the | 1285 // prevent either an unusual character from forcing a fallback font on the |
1285 // entire run, or brackets from being affected by a fallback font. | 1286 // entire run, or brackets from being affected by a fallback font. |
1286 // http://crbug.com/278913, http://crbug.com/396776 | 1287 // http://crbug.com/278913, http://crbug.com/396776 |
1287 if (run_break > run->range.start()) | 1288 if (run_break > run->range.start()) |
1288 run_break = FindRunBreakingCharacter(text, run->range.start(), run_break); | 1289 run_break = FindRunBreakingCharacter(text, run->range.start(), run_break); |
1289 | 1290 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 DCHECK(!update_layout_run_list_); | 1559 DCHECK(!update_layout_run_list_); |
1559 DCHECK(!update_display_run_list_); | 1560 DCHECK(!update_display_run_list_); |
1560 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1561 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
1561 } | 1562 } |
1562 | 1563 |
1563 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1564 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
1564 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1565 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
1565 } | 1566 } |
1566 | 1567 |
1567 } // namespace gfx | 1568 } // namespace gfx |
OLD | NEW |