| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 bool multiline() const { return multiline_; } | 249 bool multiline() const { return multiline_; } |
| 250 void SetMultiline(bool multiline); | 250 void SetMultiline(bool multiline); |
| 251 | 251 |
| 252 // Set the maximum length of the displayed layout text, not the actual text. | 252 // Set the maximum length of the displayed layout text, not the actual text. |
| 253 // A |length| of 0 forgoes a hard limit, but does not guarantee proper | 253 // A |length| of 0 forgoes a hard limit, but does not guarantee proper |
| 254 // functionality of very long strings. Applies to subsequent SetText calls. | 254 // functionality of very long strings. Applies to subsequent SetText calls. |
| 255 // WARNING: Only use this for system limits, it lacks complex text support. | 255 // WARNING: Only use this for system limits, it lacks complex text support. |
| 256 void set_truncate_length(size_t length) { truncate_length_ = length; } | 256 void set_truncate_length(size_t length) { truncate_length_ = length; } |
| 257 | 257 |
| 258 // Elides the text to fit in |display_rect| according to the specified | 258 // Elides the text to fit in |display_rect| according to the specified |
| 259 // |elide_behavior|. |ELIDE_IN_MIDDLE| is not supported. If both truncate | 259 // |elide_behavior|. |ELIDE_MIDDLE| is not supported. If a truncate length and |
| 260 // and elide are specified, the shorter of the two will be applicable. | 260 // an elide mode are specified, the shorter of the two will be applicable. |
| 261 void SetElideBehavior(ElideBehavior elide_behavior); | 261 void SetElideBehavior(ElideBehavior elide_behavior); |
| 262 | 262 |
| 263 const Rect& display_rect() const { return display_rect_; } | 263 const Rect& display_rect() const { return display_rect_; } |
| 264 void SetDisplayRect(const Rect& r); | 264 void SetDisplayRect(const Rect& r); |
| 265 | 265 |
| 266 void set_fade_head(bool fade_head) { fade_head_ = fade_head; } | |
| 267 bool fade_head() const { return fade_head_; } | |
| 268 void set_fade_tail(bool fade_tail) { fade_tail_ = fade_tail; } | |
| 269 bool fade_tail() const { return fade_tail_; } | |
| 270 | |
| 271 bool background_is_transparent() const { return background_is_transparent_; } | 266 bool background_is_transparent() const { return background_is_transparent_; } |
| 272 void set_background_is_transparent(bool transparent) { | 267 void set_background_is_transparent(bool transparent) { |
| 273 background_is_transparent_ = transparent; | 268 background_is_transparent_ = transparent; |
| 274 } | 269 } |
| 275 | 270 |
| 276 const SelectionModel& selection_model() const { return selection_model_; } | 271 const SelectionModel& selection_model() const { return selection_model_; } |
| 277 | 272 |
| 278 const Range& selection() const { return selection_model_.selection(); } | 273 const Range& selection() const { return selection_model_.selection(); } |
| 279 | 274 |
| 280 size_t cursor_position() const { return selection_model_.caret_pos(); } | 275 size_t cursor_position() const { return selection_model_.caret_pos(); } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 522 |
| 528 // Returns the line offset from the origin after applying the text alignment | 523 // Returns the line offset from the origin after applying the text alignment |
| 529 // and the display offset. | 524 // and the display offset. |
| 530 Vector2d GetLineOffset(size_t line_number); | 525 Vector2d GetLineOffset(size_t line_number); |
| 531 | 526 |
| 532 // Convert points from the text space to the view space and back. Handles the | 527 // Convert points from the text space to the view space and back. Handles the |
| 533 // display area, display offset, application LTR/RTL mode and multiline. | 528 // display area, display offset, application LTR/RTL mode and multiline. |
| 534 Point ToTextPoint(const Point& point); | 529 Point ToTextPoint(const Point& point); |
| 535 Point ToViewPoint(const Point& point); | 530 Point ToViewPoint(const Point& point); |
| 536 | 531 |
| 537 // Convert a text space x-coordinate range to corresponding rects in view | 532 // Convert a text space x-coordinate range to rects in view space. |
| 538 // space. | |
| 539 std::vector<Rect> TextBoundsToViewBounds(const Range& x); | 533 std::vector<Rect> TextBoundsToViewBounds(const Range& x); |
| 540 | 534 |
| 541 // Returns the line offset from the origin, accounting for text alignment | 535 // Returns the line offset from the origin, accounts for text alignment only. |
| 542 // only. | |
| 543 Vector2d GetAlignmentOffset(size_t line_number); | 536 Vector2d GetAlignmentOffset(size_t line_number); |
| 544 | 537 |
| 545 // Applies fade effects to |renderer|. | 538 // Applies fade effects to |renderer|. |
| 546 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); | 539 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); |
| 547 | 540 |
| 548 // Applies text shadows to |renderer|. | 541 // Applies text shadows to |renderer|. |
| 549 void ApplyTextShadows(internal::SkiaTextRenderer* renderer); | 542 void ApplyTextShadows(internal::SkiaTextRenderer* renderer); |
| 550 | 543 |
| 551 // A convenience function to check whether the glyph attached to the caret | 544 // A convenience function to check whether the glyph attached to the caret |
| 552 // is within the given range. | 545 // is within the given range. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 bool composition_and_selection_styles_applied_; | 649 bool composition_and_selection_styles_applied_; |
| 657 | 650 |
| 658 // A flag to obscure actual text with asterisks for password fields. | 651 // A flag to obscure actual text with asterisks for password fields. |
| 659 bool obscured_; | 652 bool obscured_; |
| 660 // The index at which the char should be revealed in the obscured text. | 653 // The index at which the char should be revealed in the obscured text. |
| 661 int obscured_reveal_index_; | 654 int obscured_reveal_index_; |
| 662 | 655 |
| 663 // The maximum length of text to display, 0 forgoes a hard limit. | 656 // The maximum length of text to display, 0 forgoes a hard limit. |
| 664 size_t truncate_length_; | 657 size_t truncate_length_; |
| 665 | 658 |
| 666 // The behavior for eliding or truncating. | 659 // The behavior for eliding, fading, or truncating. |
| 667 ElideBehavior elide_behavior_; | 660 ElideBehavior elide_behavior_; |
| 668 | 661 |
| 669 // The obscured and/or truncated text that will be displayed. | 662 // The obscured and/or truncated text that will be displayed. |
| 670 base::string16 layout_text_; | 663 base::string16 layout_text_; |
| 671 | 664 |
| 672 // Whether the text should be broken into multiple lines. Uses the width of | 665 // Whether the text should be broken into multiple lines. Uses the width of |
| 673 // |display_rect_| as the width cap. | 666 // |display_rect_| as the width cap. |
| 674 bool multiline_; | 667 bool multiline_; |
| 675 | 668 |
| 676 // Fade text head and/or tail, if text doesn't fit into |display_rect_|. | |
| 677 bool fade_head_; | |
| 678 bool fade_tail_; | |
| 679 | |
| 680 // Is the background transparent (either partially or fully)? | 669 // Is the background transparent (either partially or fully)? |
| 681 bool background_is_transparent_; | 670 bool background_is_transparent_; |
| 682 | 671 |
| 683 // The local display area for rendering the text. | 672 // The local display area for rendering the text. |
| 684 Rect display_rect_; | 673 Rect display_rect_; |
| 685 | 674 |
| 686 // Flag to work around a Skia bug with the PDF path (http://crbug.com/133548) | 675 // Flag to work around a Skia bug with the PDF path (http://crbug.com/133548) |
| 687 // that results in incorrect clipping when drawing to the document margins. | 676 // that results in incorrect clipping when drawing to the document margins. |
| 688 // This field allows disabling clipping to work around the issue. | 677 // This field allows disabling clipping to work around the issue. |
| 689 // TODO(asvitkine): Remove this when the underlying Skia bug is fixed. | 678 // TODO(asvitkine): Remove this when the underlying Skia bug is fixed. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 711 // Lines computed by EnsureLayout. These should be invalidated with | 700 // Lines computed by EnsureLayout. These should be invalidated with |
| 712 // ResetLayout and on |display_rect_| changes. | 701 // ResetLayout and on |display_rect_| changes. |
| 713 std::vector<internal::Line> lines_; | 702 std::vector<internal::Line> lines_; |
| 714 | 703 |
| 715 DISALLOW_COPY_AND_ASSIGN(RenderText); | 704 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 716 }; | 705 }; |
| 717 | 706 |
| 718 } // namespace gfx | 707 } // namespace gfx |
| 719 | 708 |
| 720 #endif // UI_GFX_RENDER_TEXT_H_ | 709 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |