| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 PangoItem* item = reinterpret_cast<PangoLayoutRun*>(run->data)->item; | 199 PangoItem* item = reinterpret_cast<PangoLayoutRun*>(run->data)->item; |
| 200 size_t cursor = cur.caret_pos(); | 200 size_t cursor = cur.caret_pos(); |
| 201 if (IsForwardMotion(direction, item) ? | 201 if (IsForwardMotion(direction, item) ? |
| 202 iter.IsEndOfWord(cursor) : iter.IsStartOfWord(cursor)) | 202 iter.IsEndOfWord(cursor) : iter.IsStartOfWord(cursor)) |
| 203 break; | 203 break; |
| 204 } | 204 } |
| 205 | 205 |
| 206 return cur; | 206 return cur; |
| 207 } | 207 } |
| 208 | 208 |
| 209 void RenderTextLinux::GetGlyphBounds(size_t index, | 209 ui::Range RenderTextLinux::GetGlyphBounds(size_t index) { |
| 210 ui::Range* xspan, | |
| 211 int* height) { | |
| 212 PangoRectangle pos; | 210 PangoRectangle pos; |
| 213 pango_layout_index_to_pos(layout_, TextIndexToLayoutIndex(index), &pos); | 211 pango_layout_index_to_pos(layout_, TextIndexToLayoutIndex(index), &pos); |
| 214 // TODO(derat): Support fractional ranges for subpixel positioning? | 212 // TODO(derat): Support fractional ranges for subpixel positioning? |
| 215 *xspan = ui::Range(PANGO_PIXELS(pos.x), PANGO_PIXELS(pos.x + pos.width)); | 213 return ui::Range(PANGO_PIXELS(pos.x), PANGO_PIXELS(pos.x + pos.width)); |
| 216 *height = PANGO_PIXELS(pos.height); | |
| 217 } | 214 } |
| 218 | 215 |
| 219 std::vector<Rect> RenderTextLinux::GetSubstringBounds(const ui::Range& range) { | 216 std::vector<Rect> RenderTextLinux::GetSubstringBounds(const ui::Range& range) { |
| 220 DCHECK_LE(range.GetMax(), text().length()); | 217 DCHECK_LE(range.GetMax(), text().length()); |
| 221 if (range.is_empty()) | 218 if (range.is_empty()) |
| 222 return std::vector<Rect>(); | 219 return std::vector<Rect>(); |
| 223 | 220 |
| 224 EnsureLayout(); | 221 EnsureLayout(); |
| 225 int* ranges = NULL; | 222 int* ranges = NULL; |
| 226 int n_ranges = 0; | 223 int n_ranges = 0; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 int glyph_index) const { | 495 int glyph_index) const { |
| 499 return LayoutIndexToTextIndex(run->item->offset + | 496 return LayoutIndexToTextIndex(run->item->offset + |
| 500 run->glyphs->log_clusters[glyph_index]); | 497 run->glyphs->log_clusters[glyph_index]); |
| 501 } | 498 } |
| 502 | 499 |
| 503 RenderText* RenderText::CreateInstance() { | 500 RenderText* RenderText::CreateInstance() { |
| 504 return new RenderTextLinux; | 501 return new RenderTextLinux; |
| 505 } | 502 } |
| 506 | 503 |
| 507 } // namespace gfx | 504 } // namespace gfx |
| OLD | NEW |