* khtml/editing/htmlediting_impl.cpp:
(khtml::DeleteSelectionCommandImpl::doApply): The whitespace fixup code
that makes sure proper whitespace renders after deletion was getting confused
in cases where the deletion merged blocks. Basically, I needed to move some
whitespace fixup code so it runs before deleting in the case where blocks
need to be merged. It used to run after, and was getting confused by
whitespace left over at the ends of the block after the deletion.
* layout-tests/editing/deleting/delete-block-merge-contents-012-expected.txt: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-012.html: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-013-expected.txt: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-013.html: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-014-expected.txt: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-014.html: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-015-expected.txt: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-015.html: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-016-expected.txt: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-016.html: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-017-expected.txt: Added.
* layout-tests/editing/deleting/delete-block-merge-contents-017.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7573
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 {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,14) size 756x28
+ RenderBlock {DIV} at (0,0) size 756x28
+ RenderText {TEXT} at (0,0) size 71x28
+ text run at (0,0) width 71: "This is "
+ RenderText {TEXT} at (71,0) size 106x28
+ text run at (71,0) width 106: " some text."
+selection is CARET:
+start: position 0 of child 2 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+upstream: position 8 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+downstream: position 0 of child 2 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
--- /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 < 8; i++)
+ moveSelectionForwardByCharacterCommand();
+ for (i = 0; i < 18; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+<div contenteditable id="root" class="editing">
+<div id="test">
+<div>This is some text.</div>
+<div>This is some text.</div>
+</div>
+</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 {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,14) size 756x28
+ RenderBlock {DIV} at (0,0) size 756x28
+ RenderText {TEXT} at (0,0) size 71x28
+ text run at (0,0) width 71: "This is "
+ RenderText {TEXT} at (71,0) size 100x28
+ text run at (71,0) width 100: "some text."
+selection is CARET:
+start: position 8 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+upstream: position 8 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+downstream: position 0 of child 2 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
--- /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 < 8; i++)
+ moveSelectionForwardByCharacterCommand();
+ for (i = 0; i < 19; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+<div contenteditable id="root" class="editing">
+<div id="test">
+<div>This is some text.</div>
+<div>This is some text.</div>
+</div>
+</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 {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,14) size 756x28
+ RenderBlock {DIV} at (0,0) size 756x28
+ RenderText {TEXT} at (0,0) size 65x28
+ text run at (0,0) width 65: "This is"
+ RenderText {TEXT} at (65,0) size 106x28
+ text run at (65,0) width 106: " some text."
+selection is CARET:
+start: position 7 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+upstream: position 7 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+downstream: position 0 of child 2 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
--- /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 < 7; i++)
+ moveSelectionForwardByCharacterCommand();
+ for (i = 0; i < 19; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+<div contenteditable id="root" class="editing">
+<div id="test">
+<div>This is some text.</div>
+<div>This is some text.</div>
+</div>
+</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 {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,14) size 756x28
+ RenderBlock {DIV} at (0,0) size 756x28
+ RenderText {TEXT} at (0,0) size 65x28
+ text run at (0,0) width 65: "This is"
+ RenderText {TEXT} at (65,0) size 106x28
+ text run at (65,0) width 106: " some text."
+selection is CARET:
+start: position 7 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+upstream: position 7 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+downstream: position 0 of child 2 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
--- /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 < 7; i++)
+ moveSelectionForwardByCharacterCommand();
+ for (i = 0; i < 19; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+<div contenteditable id="root" class="editing">
+<div id="test">
+<div>This is some text.</div>
+<div>This is some text.</div>
+</div>
+</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 {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,14) size 756x28
+ RenderBlock {DIV} at (0,0) size 756x28
+ RenderText {TEXT} at (0,0) size 65x28
+ text run at (0,0) width 65: "This is"
+ RenderText {TEXT} at (65,0) size 106x28
+ text run at (65,0) width 6: " "
+ text run at (71,0) width 100: "some text."
+ RenderBR {BR} at (0,0) size 0x0
+selection is CARET:
+start: position 7 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+upstream: position 7 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+downstream: position 0 of child 2 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
--- /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 < 7; i++)
+ moveSelectionForwardByCharacterCommand();
+ for (i = 0; i < 19; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+<div contenteditable id="root" class="editing">
+<div id="test">
+<div>This is some text.</div>
+<div>This is some text.</div>
+</div>
+</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 {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
+ RenderBlock {DIV} at (14,14) size 756x28
+ RenderBlock {DIV} at (0,0) size 756x28
+ RenderText {TEXT} at (0,0) size 71x28
+ text run at (0,0) width 71: "This is "
+ RenderText {TEXT} at (71,0) size 106x28
+ text run at (71,0) width 106: " some text."
+selection is CARET:
+start: position 7 of child 2 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+upstream: position 8 of child 1 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
+downstream: position 7 of child 2 {TEXT} of child 1 {DIV} of child 2 {DIV} of root {DIV}
--- /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 < 8; i++)
+ moveSelectionForwardByCharacterCommand();
+ for (i = 0; i < 18; i++)
+ extendSelectionForwardByCharacterCommand();
+ deleteCommand();
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body>
+<div contenteditable id="root" class="editing">
+<div id="test">
+<div>This is some text.</div>
+<div>This is some text.</div>
+</div>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
+2004-09-15 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Hyatt
+
+ * khtml/editing/htmlediting_impl.cpp:
+ (khtml::DeleteSelectionCommandImpl::doApply): The whitespace fixup code
+ that makes sure proper whitespace renders after deletion was getting confused
+ in cases where the deletion merged blocks. Basically, I needed to move some
+ whitespace fixup code so it runs before deleting in the case where blocks
+ need to be merged. It used to run after, and was getting confused by
+ whitespace left over at the ends of the block after the deletion.
+ * layout-tests/editing/deleting/delete-block-merge-contents-012-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-012.html: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-013-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-013.html: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-014-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-014.html: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-015-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-015.html: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-016-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-016.html: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-017-expected.txt: Added.
+ * layout-tests/editing/deleting/delete-block-merge-contents-017.html: Added.
+
2004-09-15 Ken Kocienda <kocienda@apple.com>
Reviewed by Hyatt
// be nice to be able to deal with this, but for now, bail.
return;
+ if (startBlock != endBlock) {
+ // Delete some unrendered whitespace. This prepares the startBlock to
+ // receive content that will be merged from endBlock. Do this before
+ // deleting, since deleting content can alter the notion of what
+ // should collapse away.
+ // stay in this block and delete unrenderered text from the upstreamStart location
+ deleteUnrenderedText(upstreamStart);
+ Position upstreamInPreviousBlock(upstreamStart.upstream()); // Note no StayInBlock on upstream call.
+ if (upstreamInPreviousBlock != upstreamStart)
+ // cross blocks and delete unrenderered text from the upstream
+ // position in startBlock.
+ deleteUnrenderedText(upstreamInPreviousBlock);
+ }
+
// Figure out the typing style in effect before the delete is done.
// FIXME: Improve typing style.
// See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
// Do block merge if start and end of selection are in different blocks.
if (endBlock != startBlock && downstreamEnd.node()->inDocument()) {
- LOG(Editing, "merging content to start block");
- // cross blocks and delete unrenderered text from the destination location
- deleteUnrenderedText(upstreamStart.upstream());
- // stay in this block and delete unrenderered text from the source location
- deleteUnrenderedText(upstreamStart);
- // move the downstream end position's node, and all other nodes in its
- // block to the start block.
+ LOG(Editing, "merging content from end block");
moveNodesAfterNode(downstreamEnd.node(), upstreamStart.node());
}