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 |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 // Rect can't have a negative width.) | 490 // Rect can't have a negative width.) |
| 491 virtual Range GetGlyphBounds(size_t index) = 0; | 491 virtual Range GetGlyphBounds(size_t index) = 0; |
| 492 | 492 |
| 493 const Vector2d& GetUpdatedDisplayOffset(); | 493 const Vector2d& GetUpdatedDisplayOffset(); |
| 494 void SetDisplayOffset(int horizontal_offset); | 494 void SetDisplayOffset(int horizontal_offset); |
| 495 | 495 |
| 496 // Returns the line offset from the origin after applying the text alignment | 496 // Returns the line offset from the origin after applying the text alignment |
| 497 // and the display offset. | 497 // and the display offset. |
| 498 Vector2d GetLineOffset(size_t line_number); | 498 Vector2d GetLineOffset(size_t line_number); |
| 499 | 499 |
| 500 // Retreives the |word| displayed at the given |point|. |point| is in the | |
| 501 // view's coordinates. If no word is displayed at the point, returns a nearby | |
| 502 // word. |baseline_point| should correspond to the left baseline point of the | |
| 503 // leftmost glyph of the |word| in the view's coordinates. Returns false, if | |
| 504 // no word can be retreived. | |
| 505 bool GetWordAtPoint(const Point& point, | |
| 506 NativeStyledString word, | |
| 507 Point* baseline_point); | |
| 508 | |
| 509 // Retreives the text in the given |range|. | |
| 510 base::string16 GetTextFromRange(Range range) const; | |
| 511 | |
| 500 protected: | 512 protected: |
| 501 RenderText(); | 513 RenderText(); |
| 502 | 514 |
| 503 // NOTE: The value of these accessors may be stale. Please make sure | 515 // NOTE: The value of these accessors may be stale. Please make sure |
| 504 // that these fields are up to date before accessing them. | 516 // that these fields are up to date before accessing them. |
| 505 const base::string16& layout_text() const { return layout_text_; } | 517 const base::string16& layout_text() const { return layout_text_; } |
| 506 const base::string16& display_text() const { return display_text_; } | 518 const base::string16& display_text() const { return display_text_; } |
| 507 bool text_elided() const { return text_elided_; } | 519 bool text_elided() const { return text_elided_; } |
| 508 | 520 |
| 509 const BreakList<SkColor>& colors() const { return colors_; } | 521 const BreakList<SkColor>& colors() const { return colors_; } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 // Elides |email| as needed to fit the |available_width|. | 718 // Elides |email| as needed to fit the |available_width|. |
| 707 base::string16 ElideEmail(const base::string16& email, float available_width); | 719 base::string16 ElideEmail(const base::string16& email, float available_width); |
| 708 | 720 |
| 709 // Update the cached bounds and display offset to ensure that the current | 721 // Update the cached bounds and display offset to ensure that the current |
| 710 // cursor is within the visible display area. | 722 // cursor is within the visible display area. |
| 711 void UpdateCachedBoundsAndOffset(); | 723 void UpdateCachedBoundsAndOffset(); |
| 712 | 724 |
| 713 // Draw the selection. | 725 // Draw the selection. |
| 714 void DrawSelection(Canvas* canvas); | 726 void DrawSelection(Canvas* canvas); |
| 715 | 727 |
| 728 // Returns the nearest word start boundary for |index|. First searches in | |
| 729 // CURSOR_BACKWARD direction, then in CURSOR_FORWARD direction. Returns | |
| 730 // text length if no valid boundary is found. | |
| 731 size_t GetNearestWordStartBoundary(size_t index) const; | |
| 732 | |
| 733 // Expands |range| to it's nearest word boundaries and returns the resulting | |
|
tapted
2016/09/21 04:06:55
nit: it's -> its
karandeepb
2016/09/22 08:17:39
Done.
| |
| 734 // range. Maintains directionality of |range|. | |
| 735 Range ExpandRangeToWordBoundary(const Range& range) const; | |
| 736 | |
| 737 // Returns the styled string corresponding to |range|. Returns false if the | |
| 738 // string cannot be retreived, e.g. if the text is obscured. | |
| 739 virtual bool GetStyledStringForRange(const Range& range, | |
|
tapted
2016/09/21 04:06:55
this should be in protected: - private virtuals do
karandeepb
2016/09/22 08:17:39
Shouldn't private virtual functions be preferred,
| |
| 740 NativeStyledString str) const = 0; | |
| 741 | |
| 716 // Logical UTF-16 string data to be drawn. | 742 // Logical UTF-16 string data to be drawn. |
| 717 base::string16 text_; | 743 base::string16 text_; |
| 718 | 744 |
| 719 // Horizontal alignment of the text with respect to |display_rect_|. The | 745 // Horizontal alignment of the text with respect to |display_rect_|. The |
| 720 // default is to align left if the application UI is LTR and right if RTL. | 746 // default is to align left if the application UI is LTR and right if RTL. |
| 721 HorizontalAlignment horizontal_alignment_; | 747 HorizontalAlignment horizontal_alignment_; |
| 722 | 748 |
| 723 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT. | 749 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT. |
| 724 DirectionalityMode directionality_mode_; | 750 DirectionalityMode directionality_mode_; |
| 725 | 751 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 850 // Lines computed by EnsureLayout. These should be invalidated upon | 876 // Lines computed by EnsureLayout. These should be invalidated upon |
| 851 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 877 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
| 852 std::vector<internal::Line> lines_; | 878 std::vector<internal::Line> lines_; |
| 853 | 879 |
| 854 DISALLOW_COPY_AND_ASSIGN(RenderText); | 880 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 855 }; | 881 }; |
| 856 | 882 |
| 857 } // namespace gfx | 883 } // namespace gfx |
| 858 | 884 |
| 859 #endif // UI_GFX_RENDER_TEXT_H_ | 885 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |