Bug 260055 - AX: -[WebAccessibilityObjectWrapper attributedStringForNSRange:] should exit early for ranges of zero length
Summary: AX: -[WebAccessibilityObjectWrapper attributedStringForNSRange:] should exit ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-08-10 20:50 PDT by Tyler Wilcock
Modified: 2023-08-18 10:48 PDT (History)
10 users (show)

See Also:


Attachments
Patch (2.04 KB, patch)
2023-08-10 21:28 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (2.02 KB, patch)
2023-08-17 17:19 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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].