Bug 234758 - [LFC][IFC] Take grapheme clusters into account when keeping the first "character" on the line
Summary: [LFC][IFC] Take grapheme clusters into account when keeping the first "charac...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-30 19:27 PST by zalan
Modified: 2021-12-31 06:23 PST (History)
5 users (show)

See Also:


Attachments
Patch (13.85 KB, patch)
2021-12-30 19:37 PST, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zalan 2021-12-30 19:27:46 PST
in preparation for enabling complex font codepath for IFC.
Comment 1 zalan 2021-12-30 19:37:55 PST
Created attachment 448115 [details]
Patch
Comment 2 Antti Koivisto 2021-12-31 00:47:23 PST
Comment on attachment 448115 [details]
Patch

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

> Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:296
> +    auto graphemeClustersIterator = NonSharedCharacterBreakIterator { textContent };
> +    auto nextPosition = ubrk_following(graphemeClustersIterator, inlineTextItem.start());
> +    if (nextPosition == UBRK_DONE)
> +        return inlineTextItem.length();
> +    return nextPosition - inlineTextItem.start();

Isn't it slow to make the iterator repeatedly? Maybe we should cache it or make it in the caller?
Comment 3 Antti Koivisto 2021-12-31 01:00:32 PST
Comment on attachment 448115 [details]
Patch

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

>> Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:296
>> +    auto graphemeClustersIterator = NonSharedCharacterBreakIterator { textContent };
>> +    auto nextPosition = ubrk_following(graphemeClustersIterator, inlineTextItem.start());
>> +    if (nextPosition == UBRK_DONE)
>> +        return inlineTextItem.length();
>> +    return nextPosition - inlineTextItem.start();
> 
> Isn't it slow to make the iterator repeatedly? Maybe we should cache it or make it in the caller?

I suppose it is always initialized with a different StringView so there is nothing to cache.
Comment 4 zalan 2021-12-31 06:15:29 PST
(In reply to Antti Koivisto from comment #3)
> Comment on attachment 448115 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=448115&action=review
> 
> >> Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:296
> >> +    auto graphemeClustersIterator = NonSharedCharacterBreakIterator { textContent };
> >> +    auto nextPosition = ubrk_following(graphemeClustersIterator, inlineTextItem.start());
> >> +    if (nextPosition == UBRK_DONE)
> >> +        return inlineTextItem.length();
> >> +    return nextPosition - inlineTextItem.start();
> > 
> > Isn't it slow to make the iterator repeatedly? Maybe we should cache it or make it in the caller?
> 
> I suppose it is always initialized with a different StringView so there is
> nothing to cache.
Yes. This codepath may be triggered once per line at most. It is also not a highly common case as regular web pages let their inline content fit the container. However it is very much used for testing content breaking (width: 0px).
Comment 5 EWS 2021-12-31 06:22:08 PST
Committed r287493 (245628@main): <https://commits.webkit.org/245628@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 448115 [details].
Comment 6 Radar WebKit Bug Importer 2021-12-31 06:23:18 PST
<rdar://problem/87028287>