Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 677afac9fefb30712341b5b909db687479ec7f53 https://github.com/WebKit/WebKit/commit/677afac9fefb30712341b5b909db687479ec7f53 Author: Richard Robinson <richard_robins...@apple.com> Date: 2024-04-26 (Fri, 26 Apr 2024)
Changed paths: M Source/WebCore/dom/DocumentMarkerController.cpp M Source/WebCore/dom/DocumentMarkerController.h M Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm M Source/WebKit/WebProcess/WebPage/UnifiedTextReplacementController.h Log Message: ----------- [Unified Text Replacement] Undo-ing a replacement session can sometimes result in incorrect text https://bugs.webkit.org/show_bug.cgi?id=273331 rdar://127123467 Reviewed by Aditya Keerthi. When undo-ing a text replacement session, the original text may not be restored correctly. This is because in `didEndTextReplacementSession`, the markers were being iterated from the beginning and then their ranges were replaced with the original text. However, if the original text was a different length than the marker range length, the replacement of the subsequent markers will end up using an out-of-date replacement range. Fix by iterating the markers backwards, since the replacement range of prior markers will never be affected in this case. Also perform a minor refactor to share more common logic. * Source/WebCore/dom/DocumentMarkerController.cpp: (WebCore::DocumentMarkerController::forEach<DocumentMarkerController::IterationMode::Forward>): (WebCore::DocumentMarkerController::forEach<DocumentMarkerController::IterationMode::Reversed>): (WebCore::DocumentMarkerController::forEachOfTypes): (WebCore::DocumentMarkerController::forEach): Deleted. * Source/WebCore/dom/DocumentMarkerController.h: * Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm: (WebKit::UnifiedTextReplacementController::textReplacementSessionDidUpdateStateForReplacement): (WebKit::UnifiedTextReplacementController::didEndTextReplacementSession): (WebKit::UnifiedTextReplacementController::textReplacementSessionPerformEditActionForPlainText): (WebKit::UnifiedTextReplacementController::updateStateForSelectedReplacementIfNeeded): (WebKit::UnifiedTextReplacementController::findReplacementMarkerByUUID): (WebKit::UnifiedTextReplacementController::findReplacementMarkerContainingRange): (WebKit::findReplacementMarkerByUUID): Deleted. (WebKit::findReplacementMarkerContainingRange): Deleted. * Source/WebKit/WebProcess/WebPage/UnifiedTextReplacementController.h: Canonical link: https://commits.webkit.org/278069@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes