Fix for this bug:
<rdar://problem/
3907422> REGRESSION (Mail): Pasting quoted content can place content after body element
* khtml/editing/htmlediting.cpp:
(khtml::ReplaceSelectionCommand::doApply): Detect when the body element is the "reference block" used
for determining the location for inserting content. Do not allow an insert before or after if the
reference block is the body. Perform insertNodeAt(0) and appendNode, respectively, in the block-is-body case.
* layout-tests/editing/inserting/insert-
3907422-fix-expected.txt: Added.
* layout-tests/editing/inserting/insert-
3907422-fix.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8148
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock (anonymous) at (0,0) size 784x18
+ RenderText {TEXT} at (0,0) size 21x18
+ text run at (0,0) width 21: "foo"
+ RenderBlock {BLOCKQUOTE} at (40,34) size 704x18
+ RenderText {TEXT} at (0,0) size 20x18
+ text run at (0,0) width 20: "bar"
+ RenderBlock (anonymous) at (0,68) size 784x18
+ RenderText {TEXT} at (0,0) size 22x18
+ text run at (0,0) width 22: "baz"
+ RenderText {TEXT} at (22,0) size 21x18
+ text run at (22,0) width 21: "foo"
+ RenderBlock {BLOCKQUOTE} at (40,102) size 704x18
+ RenderText {TEXT} at (0,0) size 20x18
+ text run at (0,0) width 20: "bar"
+ RenderBlock (anonymous) at (0,136) size 784x18
+ RenderText {TEXT} at (0,0) size 22x18
+ text run at (0,0) width 22: "baz"
+ RenderText {TEXT} at (0,0) size 0x0
+ RenderText {TEXT} at (0,0) size 0x0
+selection is CARET:
+start: position 3 of child 6 {TEXT} of root {BODY}
+upstream: position 3 of child 6 {TEXT} of root {BODY}
+downstream: position 1 of child 8 {TEXT} of root {BODY}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ word-wrap: break-word;
+ -khtml-nbsp-mode: space;
+ -khtml-line-break: after-white-space;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ selectAllCommand();
+ cutCommand();
+ pasteCommand();
+ pasteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body contenteditable id="root" class="editing">
+<div>foo<blockquote>bar</blockquote>baz</div>
+
+<!-- Buggy code before fix would insert blockquote after body element in second paste -->
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
+2004-12-07 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by John
+
+ Fix for this bug:
+
+ <rdar://problem/3907422> REGRESSION (Mail): Pasting quoted content can place content after body element
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::ReplaceSelectionCommand::doApply): Detect when the body element is the "reference block" used
+ for determining the location for inserting content. Do not allow an insert before or after if the
+ reference block is the body. Perform insertNodeAt(0) and appendNode, respectively, in the block-is-body case.
+ * layout-tests/editing/inserting/insert-3907422-fix-expected.txt: Added.
+ * layout-tests/editing/inserting/insert-3907422-fix.html: Added.
+
2004-12-07 Darin Adler <darin@apple.com>
Reviewed by Don.
if (node) {
NodeImpl *refNode = node;
NodeImpl *node = refNode ? refNode->nextSibling() : 0;
- if (isProbablyBlock(refNode) && (insertBlocksBefore || startAtStartOfBlock)) {
- insertNodeBefore(refNode, refBlock);
+ if (isProbablyBlock(refNode) && (insertBlocksBefore || startAtStartOfBlock) && !mergeStart) {
+ if (refBlock->id() == ID_BODY)
+ insertNodeAt(refNode, refBlock, 0);
+ else
+ insertNodeBefore(refNode, refBlock);
}
- else if (isProbablyBlock(refNode) && startAtEndOfBlock) {
- insertNodeAfter(refNode, refBlock);
+ else if (isProbablyBlock(refNode) && startAtEndOfBlock && !mergeEnd) {
+ if (refBlock->id() == ID_BODY)
+ appendNode(refNode, refBlock);
+ else
+ insertNodeAfter(refNode, refBlock);
}
else {
insertNodeAt(refNode, insertionPos.node(), insertionPos.offset());