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 <algorithm> | 8 #include <algorithm> |
| 9 #include <cstring> | 9 #include <cstring> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 bool obscured() const { return obscured_; } | 234 bool obscured() const { return obscured_; } |
| 235 void SetObscured(bool obscured); | 235 void SetObscured(bool obscured); |
| 236 | 236 |
| 237 // Makes a char in obscured text at |index| to be revealed. |index| should be | 237 // Makes a char in obscured text at |index| to be revealed. |index| should be |
| 238 // a UTF16 text index. If there is a previous revealed index, the previous one | 238 // a UTF16 text index. If there is a previous revealed index, the previous one |
| 239 // is cleared and only the last set index will be revealed. If |index| is -1 | 239 // is cleared and only the last set index will be revealed. If |index| is -1 |
| 240 // or out of range, no char will be revealed. The revealed index is also | 240 // or out of range, no char will be revealed. The revealed index is also |
| 241 // cleared when SetText or SetObscured is called. | 241 // cleared when SetText or SetObscured is called. |
| 242 void SetObscuredRevealIndex(int index); | 242 void SetObscuredRevealIndex(int index); |
| 243 | 243 |
| 244 void SetReplaceNewlineCharsWithSymbols(bool replace); | |
|
Alexei Svitkine (slow)
2014/07/15 14:42:50
Add a comment.
msw
2014/07/15 16:53:05
Done.
| |
| 245 | |
| 244 // TODO(ckocagil): Multiline text rendering is currently only supported on | 246 // TODO(ckocagil): Multiline text rendering is currently only supported on |
| 245 // Windows. Support other platforms. | 247 // Windows. Support other platforms. |
| 246 bool multiline() const { return multiline_; } | 248 bool multiline() const { return multiline_; } |
| 247 void SetMultiline(bool multiline); | 249 void SetMultiline(bool multiline); |
| 248 | 250 |
| 249 // Set the maximum length of the displayed layout text, not the actual text. | 251 // Set the maximum length of the displayed layout text, not the actual text. |
| 250 // A |length| of 0 forgoes a hard limit, but does not guarantee proper | 252 // A |length| of 0 forgoes a hard limit, but does not guarantee proper |
| 251 // functionality of very long strings. Applies to subsequent SetText calls. | 253 // functionality of very long strings. Applies to subsequent SetText calls. |
| 252 // WARNING: Only use this for system limits, it lacks complex text support. | 254 // WARNING: Only use this for system limits, it lacks complex text support. |
| 253 void set_truncate_length(size_t length) { truncate_length_ = length; } | 255 void set_truncate_length(size_t length) { truncate_length_ = length; } |
| 254 | 256 |
| 255 // The layout text will be elided to fit |display_rect| using this behavior. | 257 // The layout text will be elided to fit |display_rect| using this behavior. |
| 256 // The layout text may be shortened further by the truncate length. | 258 // The layout text may be shortened further by the truncate length. |
| 257 void SetElideBehavior(ElideBehavior elide_behavior); | 259 void SetElideBehavior(ElideBehavior elide_behavior); |
| 260 ElideBehavior elide_behavior() const { return elide_behavior_; } | |
| 258 | 261 |
| 259 const base::string16& layout_text() const { return layout_text_; } | 262 const base::string16& layout_text() const { return layout_text_; } |
| 260 | 263 |
| 261 const Rect& display_rect() const { return display_rect_; } | 264 const Rect& display_rect() const { return display_rect_; } |
| 262 void SetDisplayRect(const Rect& r); | 265 void SetDisplayRect(const Rect& r); |
| 263 | 266 |
| 264 bool background_is_transparent() const { return background_is_transparent_; } | 267 bool background_is_transparent() const { return background_is_transparent_; } |
| 265 void set_background_is_transparent(bool transparent) { | 268 void set_background_is_transparent(bool transparent) { |
| 266 background_is_transparent_ = transparent; | 269 background_is_transparent_ = transparent; |
| 267 } | 270 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 // supplied index is already at the boundary of the string. | 402 // supplied index is already at the boundary of the string. |
| 400 size_t IndexOfAdjacentGrapheme(size_t index, | 403 size_t IndexOfAdjacentGrapheme(size_t index, |
| 401 LogicalCursorDirection direction); | 404 LogicalCursorDirection direction); |
| 402 | 405 |
| 403 // Return a SelectionModel with the cursor at the current selection's start. | 406 // Return a SelectionModel with the cursor at the current selection's start. |
| 404 // The returned value represents a cursor/caret position without a selection. | 407 // The returned value represents a cursor/caret position without a selection. |
| 405 SelectionModel GetSelectionModelForSelectionStart(); | 408 SelectionModel GetSelectionModelForSelectionStart(); |
| 406 | 409 |
| 407 // Sets shadows to drawn with text. | 410 // Sets shadows to drawn with text. |
| 408 void set_shadows(const ShadowValues& shadows) { shadows_ = shadows; } | 411 void set_shadows(const ShadowValues& shadows) { shadows_ = shadows; } |
| 412 const ShadowValues& shadows() { return shadows_; } | |
| 409 | 413 |
| 410 typedef std::pair<Font, Range> FontSpan; | 414 typedef std::pair<Font, Range> FontSpan; |
| 411 // For testing purposes, returns which fonts were chosen for which parts of | 415 // For testing purposes, returns which fonts were chosen for which parts of |
| 412 // the text by returning a vector of Font and Range pairs, where each range | 416 // the text by returning a vector of Font and Range pairs, where each range |
| 413 // specifies the character range for which the corresponding font has been | 417 // specifies the character range for which the corresponding font has been |
| 414 // chosen. | 418 // chosen. |
| 415 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0; | 419 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0; |
| 416 | 420 |
| 417 // Gets the horizontal bounds (relative to the left of the text, not the view) | 421 // Gets the horizontal bounds (relative to the left of the text, not the view) |
| 418 // of the glyph starting at |index|. If the glyph is RTL then the returned | 422 // of the glyph starting at |index|. If the glyph is RTL then the returned |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 Vector2d GetLineOffset(size_t line_number); | 527 Vector2d GetLineOffset(size_t line_number); |
| 524 | 528 |
| 525 // Convert points from the text space to the view space and back. Handles the | 529 // Convert points from the text space to the view space and back. Handles the |
| 526 // display area, display offset, application LTR/RTL mode and multiline. | 530 // display area, display offset, application LTR/RTL mode and multiline. |
| 527 Point ToTextPoint(const Point& point); | 531 Point ToTextPoint(const Point& point); |
| 528 Point ToViewPoint(const Point& point); | 532 Point ToViewPoint(const Point& point); |
| 529 | 533 |
| 530 // Convert a text space x-coordinate range to rects in view space. | 534 // Convert a text space x-coordinate range to rects in view space. |
| 531 std::vector<Rect> TextBoundsToViewBounds(const Range& x); | 535 std::vector<Rect> TextBoundsToViewBounds(const Range& x); |
| 532 | 536 |
| 537 // Get the alignment, resolving ALIGN_TO_HEAD with the current text direction. | |
| 538 HorizontalAlignment GetCurrentHorizontalAlignment(); | |
| 539 | |
| 533 // Returns the line offset from the origin, accounts for text alignment only. | 540 // Returns the line offset from the origin, accounts for text alignment only. |
| 534 Vector2d GetAlignmentOffset(size_t line_number); | 541 Vector2d GetAlignmentOffset(size_t line_number); |
| 535 | 542 |
| 536 // Applies fade effects to |renderer|. | 543 // Applies fade effects to |renderer|. |
| 537 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); | 544 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); |
| 538 | 545 |
| 539 // Applies text shadows to |renderer|. | 546 // Applies text shadows to |renderer|. |
| 540 void ApplyTextShadows(internal::SkiaTextRenderer* renderer); | 547 void ApplyTextShadows(internal::SkiaTextRenderer* renderer); |
| 541 | 548 |
| 542 // A convenience function to check whether the glyph attached to the caret | 549 // A convenience function to check whether the glyph attached to the caret |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 659 | 666 |
| 660 // The maximum length of text to display, 0 forgoes a hard limit. | 667 // The maximum length of text to display, 0 forgoes a hard limit. |
| 661 size_t truncate_length_; | 668 size_t truncate_length_; |
| 662 | 669 |
| 663 // The behavior for eliding, fading, or truncating. | 670 // The behavior for eliding, fading, or truncating. |
| 664 ElideBehavior elide_behavior_; | 671 ElideBehavior elide_behavior_; |
| 665 | 672 |
| 666 // The obscured and/or truncated text that will be displayed. | 673 // The obscured and/or truncated text that will be displayed. |
| 667 base::string16 layout_text_; | 674 base::string16 layout_text_; |
| 668 | 675 |
| 676 // Whether newline characters should be replaced with newline symbols. | |
| 677 bool replace_newline_chars_with_symbols_; | |
| 678 | |
| 669 // Whether the text should be broken into multiple lines. Uses the width of | 679 // Whether the text should be broken into multiple lines. Uses the width of |
| 670 // |display_rect_| as the width cap. | 680 // |display_rect_| as the width cap. |
| 671 bool multiline_; | 681 bool multiline_; |
| 672 | 682 |
| 673 // Is the background transparent (either partially or fully)? | 683 // Is the background transparent (either partially or fully)? |
| 674 bool background_is_transparent_; | 684 bool background_is_transparent_; |
| 675 | 685 |
| 676 // The local display area for rendering the text. | 686 // The local display area for rendering the text. |
| 677 Rect display_rect_; | 687 Rect display_rect_; |
| 678 | 688 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 704 // Lines computed by EnsureLayout. These should be invalidated with | 714 // Lines computed by EnsureLayout. These should be invalidated with |
| 705 // ResetLayout and on |display_rect_| changes. | 715 // ResetLayout and on |display_rect_| changes. |
| 706 std::vector<internal::Line> lines_; | 716 std::vector<internal::Line> lines_; |
| 707 | 717 |
| 708 DISALLOW_COPY_AND_ASSIGN(RenderText); | 718 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 709 }; | 719 }; |
| 710 | 720 |
| 711 } // namespace gfx | 721 } // namespace gfx |
| 712 | 722 |
| 713 #endif // UI_GFX_RENDER_TEXT_H_ | 723 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |