| Index: ui/gfx/render_text.cc
|
| diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
|
| index c12d80357bd5d5e0483f13b4b46146e455fe941c..123098623685f0eb932c898cddba0d1dc98356ea 100644
|
| --- a/ui/gfx/render_text.cc
|
| +++ b/ui/gfx/render_text.cc
|
| @@ -1033,15 +1033,24 @@ bool RenderText::GetDecoratedWordAtPoint(const Point& point,
|
| DCHECK(!word_range.is_reversed());
|
| DCHECK(!word_range.is_empty());
|
|
|
| - const std::vector<Rect> word_bounds = GetSubstringBounds(word_range);
|
| - if (word_bounds.empty() ||
|
| - !GetDecoratedTextForRange(word_range, decorated_word)) {
|
| + return GetDecoratedTextAndBaselineForRange(word_range, decorated_word,
|
| + baseline_point);
|
| +}
|
| +
|
| +bool RenderText::GetDecoratedTextAndBaselineForRange(
|
| + const Range& range,
|
| + DecoratedText* decorated_text,
|
| + Point* baseline_point) {
|
| + if (range.is_empty() || !GetDecoratedTextForRange(range, decorated_text))
|
| return false;
|
| - }
|
|
|
| // Retrieve the baseline origin of the left-most glyph.
|
| + const std::vector<Rect> text_bounds = GetSubstringBounds(range);
|
| + if (text_bounds.empty())
|
| + return false;
|
| +
|
| const auto left_rect = std::min_element(
|
| - word_bounds.begin(), word_bounds.end(),
|
| + text_bounds.begin(), text_bounds.end(),
|
| [](const Rect& lhs, const Rect& rhs) { return lhs.x() < rhs.x(); });
|
| *baseline_point = left_rect->origin() + Vector2d(0, GetDisplayTextBaseline());
|
| return true;
|
|
|