Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle special case of merging lists in mergeParagraphs()
Handle special case of merging lists in mergeParagraphs() https://bugs.webkit.org/show_bug.cgi?id=248709 Reviewed by Ryosuke Niwa. This patch to align Webkit behavior with Gecko / Firefox and Blink / Chromium by merging these two patches from Blink: > https://src.chromium.org/viewvc/blink?view=revision&revision=165218 > https://src.chromium.org/viewvc/blink?view=revision&revision=172941 Consider a html content with two consecutive lists. When cursor is placed at the end of first list and forward delete is executed, we should merge the second list with the first one. Currently, the content of the first <li> of second list is appended to the content of last <li> of first list and two lists are still retained. This is incorrect. Uploaded patch fixes this erroneous behavior. This issue is reproduced only when list is the only visible element present. In this case, visible positions after & before the list's parent node would be NULL and hence are treated as equal. Because of this, isVisiblyAdjacent() and therefore canMergeLists() would return true. This results in invoking mergeIdenticalElements where things go wrong as we try to delete the second list and add its content to first list, while we actually have only one list and should be merging the list items of the same list. In canMergeLists(), calling isVisiblyAdjacent(positionInParentAfterNode(*firstList), positionInParentBeforeNode(*secondList) makes sense only if firstList & secondList are different lists. Hence, before invoking isVisiblyAdjacent() we need to check if the lists are identical in which case return false from canMergeLists(). * Source/WebCore/editing/DeleteSelectionCommand.cpp: (DeleteSelectionCommand:mergePargraph): Add logic to merge list aligned with other browsers * LayoutTests/editing/deleting/merge-lists.html: Add Test Case * LayoutTests/editing/deleting/merge-lists-expected.txt: Add Test Case Expectation * LayoutTests/editing/deleting/merge-list-items-in-same-list.html: Add Test Case * LayoutTests/editing/deleting/merge-list-items-in-same-list-expected.txt: Add Test Case Expectation Canonical link: https://commits.webkit.org/257650@main
- Loading branch information