Title: [263528] trunk
- Revision
- 263528
- Author
- [email protected]
- Date
- 2020-06-25 13:57:59 -0700 (Thu, 25 Jun 2020)
Log Message
Cannot delete last line of Mail Message
https://bugs.webkit.org/show_bug.cgi?id=213536
<rdar://problem/63420928>
Reviewed by Wenson Hsieh.
Source/WebCore:
LayoutTests/editing/deleting/smart-delete-paragraph-005.html
The smart paragraph deletion code did not take into account that
the previous blank line could be the start of editable content without
a paragraph before it. If this was the case, the deletion code backed up
too far, and the delete command failed. This case should be handled
in the same way that the deleting the last paragraph in editable content is
handled, by checking if we are already at the beginning of the editable
content when expanding the selection for smart paragraph deletion.
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::smartDeleteParagraphSpacers):
LayoutTests:
* editing/deleting/smart-delete-paragraph-005.html:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (263527 => 263528)
--- trunk/LayoutTests/ChangeLog 2020-06-25 20:37:34 UTC (rev 263527)
+++ trunk/LayoutTests/ChangeLog 2020-06-25 20:57:59 UTC (rev 263528)
@@ -1,3 +1,13 @@
+2020-06-25 Megan Gardner <[email protected]>
+
+ Cannot delete last line of Mail Message
+ https://bugs.webkit.org/show_bug.cgi?id=213536
+ <rdar://problem/63420928>
+
+ Reviewed by Wenson Hsieh.
+
+ * editing/deleting/smart-delete-paragraph-005.html:
+
2020-06-25 Karl Rackler <[email protected]>
Remove expectation for fast/dynamic/window-resize-scrollbars-test.html as they are passing.
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-005-expected.txt (0 => 263528)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-005-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-005-expected.txt 2020-06-25 20:57:59 UTC (rev 263528)
@@ -0,0 +1,13 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 8 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 8 of #text > DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart delete when deleting a line with only a blank line above it. Test must exist at the top of the file in order to correctly test the original bug.
+Expected Results:
+Everything should be deleted.
+
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-005.html (0 => 263528)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-005.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-005.html 2020-06-25 20:57:59 UTC (rev 263528)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.editing {
+ border: 2px solid red;
+ font-size: 24px;
+}
+.explanation {
+ border: 2px solid blue;
+ padding: 12px;
+ font-size: 24px;
+ margin-bottom: 24px;
+}
+.scenario { margin-bottom: 16px;}
+.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
+.expected-results:first-line { font-weight: bold }
+</style>
+</head>
+<body>
+<div contenteditable="true" style="width: 256px; height: 256px; border: 1px solid black"><br><div id='test'>DeleteMe</div></div>
+
+<div class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Smart delete when deleting a line with only a blank line above it.
+Test must exist at the top of the file in order to correctly test the original bug.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Everything should be deleted.
+</div>
+</div>
+
+<script src=""
+<script src=""
+<script>
+
+async function editingTest() {
+ internals.settings.setEditingBehavior("ios");
+ await UIHelper.selectWordByDoubleTapOrClick(document.getElementById('test'));
+ cutCommand();
+}
+
+runDumpAsTextEditingTest(true);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-005-expected.txt (0 => 263528)
--- trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-005-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-005-expected.txt 2020-06-25 20:57:59 UTC (rev 263528)
@@ -0,0 +1,14 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 8 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 8 of #text > DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart delete when deleting a line with only a blank line above it. Test must exist at the top of the file in order to correctly test the original bug.
+Expected Results:
+Everything should be deleted.
+
Added: trunk/LayoutTests/platform/win/editing/deleting/smart-delete-paragraph-005-expected.txt (0 => 263528)
--- trunk/LayoutTests/platform/win/editing/deleting/smart-delete-paragraph-005-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/win/editing/deleting/smart-delete-paragraph-005-expected.txt 2020-06-25 20:57:59 UTC (rev 263528)
@@ -0,0 +1,15 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 8 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 8 of #text > DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart delete when deleting a line with only a blank line above it. Test must exist at the top of the file in order to correctly test the original bug.
+Expected Results:
+Everything should be deleted.
+
Modified: trunk/Source/WebCore/ChangeLog (263527 => 263528)
--- trunk/Source/WebCore/ChangeLog 2020-06-25 20:37:34 UTC (rev 263527)
+++ trunk/Source/WebCore/ChangeLog 2020-06-25 20:57:59 UTC (rev 263528)
@@ -1,3 +1,24 @@
+2020-06-25 Megan Gardner <[email protected]>
+
+ Cannot delete last line of Mail Message
+ https://bugs.webkit.org/show_bug.cgi?id=213536
+ <rdar://problem/63420928>
+
+ Reviewed by Wenson Hsieh.
+
+ LayoutTests/editing/deleting/smart-delete-paragraph-005.html
+
+ The smart paragraph deletion code did not take into account that
+ the previous blank line could be the start of editable content without
+ a paragraph before it. If this was the case, the deletion code backed up
+ too far, and the delete command failed. This case should be handled
+ in the same way that the deleting the last paragraph in editable content is
+ handled, by checking if we are already at the beginning of the editable
+ content when expanding the selection for smart paragraph deletion.
+
+ * editing/DeleteSelectionCommand.cpp:
+ (WebCore::DeleteSelectionCommand::smartDeleteParagraphSpacers):
+
2020-06-25 Wenson Hsieh <[email protected]>
Text manipulation should exclude text rendered using icon-only fonts
Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp (263527 => 263528)
--- trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2020-06-25 20:37:34 UTC (rev 263527)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2020-06-25 20:57:59 UTC (rev 263528)
@@ -186,6 +186,7 @@
bool startAndEndInSameUnsplittableElement = unsplittableElementForPosition(visibleStart.deepEquivalent()) == unsplittableElementForPosition(visibleEnd.deepEquivalent());
visibleStart = visibleStart.previous(CannotCrossEditingBoundary);
visibleEnd = visibleEnd.next(CannotCrossEditingBoundary);
+ bool previousPositionIsStartOfContent = startOfEditableContent(visibleStart) == visibleStart;
bool previousPositionIsBlankParagraph = isBlankParagraph(visibleStart);
bool endPositonIsBlankParagraph = isBlankParagraph(visibleEnd);
bool hasBlankParagraphAfterEndOrIsEndOfContent = !selectionEndIsEndOfContent && (endPositonIsBlankParagraph || selectionEndsInParagraphSeperator);
@@ -203,8 +204,12 @@
}
if (startAndEndInSameUnsplittableElement && selectionEndIsEndOfContent && previousPositionIsBlankParagraph && selectionEndsInParagraphSeperator) {
m_needPlaceholder = false;
- VisiblePosition endOfParagraphBeforeStart = endOfParagraph(VisiblePosition { m_upstreamStart }.previous().previous());
- Position position = endOfParagraphBeforeStart.deepEquivalent();
+ VisiblePosition endOfParagraphBeforeStart;
+ if (previousPositionIsStartOfContent)
+ endOfParagraphBeforeStart = endOfParagraph(VisiblePosition { m_upstreamStart }.previous());
+ else
+ endOfParagraphBeforeStart = endOfParagraph(VisiblePosition { m_upstreamStart }.previous().previous());
+ auto position = endOfParagraphBeforeStart.deepEquivalent();
m_upstreamStart = position.upstream();
m_downstreamStart = position.downstream();
m_leadingWhitespace = m_upstreamStart.leadingWhitespacePosition(DOWNSTREAM);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes