| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return base::i18n::LEFT_TO_RIGHT; | 93 return base::i18n::LEFT_TO_RIGHT; |
| 94 } | 94 } |
| 95 | 95 |
| 96 Size RenderTextLinux::GetStringSize() { | 96 Size RenderTextLinux::GetStringSize() { |
| 97 EnsureLayout(); | 97 EnsureLayout(); |
| 98 int width = 0, height = 0; | 98 int width = 0, height = 0; |
| 99 pango_layout_get_pixel_size(layout_, &width, &height); | 99 pango_layout_get_pixel_size(layout_, &width, &height); |
| 100 return Size(width, height); | 100 return Size(width, height); |
| 101 } | 101 } |
| 102 | 102 |
| 103 int RenderTextLinux::GetBaseline() { |
| 104 EnsureLayout(); |
| 105 return PANGO_PIXELS(pango_layout_get_baseline(layout_)); |
| 106 } |
| 107 |
| 103 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { | 108 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { |
| 104 EnsureLayout(); | 109 EnsureLayout(); |
| 105 | 110 |
| 106 if (text().empty()) | 111 if (text().empty()) |
| 107 return SelectionModel(0, CURSOR_FORWARD); | 112 return SelectionModel(0, CURSOR_FORWARD); |
| 108 | 113 |
| 109 Point p(ToTextPoint(point)); | 114 Point p(ToTextPoint(point)); |
| 110 | 115 |
| 111 // When the point is outside of text, return HOME/END position. | 116 // When the point is outside of text, return HOME/END position. |
| 112 if (p.x() < 0) | 117 if (p.x() < 0) |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 return bounds; | 549 return bounds; |
| 545 } | 550 } |
| 546 | 551 |
| 547 std::vector<Rect> RenderTextLinux::GetSelectionBounds() { | 552 std::vector<Rect> RenderTextLinux::GetSelectionBounds() { |
| 548 if (selection_visual_bounds_.empty()) | 553 if (selection_visual_bounds_.empty()) |
| 549 selection_visual_bounds_ = CalculateSubstringBounds(selection()); | 554 selection_visual_bounds_ = CalculateSubstringBounds(selection()); |
| 550 return selection_visual_bounds_; | 555 return selection_visual_bounds_; |
| 551 } | 556 } |
| 552 | 557 |
| 553 } // namespace gfx | 558 } // namespace gfx |
| OLD | NEW |