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

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

Issue 968923004: Use GetDisplayText() instead of text() for rendering text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 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
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_MAC_H_ 5 #ifndef UI_GFX_RENDER_TEXT_MAC_H_
6 #define UI_GFX_RENDER_TEXT_MAC_H_ 6 #define UI_GFX_RENDER_TEXT_MAC_H_
7 7
8 #include <ApplicationServices/ApplicationServices.h> 8 #include <ApplicationServices/ApplicationServices.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 std::vector<Rect> GetSubstringBounds(const Range& range) override; 46 std::vector<Rect> GetSubstringBounds(const Range& range) override;
47 size_t TextIndexToDisplayIndex(size_t index) override; 47 size_t TextIndexToDisplayIndex(size_t index) override;
48 size_t DisplayIndexToTextIndex(size_t index) override; 48 size_t DisplayIndexToTextIndex(size_t index) override;
49 bool IsValidCursorIndex(size_t index) override; 49 bool IsValidCursorIndex(size_t index) override;
50 void OnLayoutTextAttributeChanged(bool text_changed) override; 50 void OnLayoutTextAttributeChanged(bool text_changed) override;
51 void OnDisplayTextAttributeChanged() override; 51 void OnDisplayTextAttributeChanged() override;
52 void EnsureLayout() override; 52 void EnsureLayout() override;
53 void DrawVisualText(Canvas* canvas) override; 53 void DrawVisualText(Canvas* canvas) override;
54 54
55 private: 55 private:
56 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Mac_ElidedText);
57
56 struct TextRun { 58 struct TextRun {
57 CTRunRef ct_run; 59 CTRunRef ct_run;
58 SkPoint origin; 60 SkPoint origin;
59 std::vector<uint16> glyphs; 61 std::vector<uint16> glyphs;
60 std::vector<SkPoint> glyph_positions; 62 std::vector<SkPoint> glyph_positions;
61 SkScalar width; 63 SkScalar width;
62 std::string font_name; 64 std::string font_name;
63 int font_style; 65 int font_style;
64 SkScalar text_size; 66 SkScalar text_size;
65 SkColor foreground; 67 SkColor foreground;
66 bool underline; 68 bool underline;
67 bool strike; 69 bool strike;
68 bool diagonal_strike; 70 bool diagonal_strike;
69 71
70 TextRun(); 72 TextRun();
71 ~TextRun(); 73 ~TextRun();
72 }; 74 };
73 75
76 // Update |string_size_| based on the |layout_text()|.
77 void EnsureStringSize();
78
79 // Creates Core Text line object and its attributes for the given text.
80 void EnsureLayoutInternal(
81 const base::string16& text,
82 base::ScopedCFTypeRef<CTLineRef>* line,
83 base::ScopedCFTypeRef<CFMutableArrayRef>* attributes);
84
74 // Applies RenderText styles to |attr_string| with the given |ct_font|. 85 // Applies RenderText styles to |attr_string| with the given |ct_font|.
75 void ApplyStyles(CFMutableAttributedStringRef attr_string, CTFontRef ct_font); 86 // The computed attributes are stored into |attributes_owner|.
87 void ApplyStyles(CFMutableAttributedStringRef attr_string,
tapted 2015/03/05 06:32:49 declare this as a const function? That would be a
Jun Mukai 2015/03/05 18:01:38 Done.
Jun Mukai 2015/03/05 18:41:38 Oops, this and EnsureLayoutInternal() can't be con
88 CTFontRef ct_font,
89 base::ScopedCFTypeRef<CFMutableArrayRef>* attributes_owner);
tapted 2015/03/05 06:32:49 It should be fine to return a base::ScopedCFTypeRe
Jun Mukai 2015/03/05 18:01:38 Done, but I think EnsureLayoutInternal should sema
76 90
77 // Updates |runs_| based on |line_| and sets |runs_valid_| to true. 91 // Updates |runs_| based on |line_| and sets |runs_valid_| to true.
78 void ComputeRuns(); 92 void ComputeRuns();
79 93
80 // The Core Text line of text. Created by |EnsureLayout()|. 94 // The Core Text line of text. Created by |EnsureLayout()|.
81 base::ScopedCFTypeRef<CTLineRef> line_; 95 base::ScopedCFTypeRef<CTLineRef> line_;
82 96
83 // Array to hold CFAttributedString attributes that allows Core Text to hold 97 // Array to hold CFAttributedString attributes that allows Core Text to hold
84 // weak references to them without leaking. 98 // weak references to them without leaking.
85 base::ScopedCFTypeRef<CFMutableArrayRef> attributes_; 99 base::ScopedCFTypeRef<CFMutableArrayRef> attributes_;
86 100
87 // Visual dimensions of the text. Computed by |EnsureLayout()|. 101 // Visual dimensions of the text. Computed by |EnsureLayout()|.
88 SizeF string_size_; 102 scoped_ptr<SizeF> string_size_;
89 103
90 // Common baseline for this line of text. Computed by |EnsureLayout()|. 104 // Common baseline for this line of text. Computed by |EnsureLayout()|.
91 SkScalar common_baseline_; 105 SkScalar common_baseline_;
92 106
93 // Visual text runs. Only valid if |runs_valid_| is true. Computed by 107 // Visual text runs. Only valid if |runs_valid_| is true. Computed by
94 // |ComputeRuns()|. 108 // |ComputeRuns()|.
95 std::vector<TextRun> runs_; 109 std::vector<TextRun> runs_;
96 110
97 // Indicates that |runs_| are valid, set by |ComputeRuns()|. 111 // Indicates that |runs_| are valid, set by |ComputeRuns()|.
98 bool runs_valid_; 112 bool runs_valid_;
99 113
100 DISALLOW_COPY_AND_ASSIGN(RenderTextMac); 114 DISALLOW_COPY_AND_ASSIGN(RenderTextMac);
101 }; 115 };
102 116
103 } // namespace gfx 117 } // namespace gfx
104 118
105 #endif // UI_GFX_RENDER_TEXT_MAC_H_ 119 #endif // UI_GFX_RENDER_TEXT_MAC_H_
OLDNEW
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/render_text_mac.cc » ('j') | ui/gfx/render_text_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698