OLD | NEW |
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 bool obscured() const { return obscured_; } | 249 bool obscured() const { return obscured_; } |
250 void SetObscured(bool obscured); | 250 void SetObscured(bool obscured); |
251 | 251 |
252 // Makes a char in obscured text at |index| to be revealed. |index| should be | 252 // Makes a char in obscured text at |index| to be revealed. |index| should be |
253 // a UTF16 text index. If there is a previous revealed index, the previous one | 253 // a UTF16 text index. If there is a previous revealed index, the previous one |
254 // is cleared and only the last set index will be revealed. If |index| is -1 | 254 // is cleared and only the last set index will be revealed. If |index| is -1 |
255 // or out of range, no char will be revealed. The revealed index is also | 255 // or out of range, no char will be revealed. The revealed index is also |
256 // cleared when SetText or SetObscured is called. | 256 // cleared when SetText or SetObscured is called. |
257 void SetObscuredRevealIndex(int index); | 257 void SetObscuredRevealIndex(int index); |
258 | 258 |
259 // TODO(ckocagil): Multiline text rendering is currently only supported on | 259 // TODO(ckocagil): Multiline text rendering is not supported on Mac. |
260 // Windows. Support other platforms. | |
261 bool multiline() const { return multiline_; } | 260 bool multiline() const { return multiline_; } |
262 void SetMultiline(bool multiline); | 261 void SetMultiline(bool multiline); |
263 | 262 |
| 263 // TODO(mukai): ELIDE_LONG_WORDS is not supported. |
| 264 WordWrapBehavior word_wrap_behavior() const { return word_wrap_behavior_; } |
| 265 void SetWordWrapBehavior(WordWrapBehavior behavior); |
| 266 |
264 // Set whether newline characters should be replaced with newline symbols. | 267 // Set whether newline characters should be replaced with newline symbols. |
265 void SetReplaceNewlineCharsWithSymbols(bool replace); | 268 void SetReplaceNewlineCharsWithSymbols(bool replace); |
266 | 269 |
267 // Returns true if this instance supports multiline rendering. | 270 // Returns true if this instance supports multiline rendering. |
268 virtual bool MultilineSupported() const = 0; | 271 virtual bool MultilineSupported() const = 0; |
269 | 272 |
270 // TODO(ckocagil): Add vertical alignment and line spacing support instead. | 273 // TODO(ckocagil): Add vertical alignment and line spacing support instead. |
271 int min_line_height() const { return min_line_height_; } | 274 int min_line_height() const { return min_line_height_; } |
272 void SetMinLineHeight(int line_height); | 275 void SetMinLineHeight(int line_height); |
273 | 276 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, TruncatedObscuredText); | 630 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, TruncatedObscuredText); |
628 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GraphemePositions); | 631 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GraphemePositions); |
629 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, MinLineHeight); | 632 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, MinLineHeight); |
630 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, EdgeSelectionModels); | 633 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, EdgeSelectionModels); |
631 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GetTextOffset); | 634 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GetTextOffset); |
632 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GetTextOffsetHorizontalDefaultInRTL); | 635 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GetTextOffsetHorizontalDefaultInRTL); |
633 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_MinWidth); | 636 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_MinWidth); |
634 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_NormalWidth); | 637 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_NormalWidth); |
635 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_SufficientWidth); | 638 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_SufficientWidth); |
636 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_Newline); | 639 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_Newline); |
| 640 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_WordWrapBehavior); |
637 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, NewlineWithoutMultilineFlag); | 641 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, NewlineWithoutMultilineFlag); |
638 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GlyphBounds); | 642 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GlyphBounds); |
639 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_GlyphBounds); | 643 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_GlyphBounds); |
640 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, | 644 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, |
641 MoveCursorLeftRight_MeiryoUILigatures); | 645 MoveCursorLeftRight_MeiryoUILigatures); |
642 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters); | 646 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters); |
643 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses); | 647 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses); |
644 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks); | 648 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks); |
645 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); | 649 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); |
646 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth); | 650 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 // True if the text is elided given the current behavior and display area. | 759 // True if the text is elided given the current behavior and display area. |
756 bool text_elided_; | 760 bool text_elided_; |
757 | 761 |
758 // The minimum height a line should have. | 762 // The minimum height a line should have. |
759 int min_line_height_; | 763 int min_line_height_; |
760 | 764 |
761 // Whether the text should be broken into multiple lines. Uses the width of | 765 // Whether the text should be broken into multiple lines. Uses the width of |
762 // |display_rect_| as the width cap. | 766 // |display_rect_| as the width cap. |
763 bool multiline_; | 767 bool multiline_; |
764 | 768 |
| 769 // The wrap behavior when the text is broken into lines. Do nothing unless |
| 770 // |multiline_| is set. The default value is IGNORE_LONG_WORDS. |
| 771 WordWrapBehavior word_wrap_behavior_; |
| 772 |
765 // Whether newline characters should be replaced with newline symbols. | 773 // Whether newline characters should be replaced with newline symbols. |
766 bool replace_newline_chars_with_symbols_; | 774 bool replace_newline_chars_with_symbols_; |
767 | 775 |
768 // Set to true to suppress subpixel rendering due to non-font reasons (eg. | 776 // Set to true to suppress subpixel rendering due to non-font reasons (eg. |
769 // if the background is transparent). The default value is false. | 777 // if the background is transparent). The default value is false. |
770 bool subpixel_rendering_suppressed_; | 778 bool subpixel_rendering_suppressed_; |
771 | 779 |
772 // The local display area for rendering the text. | 780 // The local display area for rendering the text. |
773 Rect display_rect_; | 781 Rect display_rect_; |
774 | 782 |
(...skipping 25 matching lines...) Expand all Loading... |
800 // Lines computed by EnsureLayout. These should be invalidated upon | 808 // Lines computed by EnsureLayout. These should be invalidated upon |
801 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 809 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
802 std::vector<internal::Line> lines_; | 810 std::vector<internal::Line> lines_; |
803 | 811 |
804 DISALLOW_COPY_AND_ASSIGN(RenderText); | 812 DISALLOW_COPY_AND_ASSIGN(RenderText); |
805 }; | 813 }; |
806 | 814 |
807 } // namespace gfx | 815 } // namespace gfx |
808 | 816 |
809 #endif // UI_GFX_RENDER_TEXT_H_ | 817 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |