Bug 260055

Summary: AX: -[WebAccessibilityObjectWrapper attributedStringForNSRange:] should exit early for ranges of zero length
Product: WebKit Reporter: Tyler Wilcock <tyler_w>
Component: AccessibilityAssignee: Tyler Wilcock <tyler_w>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cfleizach, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Tyler Wilcock 2023-08-10 20:50:40 PDT
...
Comment 1 Radar WebKit Bug Importer 2023-08-10 20:50:49 PDT
<rdar://problem/113730674>
Comment 2 Tyler Wilcock 2023-08-10 20:51:03 PDT
rdar://113616003
Comment 3 Tyler Wilcock 2023-08-10 21:28:49 PDT
Created attachment 467243 [details]
Patch
Comment 4 Andres Gonzalez 2023-08-11 11:23:02 PDT
(In reply to Tyler Wilcock from comment #3)
> Created attachment 467243 [details]
> Patch

--- a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
+++ b/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

+    auto attributedString = backingObject->attributedStringForTextMarkerRange(backingObject->textMarkerRangeForNSRange(range), AXCoreObject::SpellCheck::Yes);
+    if (![attributedString length])
+        return nil;
+
+    return attributedString.autorelease();

Looks good, just consider the 2 liner: 

    auto attributedString = backingObject->attributedStringForTextMarkerRange(backingObject->textMarkerRangeForNSRange(range), AXCoreObject::SpellCheck::Yes);
    return [attributedString length] ? attributedString.autorelease() : nil;
Comment 5 Tyler Wilcock 2023-08-17 17:16:25 PDT
rdar://113768013
Comment 6 Tyler Wilcock 2023-08-17 17:19:14 PDT
Created attachment 467318 [details]
Patch
Comment 7 EWS 2023-08-18 10:48:52 PDT
Committed 267045@main (f4896f6e7c4b): <https://commits.webkit.org/267045@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 467318 [details].