Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 0e3b3412203ccd0a2671b5a3f88f156bc9b8a298 https://github.com/WebKit/WebKit/commit/0e3b3412203ccd0a2671b5a3f88f156bc9b8a298 Author: Qianlang Chen <qianlangc...@apple.com> Date: 2024-04-04 (Thu, 04 Apr 2024)
Changed paths: M Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js Log Message: ----------- Web Inspector: DOM tree view Cmd-F search unexpectedly changes text displayed rdar://125797803 https://bugs.webkit.org/show_bug.cgi?id=272047 Reviewed by Devin Rousso. When doing a Cmd-F search in the DOM tree view, there is logic to first convert the search matches into a change list, which is a list of highlight elements to add or text to change, then execute the changes in that list. - The source for generating change list (works fine) is in `WI.highlightRangesWithStyleClass`. - The source for executing the changes (problematic) is in `WI.DOMTreeElement._updateSearchHighlight`. Executing a change list can be one of two opposite kinds: applying for showing the search results, or reverting to hide the results. When reverting the changes, the original code did it in the same order as they're applied, which can cause problems when there are multiple changes to the same node. - For instance, when the search query is "a" and some node's text is "ab ac", the change list can be something like {"ab ac"->"b ac", "b ac"->"b c"} (where the "a"s get put into newly generated highlight elements). When reverting, if it's still done in the same order, we'd be setting the text to "b ac" rather than the expected "ab ac". This commit simply make it so that reverting a change list is done in the reverse order, therefore preserving the original text when there are more than one text changes applied to the same node. * Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js: (WI.DOMTreeElement.prototype._updateSearchHighlight): (WI.DOMTreeElement.prototype._updateSearchHighlight.updateEntryShow): Deleted. (WI.DOMTreeElement.prototype._updateSearchHighlight.updateEntryHide): Deleted. - When reverting changes, do so in the reverse order. - Remove the helper functions as they don't improve readability anymore with the new logic. Canonical link: https://commits.webkit.org/277073@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes