OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 SkIntToScalar(bounds.bottom()), | 384 SkIntToScalar(bounds.bottom()), |
385 SkIntToScalar(bounds.right()), | 385 SkIntToScalar(bounds.right()), |
386 SkIntToScalar(bounds.y()), | 386 SkIntToScalar(bounds.y()), |
387 paint); | 387 paint); |
388 } | 388 } |
389 | 389 |
390 bounds.set_x(bounds.x() + bounds.width()); | 390 bounds.set_x(bounds.x() + bounds.width()); |
391 } | 391 } |
392 | 392 |
393 // Paint cursor. Replace cursor is drawn as rectangle for now. | 393 // Paint cursor. Replace cursor is drawn as rectangle for now. |
394 Rect cursor(GetUpdatedCursorBounds()); | |
395 if (cursor_visible() && focused()) | 394 if (cursor_visible() && focused()) |
396 canvas->DrawRectInt(kCursorColor, cursor.x(), cursor.y(), | 395 canvas->DrawRect(GetUpdatedCursorBounds(), kCursorColor); |
397 cursor.width(), cursor.height()); | |
398 } | 396 } |
399 | 397 |
400 SelectionModel RenderText::FindCursorPosition(const Point& point) { | 398 SelectionModel RenderText::FindCursorPosition(const Point& point) { |
401 const Font& font = default_style_.font; | 399 const Font& font = default_style_.font; |
402 int left = 0; | 400 int left = 0; |
403 int left_pos = 0; | 401 int left_pos = 0; |
404 int right = font.GetStringWidth(text()); | 402 int right = font.GetStringWidth(text()); |
405 int right_pos = text().length(); | 403 int right_pos = text().length(); |
406 | 404 |
407 int x = point.x() - (display_rect_.x() + GetUpdatedDisplayOffset().x()); | 405 int x = point.x() - (display_rect_.x() + GetUpdatedDisplayOffset().x()); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 // LTR character. | 656 // LTR character. |
659 // | 657 // |
660 // Pan to show the cursor when it overflows to the left. | 658 // Pan to show the cursor when it overflows to the left. |
661 delta_offset = display_rect_.x() - cursor_bounds_.x(); | 659 delta_offset = display_rect_.x() - cursor_bounds_.x(); |
662 } | 660 } |
663 display_offset_.Offset(delta_offset, 0); | 661 display_offset_.Offset(delta_offset, 0); |
664 cursor_bounds_.Offset(delta_offset, 0); | 662 cursor_bounds_.Offset(delta_offset, 0); |
665 } | 663 } |
666 | 664 |
667 } // namespace gfx | 665 } // namespace gfx |
OLD | NEW |