Chromium Code Reviews| Index: ui/gfx/render_text_linux.h |
| diff --git a/ui/gfx/render_text_linux.h b/ui/gfx/render_text_linux.h |
| index 79c87b002d2e2494d91860400fa52ae0387b9cfd..066914d7906259226b8fd348661a804ff474f62e 100644 |
| --- a/ui/gfx/render_text_linux.h |
| +++ b/ui/gfx/render_text_linux.h |
| @@ -51,17 +51,11 @@ class RenderTextLinux : public RenderText { |
| // Returns the run that contains |position|. Return NULL if not found. |
| GSList* GetRunContainingPosition(size_t position) const; |
| - // Given |utf8_index_of_current_grapheme|, returns the UTF-8 index of the |
| - // |next| or previous grapheme in logical order. Returns 0 if there is no |
| - // previous grapheme, or the |text_| length if there is no next grapheme. |
| - size_t Utf8IndexOfAdjacentGrapheme(size_t utf8_index_of_current_grapheme, |
| - LogicalCursorDirection direction) const; |
| - |
| // Given a |run|, returns the SelectionModel that contains the logical first |
| // or last caret position inside (not at a boundary of) the run. |
| // The returned value represents a cursor/caret position without a selection. |
| - SelectionModel FirstSelectionModelInsideRun(const PangoItem* run) const; |
| - SelectionModel LastSelectionModelInsideRun(const PangoItem* run) const; |
| + SelectionModel FirstSelectionModelInsideRun(const PangoItem* run); |
| + SelectionModel LastSelectionModelInsideRun(const PangoItem* run); |
| // Unref |layout_| and |pango_line_|. Set them to NULL. |
| void ResetLayout(); |
| @@ -75,8 +69,10 @@ class RenderTextLinux : public RenderText { |
| PangoAttribute* pango_attr, |
| PangoAttrList* attrs); |
| - size_t Utf16IndexToUtf8Index(size_t index) const; |
| - size_t Utf8IndexToUtf16Index(size_t index) const; |
| + // These functions convert between indices into text() and indices into |
| + // layout_text_. |
|
msw
2012/02/22 00:33:26
barify |layout_text_|; consider one-liner:
// Conv
benrg
2012/02/24 19:07:44
Done.
|
| + size_t TextIndexToLayoutIndex(size_t index) const; |
| + size_t LayoutIndexToTextIndex(size_t index) const; |
| // Calculate the visual bounds containing the logical substring within |from| |
| // to |to|. |
| @@ -103,6 +99,12 @@ class RenderTextLinux : public RenderText { |
| // The text length. |
| size_t layout_text_len_; |
| + // Corresponding indices from the last call of |TextIndexToLayoutIndex| or |
| + // |LayoutIndexToTextIndex|, cached so that algorithms that call these |
|
msw
2012/02/22 00:33:26
If either of these functions are called consecutiv
benrg
2012/02/22 02:25:43
Relative to caching offsets within each loop, it's
|
| + // functions in a loop are O(n) instead of O(n^2). |
| + mutable size_t last_text_index_; |
| + mutable const char* last_layout_pointer_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); |
| }; |