Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_win.h" | 5 #include "ui/gfx/render_text_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/break_iterator.h" | 9 #include "base/i18n/break_iterator.h" |
| 10 #include "base/i18n/char_iterator.h" | 10 #include "base/i18n/char_iterator.h" |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 run_break = std::min(script_item_break, | 911 run_break = std::min(script_item_break, |
| 912 TextIndexToLayoutIndex(style.GetRange().end())); | 912 TextIndexToLayoutIndex(style.GetRange().end())); |
| 913 | 913 |
| 914 // Clamp run lengths to avoid exceeding the maximum supported glyph count. | 914 // Clamp run lengths to avoid exceeding the maximum supported glyph count. |
| 915 if ((run_break - run->range.start()) > max_run_length) { | 915 if ((run_break - run->range.start()) > max_run_length) { |
| 916 run_break = run->range.start() + max_run_length; | 916 run_break = run->range.start() + max_run_length; |
| 917 if (!IsValidCodePointIndex(layout_text, run_break)) | 917 if (!IsValidCodePointIndex(layout_text, run_break)) |
| 918 --run_break; | 918 --run_break; |
| 919 } | 919 } |
| 920 | 920 |
| 921 // Break runs adjacent to UBLOCK_GEOMETRIC_SHAPES character substrings. | 921 // Break runs adjacent to character substrings in certain code blocks. |
| 922 // This avoids using their fallback fonts for more characters than needed, | 922 // This avoids using their fallback fonts for more characters than needed, |
| 923 // in cases like "\x25B6 Media Title", etc. http://crbug.com/278913 | 923 // in cases like "\x25B6 Media Title", etc. http://crbug.com/278913 |
| 924 if (run_break > run->range.start()) { | 924 if (run_break > run->range.start()) { |
| 925 const size_t run_start = run->range.start(); | 925 const size_t run_start = run->range.start(); |
| 926 const int32 run_length = static_cast<int32>(run_break - run_start); | 926 const int32 run_length = static_cast<int32>(run_break - run_start); |
| 927 base::i18n::UTF16CharIterator iter(layout_text.c_str() + run_start, | 927 base::i18n::UTF16CharIterator iter(layout_text.c_str() + run_start, |
| 928 run_length); | 928 run_length); |
| 929 const UBlockCode first_block_code = ublock_getCode(iter.get()); | 929 const UBlockCode first_block_code = ublock_getCode(iter.get()); |
| 930 while (iter.Advance() && iter.array_pos() < run_length) { | 930 while (iter.Advance() && iter.array_pos() < run_length) { |
| 931 const UBlockCode current_block_code = ublock_getCode(iter.get()); | 931 const UBlockCode current_block_code = ublock_getCode(iter.get()); |
| 932 if (current_block_code != first_block_code && | 932 if (current_block_code != first_block_code && |
| 933 (current_block_code == UBLOCK_GEOMETRIC_SHAPES || | 933 (current_block_code == UBLOCK_GEOMETRIC_SHAPES || |
| 934 first_block_code == UBLOCK_GEOMETRIC_SHAPES)) { | 934 current_block_code == UBLOCK_MISCELLANEOUS_SYMBOLS || |
| 935 first_block_code == UBLOCK_GEOMETRIC_SHAPES || | |
| 936 first_block_code == UBLOCK_MISCELLANEOUS_SYMBOLS)) { | |
|
Alexei Svitkine (slow)
2013/11/04 20:59:15
Since first_block_code doesn't change in the while
msw
2013/11/04 22:22:15
Done; plus I added a helper and refactored a littl
| |
| 935 run_break = run_start + iter.array_pos(); | 937 run_break = run_start + iter.array_pos(); |
| 936 break; | 938 break; |
| 937 } | 939 } |
| 938 } | 940 } |
| 939 } | 941 } |
| 940 | 942 |
| 941 DCHECK(IsValidCodePointIndex(layout_text, run_break)); | 943 DCHECK(IsValidCodePointIndex(layout_text, run_break)); |
| 942 | 944 |
| 943 style.UpdatePosition(LayoutIndexToTextIndex(run_break)); | 945 style.UpdatePosition(LayoutIndexToTextIndex(run_break)); |
| 944 if (script_item_break == run_break) | 946 if (script_item_break == run_break) |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1239 size_t position = LayoutIndexToTextIndex(run->range.end()); | 1241 size_t position = LayoutIndexToTextIndex(run->range.end()); |
| 1240 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); | 1242 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); |
| 1241 return SelectionModel(position, CURSOR_FORWARD); | 1243 return SelectionModel(position, CURSOR_FORWARD); |
| 1242 } | 1244 } |
| 1243 | 1245 |
| 1244 RenderText* RenderText::CreateInstance() { | 1246 RenderText* RenderText::CreateInstance() { |
| 1245 return new RenderTextWin; | 1247 return new RenderTextWin; |
| 1246 } | 1248 } |
| 1247 | 1249 |
| 1248 } // namespace gfx | 1250 } // namespace gfx |
| OLD | NEW |