Bug 205485 - [WinCairo] Some of combining family glyphs are replaced by space glyphs
Summary: [WinCairo] Some of combining family glyphs are replaced by space glyphs
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
: 206058 (view as bug list)
Depends on:
Blocks: 172565
  Show dependency treegraph
 
Reported: 2019-12-19 20:26 PST by Fujii Hironori
Modified: 2020-01-22 22:49 PST (History)
8 users (show)

See Also:


Attachments
simplified test case (124 bytes, text/html)
2019-12-19 20:33 PST, Fujii Hironori
no flags Details
WIP patch (3.39 KB, patch)
2019-12-22 22:19 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
[Screenshot] WinCairo port (135.20 KB, image/png)
2020-01-09 20:46 PST, Fujii Hironori
no flags Details
Patch (9.25 KB, patch)
2020-01-16 03:58 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (11.93 KB, patch)
2020-01-16 16:59 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch for landing (12.01 KB, patch)
2020-01-22 22:16 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2019-12-19 20:26:52 PST
[Win] fast/text/stale-TextLayout-from-first-line.html is failing since Bug 204884
Comment 1 Fujii Hironori 2019-12-19 20:33:05 PST
Created attachment 386177 [details]
simplified test case

̀ doesn't show because
ComplexTextController::adjustGlyphsAndAdvances replaces a glyph
of &#x0300 with the space glyph.

stringIndices given by collectComplexTextRunsForCharacters are incorrect.

Uniscribe returns clusters.
For " ̀", it returns [0 0]. This means both glyphs consist of a single cluster starting at 0th glyph.

Then, clusters are converted into stringIndices. It's [0 0].
This means both glyphs correspond to 0th charcther. This is incorrect.
ComplexTextController::adjustGlyphsAndAdvances replaces glyphs in the positions of space charcthers with the space glyph.
Comment 2 Fujii Hironori 2019-12-20 01:09:29 PST
fast/text/emoji-single-parent-family.html has a similar issue.
👨‍👦 shows only the father glyph because ComplexTextController replaces the boy glyph with a space glyph.

ScriptShape

input text: [👨 ‍ 👦] (length=5)
output glyphs: [6368 6318] which are fater and boy glyphs
output clusters: [0 0 1 1 1] which means consisting two clusters, and the 0th cluster starts at glyphs[0] (father glyph), 1st cluster starts at glyphs[1] (boy glyph)

Then,

stringIndices: [0 2] which means glyphs[0] points to text[0], glyphs[1] points to text[2] (zwj).

ComplexTextController replaces the boy glyph with a space glyph because glyphs[0] (child glyph) points to zwj..
Comment 3 Fujii Hironori 2019-12-22 22:19:39 PST
Created attachment 386326 [details]
WIP patch
Comment 4 Fujii Hironori 2020-01-09 20:46:09 PST
Created attachment 387312 [details]
[Screenshot] WinCairo port

It breaks happily combining family glyphs.
https://emojiterra.com/family/
Comment 5 Fujii Hironori 2020-01-14 02:54:24 PST
*** Bug 206058 has been marked as a duplicate of this bug. ***
Comment 6 Fujii Hironori 2020-01-15 02:57:12 PST
This patch solves the missing glyph problem of fast/text/stale-TextLayout-from-first-line.html,
but it doesn't pass the test yet due to another bug.

I change the summary of bug, and file another bug for fast/text/stale-TextLayout-from-first-line.html.
Comment 7 Fujii Hironori 2020-01-16 03:58:59 PST
Created attachment 387908 [details]
Patch
Comment 8 Fujii Hironori 2020-01-16 16:59:56 PST
Created attachment 387990 [details]
Patch
Comment 9 Myles C. Maxfield 2020-01-22 09:21:53 PST
Comment on attachment 387990 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=387990&action=review

> Source/WebCore/platform/graphics/win/ComplexTextControllerUniscribe.cpp:146
> +        int endGlyphIndex = !finish ? clusters[endStringIndex] : -1;

Nowadays we prefer to use out-of-band sentinels. How about Optional<unsigned>?
Comment 10 zalan 2020-01-22 09:22:47 PST
(In reply to Myles C. Maxfield from comment #9)
> Comment on attachment 387990 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=387990&action=review
> 
> > Source/WebCore/platform/graphics/win/ComplexTextControllerUniscribe.cpp:146
> > +        int endGlyphIndex = !finish ? clusters[endStringIndex] : -1;
> 
> Nowadays we prefer to use out-of-band sentinels. How about
> Optional<unsigned>?
or Optional<size_t>
Comment 11 Fujii Hironori 2020-01-22 21:23:22 PST
Comment on attachment 387990 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=387990&action=review

Thank you very much for the review.

>>> Source/WebCore/platform/graphics/win/ComplexTextControllerUniscribe.cpp:146
>>> +        int endGlyphIndex = !finish ? clusters[endStringIndex] : -1;
>> 
>> Nowadays we prefer to use out-of-band sentinels. How about Optional<unsigned>?
> 
> or Optional<size_t>

Yes, this part is bad.
It should use stringIndicesRange.end() as the sentinel if finish is true.

If the real index is used, by allowing to get the real index of end(), the code would look like:

> int endGlyphIndex = !finish ? clusters[endStringIndex] : stringIndicesRange.end().index();

If the iterator is used, by add a method to get a iterator from real index, the code would look like:

> auto endGlyphIndex = !finish ? stringIndicesRange.fromIndex(clusters[endStringIndex]) : stringIndicesRange.end();

I will take later way.
Comment 12 Fujii Hironori 2020-01-22 22:16:48 PST
Created attachment 388519 [details]
Patch for landing
Comment 13 Fujii Hironori 2020-01-22 22:20:55 PST
Comment on attachment 388519 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=388519&action=review

> Source/WebCore/platform/graphics/win/ComplexTextControllerUniscribe.cpp:162
> +        for (; glyphIndex != endGlyphIterator; ++glyphIndex)

This loop condition was greatly improved.
Less condition, no conversion from a iterator to a real index.

before:

> for (; glyphIndex != stringIndicesRange.end() && glyphIndex.index() != endGlyphIndex; ++glyphIndex)

after:

> for (; glyphIndex != endGlyphIterator; ++glyphIndex)

Thank you very much.
Comment 14 Fujii Hironori 2020-01-22 22:47:50 PST
Comment on attachment 388519 [details]
Patch for landing

Clearing flags on attachment: 388519

Committed r254965: <https://trac.webkit.org/changeset/254965>
Comment 15 Fujii Hironori 2020-01-22 22:47:53 PST
All reviewed patches have been landed.  Closing bug.
Comment 16 Radar WebKit Bug Importer 2020-01-22 22:48:17 PST
<rdar://problem/58825349>