Executing "insertunorderedlist" while selecting a contenteditable element inside...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 21:50:43 +0000 (21:50 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 21:50:43 +0000 (21:50 +0000)
commita129e1b7133b6991cded6917f7e0882a981dbdda
tree3ebade6a37e530939d2880b0d930acd3b505cbba
parent63407ea4c9238b0304348427df49544134954b01
Executing "insertunorderedlist" while selecting a contenteditable element inside a shadow dom hangs the browser
https://bugs.webkit.org/show_bug.cgi?id=184049
<rdar://problem/38931033>

Reviewed by Antti Koivisto.

Source/WebCore:

The primary hung was caused by TextIterator::advance traversing the next node in the tree order using
NodeTraversal::next which doesn't take the composed tree into account. Fixed the bug by traversing
the composed tree while sharing code with StylizedMarkupAccumulator.

This revealed a second hang in InsertListCommand::doApply() caused by endingSelection() being null,
which was caused by CompositeEditCommand::moveParagraphs failing to restore the ending selection properly
because it was computing the text indices difference from the beginning of the document until the destination.

Fixed this second bug by computing the indices against the beginning of the root editable element.
Note that editability never crosses a shadow boundary.

Test: editing/execCommand/insert-unordered-list-in-shadow-tree.html

* dom/ComposedTreeIterator.h:
(WebCore::nextSkippingChildrenInComposedTreeIgnoringUserAgentShadow): Extracted out of nextSkippingChildren
in markup.cpp.
(WebCore::nextInComposedTreeIgnoringUserAgentShadow): Added.
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::moveParagraphs): Compute the index from the beginning of the root editable
element as opposed to the beginning of the document.
* editing/TextIterator.cpp:
(WebCore::nextNode): Added.
(WebCore::isDescendantOf): Added.
(WebCore::TextIterator::advance): Use the newly added functions to traverse the composed tree when the options
contains TextIteratorTraversesFlatTree.
* editing/markup.cpp:

LayoutTests:

Added a regression test for executing InsertUnorderedList inside a shadow tree.

* editing/execCommand/insert-ordered-list-in-shadow-tree-expected.txt: Added.
* editing/execCommand/insert-ordered-list-in-shadow-tree.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238693 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/insert-unordered-list-in-shadow-tree-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/insert-unordered-list-in-shadow-tree.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/ComposedTreeIterator.h
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/markup.cpp