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

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

Issue 867003002: Cache gfx::RenderText instances in views::Label. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 9 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
« no previous file with comments | « ui/app_list/views/app_list_item_view.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
249 // is cleared and only the last set index will be revealed. If |index| is -1 249 // is cleared and only the last set index will be revealed. If |index| is -1
250 // or out of range, no char will be revealed. The revealed index is also 250 // or out of range, no char will be revealed. The revealed index is also
251 // cleared when SetText or SetObscured is called. 251 // cleared when SetText or SetObscured is called.
252 void SetObscuredRevealIndex(int index); 252 void SetObscuredRevealIndex(int index);
253 253
254 // TODO(ckocagil): Multiline text rendering is currently only supported on 254 // TODO(ckocagil): Multiline text rendering is currently only supported on
255 // Windows. Support other platforms. 255 // Windows. Support other platforms.
256 bool multiline() const { return multiline_; } 256 bool multiline() const { return multiline_; }
257 void SetMultiline(bool multiline); 257 void SetMultiline(bool multiline);
258 258
259 // Set whether newline characters should be replaced with newline symbols.
260 void SetReplaceNewlineCharsWithSymbols(bool replace);
261
262 // Returns true if this instance supports multiline rendering.
263 virtual bool MultilineSupported() const = 0;
264
259 // TODO(ckocagil): Add vertical alignment and line spacing support instead. 265 // TODO(ckocagil): Add vertical alignment and line spacing support instead.
260 int min_line_height() const { return min_line_height_; } 266 int min_line_height() const { return min_line_height_; }
261 void SetMinLineHeight(int line_height); 267 void SetMinLineHeight(int line_height);
262 268
263 // Set the maximum length of the layout text, not the actual text. 269 // Set the maximum length of the layout text, not the actual text.
264 // A |length| of 0 forgoes a hard limit, but does not guarantee proper 270 // A |length| of 0 forgoes a hard limit, but does not guarantee proper
265 // functionality of very long strings. Applies to subsequent SetText calls. 271 // functionality of very long strings. Applies to subsequent SetText calls.
266 // WARNING: Only use this for system limits, it lacks complex text support. 272 // WARNING: Only use this for system limits, it lacks complex text support.
267 void set_truncate_length(size_t length) { truncate_length_ = length; } 273 void set_truncate_length(size_t length) { truncate_length_ = length; }
268 274
269 // The layout text will be elided to fit |display_rect| using this behavior. 275 // The display text will be elided to fit |display_rect| using this behavior.
270 void SetElideBehavior(ElideBehavior elide_behavior); 276 void SetElideBehavior(ElideBehavior elide_behavior);
271 ElideBehavior elide_behavior() const { return elide_behavior_; } 277 ElideBehavior elide_behavior() const { return elide_behavior_; }
272 278
273 const Rect& display_rect() const { return display_rect_; } 279 const Rect& display_rect() const { return display_rect_; }
274 void SetDisplayRect(const Rect& r); 280 void SetDisplayRect(const Rect& r);
275 281
276 bool subpixel_rendering_suppressed() const { 282 bool subpixel_rendering_suppressed() const {
277 return subpixel_rendering_suppressed_; 283 return subpixel_rendering_suppressed_;
278 } 284 }
279 void set_subpixel_rendering_suppressed(bool suppressed) { 285 void set_subpixel_rendering_suppressed(bool suppressed) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // supplied index is already at the boundary of the string. 427 // supplied index is already at the boundary of the string.
422 size_t IndexOfAdjacentGrapheme(size_t index, 428 size_t IndexOfAdjacentGrapheme(size_t index,
423 LogicalCursorDirection direction); 429 LogicalCursorDirection direction);
424 430
425 // Return a SelectionModel with the cursor at the current selection's start. 431 // Return a SelectionModel with the cursor at the current selection's start.
426 // The returned value represents a cursor/caret position without a selection. 432 // The returned value represents a cursor/caret position without a selection.
427 SelectionModel GetSelectionModelForSelectionStart(); 433 SelectionModel GetSelectionModelForSelectionStart();
428 434
429 // Sets shadows to drawn with text. 435 // Sets shadows to drawn with text.
430 void set_shadows(const ShadowValues& shadows) { shadows_ = shadows; } 436 void set_shadows(const ShadowValues& shadows) { shadows_ = shadows; }
431 const ShadowValues& shadows() { return shadows_; } 437 const ShadowValues& shadows() const { return shadows_; }
432 438
433 typedef std::pair<Font, Range> FontSpan; 439 typedef std::pair<Font, Range> FontSpan;
434 // For testing purposes, returns which fonts were chosen for which parts of 440 // For testing purposes, returns which fonts were chosen for which parts of
435 // the text by returning a vector of Font and Range pairs, where each range 441 // the text by returning a vector of Font and Range pairs, where each range
436 // specifies the character range for which the corresponding font has been 442 // specifies the character range for which the corresponding font has been
437 // chosen. 443 // chosen.
438 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0; 444 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0;
439 445
440 // Gets the horizontal bounds (relative to the left of the text, not the view) 446 // Gets the horizontal bounds (relative to the left of the text, not the view)
441 // of the glyph starting at |index|. If the glyph is RTL then the returned 447 // of the glyph starting at |index|. If the glyph is RTL then the returned
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 // True if the text is elided given the current behavior and display area. 739 // True if the text is elided given the current behavior and display area.
734 bool text_elided_; 740 bool text_elided_;
735 741
736 // The minimum height a line should have. 742 // The minimum height a line should have.
737 int min_line_height_; 743 int min_line_height_;
738 744
739 // Whether the text should be broken into multiple lines. Uses the width of 745 // Whether the text should be broken into multiple lines. Uses the width of
740 // |display_rect_| as the width cap. 746 // |display_rect_| as the width cap.
741 bool multiline_; 747 bool multiline_;
742 748
749 // Whether newline characters should be replaced with newline symbols.
750 bool replace_newline_chars_with_symbols_;
751
743 // Set to true to suppress subpixel rendering due to non-font reasons (eg. 752 // Set to true to suppress subpixel rendering due to non-font reasons (eg.
744 // if the background is transparent). The default value is false. 753 // if the background is transparent). The default value is false.
745 bool subpixel_rendering_suppressed_; 754 bool subpixel_rendering_suppressed_;
746 755
747 // The local display area for rendering the text. 756 // The local display area for rendering the text.
748 Rect display_rect_; 757 Rect display_rect_;
749 758
750 // Flag to work around a Skia bug with the PDF path (http://crbug.com/133548) 759 // Flag to work around a Skia bug with the PDF path (http://crbug.com/133548)
751 // that results in incorrect clipping when drawing to the document margins. 760 // that results in incorrect clipping when drawing to the document margins.
752 // This field allows disabling clipping to work around the issue. 761 // This field allows disabling clipping to work around the issue.
(...skipping 22 matching lines...) Expand all
775 // Lines computed by EnsureLayout. These should be invalidated upon 784 // Lines computed by EnsureLayout. These should be invalidated upon
776 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. 785 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls.
777 std::vector<internal::Line> lines_; 786 std::vector<internal::Line> lines_;
778 787
779 DISALLOW_COPY_AND_ASSIGN(RenderText); 788 DISALLOW_COPY_AND_ASSIGN(RenderText);
780 }; 789 };
781 790
782 } // namespace gfx 791 } // namespace gfx
783 792
784 #endif // UI_GFX_RENDER_TEXT_H_ 793 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_item_view.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698