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

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

Issue 351963002: RenderTextHarfBuzz: Allow mid-glyph cursors in multi-grapheme clusters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 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
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.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <climits> 8 #include <climits>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 layout_text_.assign( 1226 layout_text_.assign(
1227 Elide(layout_text_, display_rect_.width(), elide_behavior_)); 1227 Elide(layout_text_, display_rect_.width(), elide_behavior_));
1228 } 1228 }
1229 1229
1230 // Replace the newline character with a newline symbol in single line mode. 1230 // Replace the newline character with a newline symbol in single line mode.
1231 static const base::char16 kNewline[] = { '\n', 0 }; 1231 static const base::char16 kNewline[] = { '\n', 0 };
1232 static const base::char16 kNewlineSymbol[] = { 0x2424, 0 }; 1232 static const base::char16 kNewlineSymbol[] = { 0x2424, 0 };
1233 if (!multiline_) 1233 if (!multiline_)
1234 base::ReplaceChars(layout_text_, kNewline, kNewlineSymbol, &layout_text_); 1234 base::ReplaceChars(layout_text_, kNewline, kNewlineSymbol, &layout_text_);
1235 1235
1236 grapheme_iterator_.reset(new base::i18n::BreakIterator(layout_text_,
1237 base::i18n::BreakIterator::BREAK_CHARACTER));
1238 if (!grapheme_iterator_->Init())
1239 grapheme_iterator_.reset();
1240
1236 ResetLayout(); 1241 ResetLayout();
1237 } 1242 }
1238 1243
1239 base::string16 RenderText::Elide(const base::string16& text, 1244 base::string16 RenderText::Elide(const base::string16& text,
1240 float available_width, 1245 float available_width,
1241 ElideBehavior behavior) { 1246 ElideBehavior behavior) {
1242 if (available_width <= 0 || text.empty()) 1247 if (available_width <= 0 || text.empty())
1243 return base::string16(); 1248 return base::string16();
1244 if (behavior == ELIDE_EMAIL) 1249 if (behavior == ELIDE_EMAIL)
1245 return ElideEmail(text, available_width); 1250 return ElideEmail(text, available_width);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 cursor_bounds_ += delta_offset; 1428 cursor_bounds_ += delta_offset;
1424 } 1429 }
1425 1430
1426 void RenderText::DrawSelection(Canvas* canvas) { 1431 void RenderText::DrawSelection(Canvas* canvas) {
1427 const std::vector<Rect> sel = GetSubstringBounds(selection()); 1432 const std::vector<Rect> sel = GetSubstringBounds(selection());
1428 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) 1433 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i)
1429 canvas->FillRect(*i, selection_background_focused_color_); 1434 canvas->FillRect(*i, selection_background_focused_color_);
1430 } 1435 }
1431 1436
1432 } // namespace gfx 1437 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698