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

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

Issue 276123003: Add a unit tests for RenderText::FindCursorPosition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: EnsureLayout in RenderTextWin::GetGlyphBounds; cleanup. Created 6 years, 7 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 | « ui/gfx/render_text_unittest.cc ('k') | 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/i18n/char_iterator.h" 10 #include "base/i18n/char_iterator.h"
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 } else { 651 } else {
652 pos = iter.pos() - iter.GetString().length(); 652 pos = iter.pos() - iter.GetString().length();
653 } 653 }
654 } 654 }
655 } 655 }
656 } 656 }
657 return SelectionModel(pos, CURSOR_FORWARD); 657 return SelectionModel(pos, CURSOR_FORWARD);
658 } 658 }
659 659
660 Range RenderTextWin::GetGlyphBounds(size_t index) { 660 Range RenderTextWin::GetGlyphBounds(size_t index) {
661 EnsureLayout();
661 const size_t run_index = 662 const size_t run_index =
662 GetRunContainingCaret(SelectionModel(index, CURSOR_FORWARD)); 663 GetRunContainingCaret(SelectionModel(index, CURSOR_FORWARD));
663 // Return edge bounds if the index is invalid or beyond the layout text size. 664 // Return edge bounds if the index is invalid or beyond the layout text size.
664 if (run_index >= runs_.size()) 665 if (run_index >= runs_.size())
665 return Range(string_width_); 666 return Range(string_width_);
666 internal::TextRun* run = runs_[run_index]; 667 internal::TextRun* run = runs_[run_index];
667 const size_t layout_index = TextIndexToLayoutIndex(index); 668 const size_t layout_index = TextIndexToLayoutIndex(index);
668 return Range(GetGlyphXBoundary(run, layout_index, false), 669 return Range(GetGlyphXBoundary(run, layout_index, false),
669 GetGlyphXBoundary(run, layout_index, true)); 670 GetGlyphXBoundary(run, layout_index, true));
670 } 671 }
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 size_t position = LayoutIndexToTextIndex(run->range.end()); 1272 size_t position = LayoutIndexToTextIndex(run->range.end());
1272 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); 1273 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD);
1273 return SelectionModel(position, CURSOR_FORWARD); 1274 return SelectionModel(position, CURSOR_FORWARD);
1274 } 1275 }
1275 1276
1276 RenderText* RenderText::CreateInstance() { 1277 RenderText* RenderText::CreateInstance() {
1277 return new RenderTextWin; 1278 return new RenderTextWin;
1278 } 1279 }
1279 1280
1280 } // namespace gfx 1281 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698