Changeset 269946 in webkit


Ignore:
Timestamp:
Nov 18, 2020 12:28:02 AM (3 years ago)
Author:
commit-queue@webkit.org
Message:

Release assertion failure in Optional<WebCore::SimpleRange>::operator* via CompositeEditCommand::moveParagraphs
https://bugs.webkit.org/show_bug.cgi?id=218494

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2020-11-18
Reviewed by Ryosuke Niwa.

Source/WebCore:

This is happening when insert list command is called for a list item containing a body element as a child. When
the tree is iterated looking for the end position, the body element selected as candidate, but a null position
is returned because it's considered to be in a different editing element. This happens because
Node::rootEditableElement() always returns the node itseld for body elements, but it should actually check that
the node is the document body.

Test: editing/inserting/insert-list-with-body-child-crash.html

  • dom/Node.cpp:

(WebCore::Node::isRootEditableElement const): Check node is the document body, not just a body element.
(WebCore::Node::rootEditableElement const): Ditto.

  • editing/CompositeEditCommand.cpp:

(WebCore::CompositeEditCommand::moveParagraphs): Add an assert to ensure it's not called with a null endOfParagraphToMove.

LayoutTests:

  • editing/inserting/insert-list-with-body-child-crash-expected.txt: Added.
  • editing/inserting/insert-list-with-body-child-crash.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r269942 r269946  
     12020-11-18  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Release assertion failure in Optional<WebCore::SimpleRange>::operator* via CompositeEditCommand::moveParagraphs
     4        https://bugs.webkit.org/show_bug.cgi?id=218494
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * editing/inserting/insert-list-with-body-child-crash-expected.txt: Added.
     9        * editing/inserting/insert-list-with-body-child-crash.html: Added.
     10
    1112020-11-17  Lauro Moura  <lmoura@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r269944 r269946  
     12020-11-18  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Release assertion failure in Optional<WebCore::SimpleRange>::operator* via CompositeEditCommand::moveParagraphs
     4        https://bugs.webkit.org/show_bug.cgi?id=218494
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        This is happening when insert list command is called for a list item containing a body element as a child. When
     9        the tree is iterated looking for the end position, the body element selected as candidate, but a null position
     10        is returned because it's considered to be in a different editing element. This happens because
     11        Node::rootEditableElement() always returns the node itseld for body elements, but it should actually check that
     12        the node is the document body.
     13
     14        Test: editing/inserting/insert-list-with-body-child-crash.html
     15
     16        * dom/Node.cpp:
     17        (WebCore::Node::isRootEditableElement const): Check node is the document body, not just a body element.
     18        (WebCore::Node::rootEditableElement const): Ditto.
     19        * editing/CompositeEditCommand.cpp:
     20        (WebCore::CompositeEditCommand::moveParagraphs): Add an assert to ensure it's not called with a null endOfParagraphToMove.
     21
    1222020-11-17  Said Abou-Hallawa  <said@apple.com>
    223
  • trunk/Source/WebCore/dom/Node.cpp

    r269568 r269946  
    13281328{
    13291329    return hasEditableStyle() && isElementNode() && (!parentNode() || !parentNode()->hasEditableStyle()
    1330         || !parentNode()->isElementNode() || hasTagName(bodyTag));
     1330        || !parentNode()->isElementNode() || document().body() == this);
    13311331}
    13321332
     
    13371337        if (is<Element>(*node))
    13381338            result = downcast<Element>(node);
    1339         if (is<HTMLBodyElement>(*node))
     1339        if (document().body() == node)
    13401340            break;
    13411341    }
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r269894 r269946  
    14011401        return;
    14021402
     1403    ASSERT((startOfParagraphToMove.isNull() && endOfParagraphToMove.isNull()) || !endOfParagraphToMove.isNull());
     1404
    14031405    Optional<uint64_t> startIndex;
    14041406    Optional<uint64_t> endIndex;
Note: See TracChangeset for help on using the changeset viewer.