| Index: ui/gfx/render_text.cc
|
| diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
|
| index 78bc651aee32c479ec8f84d793b7d520ee2cba33..d11cd0a8156cd168bc8411b628fe466b0550d1a8 100644
|
| --- a/ui/gfx/render_text.cc
|
| +++ b/ui/gfx/render_text.cc
|
| @@ -1028,9 +1028,10 @@ Vector2d RenderText::GetLineOffset(size_t line_number) {
|
| return offset;
|
| }
|
|
|
| -bool RenderText::GetDecoratedWordAtPoint(const Point& point,
|
| - DecoratedText* decorated_word,
|
| - Point* baseline_point) {
|
| +bool RenderText::GetDecoratedWordAndBaselineAtPoint(
|
| + const Point& point,
|
| + DecoratedText* decorated_word,
|
| + Point* baseline_point) {
|
| // FindCursorPosition doesn't currently support multiline. See
|
| // http://crbug.com/650120.
|
| if (multiline() || obscured())
|
| @@ -1047,15 +1048,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;
|
|
|