Bug 227896

Summary: PUA characters have the wrong advance in the fast text codepath
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: New BugsAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, dino, jonlee, simon.fraser, thorton, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Myles C. Maxfield 2021-07-12 23:03:34 PDT
PUA characters have the wrong advance in the fast text codepath
Comment 1 Myles C. Maxfield 2021-07-12 23:06:56 PDT
Created attachment 433389 [details]
Patch
Comment 2 Myles C. Maxfield 2021-07-12 23:07:27 PDT
<rdar://problem/80037103>
Comment 3 Tim Horton 2021-07-12 23:24:33 PDT
Comment on attachment 433389 [details]
Patch

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

> Source/WebCore/platform/graphics/FontCascade.h:254
> +    static bool treatAsSpace(UChar32 c) { return c == ' ' || c == '\t' || c == '\n' || c == noBreakSpace; }

I'm confused why the silent truncation wasn't a compiler error??

> LayoutTests/fast/text/pua-charactersTreatedAsSpace-expected.html:16
> +This test passes if you see a particular pattern of black boxes below.

particular but indescribable?
Comment 4 EWS 2021-07-13 00:52:45 PDT
Committed r279868 (239621@main): <https://commits.webkit.org/239621@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 433389 [details].
Comment 5 Darin Adler 2021-07-23 14:52:15 PDT
Comment on attachment 433389 [details]
Patch

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

>> Source/WebCore/platform/graphics/FontCascade.h:254
>> +    static bool treatAsSpace(UChar32 c) { return c == ' ' || c == '\t' || c == '\n' || c == noBreakSpace; }
> 
> I'm confused why the silent truncation wasn't a compiler error??

Integer truncation has always been silent, with few exceptions. It would be great to find a way to tighten that up.

One trick that can be used in particular cases where we want to be careful to be clever is to overload, making the integer type ambiguous if it’s not a perfect match.