| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 Point offset(ToViewPoint(Point())); | 107 Point offset(ToViewPoint(Point())); |
| 108 // Vertically centered. | 108 // Vertically centered. |
| 109 int text_y = offset.y() + ((bounds.height() - text_height) / 2); | 109 int text_y = offset.y() + ((bounds.height() - text_height) / 2); |
| 110 // TODO(xji): need to use SkCanvas->drawPosText() for gpu acceleration. | 110 // TODO(xji): need to use SkCanvas->drawPosText() for gpu acceleration. |
| 111 cairo_move_to(cr, offset.x(), text_y); | 111 cairo_move_to(cr, offset.x(), text_y); |
| 112 pango_cairo_show_layout(cr, layout); | 112 pango_cairo_show_layout(cr, layout); |
| 113 | 113 |
| 114 cairo_restore(cr); | 114 cairo_restore(cr); |
| 115 | 115 |
| 116 // Paint cursor. | 116 // Paint cursor. |
| 117 bounds = GetUpdatedCursorBounds(); | |
| 118 if (cursor_visible() && focused()) | 117 if (cursor_visible() && focused()) |
| 119 canvas->DrawRectInt(kCursorColor, | 118 canvas->DrawRect(kCursorColor, GetUpdatedCursorBounds()); |
| 120 bounds.x(), | |
| 121 bounds.y(), | |
| 122 bounds.width(), | |
| 123 bounds.height()); | |
| 124 } | 119 } |
| 125 | 120 |
| 126 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { | 121 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { |
| 127 PangoLayout* layout = EnsureLayout(); | 122 PangoLayout* layout = EnsureLayout(); |
| 128 | 123 |
| 129 if (text().empty()) | 124 if (text().empty()) |
| 130 return SelectionModel(0, 0, SelectionModel::LEADING); | 125 return SelectionModel(0, 0, SelectionModel::LEADING); |
| 131 | 126 |
| 132 Point p(ToTextPoint(point)); | 127 Point p(ToTextPoint(point)); |
| 133 | 128 |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 size_t RenderTextLinux::Utf8IndexToUtf16Index(size_t index) const { | 667 size_t RenderTextLinux::Utf8IndexToUtf16Index(size_t index) const { |
| 673 int32_t utf16_index = 0; | 668 int32_t utf16_index = 0; |
| 674 UErrorCode ec = U_ZERO_ERROR; | 669 UErrorCode ec = U_ZERO_ERROR; |
| 675 u_strFromUTF8(NULL, 0, &utf16_index, layout_text_, index, &ec); | 670 u_strFromUTF8(NULL, 0, &utf16_index, layout_text_, index, &ec); |
| 676 DCHECK(ec == U_BUFFER_OVERFLOW_ERROR || | 671 DCHECK(ec == U_BUFFER_OVERFLOW_ERROR || |
| 677 ec == U_STRING_NOT_TERMINATED_WARNING); | 672 ec == U_STRING_NOT_TERMINATED_WARNING); |
| 678 return utf16_index; | 673 return utf16_index; |
| 679 } | 674 } |
| 680 | 675 |
| 681 } // namespace gfx | 676 } // namespace gfx |
| OLD | NEW |