Title: [285450] branches/safari-612-branch
Revision
285450
Author
[email protected]
Date
2021-11-08 17:08:29 -0800 (Mon, 08 Nov 2021)

Log Message

Cherry-pick r281795. rdar://problem/85166335

    Nullptr crash in TypingCommand::willAddTypingToOpenCommand via TypingCommand::deleteKeyPressed
    https://bugs.webkit.org/show_bug.cgi?id=229277

    Patch by Rob Buis <[email protected]> on 2021-08-31
    Reviewed by Ryosuke Niwa.

    Source/WebCore:

    Rewtite CompositeEditCommand::shouldBreakOutOfEmptyListItem() to return just VisibleSelection
    and check that it is not none in TypingCommand::willAddTypingToOpenCommand.

    Test: editing/deleting/delete-key-crash.html

    * editing/CompositeEditCommand.cpp:
    (WebCore::CompositeEditCommand::moveParagraphs):
    * editing/CompositeEditCommand.h:
    * editing/TypingCommand.cpp:
    (WebCore::TypingCommand::deleteKeyPressed):

    LayoutTests:

    * editing/deleting/delete-key-crash-expected.txt: Added.
    * editing/deleting/delete-key-crash.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281795 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-612-branch/LayoutTests/ChangeLog (285449 => 285450)


--- branches/safari-612-branch/LayoutTests/ChangeLog	2021-11-09 01:04:43 UTC (rev 285449)
+++ branches/safari-612-branch/LayoutTests/ChangeLog	2021-11-09 01:08:29 UTC (rev 285450)
@@ -1,3 +1,43 @@
+2021-11-08  Kocsen Chung  <[email protected]>
+
+        Cherry-pick r281795. rdar://problem/85166335
+
+    Nullptr crash in TypingCommand::willAddTypingToOpenCommand via TypingCommand::deleteKeyPressed
+    https://bugs.webkit.org/show_bug.cgi?id=229277
+    
+    Patch by Rob Buis <[email protected]> on 2021-08-31
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebCore:
+    
+    Rewtite CompositeEditCommand::shouldBreakOutOfEmptyListItem() to return just VisibleSelection
+    and check that it is not none in TypingCommand::willAddTypingToOpenCommand.
+    
+    Test: editing/deleting/delete-key-crash.html
+    
+    * editing/CompositeEditCommand.cpp:
+    (WebCore::CompositeEditCommand::moveParagraphs):
+    * editing/CompositeEditCommand.h:
+    * editing/TypingCommand.cpp:
+    (WebCore::TypingCommand::deleteKeyPressed):
+    
+    LayoutTests:
+    
+    * editing/deleting/delete-key-crash-expected.txt: Added.
+    * editing/deleting/delete-key-crash.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281795 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-31  Rob Buis  <[email protected]>
+
+            Nullptr crash in TypingCommand::willAddTypingToOpenCommand via TypingCommand::deleteKeyPressed
+            https://bugs.webkit.org/show_bug.cgi?id=229277
+
+            Reviewed by Ryosuke Niwa.
+
+            * editing/deleting/delete-key-crash-expected.txt: Added.
+            * editing/deleting/delete-key-crash.html: Added.
+
 2021-11-08  Alan Coon  <[email protected]>
 
         Apply patch. rdar://problem/83438282

Added: branches/safari-612-branch/LayoutTests/editing/deleting/delete-key-crash-expected.txt (0 => 285450)


--- branches/safari-612-branch/LayoutTests/editing/deleting/delete-key-crash-expected.txt	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/editing/deleting/delete-key-crash-expected.txt	2021-11-09 01:08:29 UTC (rev 285450)
@@ -0,0 +1 @@
+Test passes if it does not crash.

Added: branches/safari-612-branch/LayoutTests/editing/deleting/delete-key-crash.html (0 => 285450)


--- branches/safari-612-branch/LayoutTests/editing/deleting/delete-key-crash.html	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/editing/deleting/delete-key-crash.html	2021-11-09 01:08:29 UTC (rev 285450)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<style>
+  html {
+    display: table;
+  }
+</style>
+<script>
+  if (window.testRunner)
+    window.testRunner.dumpAsText();
+  _onload_ = () => {
+    document.designMode = 'on';
+    getSelection().selectAllChildren(document.body);
+    document.execCommand('InsertNestedUnorderedList');
+    document.body.append(document.createElement('div'));
+    document.body.innerHTML += '';
+    document.execCommand('Delete');
+    document.write("Test passes if it does not crash.");
+  };
+</script>
+<body>
+</body>

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (285449 => 285450)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-11-09 01:04:43 UTC (rev 285449)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-11-09 01:08:29 UTC (rev 285450)
@@ -1,3 +1,51 @@
+2021-11-08  Kocsen Chung  <[email protected]>
+
+        Cherry-pick r281795. rdar://problem/85166335
+
+    Nullptr crash in TypingCommand::willAddTypingToOpenCommand via TypingCommand::deleteKeyPressed
+    https://bugs.webkit.org/show_bug.cgi?id=229277
+    
+    Patch by Rob Buis <[email protected]> on 2021-08-31
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebCore:
+    
+    Rewtite CompositeEditCommand::shouldBreakOutOfEmptyListItem() to return just VisibleSelection
+    and check that it is not none in TypingCommand::willAddTypingToOpenCommand.
+    
+    Test: editing/deleting/delete-key-crash.html
+    
+    * editing/CompositeEditCommand.cpp:
+    (WebCore::CompositeEditCommand::moveParagraphs):
+    * editing/CompositeEditCommand.h:
+    * editing/TypingCommand.cpp:
+    (WebCore::TypingCommand::deleteKeyPressed):
+    
+    LayoutTests:
+    
+    * editing/deleting/delete-key-crash-expected.txt: Added.
+    * editing/deleting/delete-key-crash.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281795 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-31  Rob Buis  <[email protected]>
+
+            Nullptr crash in TypingCommand::willAddTypingToOpenCommand via TypingCommand::deleteKeyPressed
+            https://bugs.webkit.org/show_bug.cgi?id=229277
+
+            Reviewed by Ryosuke Niwa.
+
+            Rewtite CompositeEditCommand::shouldBreakOutOfEmptyListItem() to return just VisibleSelection
+            and check that it is not none in TypingCommand::willAddTypingToOpenCommand.
+
+            Test: editing/deleting/delete-key-crash.html
+
+            * editing/CompositeEditCommand.cpp:
+            (WebCore::CompositeEditCommand::moveParagraphs):
+            * editing/CompositeEditCommand.h:
+            * editing/TypingCommand.cpp:
+            (WebCore::TypingCommand::deleteKeyPressed):
+
 2021-11-08  Alan Coon  <[email protected]>
 
         Apply patch. rdar://problem/83438282

Modified: branches/safari-612-branch/Source/WebCore/editing/CompositeEditCommand.cpp (285449 => 285450)


--- branches/safari-612-branch/Source/WebCore/editing/CompositeEditCommand.cpp	2021-11-09 01:04:43 UTC (rev 285449)
+++ branches/safari-612-branch/Source/WebCore/editing/CompositeEditCommand.cpp	2021-11-09 01:08:29 UTC (rev 285450)
@@ -1545,11 +1545,11 @@
     }
 }
 
-std::optional<VisibleSelection> CompositeEditCommand::shouldBreakOutOfEmptyListItem() const
+VisibleSelection CompositeEditCommand::shouldBreakOutOfEmptyListItem() const
 {
     auto emptyListItem = enclosingEmptyListItem(endingSelection().visibleStart());
     if (!emptyListItem)
-        return std::nullopt;
+        return { };
 
     auto listNode = emptyListItem->parentNode();
     // FIXME: Can't we do something better when the immediate parent wasn't a list node?
@@ -1557,7 +1557,7 @@
         || (!listNode->hasTagName(ulTag) && !listNode->hasTagName(olTag))
         || !listNode->hasEditableStyle()
         || listNode == emptyListItem->rootEditableElement())
-        return std::nullopt;
+        return { };
 
     return VisibleSelection(endingSelection().start().previous(BackwardDeletion), endingSelection().end());
 }
@@ -1565,7 +1565,7 @@
 // FIXME: Send an appropriate shouldDeleteRange call.
 bool CompositeEditCommand::breakOutOfEmptyListItem()
 {
-    if (!shouldBreakOutOfEmptyListItem())
+    if (shouldBreakOutOfEmptyListItem().isNone())
         return false;
 
     auto emptyListItem = enclosingEmptyListItem(endingSelection().visibleStart());

Modified: branches/safari-612-branch/Source/WebCore/editing/CompositeEditCommand.h (285449 => 285450)


--- branches/safari-612-branch/Source/WebCore/editing/CompositeEditCommand.h	2021-11-09 01:04:43 UTC (rev 285449)
+++ branches/safari-612-branch/Source/WebCore/editing/CompositeEditCommand.h	2021-11-09 01:08:29 UTC (rev 285450)
@@ -206,7 +206,7 @@
     void cloneParagraphUnderNewElement(const Position& start, const Position& end, Node* outerNode, Element* blockElement);
     void cleanupAfterDeletion(VisiblePosition destination = VisiblePosition());
     
-    std::optional<VisibleSelection> shouldBreakOutOfEmptyListItem() const;
+    VisibleSelection shouldBreakOutOfEmptyListItem() const;
     bool breakOutOfEmptyListItem();
     bool breakOutOfEmptyMailBlockquotedParagraph();
     

Modified: branches/safari-612-branch/Source/WebCore/editing/TypingCommand.cpp (285449 => 285450)


--- branches/safari-612-branch/Source/WebCore/editing/TypingCommand.cpp	2021-11-09 01:04:43 UTC (rev 285449)
+++ branches/safari-612-branch/Source/WebCore/editing/TypingCommand.cpp	2021-11-09 01:08:29 UTC (rev 285450)
@@ -662,8 +662,8 @@
         const Node* enclosingTableCellForPreviousPosition = enclosingNodeOfType(previousPosition.deepEquivalent(), &isTableCell);
         if (previousPosition.isNull() || enclosingTableCell != enclosingTableCellForPreviousPosition) {
             // When the caret is at the start of the editable area in an empty list item, break out of the list item.
-            if (auto deleteListSelection = shouldBreakOutOfEmptyListItem()) {
-                if (willAddTypingToOpenCommand(DeleteKey, granularity, { }, *deleteListSelection.value().firstRange())) {
+            if (auto deleteListSelection = shouldBreakOutOfEmptyListItem(); !deleteListSelection.isNone()) {
+                if (willAddTypingToOpenCommand(DeleteKey, granularity, { }, deleteListSelection.firstRange())) {
                     breakOutOfEmptyListItem();
                     typingAddedToOpenCommand(DeleteKey);
                 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to