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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 EnsureLayout(); | 229 EnsureLayout(); |
230 int* ranges = NULL; | 230 int* ranges = NULL; |
231 int n_ranges = 0; | 231 int n_ranges = 0; |
232 pango_layout_line_get_x_ranges(current_line_, | 232 pango_layout_line_get_x_ranges(current_line_, |
233 TextIndexToLayoutIndex(range.GetMin()), | 233 TextIndexToLayoutIndex(range.GetMin()), |
234 TextIndexToLayoutIndex(range.GetMax()), | 234 TextIndexToLayoutIndex(range.GetMax()), |
235 &ranges, | 235 &ranges, |
236 &n_ranges); | 236 &n_ranges); |
237 | 237 |
238 int height = 0; | 238 const int height = GetStringSize().height(); |
239 pango_layout_get_pixel_size(layout_, NULL, &height); | |
240 | 239 |
241 std::vector<Rect> bounds; | 240 std::vector<Rect> bounds; |
242 for (int i = 0; i < n_ranges; ++i) { | 241 for (int i = 0; i < n_ranges; ++i) { |
243 // TODO(derat): Support fractional bounds for subpixel positioning? | 242 // TODO(derat): Support fractional bounds for subpixel positioning? |
244 int x = PANGO_PIXELS(ranges[2 * i]); | 243 int x = PANGO_PIXELS(ranges[2 * i]); |
245 int width = PANGO_PIXELS(ranges[2 * i + 1]) - x; | 244 int width = PANGO_PIXELS(ranges[2 * i + 1]) - x; |
246 Rect rect(x, 0, width, height); | 245 Rect rect(x, 0, width, height); |
247 rect.set_origin(ToViewPoint(rect.origin())); | 246 rect.set_origin(ToViewPoint(rect.origin())); |
248 bounds.push_back(rect); | 247 bounds.push_back(rect); |
249 } | 248 } |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 int glyph_index) const { | 504 int glyph_index) const { |
506 return LayoutIndexToTextIndex(run->item->offset + | 505 return LayoutIndexToTextIndex(run->item->offset + |
507 run->glyphs->log_clusters[glyph_index]); | 506 run->glyphs->log_clusters[glyph_index]); |
508 } | 507 } |
509 | 508 |
510 RenderText* RenderText::CreateInstance() { | 509 RenderText* RenderText::CreateInstance() { |
511 return new RenderTextLinux; | 510 return new RenderTextLinux; |
512 } | 511 } |
513 | 512 |
514 } // namespace gfx | 513 } // namespace gfx |
OLD | NEW |