-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Unified Text Replacement]
willBeginTextReplacementSession
sometime…
…s does not return a context if the text lengths differ https://bugs.webkit.org/show_bug.cgi?id=274325 rdar://128285414 Reviewed by Aditya Keerthi. The length of the string produced by `editingAttributedString` and the character count produced by `TextIterator` can sometimes differ. This can happen when there are images in the HTML, as `editingAttributedString` handles them in a special case. Fix by adding a new `TextIteratorBehavior` option that acts the same as `EmitsObjectReplacementCharacters`, but only for images, and then use this behavior anywhere in UnifiedTextReplacementController that needs character ranges or counts. Also fix a few issues with attachments in attributed strings: * When converting an `AttributedString` to an `NSAttributedString` with an attachment, if the attachment does not have a "preferred" filename, an empty file wrapper will be created. Fix by always creating a file wrapper. * When converting HTML with an image to an attributed string, the position of the resulting attachment in the produced attributed string is sometimes incorrect. This is because the length of the attachment itself is never taken into account, and so consequent parts of the string will be inserted in too early of a position. Fix by accounting for the length of the attachment. * Source/WebCore/editing/TextIterator.cpp: (WebCore::TextIterator::TextIterator): (WebCore::TextIterator::handleReplacedElement): * Source/WebCore/editing/TextIteratorBehavior.h: * Source/WebCore/editing/cocoa/AttributedString.mm: (WebCore::toNSObject): * Source/WebCore/editing/cocoa/HTMLConverter.mm: (WebCore::editingAttributedString): * Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm: (WebKit::UnifiedTextReplacementController::characterRange): (WebKit::UnifiedTextReplacementController::characterCount): (WebKit::UnifiedTextReplacementController::resolveCharacterRange): (WebKit::UnifiedTextReplacementController::plainText): (WebKit::UnifiedTextReplacementController::willBeginTextReplacementSession): (WebKit::UnifiedTextReplacementController::textReplacementSessionDidReceiveReplacements): (WebKit::UnifiedTextReplacementController::textReplacementSessionDidReceiveTextWithReplacementRange): (WebKit::UnifiedTextReplacementController::textReplacementSessionPerformEditActionForPlainText): (WebKit::UnifiedTextReplacementController::contextRangeForSessionOrRangeWithUUID const): (WebKit::UnifiedTextReplacementController::replaceContentsOfRangeInSessionInternal): * Source/WebKit/WebProcess/WebPage/UnifiedTextReplacementController.h: Canonical link: https://commits.webkit.org/279002@main
- Loading branch information
Showing
6 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters