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

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

Issue 1013543006: [RenderText] Adding vertical alignment options (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed pixel tests on vertical alignment Created 5 years, 8 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_H_ 5 #ifndef UI_GFX_RENDER_TEXT_H_
6 #define UI_GFX_RENDER_TEXT_H_ 6 #define UI_GFX_RENDER_TEXT_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 const base::string16& text() const { return text_; } 208 const base::string16& text() const { return text_; }
209 void SetText(const base::string16& text); 209 void SetText(const base::string16& text);
210 void AppendText(const base::string16& text); 210 void AppendText(const base::string16& text);
211 211
212 HorizontalAlignment horizontal_alignment() const { 212 HorizontalAlignment horizontal_alignment() const {
213 return horizontal_alignment_; 213 return horizontal_alignment_;
214 } 214 }
215 void SetHorizontalAlignment(HorizontalAlignment alignment); 215 void SetHorizontalAlignment(HorizontalAlignment alignment);
216 216
217 VerticalAlignment vertical_alignment() const { return vertical_alignment_; }
218 void SetVerticalAlignment(VerticalAlignment alignment);
219
217 const FontList& font_list() const { return font_list_; } 220 const FontList& font_list() const { return font_list_; }
218 void SetFontList(const FontList& font_list); 221 void SetFontList(const FontList& font_list);
219 222
220 bool cursor_enabled() const { return cursor_enabled_; } 223 bool cursor_enabled() const { return cursor_enabled_; }
221 void SetCursorEnabled(bool cursor_enabled); 224 void SetCursorEnabled(bool cursor_enabled);
222 225
223 bool cursor_visible() const { return cursor_visible_; } 226 bool cursor_visible() const { return cursor_visible_; }
224 void set_cursor_visible(bool visible) { cursor_visible_ = visible; } 227 void set_cursor_visible(bool visible) { cursor_visible_ = visible; }
225 228
226 bool insert_mode() const { return insert_mode_; } 229 bool insert_mode() const { return insert_mode_; }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // TODO(mukai): ELIDE_LONG_WORDS is not supported. 266 // TODO(mukai): ELIDE_LONG_WORDS is not supported.
264 WordWrapBehavior word_wrap_behavior() const { return word_wrap_behavior_; } 267 WordWrapBehavior word_wrap_behavior() const { return word_wrap_behavior_; }
265 void SetWordWrapBehavior(WordWrapBehavior behavior); 268 void SetWordWrapBehavior(WordWrapBehavior behavior);
266 269
267 // Set whether newline characters should be replaced with newline symbols. 270 // Set whether newline characters should be replaced with newline symbols.
268 void SetReplaceNewlineCharsWithSymbols(bool replace); 271 void SetReplaceNewlineCharsWithSymbols(bool replace);
269 272
270 // Returns true if this instance supports multiline rendering. 273 // Returns true if this instance supports multiline rendering.
271 virtual bool MultilineSupported() const = 0; 274 virtual bool MultilineSupported() const = 0;
272 275
273 // TODO(ckocagil): Add vertical alignment and line spacing support instead. 276 // TODO(ckocagil): Add vertical alignment and line spacing support instead.
Jun Mukai 2015/04/02 00:53:12 Please remove this TODO.
274 int min_line_height() const { return min_line_height_; } 277 int min_line_height() const { return min_line_height_; }
275 void SetMinLineHeight(int line_height); 278 void SetMinLineHeight(int line_height);
276 279
277 // Set the maximum length of the layout text, not the actual text. 280 // Set the maximum length of the layout text, not the actual text.
278 // A |length| of 0 forgoes a hard limit, but does not guarantee proper 281 // A |length| of 0 forgoes a hard limit, but does not guarantee proper
279 // functionality of very long strings. Applies to subsequent SetText calls. 282 // functionality of very long strings. Applies to subsequent SetText calls.
280 // WARNING: Only use this for system limits, it lacks complex text support. 283 // WARNING: Only use this for system limits, it lacks complex text support.
281 void set_truncate_length(size_t length) { truncate_length_ = length; } 284 void set_truncate_length(size_t length) { truncate_length_ = length; }
282 285
283 // The display text will be elided to fit |display_rect| using this behavior. 286 // The display text will be elided to fit |display_rect| using this behavior.
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, NewlineWithoutMultilineFlag); 643 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, NewlineWithoutMultilineFlag);
641 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GlyphBounds); 644 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GlyphBounds);
642 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_GlyphBounds); 645 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_GlyphBounds);
643 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, 646 FRIEND_TEST_ALL_PREFIXES(RenderTextTest,
644 MoveCursorLeftRight_MeiryoUILigatures); 647 MoveCursorLeftRight_MeiryoUILigatures);
645 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters); 648 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters);
646 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses); 649 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses);
647 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks); 650 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks);
648 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); 651 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes);
649 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth); 652 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth);
653 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, VerticalAlignment);
650 654
651 // Set the cursor to |position|, with the caret trailing the previous 655 // Set the cursor to |position|, with the caret trailing the previous
652 // grapheme, or if there is no previous grapheme, leading the cursor position. 656 // grapheme, or if there is no previous grapheme, leading the cursor position.
653 // If |select| is false, the selection start is moved to the same position. 657 // If |select| is false, the selection start is moved to the same position.
654 // If the |position| is not a cursorable position (not on grapheme boundary), 658 // If the |position| is not a cursorable position (not on grapheme boundary),
655 // it is a NO-OP. 659 // it is a NO-OP.
656 void MoveCursorTo(size_t position, bool select); 660 void MoveCursorTo(size_t position, bool select);
657 661
658 // Updates |layout_text_| and |display_text_| as needed (or marks them dirty). 662 // Updates |layout_text_| and |display_text_| as needed (or marks them dirty).
659 void OnTextAttributeChanged(); 663 void OnTextAttributeChanged();
(...skipping 16 matching lines...) Expand all
676 // Draw the selection. 680 // Draw the selection.
677 void DrawSelection(Canvas* canvas); 681 void DrawSelection(Canvas* canvas);
678 682
679 // Logical UTF-16 string data to be drawn. 683 // Logical UTF-16 string data to be drawn.
680 base::string16 text_; 684 base::string16 text_;
681 685
682 // Horizontal alignment of the text with respect to |display_rect_|. The 686 // Horizontal alignment of the text with respect to |display_rect_|. The
683 // default is to align left if the application UI is LTR and right if RTL. 687 // default is to align left if the application UI is LTR and right if RTL.
684 HorizontalAlignment horizontal_alignment_; 688 HorizontalAlignment horizontal_alignment_;
685 689
690 // Vertical alignment of the text with respect to |display_rect_|. The
691 // default is to vertically align middle.
692 VerticalAlignment vertical_alignment_;
693
686 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT. 694 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT.
687 DirectionalityMode directionality_mode_; 695 DirectionalityMode directionality_mode_;
688 696
689 // The cached text direction, potentially computed from the text or UI locale. 697 // The cached text direction, potentially computed from the text or UI locale.
690 // Use GetTextDirection(), do not use this potentially invalid value directly! 698 // Use GetTextDirection(), do not use this potentially invalid value directly!
691 base::i18n::TextDirection text_direction_; 699 base::i18n::TextDirection text_direction_;
692 700
693 // A list of fonts used to render |text_|. 701 // A list of fonts used to render |text_|.
694 FontList font_list_; 702 FontList font_list_;
695 703
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 // Lines computed by EnsureLayout. These should be invalidated upon 815 // Lines computed by EnsureLayout. These should be invalidated upon
808 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. 816 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls.
809 std::vector<internal::Line> lines_; 817 std::vector<internal::Line> lines_;
810 818
811 DISALLOW_COPY_AND_ASSIGN(RenderText); 819 DISALLOW_COPY_AND_ASSIGN(RenderText);
812 }; 820 };
813 821
814 } // namespace gfx 822 } // namespace gfx
815 823
816 #endif // UI_GFX_RENDER_TEXT_H_ 824 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698