[Webkit-unassigned] [Bug 265683] AX: add Mac API to get selected text range overlapping static text element

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Dec 1 14:46:16 PST 2023


https://bugs.webkit.org/show_bug.cgi?id=265683

--- Comment #5 from Andres Gonzalez <andresg_22 at apple.com> ---
(In reply to Dominic Mazzoni from comment #2)
> Created attachment 468835 [details]
> Patch

diff --git a/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp b/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
index a47d458c0c23..0ec64c61c922 100644
--- a/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
+++ b/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
@@ -1274,6 +1274,29 @@ bool AXIsolatedObject::isNativeTextControl() const
     return false;
 }

+std::optional<CharacterRange> AXIsolatedObject::selectedStaticTextRange() const
+{
+    ASSERT(isStaticText());
+
+    AXTextMarkerRange range = tree()->selectedTextMarkerRange();
+    if (range.start().treeID() != tree()->treeID() || range.end().treeID() != tree()->treeID())
+        return std::nullopt;
+
+    if (range.start().objectID() == range.end().objectID()) {
+        if (range.start().objectID() != objectID())
+            return std::nullopt;
+
+        std::make_optional(CharacterRange(range.start().characterOffset(), range.end().characterOffset()));

AG: missing return ?

+    }
+
+    return Accessibility::retrieveValueFromMainThread<std::optional<CharacterRange>>([this] () -> std::optional<CharacterRange> {
+        if (auto* axObject = associatedAXObject())
+            return axObject->selectedStaticTextRange();
+
+        return std::nullopt;
+    });
+}
+
 int AXIsolatedObject::insertionPointLineNumber() const
 {
     return Accessibility::retrieveValueFromMainThread<int>([this] () -> int {

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20231201/90db334d/attachment.htm>


More information about the webkit-unassigned mailing list