⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286531 in webkit


Ignore:
Timestamp:
Dec 4, 2021, 7:24:46 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Fix parentNode in CompositeEditCommand::splitTreeToNode
https://bugs.webkit.org/show_bug.cgi?id=230710

Patch by Rob Buis <rbuis@igalia.com> on 2021-12-04
Reviewed by Ryosuke Niwa.

Source/WebCore:

Fix parentNode handling in CompositeEditCommand::splitTreeToNode and
also a few more IndentOutdentCommand methods to support the test case.

Test: editing/execCommand/outdent-cut-crash.html

  • editing/CompositeEditCommand.cpp:

(WebCore::CompositeEditCommand::moveParagraphs):

  • editing/IndentOutdentCommand.cpp:

(WebCore::IndentOutdentCommand::indentIntoBlockquote): do not call positionInParentAfterNode
if insertNodeBefore failed.
(WebCore::IndentOutdentCommand::outdentParagraph): need to check for null positions
before calling moveParagraphs.

LayoutTests:

  • editing/execCommand/outdent-cut-crash-expected.txt: Added.
  • editing/execCommand/outdent-cut-crash.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286530 r286531  
     12021-12-04  Rob Buis  <rbuis@igalia.com>
     2
     3        Fix parentNode in CompositeEditCommand::splitTreeToNode
     4        https://bugs.webkit.org/show_bug.cgi?id=230710
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * editing/execCommand/outdent-cut-crash-expected.txt: Added.
     9        * editing/execCommand/outdent-cut-crash.html: Added.
     10
    1112021-12-04  Tyler Wilcock  <tyler_w@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r286529 r286531  
     12021-12-04  Rob Buis  <rbuis@igalia.com>
     2
     3        Fix parentNode in CompositeEditCommand::splitTreeToNode
     4        https://bugs.webkit.org/show_bug.cgi?id=230710
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Fix parentNode handling in CompositeEditCommand::splitTreeToNode and
     9        also a few more IndentOutdentCommand methods to support the test case.
     10
     11        Test: editing/execCommand/outdent-cut-crash.html
     12
     13        * editing/CompositeEditCommand.cpp:
     14        (WebCore::CompositeEditCommand::moveParagraphs):
     15        * editing/IndentOutdentCommand.cpp:
     16        (WebCore::IndentOutdentCommand::indentIntoBlockquote): do not call positionInParentAfterNode
     17        if insertNodeBefore failed.
     18        (WebCore::IndentOutdentCommand::outdentParagraph): need to check for null positions
     19        before calling moveParagraphs.
     20
    1212021-12-04  Alan Bujtas  <zalan@apple.com>
    222
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r284792 r286531  
    17511751    ASSERT(adjustedEnd);
    17521752    RefPtr<Node> node;
    1753     for (node = &start; node && node->parentNode() != adjustedEnd; node = node->parentNode()) {
     1753    for (node = &start; node && node->parentNode() != adjustedEnd;) {
    17541754        RefPtr parentNode = node->parentNode();
    17551755        if (!parentNode || !is<Element>(*parentNode) || editingIgnoresContent(*parentNode))
     
    17601760        if (positionInParent != positionInNode)
    17611761            splitElement(downcast<Element>(*parentNode), *node);
     1762        node = parentNode;
    17621763    }
    17631764
  • trunk/Source/WebCore/editing/IndentOutdentCommand.cpp

    r280323 r286531  
    117117        if (outerBlock == nodeToSplitTo)
    118118            insertNodeAt(*targetBlockquote, start);
    119         else
    120             insertNodeBefore(*targetBlockquote, *outerBlock);
     119        else if (!insertNodeBefore(*targetBlockquote, *outerBlock))
     120            return;
    121121        startOfContents = positionInParentAfterNode(targetBlockquote.get());
    122122    }
     
    193193    auto placeholder = HTMLBRElement::create(document());
    194194    insertNodeBefore(placeholder, *splitBlockquoteNode);
    195     if (placeholder->isConnected())
    196         moveParagraph(startOfParagraph(visibleStartOfParagraph), endOfParagraph(visibleEndOfParagraph), positionBeforeNode(placeholder.ptr()), true);
     195    if (!placeholder->isConnected())
     196        return;
     197    auto visibleStartOfParagraphToMove = startOfParagraph(visibleStartOfParagraph);
     198    auto visibleEndOfParagraphToMove = endOfParagraph(visibleEndOfParagraph);
     199    if (visibleStartOfParagraphToMove.isNull() || visibleEndOfParagraphToMove.isNull())
     200        return;
     201    moveParagraph(visibleStartOfParagraphToMove, visibleEndOfParagraphToMove, positionBeforeNode(placeholder.ptr()), true);
    197202}
    198203
Note: See TracChangeset for help on using the changeset viewer.