[webkit-changes] [WebKit/WebKit] 484172: Fix for an issue while breaking out of an empty li...

Ahmad Saleem noreply at github.com
Mon Jul 3 23:21:53 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 484172ca1e49d8951d83cc876d92b171f0a0e1dd
      https://github.com/WebKit/WebKit/commit/484172ca1e49d8951d83cc876d92b171f0a0e1dd
  Author: Ahmad Saleem <ahmad.saleem792+github at gmail.com>
  Date:   2023-07-03 (Mon, 03 Jul 2023)

  Changed paths:
    A LayoutTests/editing/inserting/break-out-of-nested-lists-expected.txt
    A LayoutTests/editing/inserting/break-out-of-nested-lists.html
    M Source/WebCore/editing/Editing.cpp

  Log Message:
  -----------
  Fix for an issue while breaking out of an empty list item in case of nested lists

https://bugs.webkit.org/show_bug.cgi?id=258784

Reviewed by Wenson Hsieh.

Merge: https://src.chromium.org/viewvc/blink?view=revision&revision=164049

In case of nested lists, if we break out of the inner list in such a way that
it is split into two inner lists, then break out of the first inner list
(which lands us in outer list) and then try to break out of the outer list,
it fails. Currently, in such scenario we cannot break out of the outer list.

This is caused by appendedSublist() called from enclosingEmptyListItem().
In appendedSublist() we check if the next sibling of the list item(of outer list)
from which we are trying to break out is a list(second inner list), in this case
we will not consider this list item as an empty one. Thus, we cannot break out.

Extending the check in appendedSublist() so as to additionally check if the
list which is the next sibling of list item from which we are trying to break out
is not a descendant of the outer list(to which list item belongs), fixes the issue.

i.e. Change the following check in appendedSubList()
if (isListElement(n))
    return downcast<HTMLElement>(n);

to

if (isListElement(n) && !n->isDescendantOf(enclosingList(listItem)))
    return downcast<HTMLElement>(n);

But further analysis seemed to show that the check
if (embeddedSublist(listChildNode) || appendedSublist(listChildNode))
    return nullptr;

which we do in enclosingEmptyListItem() is not needed. Because in the cases
where the list item from which we are trying to break out has an embeddedSublist
or appendedSublist we would still want to break out of the list. Getting rid of
this check and hence these functions(which are not used anywhere else),
fixes the issue.

* Source/WebCore/editing/Editing.cpp:
(embeddedSublist): Deleted static function
(appendedSublist): Ditto
 (enclosingEmptyListItem): Remove check about above functions
* LayoutTests/editing/inserting/break-out-of-nested-lists.html: Add Test Case
* LayoutTests/editing/inserting/break-out-of-nested-lists-expected.txt: Add Test Case Expectation

Canonical link: https://commits.webkit.org/265747@main




More information about the webkit-changes mailing list