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

Unified Diff: ui/gfx/render_text.cc

Issue 795933009: [AiS] for desktop, two lines and font sytles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed braces 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/render_text.cc
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index 2b51d8aa8c75156871e18fda188ba726cad0c33a..64872c3ccc0001671b1c386271945898ee467bac 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -445,21 +445,15 @@ void RenderText::SetText(const base::string16& text) {
DCHECK(!composition_range_.IsValid());
if (text_ == text)
return;
- text_ = text;
+ text_.clear();
+ DoAppendText(text);
- // Adjust ranged styles, baselines, and colors to accommodate a new text
- // length. Clear style ranges as they might break new text graphemes and apply
+ // Clear style ranges as they might break new text graphemes and apply
// the first style to the whole text instead.
- const size_t text_length = text_.length();
- colors_.SetMax(text_length);
+ colors_.SetValue(colors_.breaks().begin()->second);
baselines_.SetValue(baselines_.breaks().begin()->second);
- baselines_.SetMax(text_length);
- for (size_t style = 0; style < NUM_TEXT_STYLES; ++style) {
- BreakList<bool>& break_list = styles_[style];
- break_list.SetValue(break_list.breaks().begin()->second);
- break_list.SetMax(text_length);
- }
- cached_bounds_and_offset_valid_ = false;
+ for (size_t style = 0; style < NUM_TEXT_STYLES; ++style)
+ styles_[style].SetValue(styles_[style].breaks().begin()->second);
// Reset selection model. SetText should always followed by SetSelectionModel
// or SetCursorPosition in upper layer.
@@ -469,7 +463,11 @@ void RenderText::SetText(const base::string16& text) {
if (directionality_mode_ == DIRECTIONALITY_FROM_TEXT)
text_direction_ = base::i18n::UNKNOWN_DIRECTION;
- obscured_reveal_index_ = -1;
+ OnTextAttributeChanged();
+}
+
+void RenderText::AppendText(const base::string16& text) {
+ DoAppendText(text);
OnTextAttributeChanged();
}
@@ -1241,6 +1239,18 @@ size_t RenderText::TextIndexToGivenTextIndex(const base::string16& given_text,
return std::min<size_t>(given_text.length(), i);
}
+void RenderText::DoAppendText(const base::string16& text) {
+ text_ += text;
+ // Adjust ranged styles and colors to accommodate a new text length.
+ const size_t text_length = text_.length();
+ colors_.SetMax(text_length);
+ baselines_.SetMax(text_length);
+ for (size_t style = 0; style < NUM_TEXT_STYLES; ++style)
+ styles_[style].SetMax(text_length);
+ cached_bounds_and_offset_valid_ = false;
msw 2015/03/18 20:20:16 Sorry, I changed my mind here a bit. I think it'd
+ obscured_reveal_index_ = -1;
+}
+
// static
bool RenderText::RangeContainsCaret(const Range& range,
size_t caret_pos,

Powered by Google App Engine
This is Rietveld 408576698