This test and corresponding infrastructure for iOS was removed, but the implementation stayed the same. We need to add this back in. This is related to https://bugs.webkit.org/show_bug.cgi?id=271969, which will track the work needed for the Mac side.
<rdar://problem/127079331>
Created attachment 471144 [details] Patch
Created attachment 471151 [details] Patch
(In reply to Joshua Hoffman from comment #3) > Created attachment 471151 [details] > Patch diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp index 32dc838ceaaf..e6495aacf498 100644 --- a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp +++ b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp @@ -621,7 +621,7 @@ WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef pageRef) return WebKit::toAPI(&WebKit::toImpl(pageRef)->trackedRepaintRects().leakRef()); } -void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length, bool suppressUnderline, WKArrayRef highlightData) +void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length, bool suppressUnderline, WKArrayRef highlightData, WKArrayRef annotationData) { Vector<WebCore::CompositionHighlight> highlights; if (highlightData) { @@ -648,7 +648,22 @@ void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int f } } - WebKit::toImpl(pageRef)->setCompositionForTesting(WebKit::toWTFString(text), from, length, suppressUnderline, highlights); + HashMap<String, Vector<WebCore::CharacterRange>> annotations; + if (annotationData) { + auto* annotationDataArray = WebKit::toImpl(annotationData); + for (auto dictionary : annotationDataArray->elementsOfType<API::Dictionary>()) { + auto location = static_cast<API::UInt64*>(dictionary->get("from"_s))->value(); + auto length = static_cast<API::UInt64*>(dictionary->get("length"_s))->value(); + auto name = static_cast<API::String*>(dictionary->get("annotation"_s))->string(); + + auto it = annotations.find(name); + if (it == annotations.end()) + it = annotations.add(name, Vector<WebCore::CharacterRange> { }).iterator; + it->value.append({ location, length }); AG: should not use it when it is == annotations.end(). + } + } + + WebKit::toImpl(pageRef)->setCompositionForTesting(WebKit::toWTFString(text), from, length, suppressUnderline, highlights, annotations); } bool WKBundlePageHasComposition(WKBundlePageRef pageRef)
Comment on attachment 471151 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=471151&action=review Looks good minus maybe one missing null check. > Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:654 > + auto* annotationDataArray = WebKit::toImpl(annotationData); > + for (auto dictionary : annotationDataArray->elementsOfType<API::Dictionary>()) { Does annotationDataArray need a null-check? Would it be possible to do this? if (auto* annotationDataArray = WebKit::toImpl(annotationData)) { ... }
Created attachment 471164 [details] Patch
Missing the glib revert—adding that now.
Created attachment 471166 [details] Patch
Created attachment 471201 [details] Patch
Committed 278171@main (26acf2ecbc14): <https://commits.webkit.org/278171@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 471201 [details].