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

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

Issue 2348143003: MacViews: Implement Force Touch/Mac dictionary lookup for Textfields. (Closed)
Patch Set: Views export, reduntant forward decl. Created 4 years, 2 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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 28 matching lines...) Expand all
39 struct SkPoint; 39 struct SkPoint;
40 class SkShader; 40 class SkShader;
41 class SkTypeface; 41 class SkTypeface;
42 42
43 namespace gfx { 43 namespace gfx {
44 namespace test { 44 namespace test {
45 class RenderTextTestApi; 45 class RenderTextTestApi;
46 } 46 }
47 47
48 class Canvas; 48 class Canvas;
49 struct DecoratedText;
49 class Font; 50 class Font;
50 51
51 namespace internal { 52 namespace internal {
52 53
53 // Internal helper class used by derived classes to draw text through Skia. 54 // Internal helper class used by derived classes to draw text through Skia.
54 class GFX_EXPORT SkiaTextRenderer { 55 class GFX_EXPORT SkiaTextRenderer {
55 public: 56 public:
56 explicit SkiaTextRenderer(Canvas* canvas); 57 explicit SkiaTextRenderer(Canvas* canvas);
57 virtual ~SkiaTextRenderer(); 58 virtual ~SkiaTextRenderer();
58 59
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // Rect can't have a negative width.) 490 // Rect can't have a negative width.)
490 virtual Range GetGlyphBounds(size_t index) = 0; 491 virtual Range GetGlyphBounds(size_t index) = 0;
491 492
492 const Vector2d& GetUpdatedDisplayOffset(); 493 const Vector2d& GetUpdatedDisplayOffset();
493 void SetDisplayOffset(int horizontal_offset); 494 void SetDisplayOffset(int horizontal_offset);
494 495
495 // 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
496 // and the display offset. 497 // and the display offset.
497 Vector2d GetLineOffset(size_t line_number); 498 Vector2d GetLineOffset(size_t line_number);
498 499
500 // Retrieves the word displayed at the given |point| along with its styling
501 // information. |point| is in the view's coordinates. If no word is displayed
502 // at the point, returns a nearby word. |baseline_point| should correspond to
503 // the left baseline point of the leftmost glyph of the |word| in the view's
504 // coordinates. Returns false, if no word can be retrieved.
505 bool GetDecoratedWordAtPoint(const Point& point,
506 DecoratedText* decorated_word,
507 Point* baseline_point);
508
509 // Retreives the text in the given |range|.
510 base::string16 GetTextFromRange(const Range& range) const;
511
499 protected: 512 protected:
500 RenderText(); 513 RenderText();
501 514
502 // 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
503 // that these fields are up to date before accessing them. 516 // that these fields are up to date before accessing them.
504 const base::string16& layout_text() const { return layout_text_; } 517 const base::string16& layout_text() const { return layout_text_; }
505 const base::string16& display_text() const { return display_text_; } 518 const base::string16& display_text() const { return display_text_; }
506 bool text_elided() const { return text_elided_; } 519 bool text_elided() const { return text_elided_; }
507 520
508 const BreakList<SkColor>& colors() const { return colors_; } 521 const BreakList<SkColor>& colors() const { return colors_; }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 // Elides |email| as needed to fit the |available_width|. 684 // Elides |email| as needed to fit the |available_width|.
672 base::string16 ElideEmail(const base::string16& email, float available_width); 685 base::string16 ElideEmail(const base::string16& email, float available_width);
673 686
674 // Update the cached bounds and display offset to ensure that the current 687 // Update the cached bounds and display offset to ensure that the current
675 // cursor is within the visible display area. 688 // cursor is within the visible display area.
676 void UpdateCachedBoundsAndOffset(); 689 void UpdateCachedBoundsAndOffset();
677 690
678 // Draw the selection. 691 // Draw the selection.
679 void DrawSelection(Canvas* canvas); 692 void DrawSelection(Canvas* canvas);
680 693
694 // Returns the nearest word start boundary for |index|. First searches in the
695 // CURSOR_BACKWARD direction, then in the CURSOR_FORWARD direction. Returns
696 // the text length if no valid boundary is found.
697 size_t GetNearestWordStartBoundary(size_t index) const;
698
699 // Expands |range| to its nearest word boundaries and returns the resulting
700 // range. Maintains directionality of |range|.
701 Range ExpandRangeToWordBoundary(const Range& range) const;
702
703 // Returns the decorated text corresponding to |range|. Returns false if the
704 // text cannot be retrieved, e.g. if the text is obscured.
705 virtual bool GetDecoratedTextForRange(
706 const Range& range,
707 DecoratedText* decorated_text) const = 0;
708
681 // Logical UTF-16 string data to be drawn. 709 // Logical UTF-16 string data to be drawn.
682 base::string16 text_; 710 base::string16 text_;
683 711
684 // Horizontal alignment of the text with respect to |display_rect_|. The 712 // Horizontal alignment of the text with respect to |display_rect_|. The
685 // default is to align left if the application UI is LTR and right if RTL. 713 // default is to align left if the application UI is LTR and right if RTL.
686 HorizontalAlignment horizontal_alignment_; 714 HorizontalAlignment horizontal_alignment_;
687 715
688 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT. 716 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT.
689 DirectionalityMode directionality_mode_; 717 DirectionalityMode directionality_mode_;
690 718
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 // Lines computed by EnsureLayout. These should be invalidated upon 843 // Lines computed by EnsureLayout. These should be invalidated upon
816 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. 844 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls.
817 std::vector<internal::Line> lines_; 845 std::vector<internal::Line> lines_;
818 846
819 DISALLOW_COPY_AND_ASSIGN(RenderText); 847 DISALLOW_COPY_AND_ASSIGN(RenderText);
820 }; 848 };
821 849
822 } // namespace gfx 850 } // namespace gfx
823 851
824 #endif // UI_GFX_RENDER_TEXT_H_ 852 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « ui/gfx/decorated_text.cc ('k') | ui/gfx/render_text.cc » ('j') | ui/gfx/render_text.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698