| 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(); | |
| 93 if (cursor_visible() && focused()) | 92 if (cursor_visible() && focused()) |
| 94 canvas->DrawRectInt(kCursorColor, | 93 canvas->DrawRect(GetUpdatedCursorBounds(), kCursorColor); |
| 95 bounds.x(), | |
| 96 bounds.y(), | |
| 97 bounds.width(), | |
| 98 bounds.height()); | |
| 99 } | 94 } |
| 100 | 95 |
| 101 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { | 96 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { |
| 102 PangoLayout* layout = EnsureLayout(); | 97 PangoLayout* layout = EnsureLayout(); |
| 103 | 98 |
| 104 if (text().empty()) | 99 if (text().empty()) |
| 105 return SelectionModel(0, 0, SelectionModel::LEADING); | 100 return SelectionModel(0, 0, SelectionModel::LEADING); |
| 106 | 101 |
| 107 Point p(ToTextPoint(point)); | 102 Point p(ToTextPoint(point)); |
| 108 | 103 |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 size_t RenderTextLinux::Utf8IndexToUtf16Index(size_t index) const { | 646 size_t RenderTextLinux::Utf8IndexToUtf16Index(size_t index) const { |
| 652 int32_t utf16_index = 0; | 647 int32_t utf16_index = 0; |
| 653 UErrorCode ec = U_ZERO_ERROR; | 648 UErrorCode ec = U_ZERO_ERROR; |
| 654 u_strFromUTF8(NULL, 0, &utf16_index, layout_text_, index, &ec); | 649 u_strFromUTF8(NULL, 0, &utf16_index, layout_text_, index, &ec); |
| 655 DCHECK(ec == U_BUFFER_OVERFLOW_ERROR || | 650 DCHECK(ec == U_BUFFER_OVERFLOW_ERROR || |
| 656 ec == U_STRING_NOT_TERMINATED_WARNING); | 651 ec == U_STRING_NOT_TERMINATED_WARNING); |
| 657 return utf16_index; | 652 return utf16_index; |
| 658 } | 653 } |
| 659 | 654 |
| 660 } // namespace gfx | 655 } // namespace gfx |
| OLD | NEW |