Diff
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-001-expected.txt (0 => 243296)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-001-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-001-expected.txt 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,21 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 11 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 1 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 26 of #text > DIV > DIV > BODY > HTML > #document
+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: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart paste when pasting a paragraph between two paragraphs.
+Expected Results:
+Extra newlines should be removed to maintin spacing between paragraphs. It should like this:
+Test paragraph.
+
+Last test paragraph.
+Test paragraph.
+
+Last test paragraph.
+execCutCommand: <div> Test paragraph. </div> <div><br></div> <div id="test">Last test paragraph.<br></div>
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-001.html (0 => 243296)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-001.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-001.html 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,64 @@
+<!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 class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Smart paste when pasting a paragraph between two paragraphs.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Extra newlines should be removed to maintin spacing between paragraphs. It should like this:<BR>
+Test paragraph.<BR>
+<br>
+Last test paragraph.<br>
+</div>
+</div>
+
+<div contenteditable id="root" class="editing" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div>
+Test paragraph.
+</div>
+<div><br></div>
+<div id="test">
+Test paragraph to remove.
+</div>
+<div><br></div>
+<div>
+Last test paragraph.
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+async function editingTest() {
+ internals.settings.setEditingBehavior("ios");
+ await UIHelper.selectWordByDoubleTapOrClick(document.getElementById('test'));
+ extendSelectionForwardByLineBoundaryCommand();
+ cutCommand();
+}
+
+runDumpAsTextEditingTest(true);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-002-expected.txt (0 => 243296)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-002-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-002-expected.txt 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,21 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of PRE > BODY > HTML > #document to 6 of PRE > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of PRE > BODY > HTML > #document to 2 of PRE > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > PRE > BODY > HTML > #document to 4 of #text > SPAN > PRE > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > SPAN > PRE > BODY > HTML > #document to 21 of #text > PRE > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of PRE > BODY > HTML > #document to 2 of PRE > BODY > HTML > #document toDOMRange:range from 2 of PRE > BODY > HTML > #document to 2 of PRE > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart deleting paragraph between two paragraphs in a pre element.
+Expected Results:
+The extra line should be removed when the paragraph is removed. It should like this:
+Test paragraph.
+
+Last test paragraph.
+Test paragraph.
+
+Last test paragraph.
+execCutCommand: Test paragraph. <br>Last test paragraph.
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-002.html (0 => 243296)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-002.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-002.html 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,58 @@
+<!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 class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Smart deleting paragraph between two paragraphs in a pre element.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+The extra line should be removed when the paragraph is removed. It should like this:
+<BR>
+Test paragraph.
+<BR>
+<BR>
+Last test paragraph.
+</div>
+</div>
+
+<pre contenteditable id="root" class="editing" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+Test paragraph.
+<br><span id="test">Test</span> paragraph to remove.
+<br>Last test paragraph.
+</pre>
+<script src=""
+<script src=""
+<script>
+
+async function editingTest() {
+ internals.settings.setEditingBehavior("ios");
+ await UIHelper.selectWordByDoubleTapOrClick(document.getElementById('test'));
+ extendSelectionForwardByLineBoundaryCommand();
+ cutCommand();
+}
+
+runDumpAsTextEditingTest(true);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-003-expected.txt (0 => 243296)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-003-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-003-expected.txt 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,20 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of BODY > HTML > #document to 3 of BODY > HTML > #document toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment toDOMRange:range from 0 of #text > DIV > #document-fragment to 4 of #text > DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > DIV > #document-fragment to 15 of #text > DIV > #document-fragment
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart paste when pasting a paragraph between two paragraphs.
+Expected Results:
+Extra newlines should be removed to maintin spacing between paragraphs. It should like this:
+Test paragraph.
+
+Last test paragraph.
+
+
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-003.html (0 => 243296)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-003.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-003.html 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,57 @@
+<!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 class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Smart paste when pasting a paragraph between two paragraphs.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Extra newlines should be removed to maintin spacing between paragraphs. It should like this:<BR>
+Test paragraph.<BR>
+<br>
+Last test paragraph.<br>
+</div>
+</div>
+
+<textarea id="test">
+Test paragraph.
+
+Test paragraph to remove.
+
+Last test paragraph.</textarea>
+<script src=""
+<script src=""
+<script>
+
+async function editingTest() {
+ internals.settings.setEditingBehavior("ios");
+ await UIHelper.selectWordByDoubleTapOrClick(document.getElementById('test'));
+ extendSelectionForwardByLineBoundaryCommand();
+ cutCommand();
+}
+
+runDumpAsTextEditingTest(true);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-004-expected.txt (0 => 243296)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-004-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-004-expected.txt 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,21 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 11 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 1 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 31 of #text > DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of DIV > BODY > HTML > #document to 6 of DIV > BODY > HTML > #document toDOMRange:range from 23 of #text > DIV > DIV > BODY > HTML > #document to 23 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart delete when removing the last paragraph.
+Expected Results:
+Extra newlines should be removed to maintin spacing between paragraphs. It should like this:
+Test paragraph.
+
+Middle test paragraph.
+Test paragraph.
+
+Middle test paragraph.
+execCutCommand: <div> Test paragraph. </div> <div><br></div> <div> Middle test paragraph.</div>
Added: trunk/LayoutTests/editing/deleting/smart-delete-paragraph-004.html (0 => 243296)
--- trunk/LayoutTests/editing/deleting/smart-delete-paragraph-004.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/smart-delete-paragraph-004.html 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,64 @@
+<!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 class="explanation">
+<div class="scenario">
+Tests:
+<br>
+Smart delete when removing the last paragraph.
+</div>
+<div class="expected-results">
+Expected Results:
+<br>
+Extra newlines should be removed to maintin spacing between paragraphs. It should like this:<BR>
+Test paragraph.<BR>
+<br>
+Middle test paragraph.<br>
+</div>
+</div>
+
+<div contenteditable id="root" class="editing" style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space;">
+<div>
+Test paragraph.
+</div>
+<div><br></div>
+<div>
+Middle test paragraph.
+</div>
+<div><br></div>
+<div id="test">
+Last test paragraph to remove.
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+
+async function editingTest() {
+ internals.settings.setEditingBehavior("ios");
+ await UIHelper.selectWordByDoubleTapOrClick(document.getElementById('test'));
+ extendSelectionForwardByLineBoundaryCommand();
+ cutCommand();
+}
+
+runDumpAsTextEditingTest(true);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/platform/ios/editing/deleting/delete-3959464-fix-expected.txt (0 => 243296)
--- trunk/LayoutTests/platform/ios/editing/deleting/delete-3959464-fix-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios/editing/deleting/delete-3959464-fix-expected.txt 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,35 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > DIV > BODY > HTML > #document to 3 of #text > 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: webViewDidChange:WebViewDidChangeNotification
+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: webViewDidChange:WebViewDidChangeNotification
+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: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > DIV > BODY > HTML > #document to 3 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+
+Should see two blank lines after "foo" each in a separate red box (class=editing).
+
+| "
+"
+| <div>
+| class="editing"
+| id="test"
+| "foo<#selection-caret>"
+| "
+"
Added: trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-001-expected.txt (0 => 243296)
--- trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-001-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-001-expected.txt 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,22 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 11 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 1 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 26 of #text > DIV > DIV > BODY > HTML > #document
+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: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart paste when pasting a paragraph between two paragraphs.
+Expected Results:
+Extra newlines should be removed to maintin spacing between paragraphs. It should like this:
+Test paragraph.
+
+Last test paragraph.
+Test paragraph.
+
+Last test paragraph.
+execCutCommand: <div> Test paragraph. </div> <div><br></div> <div id="test">Last test paragraph.<br></div>
Added: trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-002-expected.txt (0 => 243296)
--- trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-002-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-002-expected.txt 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,22 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of PRE > BODY > HTML > #document to 6 of PRE > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of PRE > BODY > HTML > #document to 2 of PRE > BODY > HTML > #document toDOMRange:range from 2 of PRE > BODY > HTML > #document to 2 of PRE > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of PRE > BODY > HTML > #document to 2 of PRE > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > PRE > BODY > HTML > #document to 4 of #text > SPAN > PRE > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > SPAN > PRE > BODY > HTML > #document to 21 of #text > PRE > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of PRE > BODY > HTML > #document to 2 of PRE > BODY > HTML > #document toDOMRange:range from 2 of PRE > BODY > HTML > #document to 2 of PRE > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart deleting paragraph between two paragraphs in a pre element.
+Expected Results:
+The extra line should be removed when the paragraph is removed. It should like this:
+Test paragraph.
+
+Last test paragraph.
+Test paragraph.
+
+Last test paragraph.
+execCutCommand: Test paragraph. <br>Last test paragraph.
Added: trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-003-expected.txt (0 => 243296)
--- trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-003-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-003-expected.txt 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,22 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment toDOMRange:range from 0 of #text > DIV > #document-fragment to 4 of #text > DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > DIV > #document-fragment to 15 of #text > DIV > #document-fragment
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart paste when pasting a paragraph between two paragraphs.
+Expected Results:
+Extra newlines should be removed to maintin spacing between paragraphs. It should like this:
+Test paragraph.
+
+Last test paragraph.
+
+
Added: trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-004-expected.txt (0 => 243296)
--- trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-004-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-004-expected.txt 2019-03-21 17:03:17 UTC (rev 243296)
@@ -0,0 +1,22 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 11 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 1 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 31 of #text > DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of DIV > BODY > HTML > #document to 6 of DIV > BODY > HTML > #document toDOMRange:range from 23 of #text > DIV > DIV > BODY > HTML > #document to 23 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests:
+Smart delete when removing the last paragraph.
+Expected Results:
+Extra newlines should be removed to maintin spacing between paragraphs. It should like this:
+Test paragraph.
+
+Middle test paragraph.
+Test paragraph.
+
+Middle test paragraph.
+execCutCommand: <div> Test paragraph. </div> <div><br></div> <div> Middle test paragraph.</div>
Modified: trunk/Source/WebCore/ChangeLog (243295 => 243296)
--- trunk/Source/WebCore/ChangeLog 2019-03-21 16:45:25 UTC (rev 243295)
+++ trunk/Source/WebCore/ChangeLog 2019-03-21 17:03:17 UTC (rev 243296)
@@ -1,3 +1,21 @@
+2019-03-21 Megan Gardner <[email protected]>
+
+ Smart delete for paragraphs.
+ https://bugs.webkit.org/show_bug.cgi?id=195837
+
+ Reviewed by Ryosuke Niwa.
+
+ Remove additional newlines to maintain spacing around paragraphs.
+
+ Tests: editing/pasteboard/smart-delete-paragraph-001.html
+ editing/pasteboard/smart-delete-paragraph-002.html
+ editing/pasteboard/smart-delete-paragraph-003.html
+ editing/pasteboard/smart-delete-paragraph-004.html
+
+ * editing/DeleteSelectionCommand.cpp:
+ (WebCore::isBlankLine):
+ (WebCore::DeleteSelectionCommand::initializePositionData):
+
2019-03-21 Cathie Chen <[email protected]>
Fixed ContentChangeObserver build error.
Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp (243295 => 243296)
--- trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2019-03-21 16:45:25 UTC (rev 243295)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2019-03-21 17:03:17 UTC (rev 243296)
@@ -172,6 +172,46 @@
setStartingSelection(VisibleSelection(newBase, newExtent, startingSelection().isDirectional()));
}
+bool DeleteSelectionCommand::shouldSmartDeleteParagraphSpacers()
+{
+ return document().editingBehavior().shouldSmartInsertDeleteParagraphs();
+}
+
+void DeleteSelectionCommand::smartDeleteParagraphSpacers()
+{
+ VisiblePosition visibleStart { m_upstreamStart };
+ VisiblePosition visibleEnd { m_downstreamEnd };
+ bool selectionEndsInParagraphSeperator = isEndOfParagraph(visibleEnd);
+ bool selectionEndIsEndOfContent = endOfEditableContent(visibleEnd) == visibleEnd;
+ bool startAndEndInSameUnsplittableElement = unsplittableElementForPosition(visibleStart.deepEquivalent()) == unsplittableElementForPosition(visibleEnd.deepEquivalent());
+ visibleStart = visibleStart.previous(CannotCrossEditingBoundary);
+ visibleEnd = visibleEnd.next(CannotCrossEditingBoundary);
+ bool previousPositionIsBlankParagraph = isBlankParagraph(visibleStart);
+ bool endPositonIsBlankParagraph = isBlankParagraph(visibleEnd);
+ bool hasBlankParagraphAfterEndOrIsEndOfContent = !selectionEndIsEndOfContent && (endPositonIsBlankParagraph || selectionEndsInParagraphSeperator);
+ if (startAndEndInSameUnsplittableElement && previousPositionIsBlankParagraph && hasBlankParagraphAfterEndOrIsEndOfContent) {
+ m_needPlaceholder = false;
+ Position position;
+ if (endPositonIsBlankParagraph)
+ position = startOfNextParagraph(startOfNextParagraph(m_downstreamEnd)).deepEquivalent();
+ else
+ position = VisiblePosition(m_downstreamEnd).next().deepEquivalent();
+ m_upstreamEnd = position.upstream();
+ m_downstreamEnd = position.downstream();
+ m_trailingWhitespace = m_downstreamEnd.trailingWhitespacePosition(VP_DEFAULT_AFFINITY);
+ setStartingSelectionOnSmartDelete(m_upstreamStart, m_downstreamEnd);
+ }
+ if (startAndEndInSameUnsplittableElement && selectionEndIsEndOfContent && previousPositionIsBlankParagraph && selectionEndsInParagraphSeperator) {
+ m_needPlaceholder = false;
+ VisiblePosition endOfParagraphBeforeStart = endOfParagraph(VisiblePosition { m_upstreamStart }.previous().previous());
+ Position position = endOfParagraphBeforeStart.deepEquivalent();
+ m_upstreamStart = position.upstream();
+ m_downstreamStart = position.downstream();
+ m_leadingWhitespace = m_upstreamStart.leadingWhitespacePosition(DOWNSTREAM);
+ setStartingSelectionOnSmartDelete(m_upstreamStart, m_upstreamEnd);
+ }
+}
+
bool DeleteSelectionCommand::initializePositionData()
{
Position start, end;
@@ -265,6 +305,9 @@
setStartingSelectionOnSmartDelete(m_downstreamStart, m_downstreamEnd);
}
+
+ if (shouldSmartDeleteParagraphSpacers())
+ smartDeleteParagraphSpacers();
}
// We must pass call parentAnchoredEquivalent on the positions since some editing positions
Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.h (243295 => 243296)
--- trunk/Source/WebCore/editing/DeleteSelectionCommand.h 2019-03-21 16:45:25 UTC (rev 243295)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.h 2019-03-21 17:03:17 UTC (rev 243296)
@@ -69,6 +69,8 @@
void removeNode(Node&, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable) override;
void deleteTextFromNode(Text&, unsigned, unsigned) override;
void removeRedundantBlocks();
+ bool shouldSmartDeleteParagraphSpacers();
+ void smartDeleteParagraphSpacers();
// This function provides access to original string after the correction has been deleted.
String originalStringForAutocorrectionAtBeginningOfSelection();
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (243295 => 243296)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2019-03-21 16:45:25 UTC (rev 243295)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2019-03-21 17:03:17 UTC (rev 243296)
@@ -777,11 +777,6 @@
fragment.removeNodePreservingChildren(*wrappingStyleSpan);
return true;
}
-
-static bool isBlankLine(VisiblePosition& position)
-{
- return isStartOfLine(position) && startOfLine(position.next()) != startOfLine(position);
-}
// At copy time, WebKit wraps copied content in a span that contains the source document's
// default styles. If the copied Range inherits any other styles from its ancestors, we put
@@ -939,7 +934,7 @@
VisiblePosition nextPosition = visiblePosition.next(CannotCrossEditingBoundary, &reachedBoundaryStart);
bool hasLineBeforePosition = isEndOfLine(previousPosition);
- return !reachedBoundaryStart && !reachedBoundaryEnd && isBlankLine(visiblePosition) && hasLineBeforePosition && isStartOfLine(nextPosition);
+ return !reachedBoundaryStart && !reachedBoundaryEnd && isBlankParagraph(visiblePosition) && hasLineBeforePosition && isStartOfLine(nextPosition);
}
void ReplaceSelectionCommand::doApply()
@@ -1382,7 +1377,7 @@
VisiblePosition positionAfterEnd = endOfInsertedContent.next(CannotCrossEditingBoundary, &reachedBoundaryEnd);
if (!reachedBoundaryStart && !reachedBoundaryEnd) {
- if (!isBlankLine(positionBeforeStart) && !isBlankLine(startOfInsertedContent) && isEndOfLine(positionBeforeStart) && !isEndOfEditableOrNonEditableContent(positionAfterEnd) && !isEndOfEditableOrNonEditableContent(endOfInsertedContent)) {
+ if (!isBlankParagraph(positionBeforeStart) && !isBlankParagraph(startOfInsertedContent) && isEndOfLine(positionBeforeStart) && !isEndOfEditableOrNonEditableContent(positionAfterEnd) && !isEndOfEditableOrNonEditableContent(endOfInsertedContent)) {
setEndingSelection(startOfInsertedContent);
insertParagraphSeparator();
auto newStart = endingSelection().visibleStart().previous(CannotCrossEditingBoundary, &reachedBoundaryStart);
@@ -1397,7 +1392,7 @@
positionBeforeStart = startOfInsertedContent.previous(CannotCrossEditingBoundary, &reachedBoundaryStart);
if (!reachedBoundaryEnd && !reachedBoundaryStart) {
- if (!isBlankLine(positionAfterEnd) && !isBlankLine(endOfInsertedContent) && isStartOfLine(positionAfterEnd) && !isEndOfLine(positionAfterEnd) && !isEndOfEditableOrNonEditableContent(positionAfterEnd)) {
+ if (!isBlankParagraph(positionAfterEnd) && !isBlankParagraph(endOfInsertedContent) && isStartOfLine(positionAfterEnd) && !isEndOfLine(positionAfterEnd) && !isEndOfEditableOrNonEditableContent(positionAfterEnd)) {
setEndingSelection(endOfInsertedContent);
insertParagraphSeparator();
m_endOfInsertedContent = endingSelection().start();
Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (243295 => 243296)
--- trunk/Source/WebCore/editing/VisibleUnits.cpp 2019-03-21 16:45:25 UTC (rev 243295)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp 2019-03-21 17:03:17 UTC (rev 243296)
@@ -1377,6 +1377,11 @@
{
return pos.isNotNull() && pos == endOfParagraph(pos, boundaryCrossingRule);
}
+
+bool isBlankParagraph(const VisiblePosition& position)
+{
+ return isStartOfParagraph(position) && startOfParagraph(position.next()) != startOfParagraph(position);
+}
VisiblePosition previousParagraphPosition(const VisiblePosition& p, int x)
{
Modified: trunk/Source/WebCore/editing/VisibleUnits.h (243295 => 243296)
--- trunk/Source/WebCore/editing/VisibleUnits.h 2019-03-21 16:45:25 UTC (rev 243295)
+++ trunk/Source/WebCore/editing/VisibleUnits.h 2019-03-21 17:03:17 UTC (rev 243296)
@@ -75,6 +75,7 @@
WEBCORE_EXPORT bool isStartOfParagraph(const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
WEBCORE_EXPORT bool isEndOfParagraph(const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
bool inSameParagraph(const VisiblePosition &, const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
+bool isBlankParagraph(const VisiblePosition &);
// blocks (true paragraphs; line break elements don't break blocks)
VisiblePosition startOfBlock(const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);