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

Changeset 259619 in webkit


Ignore:
Timestamp:
Apr 6, 2020, 6:45:56 PM (6 years ago)
Author:
Jack Lee
Message:

Nullptr crash in WebCore::lastPositionInNode when indenting text node that has user-select:all parent.
https://bugs.webkit.org/show_bug.cgi?id=210016
<rdar://problem/61014577>

Reviewed by Ryosuke Niwa.

Source/WebCore:

In rangeForParagraphSplittingTextNodesIfNeeded, added null check for previousSibling()
after splitTextNode is called, and returns empty positions to caller.

In formatSelection, check the returned positions from rangeForParagraphSplittingTextNodesIfNeeded
and stop indenting the rest of the paragraphs.

Test: fast/editing/indent-pre-user-select-all-crash.html

  • editing/ApplyBlockElementCommand.cpp:

(WebCore::ApplyBlockElementCommand::formatSelection):
(WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded):

LayoutTests:

Added a regression test for the crash.

  • fast/editing/indent-pre-user-select-all-crash-expected.txt: Added.
  • fast/editing/indent-pre-user-select-all-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r259612 r259619  
     12020-04-06  Jack Lee  <shihchieh_lee@apple.com>
     2
     3        Nullptr crash in WebCore::lastPositionInNode when indenting text node that has user-select:all parent.
     4        https://bugs.webkit.org/show_bug.cgi?id=210016
     5        <rdar://problem/61014577>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Added a regression test for the crash.
     10
     11        * fast/editing/indent-pre-user-select-all-crash-expected.txt: Added.
     12        * fast/editing/indent-pre-user-select-all-crash.html: Added.
     13
    1142020-04-06  Jason Lawrence  <lawrence.j@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r259618 r259619  
     12020-04-06  Jack Lee  <shihchieh_lee@apple.com>
     2
     3        Nullptr crash in WebCore::lastPositionInNode when indenting text node that has user-select:all parent.
     4        https://bugs.webkit.org/show_bug.cgi?id=210016
     5        <rdar://problem/61014577>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        In rangeForParagraphSplittingTextNodesIfNeeded, added null check for previousSibling()
     10        after splitTextNode is called, and returns empty positions to caller.
     11
     12        In formatSelection, check the returned positions from rangeForParagraphSplittingTextNodesIfNeeded
     13        and stop indenting the rest of the paragraphs.
     14
     15        Test: fast/editing/indent-pre-user-select-all-crash.html
     16
     17        * editing/ApplyBlockElementCommand.cpp:
     18        (WebCore::ApplyBlockElementCommand::formatSelection):
     19        (WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded):
     20
    1212020-04-06  Devin Rousso  <drousso@apple.com>
    222
  • trunk/Source/WebCore/editing/ApplyBlockElementCommand.cpp

    r246490 r259619  
    134134
    135135        rangeForParagraphSplittingTextNodesIfNeeded(endOfCurrentParagraph, start, end);
     136        if (start.isNull() || end.isNull())
     137            break;
     138
    136139        endOfCurrentParagraph = end;
    137140
     
    242245            RefPtr<Text> endContainer = end.containerText();
    243246            splitTextNode(*endContainer, end.offsetInContainerNode());
     247            if (is<Text>(endContainer) && !endContainer->previousSibling()) {
     248                start = { };
     249                end = { };
     250                return;
     251            }
    244252            if (isStartAndEndOnSameNode)
    245253                start = firstPositionInOrBeforeNode(endContainer->previousSibling());
Note: See TracChangeset for help on using the changeset viewer.