Bug 251849

Summary: AX: Remove unnecessary TextMarker methods from WebAccessibilityObjectWrapper
Product: WebKit Reporter: Andres Gonzalez <andresg_22>
Component: AccessibilityAssignee: Andres Gonzalez <andresg_22>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cfleizach, darin, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white, tyler_w, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Andres Gonzalez
Reported 2023-02-07 07:47:25 PST
Use the corresponding C functions instead.
Attachments
Patch (5.43 KB, patch)
2023-02-07 07:55 PST, Andres Gonzalez
no flags
Patch (5.44 KB, patch)
2023-02-09 08:50 PST, Andres Gonzalez
no flags
Patch (5.44 KB, patch)
2023-02-09 08:52 PST, Andres Gonzalez
no flags
Radar WebKit Bug Importer
Comment 1 2023-02-07 07:47:43 PST
Andres Gonzalez
Comment 2 2023-02-07 07:55:09 PST
Tyler Wilcock
Comment 3 2023-02-07 12:06:55 PST
Comment on attachment 464885 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=464885&action=review > COMMIT_MESSAGE:1 > +AX: Remove unnecessary TextMrker methods from WebAccessibilityObjectWrapper. Typo — TextMrker should be TextMarker
Darin Adler
Comment 4 2023-02-08 10:07:14 PST
Comment on attachment 464885 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=464885&action=review > COMMIT_MESSAGE:1 > +AX: Remove unnecessary TextMrker methods from WebAccessibilityObjectWrapper. Typo here in TextMarker. > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:535 > + [change setObject:marker.bridgingAutorelease() forKey:NSAccessibilityTextChangeValueStartMarker]; Never need autorelease when passing a value to a method, only when returning. Wastefully puts an object into the autorelease pool. Instead this should use get() and bridge_cast. You can probably find an example by searching for bridge_cast.
Darin Adler
Comment 5 2023-02-08 10:07:30 PST
Set back to review? by accident.
Andres Gonzalez
Comment 6 2023-02-09 08:42:33 PST
(In reply to Darin Adler from comment #4) > Comment on attachment 464885 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=464885&action=review > > > COMMIT_MESSAGE:1 > > +AX: Remove unnecessary TextMrker methods from WebAccessibilityObjectWrapper. > > Typo here in TextMarker. > > > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:535 > > + [change setObject:marker.bridgingAutorelease() forKey:NSAccessibilityTextChangeValueStartMarker]; > > Never need autorelease when passing a value to a method, only when > returning. Wastefully puts an object into the autorelease pool. Instead this > should use get() and bridge_cast. You can probably find an example by > searching for bridge_cast. Thanks Darin. Tried that but getting error: no matching function for call to 'bridge_cast' [change setObject:bridge_cast(marker.get()) forKey:NSAccessibilityTextChangeValueStartMarker]; ^~~~~~~~~~~ /OpenSource/WebKitBuild/Release/usr/local/include/wtf/cocoa/TypeCastsCocoa.h:59:113: note: candidate template ignored: could not match 'RetainPtr<T>' against 'WTF::RetainPtr<const __AXTextMarker>::PtrType' (aka 'const __AXTextMarker *') template<typename T> inline RetainPtr<std::remove_pointer_t<typename CFTollFreeBridgingTraits<T>::BridgedType>> bridge_cast(RetainPtr<T>&& object) ^ /OpenSource/WebKitBuild/Release/usr/local/include/wtf/cocoa/TypeCastsCocoa.h:54:79: note: candidate template ignored: substitution failure [with T = const __AXTextMarker *]: implicit instantiation of undefined template 'WTF::CFTollFreeBridgingTraits<const __AXTextMarker *>' template<typename T> inline typename CFTollFreeBridgingTraits<T>::BridgedType bridge_cast(T object) ~~~~~~~~~~~~~~~~~~~~~~~~ ^ /Users/ag/s/web/OpenSource/WebKitBuild/Release/usr/local/include/wtf/cocoa/TypeCastsCocoa.h:49:113: note: candidate template ignored: could not match 'RetainPtr<T>' against 'WTF::RetainPtr<const __AXTextMarker>::PtrType' (aka 'const __AXTextMarker *') template<typename T> inline RetainPtr<typename NSTollFreeBridgingTraits<std::remove_pointer_t<T>>::BridgedType> bridge_cast(RetainPtr<T>&& object) ^ /Users/ag/s/web/OpenSource/WebKitBuild/Release/usr/local/include/wtf/cocoa/TypeCastsCocoa.h:44:102: note: candidate template ignored: substitution failure [with T = const __AXTextMarker *]: implicit instantiation of undefined template 'WTF::NSTollFreeBridgingTraits<const __AXTextMarker>' template<typename T> inline typename NSTollFreeBridgingTraits<std::remove_pointer_t<T>>::BridgedType bridge_cast(T object) ~~~~~~~~~~~~~~~~~~~~~~~~ ^ Maybe because AXTextMarkerRef is an opaque pointer? Can get it to compile with: [change setObject:(__bridge id)(marker.get()) forKey:NSAccessibilityTextChangeValueStartMarker]; which perhaps is the right thing in this case.
Andres Gonzalez
Comment 7 2023-02-09 08:50:45 PST
Andres Gonzalez
Comment 8 2023-02-09 08:52:48 PST
Darin Adler
Comment 9 2023-02-09 09:52:41 PST
Comment on attachment 464924 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=464924&action=review > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:535 > + [change setObject:(__bridge id)marker.get() forKey:NSAccessibilityTextChangeValueStartMarker]; Great as is. To make code like this look more elegant and perhaps be more type safe we also have bridge_id_cast for cases where there is not an Objective-C equivalent. Or if there is an Objective-C toll free bridged version of AXTextMarkerRef, we could add it to the toll free bridging header and then use bridge_cast. But none of that is required, this is fine.
EWS
Comment 10 2023-02-09 11:49:27 PST
Committed 260075@main (cf1fe7b77825): <https://commits.webkit.org/260075@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 464924 [details].
Note You need to log in before you can comment on or make changes to this bug.