Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cocoa] Hook "prior context" infrastructure up to TextBreakIteratorCF #14463

Conversation

litherum
Copy link
Contributor

@litherum litherum commented May 30, 2023

7d9c042

[Cocoa] Hook "prior context" infrastructure up to TextBreakIteratorCF
https://bugs.webkit.org/show_bug.cgi?id=257467
rdar://109983296

Reviewed by Alan Baradlay.

This patch is the next step to being able to use platform text iterators to break lines.
Previously, I implemented ContextualizedNSString, which is a subclass of NSString whose
backing store is 2 StringViews: one for the prior context of the string at hand, and one
for the string at hand itself. This patch hooks up ContextualizedNSString to our
TextBreakIteratorCF class, to allow TextBreakIteratorCF to work with prior context. This
is necessary because our line breaking code requires this prior context to work correctly,
and TextBreakIterator is the object which has a Core Foundation backend. If we want to be
able to do line breaking using Core Foundation, this patch is necessary.

The next patch will do something similar for TextBreakIteratorICU (which we luckily
already have UText support for). Once that's done, we should be able to migrate entirely
from LazyLineBreakIterator to TextBreakIterator.

* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/text/TextBreakIterator.h:
(WTF::TextBreakIterator::setText):
* Source/WTF/wtf/text/cf/TextBreakIteratorCF.h:
(WTF::TextBreakIteratorCF::TextBreakIteratorCF):
(WTF::TextBreakIteratorCF::setText):
(WTF::TextBreakIteratorCF::mapModeToBackingIterator):
* Source/WTF/wtf/text/cf/TextBreakIteratorCFCharacterCluster.h:
(WTF::TextBreakIteratorCFCharacterCluster::TextBreakIteratorCFCharacterCluster):
(WTF::TextBreakIteratorCFCharacterCluster::setText):
(WTF::TextBreakIteratorCFCharacterCluster::preceding const):
(WTF::TextBreakIteratorCFCharacterCluster::following const):
(WTF::TextBreakIteratorCFCharacterCluster::isBoundary const):
* Source/WTF/wtf/text/cf/TextBreakIteratorCFStringTokenizer.h:
(WTF::TextBreakIteratorCFStringTokenizer::TextBreakIteratorCFStringTokenizer):
(WTF::TextBreakIteratorCFStringTokenizer::setText):
(WTF::TextBreakIteratorCFStringTokenizer::preceding const):
(WTF::TextBreakIteratorCFStringTokenizer::following const):
(WTF::TextBreakIteratorCFStringTokenizer::isBoundary const):
* Source/WTF/wtf/text/cocoa/ContextualizedCFString.h: Added.
* Source/WTF/wtf/text/cocoa/ContextualizedCFString.mm: Added.
(WTF::createContextualizedCFString):
* Source/WTF/wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp:
(WTF::TextBreakIterator::mapModeToBackingIterator):
* Source/WTF/wtf/text/icu/TextBreakIteratorICU.h:
(WTF::TextBreakIteratorICU::setText):
* Tools/TestWebKitAPI/Tests/WTF/TextBreakIterator.cpp:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WTF/cocoa/ContextualizedNSString.mm:
(TEST):

Canonical link: https://commits.webkit.org/264714@main

f5dc39a

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 ❌ πŸ§ͺ gtk-wk2
βœ… πŸ›  πŸ§ͺ jsc βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  πŸ§ͺ jsc-arm64 βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ›  jsc-armv7
βœ… πŸ›  tv-sim βœ… πŸ§ͺ jsc-armv7-tests
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch βœ… πŸ›  jsc-mips
βœ… πŸ›  watch-sim βœ… πŸ§ͺ jsc-mips-tests

@litherum litherum self-assigned this May 30, 2023
@litherum litherum added the Text For bugs in text layout and rendering, including international text support. label May 30, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 30, 2023
@litherum litherum removed the merging-blocked Applied to prevent a change from being merged label May 30, 2023
@litherum litherum force-pushed the eng/Cocoa-Hook-prior-context-infrastructure-up-to-TextBreakIteratorCF branch from aa20a35 to 539ded9 Compare May 30, 2023 00:54
@litherum litherum force-pushed the eng/Cocoa-Hook-prior-context-infrastructure-up-to-TextBreakIteratorCF branch from 539ded9 to f5dc39a Compare May 30, 2023 05:41
@webkit-early-warning-system
Copy link
Collaborator

Starting EWS tests for f5dc39a. Live statuses available at the PR page, #14463

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 30, 2023
@litherum litherum added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels May 31, 2023
https://bugs.webkit.org/show_bug.cgi?id=257467
rdar://109983296

Reviewed by Alan Baradlay.

This patch is the next step to being able to use platform text iterators to break lines.
Previously, I implemented ContextualizedNSString, which is a subclass of NSString whose
backing store is 2 StringViews: one for the prior context of the string at hand, and one
for the string at hand itself. This patch hooks up ContextualizedNSString to our
TextBreakIteratorCF class, to allow TextBreakIteratorCF to work with prior context. This
is necessary because our line breaking code requires this prior context to work correctly,
and TextBreakIterator is the object which has a Core Foundation backend. If we want to be
able to do line breaking using Core Foundation, this patch is necessary.

The next patch will do something similar for TextBreakIteratorICU (which we luckily
already have UText support for). Once that's done, we should be able to migrate entirely
from LazyLineBreakIterator to TextBreakIterator.

* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/text/TextBreakIterator.h:
(WTF::TextBreakIterator::setText):
* Source/WTF/wtf/text/cf/TextBreakIteratorCF.h:
(WTF::TextBreakIteratorCF::TextBreakIteratorCF):
(WTF::TextBreakIteratorCF::setText):
(WTF::TextBreakIteratorCF::mapModeToBackingIterator):
* Source/WTF/wtf/text/cf/TextBreakIteratorCFCharacterCluster.h:
(WTF::TextBreakIteratorCFCharacterCluster::TextBreakIteratorCFCharacterCluster):
(WTF::TextBreakIteratorCFCharacterCluster::setText):
(WTF::TextBreakIteratorCFCharacterCluster::preceding const):
(WTF::TextBreakIteratorCFCharacterCluster::following const):
(WTF::TextBreakIteratorCFCharacterCluster::isBoundary const):
* Source/WTF/wtf/text/cf/TextBreakIteratorCFStringTokenizer.h:
(WTF::TextBreakIteratorCFStringTokenizer::TextBreakIteratorCFStringTokenizer):
(WTF::TextBreakIteratorCFStringTokenizer::setText):
(WTF::TextBreakIteratorCFStringTokenizer::preceding const):
(WTF::TextBreakIteratorCFStringTokenizer::following const):
(WTF::TextBreakIteratorCFStringTokenizer::isBoundary const):
* Source/WTF/wtf/text/cocoa/ContextualizedCFString.h: Added.
* Source/WTF/wtf/text/cocoa/ContextualizedCFString.mm: Added.
(WTF::createContextualizedCFString):
* Source/WTF/wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp:
(WTF::TextBreakIterator::mapModeToBackingIterator):
* Source/WTF/wtf/text/icu/TextBreakIteratorICU.h:
(WTF::TextBreakIteratorICU::setText):
* Tools/TestWebKitAPI/Tests/WTF/TextBreakIterator.cpp:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WTF/cocoa/ContextualizedNSString.mm:
(TEST):

Canonical link: https://commits.webkit.org/264714@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Cocoa-Hook-prior-context-infrastructure-up-to-TextBreakIteratorCF branch from f5dc39a to 7d9c042 Compare May 31, 2023 06:46
@webkit-commit-queue
Copy link
Collaborator

Committed 264714@main (7d9c042): https://commits.webkit.org/264714@main

Reviewed commits have been landed. Closing PR #14463 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 7d9c042 into WebKit:main May 31, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 31, 2023
@litherum litherum deleted the eng/Cocoa-Hook-prior-context-infrastructure-up-to-TextBreakIteratorCF branch May 31, 2023 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Text For bugs in text layout and rendering, including international text support.
Projects
None yet
5 participants