--- /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 784x36
+ RenderText {TEXT} at (0,0) size 85x18
+ text run at (0,0) width 85: "See this bug: "
+ RenderInline {A} at (0,0) size 167x18 [color=#0000EE]
+ RenderText {TEXT} at (85,0) size 167x18
+ text run at (85,0) width 167: "<rdar://problem/3918712>"
+ RenderText {TEXT} at (252,0) size 736x36
+ text run at (252,0) width 484: " \"Paste as Quotation\" in Mail just pastes (<blockquote> tag seems to be lost)."
+ text run at (0,18) width 496: "Should see two boxes with blockquoted \"foo\" text, followed by an empty box."
+ RenderBlock {DIV} at (0,36) size 784x24
+ RenderBlock {DIV} at (0,60) size 784x104 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,38) size 756x28
+ RenderBlock {BLOCKQUOTE} at (40,0) size 676x28
+ RenderText {TEXT} at (0,0) size 32x28
+ text run at (0,0) width 32: "foo"
+ RenderBlock {DIV} at (0,164) size 784x104 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,38) size 756x28
+ RenderBlock {BLOCKQUOTE} at (40,0) size 676x28
+ RenderText {TEXT} at (0,0) size 32x28
+ text run at (0,0) width 32: "foo"
+ RenderBlock {DIV} at (0,268) size 784x28 [border: (2px solid #FF0000)]
+selection is CARET:
+start: position 0 of child 9 {DIV} of root {BODY}
+upstream: position 0 of child 9 {DIV} of root {BODY}
+downstream: position 1 of child 9 {DIV} of root {BODY}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ padding: 12px;
+ font-size: 24px;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ for (i = 0; i < 4; i++)
+ extendSelectionForwardByCharacterCommand();
+ copyCommand();
+ for (i = 0; i < 2; i++)
+ moveSelectionForwardByCharacterCommand();
+ pasteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body contenteditable id="root">
+
+See this bug: <a href="rdar://problem/3918712"><rdar://problem/3918712></a> "Paste as Quotation" in Mail just pastes (<blockquote> tag seems to be lost).
+Should see two boxes with blockquoted "foo" text, followed by an empty box.
+<div style="height: 24px"></div>
+
+<div id="test" class="editing"><div><blockquote>foo</blockquote></div></div>
+<div class="editing"></div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
--- /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 784x54
+ RenderText {TEXT} at (0,0) size 85x18
+ text run at (0,0) width 85: "See this bug: "
+ RenderInline {A} at (0,0) size 167x18 [color=#0000EE]
+ RenderText {TEXT} at (85,0) size 167x18
+ text run at (85,0) width 167: "<rdar://problem/3918712>"
+ RenderText {TEXT} at (252,0) size 777x54
+ text run at (252,0) width 484: " \"Paste as Quotation\" in Mail just pastes (<blockquote> tag seems to be lost)."
+ text run at (0,18) width 777: "Should see one box with blockquoted \"foo\" text, followed by another box with an \"x\" (not in a blockquote) and \"foo\" (in a"
+ text run at (0,36) width 79: "blockquote)."
+ RenderBlock {DIV} at (0,54) size 784x24
+ RenderBlock {DIV} at (0,78) size 784x104 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,38) size 756x28
+ RenderBlock {BLOCKQUOTE} at (40,0) size 676x28
+ RenderText {TEXT} at (0,0) size 32x28
+ text run at (0,0) width 32: "foo"
+ RenderBlock {DIV} at (0,182) size 784x132 [border: (2px solid #FF0000)]
+ RenderBlock (anonymous) at (14,14) size 756x28
+ RenderText {TEXT} at (0,0) size 12x28
+ text run at (0,0) width 12: "x"
+ RenderBlock {DIV} at (14,66) size 756x28
+ RenderBlock {BLOCKQUOTE} at (40,0) size 676x28
+ RenderText {TEXT} at (0,0) size 32x28
+ text run at (0,0) width 32: "foo"
+selection is CARET:
+start: position 3 of child 1 {TEXT} of child 1 {BLOCKQUOTE} of child 2 {DIV} of child 8 {DIV} of root {BODY}
+upstream: position 3 of child 1 {TEXT} of child 1 {BLOCKQUOTE} of child 2 {DIV} of child 8 {DIV} of root {BODY}
+downstream: position 3 of child 1 {TEXT} of child 1 {BLOCKQUOTE} of child 2 {DIV} of child 8 {DIV} of root {BODY}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ padding: 12px;
+ font-size: 24px;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ for (i = 0; i < 4; i++)
+ extendSelectionForwardByCharacterCommand();
+ copyCommand();
+ moveSelectionForwardByCharacterCommand();
+ typeCharacterCommand();
+ pasteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body contenteditable id="root">
+
+See this bug: <a href="rdar://problem/3918712"><rdar://problem/3918712></a> "Paste as Quotation" in Mail just pastes (<blockquote> tag seems to be lost).
+Should see one box with blockquoted "foo" text, followed by another box with an "x" (not in a blockquote) and "foo" (in a blockquote).
+<div style="height: 24px"></div>
+
+<div id="test" class="editing"><div><blockquote>foo</blockquote></div></div>
+<div class="editing"></div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
--- /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 784x36
+ RenderText {TEXT} at (0,0) size 85x18
+ text run at (0,0) width 85: "See this bug: "
+ RenderInline {A} at (0,0) size 167x18 [color=#0000EE]
+ RenderText {TEXT} at (85,0) size 167x18
+ text run at (85,0) width 167: "<rdar://problem/3918712>"
+ RenderText {TEXT} at (252,0) size 736x36
+ text run at (252,0) width 484: " \"Paste as Quotation\" in Mail just pastes (<blockquote> tag seems to be lost)."
+ text run at (0,18) width 585: "Should see two boxes with blockquoted \"foo\" text, followed by a box with an unquoted \"x\"."
+ RenderBlock {DIV} at (0,36) size 784x24
+ RenderBlock {DIV} at (0,60) size 784x104 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,38) size 756x28
+ RenderBlock {BLOCKQUOTE} at (40,0) size 676x28
+ RenderText {TEXT} at (0,0) size 32x28
+ text run at (0,0) width 32: "foo"
+ RenderBlock {DIV} at (0,164) size 784x104 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,38) size 756x28
+ RenderBlock {BLOCKQUOTE} at (40,0) size 676x28
+ RenderText {TEXT} at (0,0) size 32x28
+ text run at (0,0) width 32: "foo"
+ RenderBlock {DIV} at (0,268) size 784x56 [border: (2px solid #FF0000)]
+ RenderText {TEXT} at (14,14) size 12x28
+ text run at (14,14) width 12: "x"
+selection is CARET:
+start: position 0 of child 1 {TEXT} of child 9 {DIV} of root {BODY}
+upstream: position 0 of child 9 {DIV} of root {BODY}
+downstream: position 0 of child 1 {TEXT} of child 9 {DIV} of root {BODY}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ padding: 12px;
+ font-size: 24px;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ for (i = 0; i < 4; i++)
+ extendSelectionForwardByCharacterCommand();
+ copyCommand();
+ moveSelectionForwardByCharacterCommand();
+ typeCharacterCommand();
+ moveSelectionBackwardByCharacterCommand();
+ pasteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body contenteditable id="root">
+
+See this bug: <a href="rdar://problem/3918712"><rdar://problem/3918712></a> "Paste as Quotation" in Mail just pastes (<blockquote> tag seems to be lost).
+Should see two boxes with blockquoted "foo" text, followed by a box with an unquoted "x".
+<div style="height: 24px"></div>
+
+<div id="test" class="editing"><div><blockquote>foo</blockquote></div></div>
+<div class="editing"></div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
+2004-12-21 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Darin
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::ReplacementFragment::mergeStartNode): Refine concept of how this node is found based on
+ further experiements.
+ (khtml::ReplaceSelectionCommand::doApply): Add a special case for determining merges that need to
+ be done if the insertion point is in an empty block.
+ * layout-tests/editing/pasteboard/paste-text-012-expected.txt: Added.
+ * layout-tests/editing/pasteboard/paste-text-012.html: Added.
+ * layout-tests/editing/pasteboard/paste-text-013-expected.txt: Added.
+ * layout-tests/editing/pasteboard/paste-text-013.html: Added.
+ * layout-tests/editing/pasteboard/paste-text-014-expected.txt: Added.
+ * layout-tests/editing/pasteboard/paste-text-014.html: Added.
+
2004-12-21 Darin Adler <darin@apple.com>
Reviewed by Ken.
NodeImpl *ReplacementFragment::mergeStartNode() const
{
NodeImpl *node = m_fragment->firstChild();
- while (node) {
- NodeImpl *next = node->traverseNextNode();
- if (!isProbablyBlock(node))
- return node;
- node = next;
- }
- return 0;
+ if (!node)
+ return 0;
+ if (!isProbablyBlock(node))
+ return node;
+ return node->firstChild();
}
NodeImpl *ReplacementFragment::mergeEndNode() const
NodeImpl *startBlock = selection.start().node()->enclosingBlockFlowElement();
NodeImpl *endBlock = selection.end().node()->enclosingBlockFlowElement();
- bool mergeStart = !(startAtStartOfLine && (m_fragment.hasInterchangeNewline() || m_fragment.hasMoreThanOneBlock()));
- bool mergeEnd = !m_fragment.hasInterchangeNewline() && m_fragment.hasMoreThanOneBlock();
+ bool mergeStart = false;
+ bool mergeEnd = false;
+ if (startBlock == endBlock && startAtStartOfBlock && startAtEndOfBlock) {
+ // Merge start only if insertion point is in an empty block.
+ mergeStart = true;
+ }
+ else {
+ mergeStart = !(startAtStartOfLine && (m_fragment.hasInterchangeNewline() || m_fragment.hasMoreThanOneBlock()));
+ mergeEnd = !m_fragment.hasInterchangeNewline() && m_fragment.hasMoreThanOneBlock();
+ }
+
Position startPos = Position(selection.start().node()->enclosingBlockFlowElement(), 0);
Position endPos;
EStayInBlock upstreamStayInBlock = StayInBlock;