Index: ui/gfx/render_text.cc |
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc |
index 50d29e83fe14585dc6002bc9b2a502b49d5c0b31..873cd47452c137daee715e08fa797e0cb1189c4f 100644 |
--- a/ui/gfx/render_text.cc |
+++ b/ui/gfx/render_text.cc |
@@ -349,10 +349,13 @@ void SkiaTextRenderer::DiagonalStrike::Draw() { |
} |
StyleIterator::StyleIterator(const BreakList<SkColor>& colors, |
+ const BreakList<BaselineStyle>& baselines, |
const std::vector<BreakList<bool> >& styles) |
: colors_(colors), |
+ baselines_(baselines), |
styles_(styles) { |
color_ = colors_.breaks().begin(); |
+ baseline_ = baselines_.breaks().begin(); |
for (size_t i = 0; i < styles_.size(); ++i) |
style_.push_back(styles_[i].breaks().begin()); |
} |
@@ -361,6 +364,7 @@ StyleIterator::~StyleIterator() {} |
Range StyleIterator::GetRange() const { |
Range range(colors_.GetRange(color_)); |
+ range = range.Intersect(baselines_.GetRange(baseline_)); |
for (size_t i = 0; i < NUM_TEXT_STYLES; ++i) |
range = range.Intersect(styles_[i].GetRange(style_[i])); |
return range; |
@@ -368,6 +372,7 @@ Range StyleIterator::GetRange() const { |
void StyleIterator::UpdatePosition(size_t position) { |
color_ = colors_.GetBreak(position); |
+ baseline_ = baselines_.GetBreak(position); |
for (size_t i = 0; i < NUM_TEXT_STYLES; ++i) |
style_[i] = styles_[i].GetBreak(position); |
} |
@@ -428,6 +433,7 @@ void RenderText::SetText(const base::string16& text) { |
// the first style to the whole text instead. |
const size_t text_length = text_.length(); |
colors_.SetMax(text_length); |
+ baselines_.SetMax(text_length); |
msw
2015/02/18 17:07:23
You'll need to clear the baseline values here, lik
dschuyler
2015/02/18 22:36:02
Done.
|
for (size_t style = 0; style < NUM_TEXT_STYLES; ++style) { |
BreakList<bool>& break_list = styles_[style]; |
break_list.SetValue(break_list.breaks().begin()->second); |
@@ -668,6 +674,14 @@ void RenderText::ApplyColor(SkColor value, const Range& range) { |
colors_.ApplyValue(value, range); |
} |
+void RenderText::SetBaselineStyle(BaselineStyle value) { |
+ baselines_.SetValue(value); |
+} |
+ |
+void RenderText::ApplyBaselineStyle(BaselineStyle value, const Range& range) { |
+ baselines_.ApplyValue(value, range); |
+} |
+ |
void RenderText::SetStyle(TextStyle style, bool value) { |
styles_[style].SetValue(value); |
@@ -925,6 +939,7 @@ RenderText::RenderText() |
focused_(false), |
composition_range_(Range::InvalidRange()), |
colors_(kDefaultColor), |
+ baselines_(NORMAL_BASELINE), |
styles_(NUM_TEXT_STYLES), |
composition_and_selection_styles_applied_(false), |
obscured_(false), |
@@ -1259,6 +1274,7 @@ base::string16 RenderText::Elide(const base::string16& text, |
render_text->SetCursorEnabled(cursor_enabled_); |
render_text->set_truncate_length(truncate_length_); |
render_text->styles_ = styles_; |
+ render_text->baselines_ = baselines_; |
render_text->colors_ = colors_; |
render_text->SetText(text); |
if (render_text->GetContentWidthF() <= available_width) |
@@ -1283,6 +1299,7 @@ base::string16 RenderText::Elide(const base::string16& text, |
for (size_t guess = (lo + hi) / 2; lo <= hi; guess = (lo + hi) / 2) { |
// Restore colors. They will be truncated to size by SetText. |
render_text->colors_ = colors_; |
+ render_text->baselines_ = baselines_; |
msw
2015/02/18 17:07:23
With the change to clear the baseline values on Se
dschuyler
2015/02/18 22:36:02
I moved the restore break list code out to a separ
|
base::string16 new_text = |
slicer.CutString(guess, insert_ellipsis && behavior != ELIDE_TAIL); |
render_text->SetText(new_text); |