Title: [286531] trunk
- Revision
- 286531
- Author
- [email protected]
- Date
- 2021-12-04 07:24:46 -0800 (Sat, 04 Dec 2021)
Log Message
Fix parentNode in CompositeEditCommand::splitTreeToNode
https://bugs.webkit.org/show_bug.cgi?id=230710
Patch by Rob Buis <[email protected]> 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.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (286530 => 286531)
--- trunk/LayoutTests/ChangeLog 2021-12-04 15:22:57 UTC (rev 286530)
+++ trunk/LayoutTests/ChangeLog 2021-12-04 15:24:46 UTC (rev 286531)
@@ -1,3 +1,13 @@
+2021-12-04 Rob Buis <[email protected]>
+
+ Fix parentNode in CompositeEditCommand::splitTreeToNode
+ https://bugs.webkit.org/show_bug.cgi?id=230710
+
+ Reviewed by Ryosuke Niwa.
+
+ * editing/execCommand/outdent-cut-crash-expected.txt: Added.
+ * editing/execCommand/outdent-cut-crash.html: Added.
+
2021-12-04 Tyler Wilcock <[email protected]>
AX: Make ellipsis-text.html, aria-roledescription.html, and aria-switch-checked.html pass in isolated tree mode
Added: trunk/LayoutTests/editing/execCommand/outdent-cut-crash-expected.txt (0 => 286531)
--- trunk/LayoutTests/editing/execCommand/outdent-cut-crash-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/execCommand/outdent-cut-crash-expected.txt 2021-12-04 15:24:46 UTC (rev 286531)
@@ -0,0 +1 @@
+Test passes if it does not crash.
Added: trunk/LayoutTests/editing/execCommand/outdent-cut-crash.html (0 => 286531)
--- trunk/LayoutTests/editing/execCommand/outdent-cut-crash.html (rev 0)
+++ trunk/LayoutTests/editing/execCommand/outdent-cut-crash.html 2021-12-04 15:24:46 UTC (rev 286531)
@@ -0,0 +1,25 @@
+<script>
+if (window.testRunner)
+ window.testRunner.dumpAsText();
+_onload_ = () => {
+ document.designMode = 'on';
+ getSelection().selectAllChildren(input);
+ getSelection().extend(div);
+ queueMicrotask(() => {
+ document.execCommand('Cut');
+ });
+ document.execCommand('Outdent');
+ document.write("Test passes if it does not crash.");
+};
+</script>
+<body>
+ <blockquote>
+ <div>
+ <div>
+ <iframe></iframe>
+ </div>
+ <input id="input"></input>
+ </div>
+ </blockquote>
+ <div id="div"></div>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (286530 => 286531)
--- trunk/Source/WebCore/ChangeLog 2021-12-04 15:22:57 UTC (rev 286530)
+++ trunk/Source/WebCore/ChangeLog 2021-12-04 15:24:46 UTC (rev 286531)
@@ -1,3 +1,23 @@
+2021-12-04 Rob Buis <[email protected]>
+
+ Fix parentNode in CompositeEditCommand::splitTreeToNode
+ https://bugs.webkit.org/show_bug.cgi?id=230710
+
+ Reviewed by Ryosuke Niwa.
+
+ 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.
+
2021-12-04 Alan Bujtas <[email protected]>
[LFC][IFC] Set BoxGeometry for bidi inline boxes
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (286530 => 286531)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2021-12-04 15:22:57 UTC (rev 286530)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2021-12-04 15:24:46 UTC (rev 286531)
@@ -1750,7 +1750,7 @@
ASSERT(adjustedEnd);
RefPtr<Node> node;
- for (node = &start; node && node->parentNode() != adjustedEnd; node = node->parentNode()) {
+ for (node = &start; node && node->parentNode() != adjustedEnd;) {
RefPtr parentNode = node->parentNode();
if (!parentNode || !is<Element>(*parentNode) || editingIgnoresContent(*parentNode))
break;
@@ -1759,6 +1759,7 @@
VisiblePosition positionInNode = firstPositionInOrBeforeNode(node.get());
if (positionInParent != positionInNode)
splitElement(downcast<Element>(*parentNode), *node);
+ node = parentNode;
}
return node;
Modified: trunk/Source/WebCore/editing/IndentOutdentCommand.cpp (286530 => 286531)
--- trunk/Source/WebCore/editing/IndentOutdentCommand.cpp 2021-12-04 15:22:57 UTC (rev 286530)
+++ trunk/Source/WebCore/editing/IndentOutdentCommand.cpp 2021-12-04 15:24:46 UTC (rev 286531)
@@ -116,8 +116,8 @@
targetBlockquote = createBlockElement();
if (outerBlock == nodeToSplitTo)
insertNodeAt(*targetBlockquote, start);
- else
- insertNodeBefore(*targetBlockquote, *outerBlock);
+ else if (!insertNodeBefore(*targetBlockquote, *outerBlock))
+ return;
startOfContents = positionInParentAfterNode(targetBlockquote.get());
}
@@ -192,8 +192,13 @@
}
auto placeholder = HTMLBRElement::create(document());
insertNodeBefore(placeholder, *splitBlockquoteNode);
- if (placeholder->isConnected())
- moveParagraph(startOfParagraph(visibleStartOfParagraph), endOfParagraph(visibleEndOfParagraph), positionBeforeNode(placeholder.ptr()), true);
+ if (!placeholder->isConnected())
+ return;
+ auto visibleStartOfParagraphToMove = startOfParagraph(visibleStartOfParagraph);
+ auto visibleEndOfParagraphToMove = endOfParagraph(visibleEndOfParagraph);
+ if (visibleStartOfParagraphToMove.isNull() || visibleEndOfParagraphToMove.isNull())
+ return;
+ moveParagraph(visibleStartOfParagraphToMove, visibleEndOfParagraphToMove, positionBeforeNode(placeholder.ptr()), true);
}
// FIXME: We should merge this function with ApplyBlockElementCommand::formatSelection
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes