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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <cstring> | 12 #include <cstring> |
13 #include <memory> | 13 #include <memory> |
14 #include <string> | 14 #include <string> |
15 #include <utility> | 15 #include <utility> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/gtest_prod_util.h" | |
19 #include "base/i18n/rtl.h" | 18 #include "base/i18n/rtl.h" |
20 #include "base/macros.h" | 19 #include "base/macros.h" |
21 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
22 #include "third_party/skia/include/core/SkColor.h" | 21 #include "third_party/skia/include/core/SkColor.h" |
23 #include "third_party/skia/include/core/SkPaint.h" | 22 #include "third_party/skia/include/core/SkPaint.h" |
24 #include "third_party/skia/include/core/SkRefCnt.h" | 23 #include "third_party/skia/include/core/SkRefCnt.h" |
25 #include "ui/gfx/break_list.h" | 24 #include "ui/gfx/break_list.h" |
26 #include "ui/gfx/font_list.h" | 25 #include "ui/gfx/font_list.h" |
27 #include "ui/gfx/font_render_params.h" | 26 #include "ui/gfx/font_render_params.h" |
28 #include "ui/gfx/geometry/point.h" | 27 #include "ui/gfx/geometry/point.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 void UpdateStyleLengths(); | 642 void UpdateStyleLengths(); |
644 | 643 |
645 // A convenience function to check whether the glyph attached to the caret | 644 // A convenience function to check whether the glyph attached to the caret |
646 // is within the given range. | 645 // is within the given range. |
647 static bool RangeContainsCaret(const Range& range, | 646 static bool RangeContainsCaret(const Range& range, |
648 size_t caret_pos, | 647 size_t caret_pos, |
649 LogicalCursorDirection caret_affinity); | 648 LogicalCursorDirection caret_affinity); |
650 | 649 |
651 private: | 650 private: |
652 friend class test::RenderTextTestApi; | 651 friend class test::RenderTextTestApi; |
653 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, DefaultStyles); | |
654 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SetStyles); | |
655 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ApplyStyles); | |
656 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, AppendTextKeepsStyles); | |
657 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, ObscuredText); | |
658 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, RevealObscuredText); | |
659 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ElidedText); | |
660 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ElidedObscuredText); | |
661 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, TruncatedText); | |
662 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, TruncatedObscuredText); | |
663 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GraphemePositions); | |
664 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, MinLineHeight); | |
665 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, EdgeSelectionModels); | |
666 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GetTextOffset); | |
667 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GetTextOffsetHorizontalDefaultInRTL); | |
668 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, Multiline_MinWidth); | |
669 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, Multiline_NormalWidth); | |
670 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, Multiline_SufficientWidth); | |
671 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, Multiline_Newline); | |
672 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, Multiline_WordWrapBehavior); | |
673 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, | |
674 Multiline_LineBreakerBehavior); | |
675 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, | |
676 Multiline_SurrogatePairsOrCombiningChars); | |
677 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, Multiline_ZeroWidthChars); | |
678 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, NewlineWithoutMultilineFlag); | |
679 FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, GlyphBounds); | |
680 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, | |
681 MoveCursorLeftRight_MeiryoUILigatures); | |
682 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters); | |
683 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses); | |
684 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks); | |
685 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); | |
686 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth); | |
687 | 652 |
688 // Set the cursor to |position|, with the caret trailing the previous | 653 // Set the cursor to |position|, with the caret trailing the previous |
689 // grapheme, or if there is no previous grapheme, leading the cursor position. | 654 // grapheme, or if there is no previous grapheme, leading the cursor position. |
690 // If |select| is false, the selection start is moved to the same position. | 655 // If |select| is false, the selection start is moved to the same position. |
691 // If the |position| is not a cursorable position (not on grapheme boundary), | 656 // If the |position| is not a cursorable position (not on grapheme boundary), |
692 // it is a NO-OP. | 657 // it is a NO-OP. |
693 void MoveCursorTo(size_t position, bool select); | 658 void MoveCursorTo(size_t position, bool select); |
694 | 659 |
695 // Updates |layout_text_| and |display_text_| as needed (or marks them dirty). | 660 // Updates |layout_text_| and |display_text_| as needed (or marks them dirty). |
696 void OnTextAttributeChanged(); | 661 void OnTextAttributeChanged(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 // Lines computed by EnsureLayout. These should be invalidated upon | 815 // Lines computed by EnsureLayout. These should be invalidated upon |
851 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 816 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
852 std::vector<internal::Line> lines_; | 817 std::vector<internal::Line> lines_; |
853 | 818 |
854 DISALLOW_COPY_AND_ASSIGN(RenderText); | 819 DISALLOW_COPY_AND_ASSIGN(RenderText); |
855 }; | 820 }; |
856 | 821 |
857 } // namespace gfx | 822 } // namespace gfx |
858 | 823 |
859 #endif // UI_GFX_RENDER_TEXT_H_ | 824 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |