(not really a bug) RenderText::GetSubstringBounds and RenderText::GetCursorBounds disagree (integer rounding differs) |
||
Issue descriptionContext: test failures on https://codereview.chromium.org/2927953003/ A views_unittest fails on some versions of macOS due to a change in the font that RenderText is using. The test, LabelSelectionTest.MouseDragSingleLineRT, renders בגדהוזא, then selects it with the mouse. The drag start point is chosen using GetSubstringBounds() but RenderText() decides whether to select to the left or the right of the *cursor* position, using GetCursorBounds(). Both are doing the right thing. GetSubstringBounds() rounds using ceil(). This ensures the entire glyph is highlighted when selecting. GetCursorBounds() rounds to nearest. This gives the cursor the best chance of fitting nicely "between" the glyphs. RenderText::MoveCursor() is also doing the right thing by using GetCursorBounds() as the decider on which direction to go when selecting with the mouse. What's "wrong" is the test using GetSubstringBounds() in its GetCursorPoint() helper method. Unfortunately, it can't (always) use GetCursorBounds, since it doesn't support multiline text. (you can't currently edit multiline, so there's no point drawing the insertion cursor). I think to make the test happy, we can use GetCursorBounds() to select the start drag point when we know the text is single-line*, and fall back to GetSubstringBounds otherwise. Alternatively, we can force the test to use 'Lucida Grande' on Mac, but that feels more like it could bite us in future. *(Edit: multiline -> single-line)
,
Jun 21 2017
,
Jun 23 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/7d814671483a3cde6b0c9e7c616ceb1eebfd3f17 commit 7d814671483a3cde6b0c9e7c616ceb1eebfd3f17 Author: tapted <tapted@chromium.org> Date: Fri Jun 23 01:37:09 2017 Use CTFontCreateForString for RenderTextHarfbuzz on Mac The approach ends up pretty close to what's already done for Windows. On Mac, CTFontCreateForString() gives better fallbacks (i.e. they more often match what native UI does) and requires RenderTextHarfbuzz to do less work. However, it doesn't guarantee that the returned font can display every glyph in the provided string. So still use CTFontCopyDefaultCascadeListForLanguages (which is now a public API - hooray) to provide a last-resort list of fallback fonts. This CL causes a font used for Hebrew text in a test to change, which tickled a pre-existing bug/corner case in the test for some macOS versions. BUG= 696867 , 619684 , 735346 Previously landed in r481062, but tickled some OS-specific tests due to a valid discrepancy between rounding directions. Review-Url: https://codereview.chromium.org/2927953003 Cr-Commit-Position: refs/heads/master@{#481764} [modify] https://crrev.com/7d814671483a3cde6b0c9e7c616ceb1eebfd3f17/ui/gfx/font_fallback.h [modify] https://crrev.com/7d814671483a3cde6b0c9e7c616ceb1eebfd3f17/ui/gfx/font_fallback_mac.mm [modify] https://crrev.com/7d814671483a3cde6b0c9e7c616ceb1eebfd3f17/ui/gfx/font_fallback_mac_unittest.cc [modify] https://crrev.com/7d814671483a3cde6b0c9e7c616ceb1eebfd3f17/ui/gfx/font_fallback_win.cc [modify] https://crrev.com/7d814671483a3cde6b0c9e7c616ceb1eebfd3f17/ui/gfx/font_fallback_win.h [modify] https://crrev.com/7d814671483a3cde6b0c9e7c616ceb1eebfd3f17/ui/gfx/render_text_harfbuzz.cc [modify] https://crrev.com/7d814671483a3cde6b0c9e7c616ceb1eebfd3f17/ui/views/controls/label_unittest.cc
,
Jul 3 2017
Closing this out - nothing to do, but code references this issue. Full multiline editing support in RenderTextHarfbuzz may make it less interesting - that's Issue 248597 |
||
►
Sign in to add a comment |
||
Comment 1 by tapted@chromium.org
, Jun 21 2017