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

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

Issue 25039002: Always aligns text at vertically center (Textfield, Label). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 7 years, 1 month 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_win.h ('k') | ui/gfx/text_constants.h » ('j') | 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/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 485 }
486 486
487 RenderTextWin::~RenderTextWin() { 487 RenderTextWin::~RenderTextWin() {
488 } 488 }
489 489
490 Size RenderTextWin::GetStringSize() { 490 Size RenderTextWin::GetStringSize() {
491 EnsureLayout(); 491 EnsureLayout();
492 return multiline_string_size_; 492 return multiline_string_size_;
493 } 493 }
494 494
495 int RenderTextWin::GetBaseline() {
496 EnsureLayout();
497 return lines()[0].baseline;
498 }
499
500 SelectionModel RenderTextWin::FindCursorPosition(const Point& point) { 495 SelectionModel RenderTextWin::FindCursorPosition(const Point& point) {
501 if (text().empty()) 496 if (text().empty())
502 return SelectionModel(); 497 return SelectionModel();
503 498
504 EnsureLayout(); 499 EnsureLayout();
505 // Find the run that contains the point and adjust the argument location. 500 // Find the run that contains the point and adjust the argument location.
506 int x = ToTextPoint(point).x(); 501 int x = ToTextPoint(point).x();
507 size_t run_index = GetRunContainingXCoord(x); 502 size_t run_index = GetRunContainingXCoord(x);
508 if (run_index >= runs_.size()) 503 if (run_index >= runs_.size())
509 return EdgeSelectionModel((x < 0) ? CURSOR_LEFT : CURSOR_RIGHT); 504 return EdgeSelectionModel((x < 0) ? CURSOR_LEFT : CURSOR_RIGHT);
(...skipping 23 matching lines...) Expand all
533 std::vector<RenderText::FontSpan> spans; 528 std::vector<RenderText::FontSpan> spans;
534 for (size_t i = 0; i < runs_.size(); ++i) { 529 for (size_t i = 0; i < runs_.size(); ++i) {
535 spans.push_back(RenderText::FontSpan(runs_[i]->font, 530 spans.push_back(RenderText::FontSpan(runs_[i]->font,
536 Range(LayoutIndexToTextIndex(runs_[i]->range.start()), 531 Range(LayoutIndexToTextIndex(runs_[i]->range.start()),
537 LayoutIndexToTextIndex(runs_[i]->range.end())))); 532 LayoutIndexToTextIndex(runs_[i]->range.end()))));
538 } 533 }
539 534
540 return spans; 535 return spans;
541 } 536 }
542 537
538 int RenderTextWin::GetLayoutTextBaseline() {
539 EnsureLayout();
540 return lines()[0].baseline;
541 }
542
543 SelectionModel RenderTextWin::AdjacentCharSelectionModel( 543 SelectionModel RenderTextWin::AdjacentCharSelectionModel(
544 const SelectionModel& selection, 544 const SelectionModel& selection,
545 VisualCursorDirection direction) { 545 VisualCursorDirection direction) {
546 DCHECK(!needs_layout_); 546 DCHECK(!needs_layout_);
547 internal::TextRun* run; 547 internal::TextRun* run;
548 size_t run_index = GetRunContainingCaret(selection); 548 size_t run_index = GetRunContainingCaret(selection);
549 if (run_index >= runs_.size()) { 549 if (run_index >= runs_.size()) {
550 // The cursor is not in any run: we're at the visual and logical edge. 550 // The cursor is not in any run: we're at the visual and logical edge.
551 SelectionModel edge = EdgeSelectionModel(direction); 551 SelectionModel edge = EdgeSelectionModel(direction);
552 if (edge.caret_pos() == selection.caret_pos()) 552 if (edge.caret_pos() == selection.caret_pos())
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 size_t position = LayoutIndexToTextIndex(run->range.end()); 1210 size_t position = LayoutIndexToTextIndex(run->range.end());
1211 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); 1211 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD);
1212 return SelectionModel(position, CURSOR_FORWARD); 1212 return SelectionModel(position, CURSOR_FORWARD);
1213 } 1213 }
1214 1214
1215 RenderText* RenderText::CreateInstance() { 1215 RenderText* RenderText::CreateInstance() {
1216 return new RenderTextWin; 1216 return new RenderTextWin;
1217 } 1217 }
1218 1218
1219 } // namespace gfx 1219 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text_win.h ('k') | ui/gfx/text_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698