Chromium Code Reviews| 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" | 18 #include "base/gtest_prod_util.h" |
|
msw
2016/09/15 18:19:37
nit: remove this now?
karandeepb
2016/09/16 01:08:55
Done.
| |
| 19 #include "base/i18n/rtl.h" | 19 #include "base/i18n/rtl.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 22 #include "third_party/skia/include/core/SkColor.h" | 22 #include "third_party/skia/include/core/SkColor.h" |
| 23 #include "third_party/skia/include/core/SkPaint.h" | 23 #include "third_party/skia/include/core/SkPaint.h" |
| 24 #include "third_party/skia/include/core/SkRefCnt.h" | 24 #include "third_party/skia/include/core/SkRefCnt.h" |
| 25 #include "ui/gfx/break_list.h" | 25 #include "ui/gfx/break_list.h" |
| 26 #include "ui/gfx/font_list.h" | 26 #include "ui/gfx/font_list.h" |
| 27 #include "ui/gfx/font_render_params.h" | 27 #include "ui/gfx/font_render_params.h" |
| 28 #include "ui/gfx/geometry/point.h" | 28 #include "ui/gfx/geometry/point.h" |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 void UpdateStyleLengths(); | 643 void UpdateStyleLengths(); |
| 644 | 644 |
| 645 // A convenience function to check whether the glyph attached to the caret | 645 // A convenience function to check whether the glyph attached to the caret |
| 646 // is within the given range. | 646 // is within the given range. |
| 647 static bool RangeContainsCaret(const Range& range, | 647 static bool RangeContainsCaret(const Range& range, |
| 648 size_t caret_pos, | 648 size_t caret_pos, |
| 649 LogicalCursorDirection caret_affinity); | 649 LogicalCursorDirection caret_affinity); |
| 650 | 650 |
| 651 private: | 651 private: |
| 652 friend class test::RenderTextTestApi; | 652 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 | 653 |
| 688 // Set the cursor to |position|, with the caret trailing the previous | 654 // Set the cursor to |position|, with the caret trailing the previous |
| 689 // grapheme, or if there is no previous grapheme, leading the cursor position. | 655 // 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. | 656 // 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), | 657 // If the |position| is not a cursorable position (not on grapheme boundary), |
| 692 // it is a NO-OP. | 658 // it is a NO-OP. |
| 693 void MoveCursorTo(size_t position, bool select); | 659 void MoveCursorTo(size_t position, bool select); |
| 694 | 660 |
| 695 // Updates |layout_text_| and |display_text_| as needed (or marks them dirty). | 661 // Updates |layout_text_| and |display_text_| as needed (or marks them dirty). |
| 696 void OnTextAttributeChanged(); | 662 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 | 816 // Lines computed by EnsureLayout. These should be invalidated upon |
| 851 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 817 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
| 852 std::vector<internal::Line> lines_; | 818 std::vector<internal::Line> lines_; |
| 853 | 819 |
| 854 DISALLOW_COPY_AND_ASSIGN(RenderText); | 820 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 855 }; | 821 }; |
| 856 | 822 |
| 857 } // namespace gfx | 823 } // namespace gfx |
| 858 | 824 |
| 859 #endif // UI_GFX_RENDER_TEXT_H_ | 825 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |