RESOLVED FIXED 238341
AccessibilityObject::listMarkerTextForNodeAndPosition should check for presence of list item before anything else
https://bugs.webkit.org/show_bug.cgi?id=238341
Summary AccessibilityObject::listMarkerTextForNodeAndPosition should check for presen...
Tyler Wilcock
Reported 2022-03-24 11:42:35 PDT
This function is currently: String AccessibilityObject::listMarkerTextForNodeAndPosition(Node* node, const VisiblePosition& visiblePositionStart) { // If the range does not contain the start of the line, the list marker text should not be included. if (!isStartOfLine(visiblePositionStart)) return String(); // We should speak the list marker only for the first line. RenderListItem* listItem = renderListItemContainerForNode(node); if (!listItem) return String(); if (!inSameLine(visiblePositionStart, firstPositionInNode(&listItem->element()))) return String(); return listMarkerTextForNode(node); } The !isStartOfLine(visiblePositionStart) check is redundant, covered entirely by the later !inSameLine(visiblePositionStart, firstPositionInNode(&listItem->element())) check.
Attachments
Patch (2.56 KB, patch)
2022-03-24 11:45 PDT, Tyler Wilcock
no flags
Patch (2.69 KB, patch)
2022-03-25 08:31 PDT, Tyler Wilcock
no flags
Radar WebKit Bug Importer
Comment 1 2022-03-24 11:42:46 PDT
Tyler Wilcock
Comment 2 2022-03-24 11:45:13 PDT
Andres Gonzalez
Comment 3 2022-03-25 05:55:25 PDT
(In reply to Tyler Wilcock from comment #2) > Created attachment 455660 [details] > Patch --- a/Source/WebCore/ChangeLog +++ a/Source/WebCore/ChangeLog + In AccessibilityObject::listMarkerTextForNodeAndPosition, the !isStartOfLine(visiblePositionStart) + check is redundant, covered entirely by the later + !inSameLine(visiblePositionStart, + firstPositionInNode(&listItem->element())) check. This patch removes + the former check, since it can sometimes cause crashes. --- a/Source/WebCore/accessibility/AccessibilityObject.cpp +++ a/Source/WebCore/accessibility/AccessibilityObject.cpp @@ -1455,17 +1455,13 @@ static String listMarkerTextForNode(Node* node) // Returns the text associated with a list marker if this node is contained within a list item. String AccessibilityObject::listMarkerTextForNodeAndPosition(Node* node, const VisiblePosition& visiblePositionStart) { - // If the range does not contain the start of the line, the list marker text should not be included. - if (!isStartOfLine(visiblePositionStart)) - return String(); I don't see how the inSameLine check includes the above check inSameLine checks whether the two positions have the same startOfLine, but the above check is whether the given position is exactly startOfLine.
Andres Gonzalez
Comment 4 2022-03-25 06:06:07 PDT
(In reply to Andres Gonzalez from comment #3) > (In reply to Tyler Wilcock from comment #2) > > Created attachment 455660 [details] > > Patch > > --- a/Source/WebCore/ChangeLog > +++ a/Source/WebCore/ChangeLog > > + In AccessibilityObject::listMarkerTextForNodeAndPosition, the > !isStartOfLine(visiblePositionStart) > + check is redundant, covered entirely by the later > + !inSameLine(visiblePositionStart, > + firstPositionInNode(&listItem->element())) check. This patch removes > + the former check, since it can sometimes cause crashes. > > --- a/Source/WebCore/accessibility/AccessibilityObject.cpp > +++ a/Source/WebCore/accessibility/AccessibilityObject.cpp > @@ -1455,17 +1455,13 @@ static String listMarkerTextForNode(Node* node) > // Returns the text associated with a list marker if this node is contained > within a list item. > String AccessibilityObject::listMarkerTextForNodeAndPosition(Node* node, > const VisiblePosition& visiblePositionStart) > { > - // If the range does not contain the start of the line, the list marker > text should not be included. > - if (!isStartOfLine(visiblePositionStart)) > - return String(); > > I don't see how the inSameLine check includes the above check inSameLine > checks whether the two positions have the same startOfLine, but the above > check is whether the given position is exactly startOfLine. Perhaps we can try: auto* listItem = renderListItemContainerForNode(node); if (!listItem) return { }; if (!isStartOfLine(visiblePositionStart) || !inSameLine(visiblePositionStart, firstPositionInNode(&listItem->element()))) return { };
Tyler Wilcock
Comment 5 2022-03-25 08:31:29 PDT
EWS
Comment 6 2022-03-28 09:30:12 PDT
Committed r291968 (248933@main): <https://commits.webkit.org/248933@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 455764 [details].
Note You need to log in before you can comment on or make changes to this bug.