Smart Insert for paragraphs.
authormegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2019 01:56:39 +0000 (01:56 +0000)
committermegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2019 01:56:39 +0000 (01:56 +0000)
commit0d14cf123a162c10fcaf3f3e92af52b590d94c9e
treeea89cc4cc1e9458998671617f47bee189e002859
parent7d435558a5f4b0603525f1c88d5b833707e9aa57
Smart Insert for paragraphs.
https://bugs.webkit.org/show_bug.cgi?id=194880

Reviewed by Ryosuke Niwa.

Source/WebCore:

Add additional newlines to maintain spacing around paragraphs.

Tests: editing/pasteboard/smart-paste-paragraph-001.html
       editing/pasteboard/smart-paste-paragraph-002.html
       editing/pasteboard/smart-paste-paragraph-003.html
       editing/pasteboard/smart-paste-paragraph-004.html

* dom/Document.cpp:
(WebCore::Document::editingBehavior const):
* dom/Document.h:

Expose editing behaviour through document so that is can be access from the selection commands
and allow the editing behaviour to be used.

* editing/CompositeEditCommand.h:
* editing/EditingBehavior.h:
(WebCore::EditingBehavior::shouldSmartInsertDeleteParagraphs const):

Only have editing insert paragraphs on iOS and in editing elements that support multiple lines.

* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply):
(WebCore::ReplaceSelectionCommand::shouldPerformSmartParagraphReplace const):
(WebCore::ReplaceSelectionCommand::addNewLinesForSmartReplace):
* editing/ReplaceSelectionCommand.h:

Add addititional newlines when pasting full paragraphs to maintian two newlines between paragraphs
if that is what the original document had. If there are not multiple lines between paragraphs, do not
add additional new lines.

LayoutTests:

List tests are covered by paste-list-00*.
Table tests are covered by paste-table-00* and paste-into-table-*.

* editing/pasteboard/smart-paste-paragraph-001-expected.txt: Added.
* editing/pasteboard/smart-paste-paragraph-001.html: Added.
* editing/pasteboard/smart-paste-paragraph-002-expected.txt: Added.
* editing/pasteboard/smart-paste-paragraph-002.html: Added.
* editing/pasteboard/smart-paste-paragraph-003-expected.txt: Added.
* editing/pasteboard/smart-paste-paragraph-003.html: Added.
* editing/pasteboard/smart-paste-paragraph-004-expected.txt: Added.
* editing/pasteboard/smart-paste-paragraph-004.html: Added.
* platform/ios-wk2/editing/pasteboard/paste-text-016-expected.txt:
This needed to be rebaselined to match the new behaviour.
* platform/ios/editing/pasteboard/smart-paste-paragraph-001-expected.txt: Added.
* platform/ios/editing/pasteboard/smart-paste-paragraph-002-expected.txt: Added.
* platform/ios/editing/pasteboard/smart-paste-paragraph-003-expected.txt: Added.
* platform/ios/editing/pasteboard/smart-paste-paragraph-004-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243124 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/smart-paste-paragraph-001-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/smart-paste-paragraph-001.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/smart-paste-paragraph-002-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/smart-paste-paragraph-002.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/smart-paste-paragraph-003-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/smart-paste-paragraph-003.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/smart-paste-paragraph-004-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/smart-paste-paragraph-004.html [new file with mode: 0644]
LayoutTests/platform/ios-wk2/editing/pasteboard/paste-text-016-expected.txt
LayoutTests/platform/ios/editing/pasteboard/smart-paste-paragraph-001-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios/editing/pasteboard/smart-paste-paragraph-002-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios/editing/pasteboard/smart-paste-paragraph-003-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios/editing/pasteboard/smart-paste-paragraph-004-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/editing/CompositeEditCommand.h
Source/WebCore/editing/EditingBehavior.h
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/ReplaceSelectionCommand.h