Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: ui/gfx/render_text_linux.cc

Issue 15746013: Fix cursor positioning regression from r201136. GetCursorPos() shouldn't assume (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/render_text_linux.h ('k') | ui/gfx/render_text_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/gfx/render_text_linux.h ('k') | ui/gfx/render_text_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698