Summary: | [LFC][IFC] Take grapheme clusters into account when keeping the first "character" on the line | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | zalan <zalan> | ||||
Component: | Layout and Rendering | Assignee: | zalan <zalan> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | bfulgham, koivisto, simon.fraser, webkit-bug-importer, zalan | ||||
Priority: | P2 | Keywords: | InRadar | ||||
Version: | WebKit Nightly Build | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Attachments: |
|
Description
zalan
2021-12-30 19:27:46 PST
Created attachment 448115 [details]
Patch
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 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. (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). 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]. |