Reviewed by Hyatt
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Sep 2004 20:58:30 +0000 (20:58 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Sep 2004 20:58:30 +0000 (20:58 +0000)
        * 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

14 files changed:
LayoutTests/editing/deleting/delete-block-merge-contents-012-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-012.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-013-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-013.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-014-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-014.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-015-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-015.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-016-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-016.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-017-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-merge-contents-017.html [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/htmlediting_impl.cpp

diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-012-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-012-expected.txt
new file mode 100644 (file)
index 0000000..dc24928
--- /dev/null
@@ -0,0 +1,16 @@
+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}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-012.html b/LayoutTests/editing/deleting/delete-block-merge-contents-012.html
new file mode 100644 (file)
index 0000000..1d80952
--- /dev/null
@@ -0,0 +1,40 @@
+<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>
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-013-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-013-expected.txt
new file mode 100644 (file)
index 0000000..cdeb028
--- /dev/null
@@ -0,0 +1,16 @@
+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}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-013.html b/LayoutTests/editing/deleting/delete-block-merge-contents-013.html
new file mode 100644 (file)
index 0000000..1addb5c
--- /dev/null
@@ -0,0 +1,40 @@
+<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>
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-014-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-014-expected.txt
new file mode 100644 (file)
index 0000000..c2fa680
--- /dev/null
@@ -0,0 +1,16 @@
+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}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-014.html b/LayoutTests/editing/deleting/delete-block-merge-contents-014.html
new file mode 100644 (file)
index 0000000..d674642
--- /dev/null
@@ -0,0 +1,40 @@
+<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>
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-015-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-015-expected.txt
new file mode 100644 (file)
index 0000000..c2fa680
--- /dev/null
@@ -0,0 +1,16 @@
+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}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-015.html b/LayoutTests/editing/deleting/delete-block-merge-contents-015.html
new file mode 100644 (file)
index 0000000..daa9463
--- /dev/null
@@ -0,0 +1,40 @@
+<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>
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-016-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-016-expected.txt
new file mode 100644 (file)
index 0000000..6cbd531
--- /dev/null
@@ -0,0 +1,18 @@
+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}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-016.html b/LayoutTests/editing/deleting/delete-block-merge-contents-016.html
new file mode 100644 (file)
index 0000000..2e1e3eb
--- /dev/null
@@ -0,0 +1,40 @@
+<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>
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-017-expected.txt b/LayoutTests/editing/deleting/delete-block-merge-contents-017-expected.txt
new file mode 100644 (file)
index 0000000..947c785
--- /dev/null
@@ -0,0 +1,16 @@
+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}
diff --git a/LayoutTests/editing/deleting/delete-block-merge-contents-017.html b/LayoutTests/editing/deleting/delete-block-merge-contents-017.html
new file mode 100644 (file)
index 0000000..f32c7b5
--- /dev/null
@@ -0,0 +1,40 @@
+<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>
index 5c0fae8059a3c820ffa51a0f61a216fdfb45c4da..31a9bd81f35f1468ae99d6cb3af3e7a5255ad649 100644 (file)
@@ -1,3 +1,27 @@
+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
index 7df661e625c7370b98862f3409ee6a0cbf16ead1..9db835605039ed7741fb501f4457fffd3e7f8fb3 100644 (file)
@@ -1087,6 +1087,20 @@ void DeleteSelectionCommandImpl::doApply()
         // 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
@@ -1172,13 +1186,7 @@ void DeleteSelectionCommandImpl::doApply()
     
     // 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());
     }