Bug 273284 - AX: Re-enable accessibility/ios-simulator/inline-prediction-attributed-string test
Summary: AX: Re-enable accessibility/ios-simulator/inline-prediction-attributed-string...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joshua Hoffman
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2024-04-25 15:47 PDT by Joshua Hoffman
Modified: 2024-04-30 09:53 PDT (History)
5 users (show)

See Also:


Attachments
Patch (26.40 KB, patch)
2024-04-25 16:08 PDT, Joshua Hoffman
no flags Details | Formatted Diff | Diff
Patch (26.61 KB, patch)
2024-04-25 19:39 PDT, Joshua Hoffman
no flags Details | Formatted Diff | Diff
Patch (26.70 KB, patch)
2024-04-26 09:58 PDT, Joshua Hoffman
no flags Details | Formatted Diff | Diff
Patch (27.87 KB, patch)
2024-04-26 12:12 PDT, Joshua Hoffman
no flags Details | Formatted Diff | Diff
Patch (28.54 KB, patch)
2024-04-29 11:25 PDT, Joshua Hoffman
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Hoffman 2024-04-25 15:47:17 PDT
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.
Comment 1 Radar WebKit Bug Importer 2024-04-25 15:47:27 PDT
<rdar://problem/127079331>
Comment 2 Joshua Hoffman 2024-04-25 16:08:56 PDT
Created attachment 471144 [details]
Patch
Comment 3 Joshua Hoffman 2024-04-25 19:39:40 PDT
Created attachment 471151 [details]
Patch
Comment 4 Andres Gonzalez 2024-04-26 07:21:34 PDT
(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 5 Tyler Wilcock 2024-04-26 08:28:05 PDT
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)) {
    ...
}
Comment 6 Joshua Hoffman 2024-04-26 09:58:54 PDT
Created attachment 471164 [details]
Patch
Comment 7 Joshua Hoffman 2024-04-26 12:12:15 PDT
Missing the glib revert—adding that now.
Comment 8 Joshua Hoffman 2024-04-26 12:12:47 PDT
Created attachment 471166 [details]
Patch
Comment 9 Joshua Hoffman 2024-04-29 11:25:22 PDT
Created attachment 471201 [details]
Patch
Comment 10 EWS 2024-04-30 09:53:15 PDT
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].