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 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // Vertically centered. | 277 // Vertically centered. |
278 int text_y = offset.y() + ((bounds.height() - text_height) / 2); | 278 int text_y = offset.y() + ((bounds.height() - text_height) / 2); |
279 // TODO(xji): need to use SkCanvas->drawPosText() for gpu acceleration. | 279 // TODO(xji): need to use SkCanvas->drawPosText() for gpu acceleration. |
280 cairo_move_to(cr, offset.x(), text_y); | 280 cairo_move_to(cr, offset.x(), text_y); |
281 pango_cairo_show_layout(cr, layout_); | 281 pango_cairo_show_layout(cr, layout_); |
282 | 282 |
283 cairo_restore(cr); | 283 cairo_restore(cr); |
284 } | 284 } |
285 | 285 |
286 size_t RenderTextLinux::IndexOfAdjacentGrapheme(size_t index, bool next) { | 286 size_t RenderTextLinux::IndexOfAdjacentGrapheme(size_t index, bool next) { |
287 if (index > text().length()) | |
288 return text().length(); | |
289 EnsureLayout(); | 287 EnsureLayout(); |
290 return Utf16IndexOfAdjacentGrapheme(Utf16IndexToUtf8Index(index), next); | 288 return Utf16IndexOfAdjacentGrapheme(Utf16IndexToUtf8Index(index), next); |
291 } | 289 } |
292 | 290 |
293 GSList* RenderTextLinux::GetRunContainingPosition(size_t position) const { | 291 GSList* RenderTextLinux::GetRunContainingPosition(size_t position) const { |
294 GSList* run = current_line_->runs; | 292 GSList* run = current_line_->runs; |
295 while (run) { | 293 while (run) { |
296 PangoItem* item = reinterpret_cast<PangoLayoutRun*>(run->data)->item; | 294 PangoItem* item = reinterpret_cast<PangoLayoutRun*>(run->data)->item; |
297 size_t run_start = Utf8IndexToUtf16Index(item->offset); | 295 size_t run_start = Utf8IndexToUtf16Index(item->offset); |
298 size_t run_end = Utf8IndexToUtf16Index(item->offset + item->length); | 296 size_t run_end = Utf8IndexToUtf16Index(item->offset + item->length); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 } | 683 } |
686 | 684 |
687 void RenderTextLinux::GetSelectionBounds(std::vector<Rect>* bounds) { | 685 void RenderTextLinux::GetSelectionBounds(std::vector<Rect>* bounds) { |
688 if (selection_visual_bounds_.empty()) | 686 if (selection_visual_bounds_.empty()) |
689 CalculateSubstringBounds(GetSelectionStart(), GetCursorPosition(), | 687 CalculateSubstringBounds(GetSelectionStart(), GetCursorPosition(), |
690 &selection_visual_bounds_); | 688 &selection_visual_bounds_); |
691 *bounds = selection_visual_bounds_; | 689 *bounds = selection_visual_bounds_; |
692 } | 690 } |
693 | 691 |
694 } // namespace gfx | 692 } // namespace gfx |
OLD | NEW |