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

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

Issue 10696058: Ignore Unicode BiDi control characters in missing glyphs check in RenderTextWin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 *font = platform_font->DeriveFontWithHeight(font_height, target_style); 217 *font = platform_font->DeriveFontWithHeight(font_height, target_style);
218 return; 218 return;
219 } 219 }
220 220
221 const int current_style = (font->GetStyle() & kStyleMask); 221 const int current_style = (font->GetStyle() & kStyleMask);
222 const int current_size = font->GetFontSize(); 222 const int current_size = font->GetFontSize();
223 if (current_style != target_style || current_size != font_size) 223 if (current_style != target_style || current_size != font_size)
224 *font = font->DeriveFont(font_size - current_size, font_style); 224 *font = font->DeriveFont(font_size - current_size, font_style);
225 } 225 }
226 226
227 // Returns true if |c| is a Unicode BiDi control character.
228 bool IsUnicodeBidiControlCharacter(char16 c) {
229 return c == base::i18n::kRightToLeftMark ||
230 c == base::i18n::kLeftToRightMark ||
231 c == base::i18n::kLeftToRightEmbeddingMark ||
232 c == base::i18n::kRightToLeftEmbeddingMark ||
233 c == base::i18n::kPopDirectionalFormatting ||
234 c == base::i18n::kLeftToRightOverride ||
235 c == base::i18n::kRightToLeftOverride;
236 }
237
227 } // namespace 238 } // namespace
228 239
229 namespace internal { 240 namespace internal {
230 241
231 TextRun::TextRun() 242 TextRun::TextRun()
232 : strike(false), 243 : strike(false),
233 underline(false), 244 underline(false),
234 width(0), 245 width(0),
235 preceding_run_widths(0), 246 preceding_run_widths(0),
236 glyph_count(0), 247 glyph_count(0),
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 842
832 const wchar_t* run_text = &(text()[run->range.start()]); 843 const wchar_t* run_text = &(text()[run->range.start()]);
833 for (size_t char_index = 0; char_index < run->range.length(); ++char_index) { 844 for (size_t char_index = 0; char_index < run->range.length(); ++char_index) {
834 const int glyph_index = run->logical_clusters[char_index]; 845 const int glyph_index = run->logical_clusters[char_index];
835 DCHECK_GE(glyph_index, 0); 846 DCHECK_GE(glyph_index, 0);
836 DCHECK_LT(glyph_index, run->glyph_count); 847 DCHECK_LT(glyph_index, run->glyph_count);
837 848
838 if (run->glyphs[glyph_index] == properties.wgDefault) 849 if (run->glyphs[glyph_index] == properties.wgDefault)
839 return true; 850 return true;
840 851
841 // Windows Vista sometimes returns glyphs equal to wgBlank (instead of 852 // Windows Vista sometimes returns glyphs equal to wgBlank (instead of
msw 2012/06/29 23:17:24 Does it make sense to limit this case to Windows V
Alexei Svitkine (slow) 2012/06/29 23:26:03 Yes, I'd rather be safe and check for this always
842 // wgDefault), with fZeroWidth set. Treat such cases as having missing 853 // wgDefault), with fZeroWidth set. Treat such cases as having missing
843 // glyphs if the corresponding character is not whitespace. 854 // glyphs if the corresponding character is not whitespace.
844 // See: http://crbug.com/125629 855 // See: http://crbug.com/125629
845 if (run->glyphs[glyph_index] == properties.wgBlank && 856 if (run->glyphs[glyph_index] == properties.wgBlank &&
846 run->visible_attributes[glyph_index].fZeroWidth && 857 run->visible_attributes[glyph_index].fZeroWidth &&
847 !IsWhitespace(run_text[char_index])) { 858 !IsWhitespace(run_text[char_index]) &&
859 !IsUnicodeBidiControlCharacter(run_text[char_index])) {
xji 2012/06/29 23:13:19 so, it always return wgBlank && fZeroWidth for bid
Alexei Svitkine (slow) 2012/06/29 23:26:03 We don't care about the cases where it doesn't ret
848 return true; 860 return true;
849 } 861 }
850 } 862 }
851 863
852 return false; 864 return false;
853 } 865 }
854 866
855 const std::vector<Font>* RenderTextWin::GetLinkedFonts(const Font& font) const { 867 const std::vector<Font>* RenderTextWin::GetLinkedFonts(const Font& font) const {
856 const std::string& font_name = font.GetFontName(); 868 const std::string& font_name = font.GetFontName();
857 std::map<std::string, std::vector<Font> >::const_iterator it = 869 std::map<std::string, std::vector<Font> >::const_iterator it =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 const internal::TextRun* run) { 909 const internal::TextRun* run) {
898 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); 910 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD);
899 return SelectionModel(caret, CURSOR_FORWARD); 911 return SelectionModel(caret, CURSOR_FORWARD);
900 } 912 }
901 913
902 RenderText* RenderText::CreateRenderText() { 914 RenderText* RenderText::CreateRenderText() {
903 return new RenderTextWin; 915 return new RenderTextWin;
904 } 916 }
905 917
906 } // namespace gfx 918 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698