Commit 8f462482 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Rewrite ElideText unittests

This CL is rewriting the ElideText unittests.
The goal of this rewrite is to allow adding more unittests.
  * ELIDE_HEAD
  * ELIDE_EMAIL
  * ELIDE_MIDDLE
  * Eliding with styles

It is now using a templated tests to ease debugging.

A change to the way glyph_width_for_test_ work was needed.
Zero width codepoints will stay zero width, even if a
glyph width is provided. This is required to ensures
RLM and LRM (directional marker) stay with width zero.
Otherwise a DCHECK is failing since the text can be larger
with eliding (2 glyphs instead of 1 glyph).

Bug: 1025561
Change-Id: I19f18fb99f52edbbb59d170f7b47bef3a3f3de5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1975056
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726406}
parent 360eb8f5
...@@ -1337,10 +1337,13 @@ void ShapeRunWithFont(const ShapeRunWithFontInput& in, ...@@ -1337,10 +1337,13 @@ void ShapeRunWithFont(const ShapeRunWithFontInput& in,
const SkScalar y_offset = const SkScalar y_offset =
HarfBuzzUnitsToSkiaScalar(hb_positions[i].y_offset); HarfBuzzUnitsToSkiaScalar(hb_positions[i].y_offset);
out->positions[i].set(out->width + x_offset, -y_offset); out->positions[i].set(out->width + x_offset, -y_offset);
out->width += (in.glyph_width_for_test > 0)
? in.glyph_width_for_test if (in.glyph_width_for_test == 0)
: HarfBuzzUnitsToFloat(hb_positions[i].x_advance) + out->width +=
in.glyph_spacing; HarfBuzzUnitsToFloat(hb_positions[i].x_advance) + in.glyph_spacing;
else if (hb_positions[i].x_advance) // Leave zero-width glyphs alone.
out->width += in.glyph_width_for_test;
// Round run widths if subpixel positioning is off to match native behavior. // Round run widths if subpixel positioning is off to match native behavior.
if (!in.render_params.subpixel_positioning) if (!in.render_params.subpixel_positioning)
out->width = std::round(out->width); out->width = std::round(out->width);
......
This diff is collapsed.
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