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

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: comments addressed 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
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 // Returns true if this instance supports multiline rendering.
260 virtual bool MultilineSupported() const = 0;
261
259 // TODO(ckocagil): Add vertical alignment and line spacing support instead. 262 // TODO(ckocagil): Add vertical alignment and line spacing support instead.
260 int min_line_height() const { return min_line_height_; } 263 int min_line_height() const { return min_line_height_; }
261 void SetMinLineHeight(int line_height); 264 void SetMinLineHeight(int line_height);
262 265
263 // Set the maximum length of the layout text, not the actual text. 266 // 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 267 // A |length| of 0 forgoes a hard limit, but does not guarantee proper
265 // functionality of very long strings. Applies to subsequent SetText calls. 268 // functionality of very long strings. Applies to subsequent SetText calls.
266 // WARNING: Only use this for system limits, it lacks complex text support. 269 // WARNING: Only use this for system limits, it lacks complex text support.
267 void set_truncate_length(size_t length) { truncate_length_ = length; } 270 void set_truncate_length(size_t length) { truncate_length_ = length; }
268 271
269 // The layout text will be elided to fit |display_rect| using this behavior. 272 // The layout text will be elided to fit |display_rect| using this behavior.
msw 2015/02/25 23:54:26 nit: please update this comment: s/layout/display/
Jun Mukai 2015/02/26 01:40:24 Done.
270 void SetElideBehavior(ElideBehavior elide_behavior); 273 void SetElideBehavior(ElideBehavior elide_behavior);
271 ElideBehavior elide_behavior() const { return elide_behavior_; } 274 ElideBehavior elide_behavior() const { return elide_behavior_; }
272 275
273 const Rect& display_rect() const { return display_rect_; } 276 const Rect& display_rect() const { return display_rect_; }
274 void SetDisplayRect(const Rect& r); 277 void SetDisplayRect(const Rect& r);
275 278
276 bool subpixel_rendering_suppressed() const { 279 bool subpixel_rendering_suppressed() const {
277 return subpixel_rendering_suppressed_; 280 return subpixel_rendering_suppressed_;
278 } 281 }
279 void set_subpixel_rendering_suppressed(bool suppressed) { 282 void set_subpixel_rendering_suppressed(bool suppressed) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 DirectionalityMode directionality_mode() const { 350 DirectionalityMode directionality_mode() const {
348 return directionality_mode_; 351 return directionality_mode_;
349 } 352 }
350 base::i18n::TextDirection GetDisplayTextDirection(); 353 base::i18n::TextDirection GetDisplayTextDirection();
351 354
352 // Returns the visual movement direction corresponding to the logical end 355 // Returns the visual movement direction corresponding to the logical end
353 // of the text, considering only the dominant direction returned by 356 // of the text, considering only the dominant direction returned by
354 // |GetDisplayTextDirection()|, not the direction of a particular run. 357 // |GetDisplayTextDirection()|, not the direction of a particular run.
355 VisualCursorDirection GetVisualDirectionOfLogicalEnd(); 358 VisualCursorDirection GetVisualDirectionOfLogicalEnd();
356 359
360 // Returns the un-elided text, but replaced when obscured.
msw 2015/02/25 23:54:26 nit: consider a comment matching the format of tha
Jun Mukai 2015/02/26 01:40:25 Removed this, adding this was my mistake, Because
361 const base::string16& GetAccessibleText();
msw 2015/02/25 23:54:26 Let's call this GetLayoutText().
Jun Mukai 2015/02/26 01:40:25 ditto
362
357 // Returns the text used to display, which may be obscured, truncated or 363 // Returns the text used to display, which may be obscured, truncated or
358 // elided. The subclass may compute elided text on the fly, or use 364 // elided. The subclass may compute elided text on the fly, or use
359 // precomputed the elided text. 365 // precomputed the elided text.
360 virtual const base::string16& GetDisplayText() = 0; 366 virtual const base::string16& GetDisplayText() = 0;
361 367
362 // Returns the size required to display the current string (which is the 368 // Returns the size required to display the current string (which is the
363 // wrapped size in multiline mode). The returned size does not include space 369 // wrapped size in multiline mode). The returned size does not include space
364 // reserved for the cursor or the offset text shadows. 370 // reserved for the cursor or the offset text shadows.
365 virtual Size GetStringSize() = 0; 371 virtual Size GetStringSize() = 0;
366 372
(...skipping 54 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 // Lines computed by EnsureLayout. These should be invalidated upon 775 // Lines computed by EnsureLayout. These should be invalidated upon
770 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. 776 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls.
771 std::vector<internal::Line> lines_; 777 std::vector<internal::Line> lines_;
772 778
773 DISALLOW_COPY_AND_ASSIGN(RenderText); 779 DISALLOW_COPY_AND_ASSIGN(RenderText);
774 }; 780 };
775 781
776 } // namespace gfx 782 } // namespace gfx
777 783
778 #endif // UI_GFX_RENDER_TEXT_H_ 784 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698