| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 *font = platform_font->DeriveFontWithHeight(font_height, target_style); | 218 *font = platform_font->DeriveFontWithHeight(font_height, target_style); |
| 219 return; | 219 return; |
| 220 } | 220 } |
| 221 | 221 |
| 222 const int current_style = (font->GetStyle() & kStyleMask); | 222 const int current_style = (font->GetStyle() & kStyleMask); |
| 223 const int current_size = font->GetFontSize(); | 223 const int current_size = font->GetFontSize(); |
| 224 if (current_style != target_style || current_size != font_size) | 224 if (current_style != target_style || current_size != font_size) |
| 225 *font = font->DeriveFont(font_size - current_size, font_style); | 225 *font = font->DeriveFont(font_size - current_size, font_style); |
| 226 } | 226 } |
| 227 | 227 |
| 228 // Returns true if |c| is a Unicode BiDi control character. |
| 229 bool IsUnicodeBidiControlCharacter(char16 c) { |
| 230 return c == base::i18n::kRightToLeftMark || |
| 231 c == base::i18n::kLeftToRightMark || |
| 232 c == base::i18n::kLeftToRightEmbeddingMark || |
| 233 c == base::i18n::kRightToLeftEmbeddingMark || |
| 234 c == base::i18n::kPopDirectionalFormatting || |
| 235 c == base::i18n::kLeftToRightOverride || |
| 236 c == base::i18n::kRightToLeftOverride; |
| 237 } |
| 238 |
| 228 } // namespace | 239 } // namespace |
| 229 | 240 |
| 230 namespace internal { | 241 namespace internal { |
| 231 | 242 |
| 232 TextRun::TextRun() | 243 TextRun::TextRun() |
| 233 : strike(false), | 244 : strike(false), |
| 234 underline(false), | 245 underline(false), |
| 235 width(0), | 246 width(0), |
| 236 preceding_run_widths(0), | 247 preceding_run_widths(0), |
| 237 glyph_count(0), | 248 glyph_count(0), |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 | 887 |
| 877 if (run->glyphs[glyph_index] == properties.wgDefault) | 888 if (run->glyphs[glyph_index] == properties.wgDefault) |
| 878 return true; | 889 return true; |
| 879 | 890 |
| 880 // Windows Vista sometimes returns glyphs equal to wgBlank (instead of | 891 // Windows Vista sometimes returns glyphs equal to wgBlank (instead of |
| 881 // wgDefault), with fZeroWidth set. Treat such cases as having missing | 892 // wgDefault), with fZeroWidth set. Treat such cases as having missing |
| 882 // glyphs if the corresponding character is not whitespace. | 893 // glyphs if the corresponding character is not whitespace. |
| 883 // See: http://crbug.com/125629 | 894 // See: http://crbug.com/125629 |
| 884 if (run->glyphs[glyph_index] == properties.wgBlank && | 895 if (run->glyphs[glyph_index] == properties.wgBlank && |
| 885 run->visible_attributes[glyph_index].fZeroWidth && | 896 run->visible_attributes[glyph_index].fZeroWidth && |
| 886 !IsWhitespace(run_text[char_index])) { | 897 !IsWhitespace(run_text[char_index]) && |
| 898 !IsUnicodeBidiControlCharacter(run_text[char_index])) { |
| 887 return true; | 899 return true; |
| 888 } | 900 } |
| 889 } | 901 } |
| 890 | 902 |
| 891 return false; | 903 return false; |
| 892 } | 904 } |
| 893 | 905 |
| 894 const std::vector<Font>* RenderTextWin::GetLinkedFonts(const Font& font) const { | 906 const std::vector<Font>* RenderTextWin::GetLinkedFonts(const Font& font) const { |
| 895 const std::string& font_name = font.GetFontName(); | 907 const std::string& font_name = font.GetFontName(); |
| 896 std::map<std::string, std::vector<Font> >::const_iterator it = | 908 std::map<std::string, std::vector<Font> >::const_iterator it = |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 const internal::TextRun* run) { | 948 const internal::TextRun* run) { |
| 937 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); | 949 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); |
| 938 return SelectionModel(caret, CURSOR_FORWARD); | 950 return SelectionModel(caret, CURSOR_FORWARD); |
| 939 } | 951 } |
| 940 | 952 |
| 941 RenderText* RenderText::CreateRenderText() { | 953 RenderText* RenderText::CreateRenderText() { |
| 942 return new RenderTextWin; | 954 return new RenderTextWin; |
| 943 } | 955 } |
| 944 | 956 |
| 945 } // namespace gfx | 957 } // namespace gfx |
| OLD | NEW |