Commit 40d68ca9 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Remove usages of gfx::RangeF::Round from label_unittest

Bug: 1111044
Change-Id: I4772cf9f6246a498301cb9893caccddcd3c18f65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2332324
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795269}
parent 92af6f7b
......@@ -191,31 +191,31 @@ class LabelSelectionTest : public LabelTest {
SimulatePaint();
gfx::RenderText* render_text =
label()->GetRenderTextForSelectionController();
const gfx::Range range(index, index + 1);
const std::vector<gfx::Rect> bounds =
render_text->GetSubstringBounds(range);
DCHECK_EQ(1u, bounds.size());
const int mid_y = bounds[0].y() + bounds[0].height() / 2;
// For single-line text, use the glyph bounds since it gives a better
// representation of the midpoint between glyphs when considering selection.
// TODO(tapted): When GetCursorSpan() supports returning a vertical range
// as well as a horizontal range, just use that here.
// TODO(crbug.com/248597): Add multiline support to GetCursorBounds(...).
if (!render_text->multiline()) {
return gfx::Point(render_text->GetCursorSpan(range).Round().start(),
mid_y);
return render_text
->GetCursorBounds(gfx::SelectionModel(index, gfx::CURSOR_FORWARD),
true)
.left_center();
}
// Otherwise, GetCursorSpan() will give incorrect results. Multiline
// Otherwise, GetCursorBounds() will give incorrect results. Multiline
// editing is not supported (http://crbug.com/248597) so there hasn't been
// a need to draw a cursor. Instead, derive a point from the selection
// bounds, which always rounds up to an integer after the end of a glyph.
// This rounding differs to the glyph bounds, which rounds to nearest
// integer. See http://crbug.com/735346.
auto bounds = render_text->GetSubstringBounds({index, index + 1});
DCHECK_EQ(1u, bounds.size());
const bool rtl =
render_text->GetDisplayTextDirection() == base::i18n::RIGHT_TO_LEFT;
// Return Point corresponding to the leading edge of the character.
return gfx::Point(rtl ? bounds[0].right() - 1 : bounds[0].x() + 1, mid_y);
return rtl ? bounds[0].right_center() + gfx::Vector2d(-1, 0)
: bounds[0].left_center() + gfx::Vector2d(1, 0);
}
size_t GetLineCount() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment