RESOLVED FIXED 219491
Prelininary refactoring of TextMarker and TextMarkerRange.
https://bugs.webkit.org/show_bug.cgi?id=219491
Summary Prelininary refactoring of TextMarker and TextMarkerRange.
Andres Gonzalez
Reported 2020-12-03 08:07:36 PST
Prelininary refactoring of TextMarker and TextMarkerRange.
Attachments
Patch (31.96 KB, patch)
2020-12-03 08:35 PST, Andres Gonzalez
no flags
Patch (62.08 KB, patch)
2020-12-04 10:52 PST, Andres Gonzalez
no flags
Patch (62.31 KB, patch)
2020-12-05 10:59 PST, Andres Gonzalez
no flags
Andres Gonzalez
Comment 1 2020-12-03 08:35:44 PST
chris fleizach
Comment 2 2020-12-03 10:37:49 PST
Comment on attachment 415303 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=415303&action=review > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:613 > +static id AXTextMarkerRangeStart(id textMarkerRange) should these methods return the actual types rather than id (since we're refactoring anyway) > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:627 > +static bool getBytesFromAXTextMarker(CFTypeRef textMarker, void* bytes, size_t length) I think we can use a TextMarkerData* instead of a void* and then avoid the size parameter
Andres Gonzalez
Comment 3 2020-12-04 10:52:42 PST
Andres Gonzalez
Comment 4 2020-12-04 10:56:21 PST
(In reply to chris fleizach from comment #2) > Comment on attachment 415303 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=415303&action=review > > > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:613 > > +static id AXTextMarkerRangeStart(id textMarkerRange) > > should these methods return the actual types rather than id (since we're > refactoring anyway) Done. More work than I anticipated, but done and tested now. > > > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:627 > > +static bool getBytesFromAXTextMarker(CFTypeRef textMarker, void* bytes, size_t length) > > I think we can use a > TextMarkerData* > > instead of a void* and then avoid the size parameter Done, good catch.
Andres Gonzalez
Comment 5 2020-12-05 10:59:50 PST
EWS
Comment 6 2020-12-05 13:25:57 PST
Committed r270476: <https://trac.webkit.org/changeset/270476> All reviewed patches have been landed. Closing bug and clearing flags on attachment 415491 [details].
Radar WebKit Bug Importer
Comment 7 2020-12-05 13:26:17 PST
Simon Fraser (smfr)
Comment 8 2020-12-05 20:06:31 PST
Comment on attachment 415491 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=415491&action=review > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:637 > + memcpy(&data, AXTextMarkerGetBytePtr(textMarker), sizeof(data)); How do we know that the binary layout of the result of AXTextMarkerGetBytePtr matches TextMarkerData? > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:704 > +AXTextMarkerRef textMarkerForCharacterOffset(AXObjectCache* cache, const CharacterOffset& characterOffset) Should functions like this return RetainPtr<AXTextMarkerRef>?
Andres Gonzalez
Comment 9 2020-12-07 08:23:11 PST
(In reply to Simon Fraser (smfr) from comment #8) > Comment on attachment 415491 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=415491&action=review > > > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:637 > > + memcpy(&data, AXTextMarkerGetBytePtr(textMarker), sizeof(data)); > > How do we know that the binary layout of the result of > AXTextMarkerGetBytePtr matches TextMarkerData? Please, see https://bugs.webkit.org/show_bug.cgi?id=219601. Added a size check. We should eventually make the definition of TextMarkerData common to both the system APIs and Webkit, but in the meantime this check has served us well for a few years already. > > > Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:704 > > +AXTextMarkerRef textMarkerForCharacterOffset(AXObjectCache* cache, const CharacterOffset& characterOffset) > > Should functions like this return RetainPtr<AXTextMarkerRef>? The idea is to add a class AXTextMarker that wraps and retains the system AXTextMarkerRef. This class will expose the conversions to the WebCore types, VisiblePosition, CharacterOffset, etc. For now, I don't see any downside in keeping the return values to be the raw AXTextMarkerRefs as before.
Note You need to log in before you can comment on or make changes to this bug.