Chromium Code Reviews| Index: ui/gfx/render_text_linux.h |
| =================================================================== |
| --- ui/gfx/render_text_linux.h (revision 97884) |
| +++ ui/gfx/render_text_linux.h (working copy) |
| @@ -6,6 +6,8 @@ |
| #define UI_GFX_RENDER_TEXT_LINUX_H_ |
| #pragma once |
| +#include <pango/pango.h> |
| + |
| #include "ui/gfx/render_text.h" |
| namespace gfx { |
| @@ -16,7 +18,91 @@ |
| RenderTextLinux(); |
| virtual ~RenderTextLinux(); |
| -private: |
| + // Overridden from RenderText: |
| + virtual void SetText(const string16& text) OVERRIDE; |
| + virtual void SetDisplayRect(const Rect&r) OVERRIDE; |
| + virtual void SetCompositionRange(const ui::Range& composition_range) OVERRIDE; |
| + virtual void ApplyStyleRange(StyleRange style_range) OVERRIDE; |
| + virtual void ApplyDefaultStyle() OVERRIDE; |
| + virtual base::i18n::TextDirection GetTextDirection() OVERRIDE; |
| + virtual int GetStringWidth() OVERRIDE; |
| + virtual void Draw(Canvas* canvas) OVERRIDE; |
| + virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; |
| + virtual Rect GetCursorBounds(const SelectionModel& position, |
| + bool insert_mode) OVERRIDE; |
| + |
| + protected: |
| + // Overridden from RenderText: |
| + virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current, |
| + BreakType break_type) OVERRIDE; |
| + virtual SelectionModel GetRightSelectionModel(const SelectionModel& current, |
| + BreakType break_type) OVERRIDE; |
| + virtual size_t GetIndexOfPreviousGrapheme(size_t position) OVERRIDE; |
| + |
| + private: |
| + enum RelativeLogicalPosition { |
| + PREVIOUS, |
| + NEXT |
| + }; |
| + |
| + // Get the SelectionModels corresponding to the left or right text ends. |
| + // The returned value represents a cursor/caret position without a selection. |
| + SelectionModel LeftEndSelectionModel(); |
| + SelectionModel RightEndSelectionModel(); |
| + |
| + // Returns the run that contains |position|. Return NULL if not found. |
| + GSList* GetRunContainingPosition(size_t position) const; |
| + |
| + // Given |utf16_index_of_current_grapheme|, returns the UTF8 or UTF16 index of |
| + // next grapheme in the text if |pos| is NEXT, otherwise, returns the index of |
| + // previous grapheme. Returns 0 if there is no previous grapheme, and returns |
| + // the |text_| length if there is no next grapheme. |
| + size_t Utf8IndexOfAdjacentGrapheme(size_t utf16_index_of_current_grapheme, |
| + RelativeLogicalPosition pos) const; |
| + size_t Utf16IndexOfAdjacentGrapheme(size_t utf16_index_of_current_grapheme, |
| + RelativeLogicalPosition pos) 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; |
| + |
| + // Get the selection model that visually left or right of |current| by one |
|
msw
2011/08/29 20:38:05
remove "that " or change it to "that is".
xji
2011/08/30 00:39:41
Done.
|
| + // grapheme. |
| + // The returned value represents a cursor/caret position without a selection. |
| + SelectionModel LeftSelectionModel(const SelectionModel& current); |
| + SelectionModel RightSelectionModel(const SelectionModel& current); |
| + |
| + // Create, setup, and return pango layout and pango layout line if |layout_| |
| + // is NULL. Otherwise, return the cached |layout_|. |
|
msw
2011/08/29 20:38:05
Can you rephrase this comment? You're not returnin
xji
2011/08/30 00:39:41
Done.
|
| + PangoLayout* EnsureLayout(); |
| + |
| + // Unref |layout_| and |pango_line_|. Set them to NULL. |
| + void ResetLayout(); |
| + |
| + // Setup pango attribute: foreground, background, font, strike. |
| + void SetupPangoAttributes(PangoLayout* layout); |
| + |
| + // Append one pango attribute |pango_attr| into pango attribute list |attrs|. |
| + void AppendPangoAttribute(size_t start, |
| + size_t end, |
| + PangoAttribute* pango_attr, |
| + PangoAttrList* attrs); |
| + |
| + // Returns |run|'s visually previous run. |
| + GSList* GetPreviousRun(GSList* run) const; |
|
msw
2011/08/29 20:38:05
Do you think it's worth warning that this function
xji
2011/08/30 00:39:41
added a comment.
|
| + |
| + // Returns the last run in |layout_line_|. |
|
msw
2011/08/29 20:38:05
Same question about an O(n) warning here.
xji
2011/08/30 00:39:41
Done.
|
| + GSList* GetLastRun() const; |
| + |
| + size_t Utf16IndexToUtf8Index(size_t index) const; |
| + size_t Utf8IndexToUtf16Index(size_t index) const; |
| + |
| + PangoLayout* layout_; |
| + |
| + PangoLayoutLine* layout_line_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); |
| }; |