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

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

Issue 8536047: Separate selection highlight from pango layout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: address comments Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 11
11 #include "ui/gfx/render_text.h" 12 #include "ui/gfx/render_text.h"
12 13
13 namespace gfx { 14 namespace gfx {
14 15
15 // RenderTextLinux is the Linux implementation of RenderText using Pango. 16 // RenderTextLinux is the Linux implementation of RenderText using Pango.
16 class RenderTextLinux : public RenderText { 17 class RenderTextLinux : public RenderText {
17 public: 18 public:
18 RenderTextLinux(); 19 RenderTextLinux();
19 virtual ~RenderTextLinux(); 20 virtual ~RenderTextLinux();
20 21
21 // Overridden from RenderText: 22 // Overridden from RenderText:
22 virtual base::i18n::TextDirection GetTextDirection() OVERRIDE; 23 virtual base::i18n::TextDirection GetTextDirection() OVERRIDE;
23 virtual int GetStringWidth() OVERRIDE; 24 virtual int GetStringWidth() OVERRIDE;
24 virtual void Draw(Canvas* canvas) OVERRIDE; 25 virtual void Draw(Canvas* canvas) OVERRIDE;
25 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; 26 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE;
26 virtual Rect GetCursorBounds(const SelectionModel& position, 27 virtual Rect GetCursorBounds(const SelectionModel& position,
27 bool insert_mode) OVERRIDE; 28 bool insert_mode) OVERRIDE;
28 29
29 protected: 30 protected:
30 // Overridden from RenderText: 31 // Overridden from RenderText:
31 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current, 32 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current,
32 BreakType break_type) OVERRIDE; 33 BreakType break_type) OVERRIDE;
33 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current, 34 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current,
34 BreakType break_type) OVERRIDE; 35 BreakType break_type) OVERRIDE;
35 virtual SelectionModel LeftEndSelectionModel() OVERRIDE; 36 virtual SelectionModel LeftEndSelectionModel() OVERRIDE;
36 virtual SelectionModel RightEndSelectionModel() OVERRIDE; 37 virtual SelectionModel RightEndSelectionModel() OVERRIDE;
38 virtual void GetSubstringBounds(size_t from,
39 size_t to,
40 std::vector<Rect>* bounds) OVERRIDE;
41 virtual void SetSelectionModel(
42 const SelectionModel& selection_model) OVERRIDE;
Alexei Svitkine (slow) 2011/11/29 15:41:37 Nit: If you name the parameter |model|, you can ke
xji 2011/11/29 23:07:15 Done.
37 virtual bool IsCursorablePosition(size_t position) OVERRIDE; 43 virtual bool IsCursorablePosition(size_t position) OVERRIDE;
38 virtual void UpdateLayout() OVERRIDE; 44 virtual void UpdateLayout() OVERRIDE;
45 virtual void DrawVisualText(Canvas* canvas) OVERRIDE;
39 46
40 private: 47 private:
41 virtual size_t IndexOfAdjacentGrapheme(size_t index, bool next) OVERRIDE; 48 virtual size_t IndexOfAdjacentGrapheme(size_t index, bool next) OVERRIDE;
42 49
43 // Returns the run that contains |position|. Return NULL if not found. 50 // Returns the run that contains |position|. Return NULL if not found.
44 GSList* GetRunContainingPosition(size_t position) const; 51 GSList* GetRunContainingPosition(size_t position) const;
45 52
46 // Given |utf8_index_of_current_grapheme|, returns the UTF8 or UTF16 index of 53 // Given |utf8_index_of_current_grapheme|, returns the UTF8 or UTF16 index of
47 // next grapheme in the text if |next| is true, otherwise, returns the index 54 // next grapheme in the text if |next| is true, otherwise, returns the index
48 // of previous grapheme. Returns 0 if there is no previous grapheme, and 55 // of previous grapheme. Returns 0 if there is no previous grapheme, and
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // The complexity is O(n) since it is a single-linked list. 96 // The complexity is O(n) since it is a single-linked list.
90 PangoLayoutRun* GetPreviousRun(PangoLayoutRun* run) const; 97 PangoLayoutRun* GetPreviousRun(PangoLayoutRun* run) const;
91 98
92 // Returns the last run in |current_line_|. 99 // Returns the last run in |current_line_|.
93 // The complexity is O(n) since it is a single-linked list. 100 // The complexity is O(n) since it is a single-linked list.
94 PangoLayoutRun* GetLastRun() const; 101 PangoLayoutRun* GetLastRun() const;
95 102
96 size_t Utf16IndexToUtf8Index(size_t index) const; 103 size_t Utf16IndexToUtf8Index(size_t index) const;
97 size_t Utf8IndexToUtf16Index(size_t index) const; 104 size_t Utf8IndexToUtf16Index(size_t index) const;
98 105
106 // Calculate the visual bounds containing the logical substring within |from|
107 // to |to| into |bounds|.
108 void CalculateSubstringBounds(size_t from,
109 size_t to,
110 std::vector<Rect>* bounds);
111
112 // Save the visual bounds of logical selection into |bounds|.
113 void GetSelectionBounds(std::vector<Rect>* bounds);
114
99 // Pango Layout. 115 // Pango Layout.
100 PangoLayout* layout_; 116 PangoLayout* layout_;
101 // A single line layout resulting from laying out via |layout_|. 117 // A single line layout resulting from laying out via |layout_|.
102 PangoLayoutLine* current_line_; 118 PangoLayoutLine* current_line_;
103 119
104 // Information about character attributes. 120 // Information about character attributes.
105 PangoLogAttr* log_attrs_; 121 PangoLogAttr* log_attrs_;
106 // Number of attributes in |log_attrs_|. 122 // Number of attributes in |log_attrs_|.
107 int num_log_attrs_; 123 int num_log_attrs_;
108 124
125 // Vector of the visual bounds containing the logical substring of selection.
126 std::vector<Rect> selection_visual_bounds_;
127
109 // The text in the |layout_|. 128 // The text in the |layout_|.
110 const char* layout_text_; 129 const char* layout_text_;
111 // The text length. 130 // The text length.
112 size_t layout_text_len_; 131 size_t layout_text_len_;
113 132
114 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); 133 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux);
115 }; 134 };
116 135
117 } // namespace gfx 136 } // namespace gfx
118 137
119 #endif // UI_GFX_RENDER_TEXT_LINUX_H_ 138 #endif // UI_GFX_RENDER_TEXT_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698