Fix GetSubstringBounds() rounding to floor x coordinate
Before this CL, RenderText::GetSubstringBounds() rounded up both the starting x and ending x that it computed. As a result, the left edge of the substring could be slightly outside the returned bounds, and the right edge of the returned bounds might contain some small portion of the next characters. When the output of GetSubstringBounds() is used as input for set_display_rect(), this rounding behavior could show up as small artifacts trailing the domain and/or clipping the first character slightly (see screenshots in linked bug). This CL makes GetSubstringBounds() round down the starting x coordinate. This provides the guarantee that the returned bounds always fully contain the substring -- that is, the bounds will be slightly larger rather than slightly smaller when rounding occurs. An alternative I considered was to introduce GetSubstringBoundsF and let consumers do their own rounding. However, as far as I can tell no other caller cares about the rounding behavior so it seemed like unnecessary complexity to add a float version of the method. Bug: 1108045, 1111044 Change-Id: I733326ef0544c4ecbe3e39bb9bd8f7a410bc0047 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317820 Commit-Queue: Emily Stark <estark@chromium.org> Reviewed-by:Michael Wasserman <msw@chromium.org> Reviewed-by:
Etienne Bergeron <etienneb@chromium.org> Cr-Commit-Position: refs/heads/master@{#793692}
Showing
Please register or sign in to comment