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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 private: | 129 private: |
130 BreakList<SkColor> colors_; | 130 BreakList<SkColor> colors_; |
131 std::vector<BreakList<bool> > styles_; | 131 std::vector<BreakList<bool> > styles_; |
132 | 132 |
133 BreakList<SkColor>::const_iterator color_; | 133 BreakList<SkColor>::const_iterator color_; |
134 std::vector<BreakList<bool>::const_iterator> style_; | 134 std::vector<BreakList<bool>::const_iterator> style_; |
135 | 135 |
136 DISALLOW_COPY_AND_ASSIGN(StyleIterator); | 136 DISALLOW_COPY_AND_ASSIGN(StyleIterator); |
137 }; | 137 }; |
138 | 138 |
139 // Line segments are slices of the layout text to be rendered on a single line. | 139 // Line segments are slices of the display text to be rendered on a single line. |
140 struct LineSegment { | 140 struct LineSegment { |
141 LineSegment(); | 141 LineSegment(); |
142 ~LineSegment(); | 142 ~LineSegment(); |
143 | 143 |
144 // X coordinates of this line segment in text space. | 144 // X coordinates of this line segment in text space. |
145 Range x_range; | 145 Range x_range; |
146 | 146 |
147 // The character range this segment corresponds to. | 147 // The character range this segment corresponds to. |
148 Range char_range; | 148 Range char_range; |
149 | 149 |
150 // The width of this line segment in text space. This could be slightly | 150 // The width of this line segment in text space. This could be slightly |
151 // different from x_range.length(). | 151 // different from x_range.length(). |
152 // TODO(mukai): Fix Range to support float values and merge it into x_range. | 152 // TODO(mukai): Fix Range to support float values and merge it into x_range. |
153 float width; | 153 float width; |
154 | 154 |
155 // Index of the text run that generated this segment. | 155 // Index of the text run that generated this segment. |
156 size_t run; | 156 size_t run; |
157 }; | 157 }; |
158 | 158 |
159 // A line of layout text, comprised of a line segment list and some metrics. | 159 // A line of display text, comprised of a line segment list and some metrics. |
160 struct Line { | 160 struct Line { |
161 Line(); | 161 Line(); |
162 ~Line(); | 162 ~Line(); |
163 | 163 |
164 // Segments that make up this line in visual order. | 164 // Segments that make up this line in visual order. |
165 std::vector<LineSegment> segments; | 165 std::vector<LineSegment> segments; |
166 | 166 |
167 // The sum of segment widths and the maximum of segment heights. | 167 // The sum of segment widths and the maximum of segment heights. |
168 SizeF size; | 168 SizeF size; |
169 | 169 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 bool obscured() const { return obscured_; } | 244 bool obscured() const { return obscured_; } |
245 void SetObscured(bool obscured); | 245 void SetObscured(bool obscured); |
246 | 246 |
247 // Makes a char in obscured text at |index| to be revealed. |index| should be | 247 // Makes a char in obscured text at |index| to be revealed. |index| should be |
248 // a UTF16 text index. If there is a previous revealed index, the previous one | 248 // a UTF16 text index. If there is a previous revealed index, the previous one |
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 // Set whether newline characters should be replaced with newline symbols. | |
255 void SetReplaceNewlineCharsWithSymbols(bool replace); | |
256 | |
257 // TODO(ckocagil): Multiline text rendering is currently only supported on | 254 // TODO(ckocagil): Multiline text rendering is currently only supported on |
258 // Windows. Support other platforms. | 255 // Windows. Support other platforms. |
259 bool multiline() const { return multiline_; } | 256 bool multiline() const { return multiline_; } |
260 void SetMultiline(bool multiline); | 257 void SetMultiline(bool multiline); |
261 | 258 |
262 // TODO(ckocagil): Add vertical alignment and line spacing support instead. | 259 // TODO(ckocagil): Add vertical alignment and line spacing support instead. |
263 int min_line_height() const { return min_line_height_; } | 260 int min_line_height() const { return min_line_height_; } |
264 void SetMinLineHeight(int line_height); | 261 void SetMinLineHeight(int line_height); |
265 | 262 |
266 // Set the maximum length of the displayed layout text, not the actual text. | 263 // Set the maximum length of the layout text, not the actual text. |
267 // A |length| of 0 forgoes a hard limit, but does not guarantee proper | 264 // A |length| of 0 forgoes a hard limit, but does not guarantee proper |
268 // functionality of very long strings. Applies to subsequent SetText calls. | 265 // functionality of very long strings. Applies to subsequent SetText calls. |
269 // WARNING: Only use this for system limits, it lacks complex text support. | 266 // WARNING: Only use this for system limits, it lacks complex text support. |
270 void set_truncate_length(size_t length) { truncate_length_ = length; } | 267 void set_truncate_length(size_t length) { truncate_length_ = length; } |
271 | 268 |
272 // The layout text will be elided to fit |display_rect| using this behavior. | 269 // The layout text will be elided to fit |display_rect| using this behavior. |
273 // The layout text may be shortened further by the truncate length. | |
274 void SetElideBehavior(ElideBehavior elide_behavior); | 270 void SetElideBehavior(ElideBehavior elide_behavior); |
275 ElideBehavior elide_behavior() const { return elide_behavior_; } | 271 ElideBehavior elide_behavior() const { return elide_behavior_; } |
276 | 272 |
277 const base::string16& layout_text() const { return layout_text_; } | |
278 | |
279 const Rect& display_rect() const { return display_rect_; } | 273 const Rect& display_rect() const { return display_rect_; } |
280 void SetDisplayRect(const Rect& r); | 274 void SetDisplayRect(const Rect& r); |
281 | 275 |
282 bool background_is_transparent() const { return background_is_transparent_; } | 276 bool background_is_transparent() const { return background_is_transparent_; } |
283 void set_background_is_transparent(bool transparent) { | 277 void set_background_is_transparent(bool transparent) { |
284 background_is_transparent_ = transparent; | 278 background_is_transparent_ = transparent; |
285 } | 279 } |
286 | 280 |
287 const SelectionModel& selection_model() const { return selection_model_; } | 281 const SelectionModel& selection_model() const { return selection_model_; } |
288 | 282 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 | 338 |
345 // Returns whether this style is enabled consistently across the entire | 339 // Returns whether this style is enabled consistently across the entire |
346 // RenderText. | 340 // RenderText. |
347 bool GetStyle(TextStyle style) const; | 341 bool GetStyle(TextStyle style) const; |
348 | 342 |
349 // Set or get the text directionality mode and get the text direction yielded. | 343 // Set or get the text directionality mode and get the text direction yielded. |
350 void SetDirectionalityMode(DirectionalityMode mode); | 344 void SetDirectionalityMode(DirectionalityMode mode); |
351 DirectionalityMode directionality_mode() const { | 345 DirectionalityMode directionality_mode() const { |
352 return directionality_mode_; | 346 return directionality_mode_; |
353 } | 347 } |
354 base::i18n::TextDirection GetTextDirection(); | 348 base::i18n::TextDirection GetDisplayTextDirection(); |
355 | 349 |
356 // Returns the visual movement direction corresponding to the logical end | 350 // Returns the visual movement direction corresponding to the logical end |
357 // of the text, considering only the dominant direction returned by | 351 // of the text, considering only the dominant direction returned by |
358 // |GetTextDirection()|, not the direction of a particular run. | 352 // |GetDisplayTextDirection()|, not the direction of a particular run. |
359 VisualCursorDirection GetVisualDirectionOfLogicalEnd(); | 353 VisualCursorDirection GetVisualDirectionOfLogicalEnd(); |
360 | 354 |
355 // Returns the text used to display, which may be obscured, | |
msw
2015/02/13 22:19:05
nit: update line wrapping (can fit "truncated or")
oshima
2015/02/13 23:24:11
Done.
| |
356 // truncated or elided. The subclass may compute elided text on the fly, | |
357 // or use precomputed the elided text. | |
358 virtual const base::string16& GetDisplayText() = 0; | |
359 | |
361 // Returns the size required to display the current string (which is the | 360 // Returns the size required to display the current string (which is the |
362 // wrapped size in multiline mode). The returned size does not include space | 361 // wrapped size in multiline mode). The returned size does not include space |
363 // reserved for the cursor or the offset text shadows. | 362 // reserved for the cursor or the offset text shadows. |
364 virtual Size GetStringSize() = 0; | 363 virtual Size GetStringSize() = 0; |
365 | 364 |
366 // This is same as GetStringSize except that fractional size is returned. | 365 // This is same as GetStringSize except that fractional size is returned. |
367 // The default implementation is same as GetStringSize. Certain platforms that | 366 // The default implementation is same as GetStringSize. Certain platforms that |
368 // compute the text size as floating-point values, like Mac, will override | 367 // compute the text size as floating-point values, like Mac, will override |
369 // this method. | 368 // this method. |
370 // See comment in Canvas::GetStringWidthF for its usage. | 369 // See comment in Canvas::GetStringWidthF for its usage. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 // Range will have is_reversed() true. (This does not return a Rect because a | 440 // Range will have is_reversed() true. (This does not return a Rect because a |
442 // Rect can't have a negative width.) | 441 // Rect can't have a negative width.) |
443 virtual Range GetGlyphBounds(size_t index) = 0; | 442 virtual Range GetGlyphBounds(size_t index) = 0; |
444 | 443 |
445 const Vector2d& GetUpdatedDisplayOffset(); | 444 const Vector2d& GetUpdatedDisplayOffset(); |
446 void SetDisplayOffset(int horizontal_offset); | 445 void SetDisplayOffset(int horizontal_offset); |
447 | 446 |
448 protected: | 447 protected: |
449 RenderText(); | 448 RenderText(); |
450 | 449 |
450 const base::string16& layout_text() const { return layout_text_; } | |
451 const base::string16& display_text() const { return display_text_; } | |
452 bool text_elided() const { return text_elided_; } | |
453 | |
451 const BreakList<SkColor>& colors() const { return colors_; } | 454 const BreakList<SkColor>& colors() const { return colors_; } |
452 const std::vector<BreakList<bool> >& styles() const { return styles_; } | 455 const std::vector<BreakList<bool> >& styles() const { return styles_; } |
453 | 456 |
454 const std::vector<internal::Line>& lines() const { return lines_; } | 457 const std::vector<internal::Line>& lines() const { return lines_; } |
455 void set_lines(std::vector<internal::Line>* lines) { lines_.swap(*lines); } | 458 void set_lines(std::vector<internal::Line>* lines) { lines_.swap(*lines); } |
456 | 459 |
457 // Returns the baseline of the current text. The return value depends on | 460 // Returns the baseline of the current text. The return value depends on |
458 // the text and its layout while the return value of GetBaseline() doesn't. | 461 // the text and its layout while the return value of GetBaseline() doesn't. |
459 // GetAlignmentOffset() takes into account the difference between them. | 462 // GetAlignmentOffset() takes into account the difference between them. |
460 // | 463 // |
461 // We'd like a RenderText to show the text always on the same baseline | 464 // We'd like a RenderText to show the text always on the same baseline |
462 // regardless of the text, so the text does not jump up or down depending | 465 // regardless of the text, so the text does not jump up or down depending |
463 // on the text. However, underlying layout engines return different baselines | 466 // on the text. However, underlying layout engines return different baselines |
464 // depending on the text. In general, layout engines determine the minimum | 467 // depending on the text. In general, layout engines determine the minimum |
465 // bounding box for the text and return the baseline from the top of the | 468 // bounding box for the text and return the baseline from the top of the |
466 // bounding box. So the baseline changes depending on font metrics used to | 469 // bounding box. So the baseline changes depending on font metrics used to |
467 // layout the text. | 470 // layout the text. |
468 // | 471 // |
469 // For example, suppose there are FontA and FontB and the baseline of FontA | 472 // For example, suppose there are FontA and FontB and the baseline of FontA |
470 // is smaller than the one of FontB. If the text is laid out only with FontA, | 473 // is smaller than the one of FontB. If the text is laid out only with FontA, |
471 // then the baseline of FontA may be returned. If the text includes some | 474 // then the baseline of FontA may be returned. If the text includes some |
472 // characters which are laid out with FontB, then the baseline of FontB may | 475 // characters which are laid out with FontB, then the baseline of FontB may |
473 // be returned. | 476 // be returned. |
474 // | 477 // |
475 // GetBaseline() returns the fixed baseline regardless of the text. | 478 // GetBaseline() returns the fixed baseline regardless of the text. |
476 // GetLayoutTextBaseline() returns the baseline determined by the underlying | 479 // GetDisplayTextBaseline() returns the baseline determined by the underlying |
477 // layout engine, and it changes depending on the text. GetAlignmentOffset() | 480 // layout engine, and it changes depending on the text. GetAlignmentOffset() |
478 // returns the difference between them. | 481 // returns the difference between them. |
479 virtual int GetLayoutTextBaseline() = 0; | 482 virtual int GetDisplayTextBaseline() = 0; |
480 | 483 |
481 void set_cached_bounds_and_offset_valid(bool valid) { | 484 void set_cached_bounds_and_offset_valid(bool valid) { |
482 cached_bounds_and_offset_valid_ = valid; | 485 cached_bounds_and_offset_valid_ = valid; |
483 } | 486 } |
484 | 487 |
485 // Get the selection model that visually neighbors |position| by |break_type|. | 488 // Get the selection model that visually neighbors |position| by |break_type|. |
486 // The returned value represents a cursor/caret position without a selection. | 489 // The returned value represents a cursor/caret position without a selection. |
487 SelectionModel GetAdjacentSelectionModel(const SelectionModel& current, | 490 SelectionModel GetAdjacentSelectionModel(const SelectionModel& current, |
488 BreakType break_type, | 491 BreakType break_type, |
489 VisualCursorDirection direction); | 492 VisualCursorDirection direction); |
(...skipping 18 matching lines...) Expand all Loading... | |
508 virtual void SetSelectionModel(const SelectionModel& model); | 511 virtual void SetSelectionModel(const SelectionModel& model); |
509 | 512 |
510 // Get the visual bounds containing the logical substring within the |range|. | 513 // Get the visual bounds containing the logical substring within the |range|. |
511 // If |range| is empty, the result is empty. These bounds could be visually | 514 // If |range| is empty, the result is empty. These bounds could be visually |
512 // discontinuous if the substring is split by a LTR/RTL level change. | 515 // discontinuous if the substring is split by a LTR/RTL level change. |
513 // These bounds are in local coordinates, but may be outside the visible | 516 // These bounds are in local coordinates, but may be outside the visible |
514 // region if the text is longer than the textfield. Subsequent text, cursor, | 517 // region if the text is longer than the textfield. Subsequent text, cursor, |
515 // or bounds changes may invalidate returned values. | 518 // or bounds changes may invalidate returned values. |
516 virtual std::vector<Rect> GetSubstringBounds(const Range& range) = 0; | 519 virtual std::vector<Rect> GetSubstringBounds(const Range& range) = 0; |
517 | 520 |
518 // Convert between indices into |text_| and indices into |obscured_text_|, | 521 // Convert between indices into |text_| and indices into |
519 // which differ when the text is obscured. Regardless of whether or not the | 522 // GetDisplayText(), which differ when the text is obscured, |
520 // text is obscured, the character (code point) offsets always match. | 523 // truncated or elided. Regardless of whether or not the text is |
521 virtual size_t TextIndexToLayoutIndex(size_t index) const = 0; | 524 // obscured, the character (code point) offsets always match. |
522 virtual size_t LayoutIndexToTextIndex(size_t index) const = 0; | 525 virtual size_t TextIndexToDisplayIndex(size_t index) = 0; |
526 virtual size_t DisplayIndexToTextIndex(size_t index) = 0; | |
523 | 527 |
524 // Reset the layout to be invalid. | 528 // Notifies that layout text, or attributes that affect the layout text |
525 virtual void ResetLayout() = 0; | 529 // shape have changed. |text_changed| is true if the content of the |
530 // |layout_text_| has changed, not just attributes. | |
531 virtual void OnLayoutTextAttributeChanged(bool text_changed) = 0; | |
532 | |
533 // Notifies that attributes that affect the display text shape have changed. | |
534 virtual void OnDisplayTextAttributeChanged() = 0; | |
526 | 535 |
527 // Ensure the text is laid out, lines are computed, and |lines_| is valid. | 536 // Ensure the text is laid out, lines are computed, and |lines_| is valid. |
528 virtual void EnsureLayout() = 0; | 537 virtual void EnsureLayout() = 0; |
529 | 538 |
530 // Draw the text. | 539 // Draw the text. |
531 virtual void DrawVisualText(Canvas* canvas) = 0; | 540 virtual void DrawVisualText(Canvas* canvas) = 0; |
532 | 541 |
533 // Returns the text used for layout, which may be obscured or truncated. | 542 // Update the display text. |
534 const base::string16& GetLayoutText() const; | 543 void UpdateDisplayText(float text_width); |
535 | 544 |
536 // Returns layout text positions that are suitable for breaking lines. | 545 // Returns display text positions that are suitable for breaking lines. |
537 const BreakList<size_t>& GetLineBreaks(); | 546 const BreakList<size_t>& GetLineBreaks(); |
538 | 547 |
539 // Apply (and undo) temporary composition underlines and selection colors. | 548 // Apply (and undo) temporary composition underlines and selection colors. |
540 void ApplyCompositionAndSelectionStyles(); | 549 void ApplyCompositionAndSelectionStyles(); |
541 void UndoCompositionAndSelectionStyles(); | 550 void UndoCompositionAndSelectionStyles(); |
542 | 551 |
543 // Returns the line offset from the origin after applying the text alignment | 552 // Returns the line offset from the origin after applying the text alignment |
544 // and the display offset. | 553 // and the display offset. |
545 Vector2d GetLineOffset(size_t line_number); | 554 Vector2d GetLineOffset(size_t line_number); |
546 | 555 |
(...skipping 10 matching lines...) Expand all Loading... | |
557 | 566 |
558 // Returns the line offset from the origin, accounts for text alignment only. | 567 // Returns the line offset from the origin, accounts for text alignment only. |
559 Vector2d GetAlignmentOffset(size_t line_number); | 568 Vector2d GetAlignmentOffset(size_t line_number); |
560 | 569 |
561 // Applies fade effects to |renderer|. | 570 // Applies fade effects to |renderer|. |
562 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); | 571 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); |
563 | 572 |
564 // Applies text shadows to |renderer|. | 573 // Applies text shadows to |renderer|. |
565 void ApplyTextShadows(internal::SkiaTextRenderer* renderer); | 574 void ApplyTextShadows(internal::SkiaTextRenderer* renderer); |
566 | 575 |
576 // Get the text direction for the current directionality mode and given | |
577 // |text|. | |
578 base::i18n::TextDirection GetTextDirection(const base::string16& text); | |
579 | |
567 // A convenience function to check whether the glyph attached to the caret | 580 // A convenience function to check whether the glyph attached to the caret |
568 // is within the given range. | 581 // is within the given range. |
569 static bool RangeContainsCaret(const Range& range, | 582 static bool RangeContainsCaret(const Range& range, |
570 size_t caret_pos, | 583 size_t caret_pos, |
571 LogicalCursorDirection caret_affinity); | 584 LogicalCursorDirection caret_affinity); |
572 | 585 |
573 private: | 586 private: |
574 friend class RenderTextTest; | 587 friend class RenderTextTest; |
575 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, DefaultStyle); | 588 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, DefaultStyle); |
576 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SetColorAndStyle); | 589 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SetColorAndStyle); |
(...skipping 24 matching lines...) Expand all Loading... | |
601 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); | 614 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); |
602 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth); | 615 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth); |
603 | 616 |
604 // Set the cursor to |position|, with the caret trailing the previous | 617 // Set the cursor to |position|, with the caret trailing the previous |
605 // grapheme, or if there is no previous grapheme, leading the cursor position. | 618 // grapheme, or if there is no previous grapheme, leading the cursor position. |
606 // If |select| is false, the selection start is moved to the same position. | 619 // If |select| is false, the selection start is moved to the same position. |
607 // If the |position| is not a cursorable position (not on grapheme boundary), | 620 // If the |position| is not a cursorable position (not on grapheme boundary), |
608 // it is a NO-OP. | 621 // it is a NO-OP. |
609 void MoveCursorTo(size_t position, bool select); | 622 void MoveCursorTo(size_t position, bool select); |
610 | 623 |
611 // Updates |layout_text_| if the text is obscured or truncated. | 624 // Updates |layout_text_| and |display_text_| as needed (or marks them dirty). |
612 void UpdateLayoutText(); | 625 void OnTextAttributeChanged(); |
613 | 626 |
614 // Elides |text| as needed to fit in the |available_width| using |behavior|. | 627 // Elides |text| as needed to fit in the |available_width| using |behavior|. |
628 // |text_width| is the pre-calculated width of the text shaped by this render | |
629 // text, or pass 0 if the width is unknown. | |
615 base::string16 Elide(const base::string16& text, | 630 base::string16 Elide(const base::string16& text, |
631 float text_width, | |
616 float available_width, | 632 float available_width, |
617 ElideBehavior behavior); | 633 ElideBehavior behavior); |
618 | 634 |
619 // Elides |email| as needed to fit the |available_width|. | 635 // Elides |email| as needed to fit the |available_width|. |
620 base::string16 ElideEmail(const base::string16& email, float available_width); | 636 base::string16 ElideEmail(const base::string16& email, float available_width); |
621 | 637 |
622 // Update the cached bounds and display offset to ensure that the current | 638 // Update the cached bounds and display offset to ensure that the current |
623 // cursor is within the visible display area. | 639 // cursor is within the visible display area. |
624 void UpdateCachedBoundsAndOffset(); | 640 void UpdateCachedBoundsAndOffset(); |
625 | 641 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 // The background color used for drawing the selection when focused. | 682 // The background color used for drawing the selection when focused. |
667 SkColor selection_background_focused_color_; | 683 SkColor selection_background_focused_color_; |
668 | 684 |
669 // The focus state of the text. | 685 // The focus state of the text. |
670 bool focused_; | 686 bool focused_; |
671 | 687 |
672 // Composition text range. | 688 // Composition text range. |
673 Range composition_range_; | 689 Range composition_range_; |
674 | 690 |
675 // Color and style breaks, used to color and stylize ranges of text. | 691 // Color and style breaks, used to color and stylize ranges of text. |
676 // BreakList positions are stored with text indices, not layout indices. | 692 // BreakList positions are stored with text indices, not display indices. |
677 // TODO(msw): Expand to support cursor, selection, background, etc. colors. | 693 // TODO(msw): Expand to support cursor, selection, background, etc. colors. |
678 BreakList<SkColor> colors_; | 694 BreakList<SkColor> colors_; |
679 std::vector<BreakList<bool> > styles_; | 695 std::vector<BreakList<bool> > styles_; |
680 | 696 |
681 // Breaks saved without temporary composition and selection styling. | 697 // Breaks saved without temporary composition and selection styling. |
682 BreakList<SkColor> saved_colors_; | 698 BreakList<SkColor> saved_colors_; |
683 BreakList<bool> saved_underlines_; | 699 BreakList<bool> saved_underlines_; |
684 bool composition_and_selection_styles_applied_; | 700 bool composition_and_selection_styles_applied_; |
685 | 701 |
686 // A flag to obscure actual text with asterisks for password fields. | 702 // A flag to obscure actual text with asterisks for password fields. |
687 bool obscured_; | 703 bool obscured_; |
688 // The index at which the char should be revealed in the obscured text. | 704 // The index at which the char should be revealed in the obscured text. |
689 int obscured_reveal_index_; | 705 int obscured_reveal_index_; |
690 | 706 |
691 // The maximum length of text to display, 0 forgoes a hard limit. | 707 // The maximum length of text to display, 0 forgoes a hard limit. |
692 size_t truncate_length_; | 708 size_t truncate_length_; |
693 | 709 |
710 // The obscured and/or truncated text used to layout the text to display. | |
711 base::string16 layout_text_; | |
712 | |
713 // The elided text displayed visually. This is empty if the text | |
714 // does not have to be elided, or became empty as a result of eliding. | |
715 // TODO(oshima): When the text is elided, painting can be done only with | |
716 // display text info, so it should be able to clear the |layout_text_| and | |
717 // associated information. | |
718 base::string16 display_text_; | |
719 | |
694 // The behavior for eliding, fading, or truncating. | 720 // The behavior for eliding, fading, or truncating. |
695 ElideBehavior elide_behavior_; | 721 ElideBehavior elide_behavior_; |
696 | 722 |
697 // The obscured and/or truncated text that will be displayed. | 723 // True if the text is elided given the current behavior and display area. |
698 base::string16 layout_text_; | 724 bool text_elided_; |
699 | 725 |
700 // Whether newline characters should be replaced with newline symbols. | 726 // Whether newline characters should be replaced with newline symbols. |
701 bool replace_newline_chars_with_symbols_; | 727 bool replace_newline_chars_with_symbols_; |
msw
2015/02/13 22:19:05
You didn't actually remove this...
oshima
2015/02/13 23:24:11
Done.
| |
702 | 728 |
703 // The minimum height a line should have. | 729 // The minimum height a line should have. |
704 int min_line_height_; | 730 int min_line_height_; |
705 | 731 |
706 // Whether the text should be broken into multiple lines. Uses the width of | 732 // Whether the text should be broken into multiple lines. Uses the width of |
707 // |display_rect_| as the width cap. | 733 // |display_rect_| as the width cap. |
708 bool multiline_; | 734 bool multiline_; |
709 | 735 |
710 // Is the background transparent (either partially or fully)? | 736 // Is the background transparent (either partially or fully)? |
711 bool background_is_transparent_; | 737 bool background_is_transparent_; |
(...skipping 16 matching lines...) Expand all Loading... | |
728 // centered. | 754 // centered. |
729 int baseline_; | 755 int baseline_; |
730 | 756 |
731 // The cached bounds and offset are invalidated by changes to the cursor, | 757 // The cached bounds and offset are invalidated by changes to the cursor, |
732 // selection, font, and other operations that adjust the visible text bounds. | 758 // selection, font, and other operations that adjust the visible text bounds. |
733 bool cached_bounds_and_offset_valid_; | 759 bool cached_bounds_and_offset_valid_; |
734 | 760 |
735 // Text shadows to be drawn. | 761 // Text shadows to be drawn. |
736 ShadowValues shadows_; | 762 ShadowValues shadows_; |
737 | 763 |
738 // A list of valid layout text line break positions. | 764 // A list of valid display text line break positions. |
739 BreakList<size_t> line_breaks_; | 765 BreakList<size_t> line_breaks_; |
740 | 766 |
741 // Lines computed by EnsureLayout. These should be invalidated with | 767 // Lines computed by EnsureLayout. These should be invalidated upon |
742 // ResetLayout and on |display_rect_| changes. | 768 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
743 std::vector<internal::Line> lines_; | 769 std::vector<internal::Line> lines_; |
744 | 770 |
745 DISALLOW_COPY_AND_ASSIGN(RenderText); | 771 DISALLOW_COPY_AND_ASSIGN(RenderText); |
746 }; | 772 }; |
747 | 773 |
748 } // namespace gfx | 774 } // namespace gfx |
749 | 775 |
750 #endif // UI_GFX_RENDER_TEXT_H_ | 776 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |