LayoutTests:
Reviewed by harrison
Pasted content would end up inside the block that contained the end of
the selection that was pasted into and not the block that contained
the start of the selection that was pasted into:
* editing/pasteboard/merge-end-5-expected.checksum: Added.
* editing/pasteboard/merge-end-5-expected.png: Added.
* editing/pasteboard/merge-end-5-expected.txt: Added.
* editing/pasteboard/merge-end-5.html: Added.
Inserting a paragraph separator was splitting and cloning the body element
if the html element was editable:
* editing/inserting/editable-html-element-expected.checksum: Added.
* editing/inserting/editable-html-element-expected.png: Added.
* editing/inserting/editable-html-element-expected.txt: Added.
* editing/inserting/editable-html-element.html: Added.
Since we now sometimes merge backward (from content already in the
document to just inserted content) during the end merge, the node that
contains the old caret is removed more often during paste. The editing
delegate notifications in these tests reflect this:
* editing/pasteboard/paste-line-endings-007-expected.txt:
* editing/pasteboard/paste-line-endings-008-expected.txt:
* editing/pasteboard/paste-line-endings-009-expected.txt:
Now demonstrates a bug where the html element is focused, but its contents
aren't selected:
* editing/selection/focus_editable_html-expected.checksum:
* editing/selection/focus_editable_html-expected.png:
* editing/selection/focus_editable_html-expected.txt:
* editing/selection/focus_editable_html.html:
WebCore:
Reviewed by harrison
* dom/Node.cpp:
(WebCore::Node::rootEditableElement):
Restored code to stop at the body tag. Editing shouldn't be allowed to
happen outside the body, so it needs to be the editable root even if the
html element is contentEditable.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::shouldMergeEnd):
Now takes in more information so it can be "the decider".
(WebCore::ReplaceSelectionCommand::doApply):
Merging two paragraphs will destroy the moved one's block styles. Perform
the end merge backward (from content already in the document to just inserted
content) if moving forward would move the paragraph that contained the start of
the selection being pasted into, since we always want to preserve that paragraph's
block style.
Moving backward in this case is also helpful because otherwise it would be
difficult to remember the position where inserted content began (since merging
would remove m_firstNodeInserted). That position is needed in order to select
the replacement and to add smart replace whitespace.
(WebCore::ReplaceSelectionCommand::removeEndBRIfNeeded):
If [br, 0] is at the end of a block, the br is not necessarily collapsed
in quirks mode. [br, 0] needs to also not be at the start of a block.
* editing/ReplaceSelectionCommand.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14195
268f45cc-cd09-0410-ab3c-
d52691b4dbfc