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

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

Issue 985923002: Revert of adding baseline options for super/sub scripting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 Canvas* canvas_; 102 Canvas* canvas_;
103 SkCanvas* canvas_skia_; 103 SkCanvas* canvas_skia_;
104 SkPaint paint_; 104 SkPaint paint_;
105 SkScalar underline_thickness_; 105 SkScalar underline_thickness_;
106 SkScalar underline_position_; 106 SkScalar underline_position_;
107 scoped_ptr<DiagonalStrike> diagonal_; 107 scoped_ptr<DiagonalStrike> diagonal_;
108 108
109 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); 109 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer);
110 }; 110 };
111 111
112 // Internal helper class used to iterate colors, baselines, and styles. 112 // Internal helper class used by derived classes to iterate colors and styles.
113 class StyleIterator { 113 class StyleIterator {
114 public: 114 public:
115 StyleIterator(const BreakList<SkColor>& colors, 115 StyleIterator(const BreakList<SkColor>& colors,
116 const BreakList<BaselineStyle>& baselines, 116 const std::vector<BreakList<bool> >& styles);
117 const std::vector<BreakList<bool>>& styles);
118 ~StyleIterator(); 117 ~StyleIterator();
119 118
120 // Get the colors and styles at the current iterator position. 119 // Get the colors and styles at the current iterator position.
121 SkColor color() const { return color_->second; } 120 SkColor color() const { return color_->second; }
122 BaselineStyle baseline() const { return baseline_->second; }
123 bool style(TextStyle s) const { return style_[s]->second; } 121 bool style(TextStyle s) const { return style_[s]->second; }
124 122
125 // Get the intersecting range of the current iterator set. 123 // Get the intersecting range of the current iterator set.
126 Range GetRange() const; 124 Range GetRange() const;
127 125
128 // Update the iterator to point to colors and styles applicable at |position|. 126 // Update the iterator to point to colors and styles applicable at |position|.
129 void UpdatePosition(size_t position); 127 void UpdatePosition(size_t position);
130 128
131 private: 129 private:
132 BreakList<SkColor> colors_; 130 BreakList<SkColor> colors_;
133 BreakList<BaselineStyle> baselines_;
134 std::vector<BreakList<bool> > styles_; 131 std::vector<BreakList<bool> > styles_;
135 132
136 BreakList<SkColor>::const_iterator color_; 133 BreakList<SkColor>::const_iterator color_;
137 BreakList<BaselineStyle>::const_iterator baseline_;
138 std::vector<BreakList<bool>::const_iterator> style_; 134 std::vector<BreakList<bool>::const_iterator> style_;
139 135
140 DISALLOW_COPY_AND_ASSIGN(StyleIterator); 136 DISALLOW_COPY_AND_ASSIGN(StyleIterator);
141 }; 137 };
142 138
143 // Line segments are slices of the display text to be rendered on a single line. 139 // Line segments are slices of the display text to be rendered on a single line.
144 struct LineSegment { 140 struct LineSegment {
145 LineSegment(); 141 LineSegment();
146 ~LineSegment(); 142 ~LineSegment();
147 143
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 void SelectWord(); 325 void SelectWord();
330 326
331 const Range& GetCompositionRange() const; 327 const Range& GetCompositionRange() const;
332 void SetCompositionRange(const Range& composition_range); 328 void SetCompositionRange(const Range& composition_range);
333 329
334 // Set the text color over the entire text or a logical character range. 330 // Set the text color over the entire text or a logical character range.
335 // The |range| should be valid, non-reversed, and within [0, text().length()]. 331 // The |range| should be valid, non-reversed, and within [0, text().length()].
336 void SetColor(SkColor value); 332 void SetColor(SkColor value);
337 void ApplyColor(SkColor value, const Range& range); 333 void ApplyColor(SkColor value, const Range& range);
338 334
339 // Set the baseline style over the entire text or a logical character range.
340 // The |range| should be valid, non-reversed, and within [0, text().length()].
341 void SetBaselineStyle(BaselineStyle value);
342 void ApplyBaselineStyle(BaselineStyle value, const Range& range);
343
344 // Set various text styles over the entire text or a logical character range. 335 // Set various text styles over the entire text or a logical character range.
345 // The respective |style| is applied if |value| is true, or removed if false. 336 // The respective |style| is applied if |value| is true, or removed if false.
346 // The |range| should be valid, non-reversed, and within [0, text().length()]. 337 // The |range| should be valid, non-reversed, and within [0, text().length()].
347 void SetStyle(TextStyle style, bool value); 338 void SetStyle(TextStyle style, bool value);
348 void ApplyStyle(TextStyle style, bool value, const Range& range); 339 void ApplyStyle(TextStyle style, bool value, const Range& range);
349 340
350 // Returns whether this style is enabled consistently across the entire 341 // Returns whether this style is enabled consistently across the entire
351 // RenderText. 342 // RenderText.
352 bool GetStyle(TextStyle style) const; 343 bool GetStyle(TextStyle style) const;
353 344
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 protected: 449 protected:
459 RenderText(); 450 RenderText();
460 451
461 // NOTE: The value of these accessors may be stale. Please make sure 452 // NOTE: The value of these accessors may be stale. Please make sure
462 // that these fields are up-to-date before accessing them. 453 // that these fields are up-to-date before accessing them.
463 const base::string16& layout_text() const { return layout_text_; } 454 const base::string16& layout_text() const { return layout_text_; }
464 const base::string16& display_text() const { return display_text_; } 455 const base::string16& display_text() const { return display_text_; }
465 bool text_elided() const { return text_elided_; } 456 bool text_elided() const { return text_elided_; }
466 457
467 const BreakList<SkColor>& colors() const { return colors_; } 458 const BreakList<SkColor>& colors() const { return colors_; }
468 const BreakList<BaselineStyle>& baselines() const { return baselines_; }
469 const std::vector<BreakList<bool> >& styles() const { return styles_; } 459 const std::vector<BreakList<bool> >& styles() const { return styles_; }
470 460
471 const std::vector<internal::Line>& lines() const { return lines_; } 461 const std::vector<internal::Line>& lines() const { return lines_; }
472 void set_lines(std::vector<internal::Line>* lines) { lines_.swap(*lines); } 462 void set_lines(std::vector<internal::Line>* lines) { lines_.swap(*lines); }
473 463
474 // Returns the baseline of the current text. The return value depends on 464 // Returns the baseline of the current text. The return value depends on
475 // the text and its layout while the return value of GetBaseline() doesn't. 465 // the text and its layout while the return value of GetBaseline() doesn't.
476 // GetAlignmentOffset() takes into account the difference between them. 466 // GetAlignmentOffset() takes into account the difference between them.
477 // 467 //
478 // We'd like a RenderText to show the text always on the same baseline 468 // We'd like a RenderText to show the text always on the same baseline
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 685
696 // The background color used for drawing the selection when focused. 686 // The background color used for drawing the selection when focused.
697 SkColor selection_background_focused_color_; 687 SkColor selection_background_focused_color_;
698 688
699 // The focus state of the text. 689 // The focus state of the text.
700 bool focused_; 690 bool focused_;
701 691
702 // Composition text range. 692 // Composition text range.
703 Range composition_range_; 693 Range composition_range_;
704 694
705 // Color, baseline, and style breaks, used to modify ranges of text. 695 // Color and style breaks, used to color and stylize ranges of text.
706 // BreakList positions are stored with text indices, not display indices. 696 // BreakList positions are stored with text indices, not display indices.
707 // TODO(msw): Expand to support cursor, selection, background, etc. colors. 697 // TODO(msw): Expand to support cursor, selection, background, etc. colors.
708 BreakList<SkColor> colors_; 698 BreakList<SkColor> colors_;
709 BreakList<BaselineStyle> baselines_;
710 std::vector<BreakList<bool> > styles_; 699 std::vector<BreakList<bool> > styles_;
711 700
712 // Breaks saved without temporary composition and selection styling. 701 // Breaks saved without temporary composition and selection styling.
713 BreakList<SkColor> saved_colors_; 702 BreakList<SkColor> saved_colors_;
714 BreakList<bool> saved_underlines_; 703 BreakList<bool> saved_underlines_;
715 bool composition_and_selection_styles_applied_; 704 bool composition_and_selection_styles_applied_;
716 705
717 // A flag to obscure actual text with asterisks for password fields. 706 // A flag to obscure actual text with asterisks for password fields.
718 bool obscured_; 707 bool obscured_;
719 // The index at which the char should be revealed in the obscured text. 708 // The index at which the char should be revealed in the obscured text.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 // Lines computed by EnsureLayout. These should be invalidated upon 769 // Lines computed by EnsureLayout. These should be invalidated upon
781 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. 770 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls.
782 std::vector<internal::Line> lines_; 771 std::vector<internal::Line> lines_;
783 772
784 DISALLOW_COPY_AND_ASSIGN(RenderText); 773 DISALLOW_COPY_AND_ASSIGN(RenderText);
785 }; 774 };
786 775
787 } // namespace gfx 776 } // namespace gfx
788 777
789 #endif // UI_GFX_RENDER_TEXT_H_ 778 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698