New issue
Advanced search Search tips

Issue 897967 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 9
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Remove whitespace from text elision

Project Member Reported by pbos@chromium.org, Oct 22

Issue description

Text elision can include whitespace, which looks unpolished in my eyes:

ELIDE_TAIL of 800372 - Harmony extension popup... becomes:

"800372 - Harmony ..."

I believe this should be typeset as "800372 - Harmony..."

ELIDE_MIDDLE of "Foo barb baz" could be:

"Foo ... baz"
I believe this should be typeset as "Foo...baz".
Without removing whitespace there's also risk for asymmetry: "Foo... ba" or "Fo ...baz"

Are these controversial, or can we just exclude whitespace from text elision boundaries?

Related question: text_utils.cc's FindValidBoundaryBefore / ..After both check "CharIsMark(" to check for a combining mark character, though the base::string16::substr usage in StringSlicer::CutString either includes or excludes this character as substr(start, len) uses [start, start + len), which includes the mark if it's the first character (start), but excludes it if it's the trailing character.

Also it looks like CutString uses FindValidBoundaryBefore for ELIDE_HEAD but it looks to me like it should be using FindValidBoundaryAfter since BoundaryBefore would potentially (?) expand the bounds of the suffix.

msw@ / tapted@ I'd really like to get your input here. These classes are very new to me.
 
Anecdotally, I haven't managed to convince macOS to put a space next to an eliding ellipsis. See attached.

It's possible that Apple's algo is smarter than just "trim whitespace" though. E.g. one case seems to move the ellipsis a little such that there is no need to trim.

For the related question/s - I don't know too much history about the specific implementations - what you describe does sound like a possible bug. Unless history or tests say otherwise, and you have cases that are broken, it sounds like it's worth fixing.
Screen Shot 2018-10-23 at 17.43.15.png
47.2 KB View Download
Screen Shot 2018-10-23 at 17.41.15.png
179 KB View Download
I don't see any obvious problems with removing whitespace. The latter two points sound like possible bugs, any fixes should include specific examples of broken behavior and regression unit tests. Thanks for digging in!
Here's what I'm specifically trying to solve. I assume Mac's material menus will need the corresponding problem fixed (so we need both ELIDE_TAIL and ELIDE_MIDDLE "working").

Do I understand correctly that what CharIsMark is checking is essentially for things like "COMBINING ACUTE ACCENT" and skipping past them (in either direction) so that the entire glyph is removed? If so I'll try to find cases that I believe might be broken.
space_elide_tail.png
27.7 KB View Download
Right, that example screenshot is helpful.

I believe your understanding of CharIsMark is correct. Hopefully there are tests of that behavior somewhere.
Labels: Hotlist-DesktopUIConsider
Labels: Group-Platform
Labels: Hotlist-Polish
Status: Assigned (was: Untriaged)
Labels: -Hotlist-DesktopUIConsider Hotlist-DesktopUITriaged
Labels: Hotlist-DesktopUIChecked Hotlist-DesktopUIToolingRequired
** UI Mass triage **
Labels: M-73 Target-73
Cc: pbos@chromium.org
Owner: dfried@chromium.org
Status: Started (was: Assigned)
Project Member

Comment 14 by bugdroid1@chromium.org, Jan 9

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e

commit 76d8382fb1d1ff05db2be8738276c4e6cafbaf1e
Author: Dana Fried <dfried@chromium.org>
Date: Wed Jan 09 22:24:30 2019

Trim whitespace during head and tail string elision.

All string elision that removes the head or tail of a string will now
remove any whitespace adjacent to the elision point as well.

Furthermore, eliding the beginning of a string will never result in more
unicode codepoints or bytes than was initially requested. Previously,
it was possible to end up including a character with combining marks or
a character whose codepoint was split by the target number of
characters.

This does affect filename elision. For example, eliding "foo bar.gif" to
the width of 9 characters results in "foo….gif" rather than "foo ….gif",
because the filename elision logic elides the tail of the base filename
rather than eliding the middle of the full filename.

Bug:  897967 
Change-Id: I0e5e170b656c185a91de64ef042d01ec3920ceb8
Reviewed-on: https://chromium-review.googlesource.com/c/1387737
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Michael Wasserman <msw@chromium.org>
Commit-Queue: Dana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#621337}
[modify] https://crrev.com/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e/ash/public/cpp/app_list/tokenized_string_char_iterator.cc
[modify] https://crrev.com/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e/base/i18n/char_iterator.cc
[modify] https://crrev.com/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e/base/i18n/char_iterator.h
[modify] https://crrev.com/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e/base/i18n/char_iterator_unittest.cc
[modify] https://crrev.com/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e/ui/gfx/text_elider.cc
[modify] https://crrev.com/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e/ui/gfx/text_elider_unittest.cc
[modify] https://crrev.com/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e/ui/gfx/text_utils.cc
[modify] https://crrev.com/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e/ui/gfx/text_utils.h
[modify] https://crrev.com/76d8382fb1d1ff05db2be8738276c4e6cafbaf1e/ui/gfx/text_utils_unittest.cc

Status: Fixed (was: Started)

Sign in to add a comment