[webkit-changes] [WebKit/WebKit] 31be36: Handle special case of merging lists in mergeParag...
Ahmad Saleem
noreply at github.com
Fri Dec 9 15:46:06 PST 2022
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 31be36f212e4872dfd9761736dba5814453ac8a2
https://github.com/WebKit/WebKit/commit/31be36f212e4872dfd9761736dba5814453ac8a2
Author: Ahmad Saleem <ahmad.saleem792+github at gmail.com>
Date: 2022-12-09 (Fri, 09 Dec 2022)
Changed paths:
A LayoutTests/editing/deleting/merge-list-items-in-same-list-expected.txt
A LayoutTests/editing/deleting/merge-list-items-in-same-list.html
A LayoutTests/editing/deleting/merge-lists-expected.txt
A LayoutTests/editing/deleting/merge-lists.html
M Source/WebCore/editing/DeleteSelectionCommand.cpp
Log Message:
-----------
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
More information about the webkit-changes
mailing list