Bug 235937

Summary: [LFC][IFC] Using Fontcascade::spaceWidth to subtract the trailing space width may result in incorrect layout
Product: WebKit Reporter: zalan <zalan>
Component: Layout and RenderingAssignee: zalan <zalan>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, koivisto, mjs, mmaxfield, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=235995
Bug Depends on: 235998    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch ews-feeder: commit-queue-

Description zalan 2022-01-31 20:23:58 PST
when the primary font does not have space glyph.
Comment 1 zalan 2022-01-31 20:24:16 PST
<rdar://88059633>
Comment 2 zalan 2022-01-31 20:28:09 PST
Created attachment 450492 [details]
Patch
Comment 3 zalan 2022-02-01 08:16:43 PST
Created attachment 450529 [details]
Patch
Comment 4 zalan 2022-02-01 09:06:55 PST
Created attachment 450538 [details]
Patch
Comment 5 Maciej Stachowiak 2022-02-01 12:10:21 PST
<rdar://88059633>
Comment 6 zalan 2022-02-01 13:04:45 PST
Created attachment 450559 [details]
Patch
Comment 7 EWS 2022-02-01 14:53:21 PST
Committed r288914 (246654@main): <https://commits.webkit.org/246654@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 450559 [details].
Comment 8 WebKit Commit Bot 2022-02-01 20:02:17 PST
Re-opened since this is blocked by bug 235998
Comment 9 zalan 2022-02-01 20:18:05 PST
Created attachment 450605 [details]
Patch
Comment 10 zalan 2022-02-01 20:22:50 PST
null terminator? where we're going we don't need null terminator.
Comment 11 EWS 2022-02-01 21:52:10 PST
Committed r288944 (246674@main): <https://commits.webkit.org/246674@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 450605 [details].
Comment 12 Myles C. Maxfield 2022-02-01 22:20:40 PST
Comment on attachment 450605 [details]
Patch

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

> Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:94
> +    return fontCascade.width(TextRun { String { &space, 1 } });

There are no performance problems with this?
Comment 13 zalan 2022-02-02 06:37:55 PST
(In reply to Myles C. Maxfield from comment #12)
> Comment on attachment 450605 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=450605&action=review
> 
> > Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:94
> > +    return fontCascade.width(TextRun { String { &space, 1 } });
> 
> There are no performance problems with this?
I had run our classic PerformanceTests/Layout/line-layout-simple.html microbenchmark locally before landing this and it showed about 0.5% regression.
I also tested it with a slightly different version of the patch:
  const auto& spaceGlyphData = fontCascade.glyphDataForCharacter(space, false);
  return (!spaceGlyphData.font ? fontCascade.spaceWidth() : spaceGlyphData.font>widthForGlyph(spaceGlyphData.glyph)) + fontCascade.letterSpacing();
and it came back with the same numbers.