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

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

Issue 9390022: Simplify handling of BiDi cursor movement (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (no changes) Created 8 years, 9 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
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 #ifndef UI_GFX_RENDER_TEXT_LINUX_H_ 5 #ifndef UI_GFX_RENDER_TEXT_LINUX_H_
6 #define UI_GFX_RENDER_TEXT_LINUX_H_ 6 #define UI_GFX_RENDER_TEXT_LINUX_H_
7 #pragma once 7 #pragma once
8 8
9 #include <pango/pango.h> 9 #include <pango/pango.h>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ui/gfx/render_text.h" 12 #include "ui/gfx/render_text.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 15
16 // RenderTextLinux is the Linux implementation of RenderText using Pango. 16 // RenderTextLinux is the Linux implementation of RenderText using Pango.
17 class RenderTextLinux : public RenderText { 17 class RenderTextLinux : public RenderText {
18 public: 18 public:
19 RenderTextLinux(); 19 RenderTextLinux();
20 virtual ~RenderTextLinux(); 20 virtual ~RenderTextLinux();
21 21
22 // Overridden from RenderText: 22 // Overridden from RenderText:
23 virtual base::i18n::TextDirection GetTextDirection() OVERRIDE; 23 virtual base::i18n::TextDirection GetTextDirection() OVERRIDE;
24 virtual int GetStringWidth() OVERRIDE; 24 virtual Size GetStringSize() OVERRIDE;
25 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; 25 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE;
26 virtual Rect GetCursorBounds(const SelectionModel& position,
27 bool insert_mode) OVERRIDE;
28 26
29 protected: 27 protected:
30 // Overridden from RenderText: 28 // Overridden from RenderText:
31 virtual SelectionModel AdjacentCharSelectionModel( 29 virtual SelectionModel AdjacentCharSelectionModel(
32 const SelectionModel& selection, 30 const SelectionModel& selection,
33 VisualCursorDirection direction) OVERRIDE; 31 VisualCursorDirection direction) OVERRIDE;
34 virtual SelectionModel AdjacentWordSelectionModel( 32 virtual SelectionModel AdjacentWordSelectionModel(
35 const SelectionModel& selection, 33 const SelectionModel& selection,
36 VisualCursorDirection direction) OVERRIDE; 34 VisualCursorDirection direction) OVERRIDE;
37 virtual SelectionModel EdgeSelectionModel( 35 virtual void GetGlyphBounds(size_t index,
38 VisualCursorDirection direction) OVERRIDE; 36 ui::Range* xspan,
39 virtual std::vector<Rect> GetSubstringBounds(size_t from, size_t to) OVERRIDE; 37 int* height) OVERRIDE;
38 virtual std::vector<Rect> GetSubstringBounds(ui::Range range) OVERRIDE;
40 virtual void SetSelectionModel(const SelectionModel& model) OVERRIDE; 39 virtual void SetSelectionModel(const SelectionModel& model) OVERRIDE;
41 virtual bool IsCursorablePosition(size_t position) OVERRIDE; 40 virtual bool IsCursorablePosition(size_t position) OVERRIDE;
42 virtual void UpdateLayout() OVERRIDE; 41 virtual void UpdateLayout() OVERRIDE;
43 virtual void EnsureLayout() OVERRIDE; 42 virtual void EnsureLayout() OVERRIDE;
44 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; 43 virtual void DrawVisualText(Canvas* canvas) OVERRIDE;
45 44
46 private: 45 private:
47 virtual size_t IndexOfAdjacentGrapheme( 46 virtual size_t IndexOfAdjacentGrapheme(
48 size_t index, 47 size_t index,
49 LogicalCursorDirection direction) OVERRIDE; 48 LogicalCursorDirection direction) OVERRIDE;
50 49
51 // Returns the run that contains |position|. Return NULL if not found. 50 // Returns the run that contains the character attached to the caret in the
52 GSList* GetRunContainingPosition(size_t position) const; 51 // given selection model. Return NULL if not found.
52 GSList* GetRunContainingCaret(const SelectionModel& caret) const;
53 53
54 // Given a |run|, returns the SelectionModel that contains the logical first 54 // Given a |run|, returns the SelectionModel that contains the logical first
55 // or last caret position inside (not at a boundary of) the run. 55 // or last caret position inside (not at a boundary of) the run.
56 // The returned value represents a cursor/caret position without a selection. 56 // The returned value represents a cursor/caret position without a selection.
57 SelectionModel FirstSelectionModelInsideRun(const PangoItem* run); 57 SelectionModel FirstSelectionModelInsideRun(const PangoItem* run);
58 SelectionModel LastSelectionModelInsideRun(const PangoItem* run); 58 SelectionModel LastSelectionModelInsideRun(const PangoItem* run);
59 59
60 // Unref |layout_| and |pango_line_|. Set them to NULL. 60 // Unref |layout_| and |pango_line_|. Set them to NULL.
61 void ResetLayout(); 61 void ResetLayout();
62 62
63 // Setup pango attribute: foreground, background, font, strike. 63 // Setup pango attribute: foreground, background, font, strike.
64 void SetupPangoAttributes(PangoLayout* layout); 64 void SetupPangoAttributes(PangoLayout* layout);
65 65
66 // Append one pango attribute |pango_attr| into pango attribute list |attrs|. 66 // Append one pango attribute |pango_attr| into pango attribute list |attrs|.
67 void AppendPangoAttribute(size_t start, 67 void AppendPangoAttribute(size_t start,
68 size_t end, 68 size_t end,
69 PangoAttribute* pango_attr, 69 PangoAttribute* pango_attr,
70 PangoAttrList* attrs); 70 PangoAttrList* attrs);
71 71
72 // Convert between indices into text() and indices into |layout_text_|. 72 // Convert between indices into text() and indices into |layout_text_|.
73 size_t TextIndexToLayoutIndex(size_t index) const; 73 size_t TextIndexToLayoutIndex(size_t index) const;
74 size_t LayoutIndexToTextIndex(size_t index) const; 74 size_t LayoutIndexToTextIndex(size_t index) const;
75 75
76 // Calculate the visual bounds containing the logical substring within |from| 76 // Calculate the visual bounds containing the logical substring within the
77 // to |to|. 77 // given range.
78 std::vector<Rect> CalculateSubstringBounds(size_t from, size_t to); 78 std::vector<Rect> CalculateSubstringBounds(ui::Range range);
79 79
80 // Get the visual bounds of the logical selection. 80 // Get the visual bounds of the logical selection.
81 std::vector<Rect> GetSelectionBounds(); 81 std::vector<Rect> GetSelectionBounds();
82 82
83 // Pango Layout. 83 // Pango Layout.
84 PangoLayout* layout_; 84 PangoLayout* layout_;
85 // A single line layout resulting from laying out via |layout_|. 85 // A single line layout resulting from laying out via |layout_|.
86 PangoLayoutLine* current_line_; 86 PangoLayoutLine* current_line_;
87 87
88 // Information about character attributes. 88 // Information about character attributes.
89 PangoLogAttr* log_attrs_; 89 PangoLogAttr* log_attrs_;
90 // Number of attributes in |log_attrs_|. 90 // Number of attributes in |log_attrs_|.
91 int num_log_attrs_; 91 int num_log_attrs_;
92 92
93 // Vector of the visual bounds containing the logical substring of selection. 93 // Vector of the visual bounds containing the logical substring of selection.
94 std::vector<Rect> selection_visual_bounds_; 94 std::vector<Rect> selection_visual_bounds_;
95 95
96 // The text in the |layout_|. 96 // The text in the |layout_|.
97 const char* layout_text_; 97 const char* layout_text_;
98 // The text length. 98 // The text length.
99 size_t layout_text_len_; 99 size_t layout_text_len_;
100 100
101 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); 101 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux);
102 }; 102 };
103 103
104 } // namespace gfx 104 } // namespace gfx
105 105
106 #endif // UI_GFX_RENDER_TEXT_LINUX_H_ 106 #endif // UI_GFX_RENDER_TEXT_LINUX_H_
OLDNEW
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/render_text_linux.cc » ('j') | ui/gfx/render_text_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698