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

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

Issue 8747001: Reintroduce password support to NativeTextfieldViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: new implementation, linux only Created 8 years, 10 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>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; 44 virtual void DrawVisualText(Canvas* canvas) OVERRIDE;
45 45
46 private: 46 private:
47 virtual size_t IndexOfAdjacentGrapheme( 47 virtual size_t IndexOfAdjacentGrapheme(
48 size_t index, 48 size_t index,
49 LogicalCursorDirection direction) OVERRIDE; 49 LogicalCursorDirection direction) OVERRIDE;
50 50
51 // Returns the run that contains |position|. Return NULL if not found. 51 // Returns the run that contains |position|. Return NULL if not found.
52 GSList* GetRunContainingPosition(size_t position) const; 52 GSList* GetRunContainingPosition(size_t position) const;
53 53
54 // Given |utf8_index_of_current_grapheme|, returns the UTF-8 index of the
55 // |next| or previous grapheme in logical order. Returns 0 if there is no
56 // previous grapheme, or the |text_| length if there is no next grapheme.
57 size_t Utf8IndexOfAdjacentGrapheme(size_t utf8_index_of_current_grapheme,
58 LogicalCursorDirection direction) const;
59
60 // Given a |run|, returns the SelectionModel that contains the logical first 54 // Given a |run|, returns the SelectionModel that contains the logical first
61 // 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.
62 // The returned value represents a cursor/caret position without a selection. 56 // The returned value represents a cursor/caret position without a selection.
63 SelectionModel FirstSelectionModelInsideRun(const PangoItem* run) const; 57 SelectionModel FirstSelectionModelInsideRun(const PangoItem* run);
64 SelectionModel LastSelectionModelInsideRun(const PangoItem* run) const; 58 SelectionModel LastSelectionModelInsideRun(const PangoItem* run);
65 59
66 // Unref |layout_| and |pango_line_|. Set them to NULL. 60 // Unref |layout_| and |pango_line_|. Set them to NULL.
67 void ResetLayout(); 61 void ResetLayout();
68 62
69 // Setup pango attribute: foreground, background, font, strike. 63 // Setup pango attribute: foreground, background, font, strike.
70 void SetupPangoAttributes(PangoLayout* layout); 64 void SetupPangoAttributes(PangoLayout* layout);
71 65
72 // Append one pango attribute |pango_attr| into pango attribute list |attrs|. 66 // Append one pango attribute |pango_attr| into pango attribute list |attrs|.
73 void AppendPangoAttribute(size_t start, 67 void AppendPangoAttribute(size_t start,
74 size_t end, 68 size_t end,
75 PangoAttribute* pango_attr, 69 PangoAttribute* pango_attr,
76 PangoAttrList* attrs); 70 PangoAttrList* attrs);
77 71
78 size_t Utf16IndexToUtf8Index(size_t index) const; 72 // These functions convert between indices into text() and indices into
79 size_t Utf8IndexToUtf16Index(size_t index) const; 73 // layout_text_.
msw 2012/02/22 00:33:26 barify |layout_text_|; consider one-liner: // Conv
benrg 2012/02/24 19:07:44 Done.
74 size_t TextIndexToLayoutIndex(size_t index) const;
75 size_t LayoutIndexToTextIndex(size_t index) const;
80 76
81 // Calculate the visual bounds containing the logical substring within |from| 77 // Calculate the visual bounds containing the logical substring within |from|
82 // to |to|. 78 // to |to|.
83 std::vector<Rect> CalculateSubstringBounds(size_t from, size_t to); 79 std::vector<Rect> CalculateSubstringBounds(size_t from, size_t to);
84 80
85 // Get the visual bounds of the logical selection. 81 // Get the visual bounds of the logical selection.
86 std::vector<Rect> GetSelectionBounds(); 82 std::vector<Rect> GetSelectionBounds();
87 83
88 // Pango Layout. 84 // Pango Layout.
89 PangoLayout* layout_; 85 PangoLayout* layout_;
90 // A single line layout resulting from laying out via |layout_|. 86 // A single line layout resulting from laying out via |layout_|.
91 PangoLayoutLine* current_line_; 87 PangoLayoutLine* current_line_;
92 88
93 // Information about character attributes. 89 // Information about character attributes.
94 PangoLogAttr* log_attrs_; 90 PangoLogAttr* log_attrs_;
95 // Number of attributes in |log_attrs_|. 91 // Number of attributes in |log_attrs_|.
96 int num_log_attrs_; 92 int num_log_attrs_;
97 93
98 // Vector of the visual bounds containing the logical substring of selection. 94 // Vector of the visual bounds containing the logical substring of selection.
99 std::vector<Rect> selection_visual_bounds_; 95 std::vector<Rect> selection_visual_bounds_;
100 96
101 // The text in the |layout_|. 97 // The text in the |layout_|.
102 const char* layout_text_; 98 const char* layout_text_;
103 // The text length. 99 // The text length.
104 size_t layout_text_len_; 100 size_t layout_text_len_;
105 101
102 // Corresponding indices from the last call of |TextIndexToLayoutIndex| or
103 // |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
104 // functions in a loop are O(n) instead of O(n^2).
105 mutable size_t last_text_index_;
106 mutable const char* last_layout_pointer_;
107
106 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); 108 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux);
107 }; 109 };
108 110
109 } // namespace gfx 111 } // namespace gfx
110 112
111 #endif // UI_GFX_RENDER_TEXT_LINUX_H_ 113 #endif // UI_GFX_RENDER_TEXT_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698