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_linux.h" | 5 #include "ui/gfx/render_text_linux.h" |
6 | 6 |
7 #include <pango/pangocairo.h> | 7 #include <pango/pangocairo.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 Point offset(ToViewPoint(Point())); | 82 Point offset(ToViewPoint(Point())); |
83 // Vertically centered. | 83 // Vertically centered. |
84 int text_y = offset.y() + ((bounds.height() - text_height) / 2); | 84 int text_y = offset.y() + ((bounds.height() - text_height) / 2); |
85 // TODO(xji): need to use SkCanvas->drawPosText() for gpu acceleration. | 85 // TODO(xji): need to use SkCanvas->drawPosText() for gpu acceleration. |
86 cairo_move_to(cr, offset.x(), text_y); | 86 cairo_move_to(cr, offset.x(), text_y); |
87 pango_cairo_show_layout(cr, layout); | 87 pango_cairo_show_layout(cr, layout); |
88 | 88 |
89 cairo_restore(cr); | 89 cairo_restore(cr); |
90 | 90 |
91 // Paint cursor. | 91 // Paint cursor. |
| 92 bounds = GetUpdatedCursorBounds(); |
92 if (cursor_visible() && focused()) | 93 if (cursor_visible() && focused()) |
93 canvas->DrawRect(GetUpdatedCursorBounds(), kCursorColor); | 94 canvas->DrawRectInt(kCursorColor, |
| 95 bounds.x(), |
| 96 bounds.y(), |
| 97 bounds.width(), |
| 98 bounds.height()); |
94 } | 99 } |
95 | 100 |
96 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { | 101 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { |
97 PangoLayout* layout = EnsureLayout(); | 102 PangoLayout* layout = EnsureLayout(); |
98 | 103 |
99 if (text().empty()) | 104 if (text().empty()) |
100 return SelectionModel(0, 0, SelectionModel::LEADING); | 105 return SelectionModel(0, 0, SelectionModel::LEADING); |
101 | 106 |
102 Point p(ToTextPoint(point)); | 107 Point p(ToTextPoint(point)); |
103 | 108 |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 size_t RenderTextLinux::Utf8IndexToUtf16Index(size_t index) const { | 651 size_t RenderTextLinux::Utf8IndexToUtf16Index(size_t index) const { |
647 int32_t utf16_index = 0; | 652 int32_t utf16_index = 0; |
648 UErrorCode ec = U_ZERO_ERROR; | 653 UErrorCode ec = U_ZERO_ERROR; |
649 u_strFromUTF8(NULL, 0, &utf16_index, layout_text_, index, &ec); | 654 u_strFromUTF8(NULL, 0, &utf16_index, layout_text_, index, &ec); |
650 DCHECK(ec == U_BUFFER_OVERFLOW_ERROR || | 655 DCHECK(ec == U_BUFFER_OVERFLOW_ERROR || |
651 ec == U_STRING_NOT_TERMINATED_WARNING); | 656 ec == U_STRING_NOT_TERMINATED_WARNING); |
652 return utf16_index; | 657 return utf16_index; |
653 } | 658 } |
654 | 659 |
655 } // namespace gfx | 660 } // namespace gfx |
OLD | NEW |