From b21235bb8e7dd9fcec5d6420bbbec4f9d3a2215f Mon Sep 17 00:00:00 2001 From: Megan Gardner Date: Tue, 21 May 2024 15:06:37 -0700 Subject: [PATCH] Text not visible after undo-ing UnifiedTextReplacement. https://bugs.webkit.org/show_bug.cgi?id=274427 rdar://128292480 Reviewed by Wenson Hsieh and Aditya Keerthi. We were only clearing document markers in a specific range, but after text has been replaced, those nodes might not be in that range any longer. Just clear all the markers associated with an ID, regardless of location. * Source/WebCore/dom/DocumentMarkerController.h: * Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm: (WebKit::UnifiedTextReplacementController::removeTransparentMarkersForUUID): Canonical link: https://commits.webkit.org/279078@main --- Source/WebCore/dom/DocumentMarkerController.h | 2 +- .../WebPage/Cocoa/UnifiedTextReplacementController.mm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/WebCore/dom/DocumentMarkerController.h b/Source/WebCore/dom/DocumentMarkerController.h index 5ae57d2076538..c6a7b89379cf1 100644 --- a/Source/WebCore/dom/DocumentMarkerController.h +++ b/Source/WebCore/dom/DocumentMarkerController.h @@ -79,6 +79,7 @@ class DocumentMarkerController final : public CanMakeCheckedPtr& filterFunction, OptionSet = DocumentMarker::allMarkers(), RemovePartiallyOverlappingMarker = RemovePartiallyOverlappingMarker::No); WEBCORE_EXPORT void removeMarkers(OptionSet = DocumentMarker::allMarkers()); + WEBCORE_EXPORT void removeMarkers(OptionSet, const Function& filterFunction); void removeMarkers(Node&, OptionSet = DocumentMarker::allMarkers()); void repaintMarkers(OptionSet = DocumentMarker::allMarkers()); void shiftMarkers(Node&, unsigned startOffset, int delta); @@ -115,7 +116,6 @@ class DocumentMarkerController final : public CanMakeCheckedPtr, std::unique_ptr>>; bool possiblyHasMarkers(OptionSet) const; - void removeMarkers(OptionSet, const Function& filterFunction); OptionSet removeMarkersFromList(MarkerMap::iterator, OptionSet, const Function& filterFunction = nullptr); void forEachOfTypes(OptionSet, Function&&); diff --git a/Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm b/Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm index 0ac6439967440..76bceb95f6c94 100644 --- a/Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm +++ b/Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm @@ -332,9 +332,9 @@ return; } - document->markers().filterMarkers(range, [&](const WebCore::DocumentMarker& marker) { + document->markers().removeMarkers({ WebCore::DocumentMarker::Type::TransparentContent }, [&](const WebCore::DocumentMarker& marker) { return std::get(marker.data()).uuid == uuid ? WebCore::FilterMarkerResult::Remove : WebCore::FilterMarkerResult::Keep; - }, { WebCore::DocumentMarker::Type::TransparentContent }); + }); } void UnifiedTextReplacementController::removeTransparentMarkersForSession(const WTF::UUID& uuid, RemoveAllMarkersForSession removeAll)