RESOLVED FIXED 239406
Optimize id matching in AccessibilityObject::ariaElementsReferencedByAttribute()
https://bugs.webkit.org/show_bug.cgi?id=239406
Summary Optimize id matching in AccessibilityObject::ariaElementsReferencedByAttribute()
Chris Dumez
Reported 2022-04-15 14:28:50 PDT
Optimize id matching in AccessibilityObject::ariaElementsReferencedByAttribute().
Attachments
Patch (9.03 KB, patch)
2022-04-15 14:35 PDT, Chris Dumez
no flags
Radar WebKit Bug Importer
Comment 1 2022-04-15 14:28:59 PDT
Chris Dumez
Comment 2 2022-04-15 14:35:39 PDT
Darin Adler
Comment 3 2022-04-15 16:13:09 PDT
Comment on attachment 457726 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457726&action=review > Source/WebCore/accessibility/AccessibilityObject.cpp:3932 > + if (!SpaceSplitString::spaceSplitStringContainsValue(idList, id)) > continue; If we are going to walk an entire DOM tree and check every attribute value against a set, I think we should probably convert it into a HashSet<AtomString>, don’t you?
Chris Dumez
Comment 4 2022-04-15 16:19:27 PDT
Comment on attachment 457726 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457726&action=review >> Source/WebCore/accessibility/AccessibilityObject.cpp:3932 >> continue; > > If we are going to walk an entire DOM tree and check every attribute value against a set, I think we should probably convert it into a HashSet<AtomString>, don’t you? I don't understand the comment and how I can leverage a HashSet<AtomString>. We have a string stored in the variable 'id', we want to iterate the whole DOM tree and find all Elements that have that id string in their attribute |attribute| (which is one of the few aria- attributes). Another tricky thing is that apparently, the value of |attribute| is a HTMLSpace-separated string and we want to know if any of the substrings in that attribute value match the string stored in id. Seems to me that the implementation I have now is pretty efficient given the current constraints? Ideally, at some point, we wouldn't need to iterate the whole DOM tree and we'd know which elements may match ahead of time. I talked to Tyler about that and he said that's on his TODO list.
Darin Adler
Comment 5 2022-04-15 16:46:02 PDT
Comment on attachment 457726 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457726&action=review >>> Source/WebCore/accessibility/AccessibilityObject.cpp:3932 >>> continue; >> >> If we are going to walk an entire DOM tree and check every attribute value against a set, I think we should probably convert it into a HashSet<AtomString>, don’t you? > > I don't understand the comment and how I can leverage a HashSet<AtomString>. > > We have a string stored in the variable 'id', we want to iterate the whole DOM tree and find all Elements that have that id string in their attribute |attribute| (which is one of the few aria- attributes). Another tricky thing is that apparently, the value of |attribute| is a HTMLSpace-separated string and we want to know if any of the substrings in that attribute value match the string stored in id. > Seems to me that the implementation I have now is pretty efficient given the current constraints? > > Ideally, at some point, we wouldn't need to iterate the whole DOM tree and we'd know which elements may match ahead of time. I talked to Tyler about that and he said that's on his TODO list. Oh, I didn’t realize that the attributes from each element were the things we're splitting!
Chris Dumez
Comment 6 2022-04-15 16:46:23 PDT
(In reply to Chris Dumez from comment #4) > Comment on attachment 457726 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=457726&action=review > > >> Source/WebCore/accessibility/AccessibilityObject.cpp:3932 > >> continue; > > > > If we are going to walk an entire DOM tree and check every attribute value against a set, I think we should probably convert it into a HashSet<AtomString>, don’t you? > > I don't understand the comment and how I can leverage a HashSet<AtomString>. > > We have a string stored in the variable 'id', we want to iterate the whole > DOM tree and find all Elements that have that id string in their attribute > |attribute| (which is one of the few aria- attributes). Another tricky thing > is that apparently, the value of |attribute| is a HTMLSpace-separated string > and we want to know if any of the substrings in that attribute value match > the string stored in id. > Seems to me that the implementation I have now is pretty efficient given the > current constraints? > > Ideally, at some point, we wouldn't need to iterate the whole DOM tree and > we'd know which elements may match ahead of time. I talked to Tyler about > that and he said that's on his TODO list. I think the misunderstanding may be that each Element in the DOM tree has a list of ids as a space-separate attribute value, and we're matching them against a single id string. If it was the other way around (each element has a single id and we need to match against a list of ids we have), then a HashSet<AtomString> for the list of ids we have would totally make sense.
Darin Adler
Comment 7 2022-04-15 16:55:42 PDT
(In reply to Chris Dumez from comment #6) > I think the misunderstanding may be that each Element in the DOM tree has a > list of ids as a space-separate attribute value, and we're matching them > against a single id string. Yes, that was it.
EWS
Comment 8 2022-04-16 16:00:27 PDT
Committed r292943 (249708@main): <https://commits.webkit.org/249708@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 457726 [details].
Note You need to log in before you can comment on or make changes to this bug.