LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jun 2006 00:20:29 +0000 (00:20 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jun 2006 00:20:29 +0000 (00:20 +0000)
        Reviewed by levi

        * editing/deleting/table-cells-expected.checksum: Added.
        * editing/deleting/table-cells-expected.png: Added.
        * editing/deleting/table-cells-expected.txt: Added.
        * editing/deleting/table-cells.html: Added.
        * editing/inserting/paragraph-separator-in-table-1-expected.checksum: Added.
        * editing/inserting/paragraph-separator-in-table-1-expected.png: Added.
        * editing/inserting/paragraph-separator-in-table-1-expected.txt: Added.
        * editing/inserting/paragraph-separator-in-table-1.html: Added.
        * editing/inserting/paragraph-separator-in-table-2-expected.checksum: Added.
        * editing/inserting/paragraph-separator-in-table-2-expected.png: Added.
        * editing/inserting/paragraph-separator-in-table-2-expected.txt: Added.
        * editing/inserting/paragraph-separator-in-table-2.html: Added.

WebCore:

        Reviewed by levi

        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::initializePositionData): Fix a bug in the code
        to stop merges across table cells.
        (WebCore::DeleteSelectionCommand::mergeParagraphs): Move the code to stop merges
        across table cells to initializePositionData so that its changes to
        m_mergeBlocksAfterDelete can take effect on the endingPosition.
        * editing/InsertParagraphSeparatorCommand.cpp:
        (WebCore::InsertParagraphSeparatorCommand::doApply): Turn into an InsertLineBreak
        instead of splitting/cloning a table cell.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14962 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/deleting/table-cells-expected.checksum [new file with mode: 0644]
LayoutTests/editing/deleting/table-cells-expected.png [new file with mode: 0644]
LayoutTests/editing/deleting/table-cells-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/table-cells.html [new file with mode: 0644]
LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/paragraph-separator-in-table-1.html [new file with mode: 0644]
LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/paragraph-separator-in-table-2.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/InsertParagraphSeparatorCommand.cpp

index aa2c031a2cefcfbb46e5893bbe176a6a928d67f7..86767f6bcc766b3b7fe8fcf57406a59beec2d933 100644 (file)
@@ -1,3 +1,20 @@
+2006-06-21  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+
+        * editing/deleting/table-cells-expected.checksum: Added.
+        * editing/deleting/table-cells-expected.png: Added.
+        * editing/deleting/table-cells-expected.txt: Added.
+        * editing/deleting/table-cells.html: Added.
+        * editing/inserting/paragraph-separator-in-table-1-expected.checksum: Added.
+        * editing/inserting/paragraph-separator-in-table-1-expected.png: Added.
+        * editing/inserting/paragraph-separator-in-table-1-expected.txt: Added.
+        * editing/inserting/paragraph-separator-in-table-1.html: Added.
+        * editing/inserting/paragraph-separator-in-table-2-expected.checksum: Added.
+        * editing/inserting/paragraph-separator-in-table-2-expected.png: Added.
+        * editing/inserting/paragraph-separator-in-table-2-expected.txt: Added.
+        * editing/inserting/paragraph-separator-in-table-2.html: Added.
+
 2006-06-21  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
diff --git a/LayoutTests/editing/deleting/table-cells-expected.checksum b/LayoutTests/editing/deleting/table-cells-expected.checksum
new file mode 100644 (file)
index 0000000..3b8317c
--- /dev/null
@@ -0,0 +1 @@
+8107f89539aea1d9a73cbdf5f1ef50e4
\ No newline at end of file
diff --git a/LayoutTests/editing/deleting/table-cells-expected.png b/LayoutTests/editing/deleting/table-cells-expected.png
new file mode 100644 (file)
index 0000000..76035ff
Binary files /dev/null and b/LayoutTests/editing/deleting/table-cells-expected.png differ
diff --git a/LayoutTests/editing/deleting/table-cells-expected.txt b/LayoutTests/editing/deleting/table-cells-expected.txt
new file mode 100644 (file)
index 0000000..2e03acd
--- /dev/null
@@ -0,0 +1,28 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 24 of #text > DIV > TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document to 24 of #text > DIV > TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderView 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 {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 717x18
+          text run at (0,0) width 361: "This tests deletion of a selection that spans multiple cells. "
+          text run at (361,0) width 356: "Just table content should be removed, not table structure."
+      RenderBlock {DIV} at (0,34) size 784x28
+        RenderTable {TABLE} at (0,0) size 339x28 [border: (1px outset #808080)]
+          RenderTableSection {TBODY} at (1,1) size 337x26
+            RenderTableRow {TR} at (0,2) size 337x22
+              RenderTableCell {TD} at (2,2) size 157x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+                RenderBlock {DIV} at (2,2) size 153x18
+                  RenderText {#text} at (0,0) size 153x18
+                    text run at (0,0) width 153: "These two pieces of text"
+              RenderTableCell {TD} at (161,2) size 174x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+                RenderBlock {DIV} at (2,2) size 170x18
+                  RenderText {#text} at (0,0) size 170x18
+                    text run at (0,0) width 170: "should be in different cells."
+caret: position 24 of child 0 {#text} of child 0 {DIV} of child 0 {TD} of child 0 {TR} of child 0 {TBODY} of child 0 {TABLE} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/deleting/table-cells.html b/LayoutTests/editing/deleting/table-cells.html
new file mode 100644 (file)
index 0000000..61ffe55
--- /dev/null
@@ -0,0 +1,11 @@
+<p>This tests deletion of a selection that spans multiple cells.  Just table content should be removed, not table structure.</p>
+<div id="test" contenteditable="true"><table border="1"><tr><td><div>These two pieces of text<span id="start">blah</span></div></td><td><div><span id="end">blah</span> should be in different cells.</div></td></tr></table>
+
+<script>
+var start = document.getElementById("start").firstChild;
+var end = document.getElementById("end").firstChild;
+
+var s = window.getSelection();
+s.setBaseAndExtent(start, 0, end, end.length);
+document.execCommand("Delete");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.checksum b/LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.checksum
new file mode 100644 (file)
index 0000000..ba43f68
--- /dev/null
@@ -0,0 +1 @@
+0f3d484da568dcc0bc188b8cb81a6f6f
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.png b/LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.png
new file mode 100644 (file)
index 0000000..c2888bf
Binary files /dev/null and b/LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.png differ
diff --git a/LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.txt b/LayoutTests/editing/inserting/paragraph-separator-in-table-1-expected.txt
new file mode 100644 (file)
index 0000000..8e0eb72
--- /dev/null
@@ -0,0 +1,30 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document to 5 of #text > TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document toDOMRange:range from 2 of TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document to 2 of TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderView 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 {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 613x18
+          text run at (0,0) width 337: "This tests InsertParagraphSeparator inside table cells. "
+          text run at (337,0) width 276: "'Cell' and 'Two' should be on separate lines."
+      RenderBlock {DIV} at (0,34) size 784x46
+        RenderTable {TABLE} at (0,0) size 103x46 [border: (1px outset #808080)]
+          RenderTableSection {TBODY} at (1,1) size 101x44
+            RenderTableRow {TR} at (0,2) size 101x40
+              RenderTableCell {TD} at (2,11) size 61x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 57x18
+                  text run at (2,2) width 57: "Cell One"
+              RenderTableCell {TD} at (65,2) size 34x40 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 30x18
+                  text run at (2,2) width 30: "Cell "
+                RenderBR {BR} at (32,16) size 0x0
+                RenderInline {SPAN} at (0,0) size 30x18
+                  RenderText {#text} at (2,20) size 30x18
+                    text run at (2,20) width 30: "Two"
+caret: position 0 of child 0 {#text} of child 2 {SPAN} of child 1 {TD} of child 0 {TR} of child 0 {TBODY} of child 0 {TABLE} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/paragraph-separator-in-table-1.html b/LayoutTests/editing/inserting/paragraph-separator-in-table-1.html
new file mode 100644 (file)
index 0000000..6e95ded
--- /dev/null
@@ -0,0 +1,11 @@
+<p>This tests InsertParagraphSeparator inside table cells.  'Cell' and 'Two' should be on separate lines.</p>
+
+<div contenteditable="true"><table border="1"><tr><td>Cell One</td><td>Cell <span id="test">Two</span></td></tr></table></div>
+
+<script>
+var e = document.getElementById("test").firstChild;
+var s = window.getSelection();
+
+s.setPosition(e, 0);
+document.execCommand("InsertParagraph");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.checksum b/LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.checksum
new file mode 100644 (file)
index 0000000..eb14f53
--- /dev/null
@@ -0,0 +1 @@
+3c327e1aa803f57d837d1e929a5b57ca
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.png b/LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.png
new file mode 100644 (file)
index 0000000..056bdac
Binary files /dev/null and b/LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.png differ
diff --git a/LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.txt b/LayoutTests/editing/inserting/paragraph-separator-in-table-2-expected.txt
new file mode 100644 (file)
index 0000000..767945e
--- /dev/null
@@ -0,0 +1,29 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 2 of TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document to 2 of TD > TR > TBODY > TABLE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderView 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 {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 768x36
+          text run at (0,0) width 337: "This tests InsertParagraphSeparator inside table cells. "
+          text run at (337,0) width 431: "The first cell should contain 'Cell' and a newline, and the second cell"
+          text run at (0,18) width 136: "should contain 'Two'."
+      RenderBlock {DIV} at (0,52) size 784x46
+        RenderTable {TABLE} at (0,0) size 80x46 [border: (1px outset #808080)]
+          RenderTableSection {TBODY} at (1,1) size 78x44
+            RenderTableRow {TR} at (0,2) size 78x40
+              RenderTableCell {TD} at (2,2) size 34x40 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 30x18
+                  text run at (2,2) width 30: "Cell "
+                RenderBR {BR} at (32,16) size 0x0
+                RenderBR {BR} at (2,20) size 0x18
+              RenderTableCell {TD} at (38,11) size 38x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 34x18
+                  text run at (2,2) width 34: " Two"
+caret: position 0 of child 2 {BR} of child 0 {TD} of child 0 {TR} of child 0 {TBODY} of child 0 {TABLE} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/paragraph-separator-in-table-2.html b/LayoutTests/editing/inserting/paragraph-separator-in-table-2.html
new file mode 100644 (file)
index 0000000..44ceda8
--- /dev/null
@@ -0,0 +1,12 @@
+<p>This tests InsertParagraphSeparator inside table cells.  The first cell should contain 'Cell' and a newline, and the second cell should contain 'Two'.</p>
+
+<div contenteditable="true"><table border="1"><tr><td>Cell <span id="start">One</span></td><td><span id="end">Cell</span> Two</td></tr></table></div>
+
+<script>
+var start = document.getElementById("start").firstChild;
+var end = document.getElementById("end").firstChild;
+var s = window.getSelection();
+
+s.setBaseAndExtent(start, 0, end, end.length);
+document.execCommand("InsertParagraph");
+</script>
\ No newline at end of file
index 35439963f4a1fdffa391ddb38a6955f647f81b75..94c142e5b1fea2055922dc497987e42b2decbb28 100644 (file)
@@ -1,3 +1,17 @@
+2006-06-21  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::initializePositionData): Fix a bug in the code
+        to stop merges across table cells.
+        (WebCore::DeleteSelectionCommand::mergeParagraphs): Move the code to stop merges
+        across table cells to initializePositionData so that its changes to 
+        m_mergeBlocksAfterDelete can take effect on the endingPosition.
+        * editing/InsertParagraphSeparatorCommand.cpp:
+        (WebCore::InsertParagraphSeparatorCommand::doApply): Turn into an InsertLineBreak
+        instead of splitting/cloning a table cell.
+
 2006-06-21  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by John.
index 1c4ea88111c5b8c2b08876d37b874319c5877ae0..cb44fce446245b58b559b64d6cd313921c7a0e23 100644 (file)
@@ -101,6 +101,13 @@ void DeleteSelectionCommand::initializePositionData()
 {
     initializeStartEnd();
     
+    Node* startCell = enclosingTableCell(m_upstreamStart.node());
+    Node* endCell = enclosingTableCell(m_downstreamEnd.node());
+    // Don't move content between parts of a table or between table and non-table content.
+    // FIXME: This isn't right.  A borderless table with two rows and a single column would appear as two paragraphs.
+    if ((startCell || endCell) && endCell != startCell)
+        m_mergeBlocksAfterDelete = false;
+    
     // Usually the start and the end of the selection to delete are pulled together as a result of the deletion.
     // Sometimes they aren't (like when no merge is requested), so we must choose one position to hold the caret 
     // and receive the placeholder after deletion.
@@ -109,7 +116,7 @@ void DeleteSelectionCommand::initializePositionData()
         m_endingPosition = m_downstreamEnd;
     else
         m_endingPosition = m_downstreamStart;
-        
+
     // Handle leading and trailing whitespace, as well as smart delete adjustments to the selection
     m_leadingWhitespace = m_upstreamStart.leadingWhitespacePosition(m_selectionToDelete.affinity());
     m_trailingWhitespace = m_downstreamEnd.trailingWhitespacePosition(VP_DEFAULT_AFFINITY);
@@ -403,11 +410,6 @@ void DeleteSelectionCommand::mergeParagraphs()
     if (m_endBlock == m_startBlock)
         return;
         
-    // Don't move content between parts of a table or between table and non-table content.
-    // FIXME: This isn't right.  A borderless table with two rows and a single column would appear as two paragraphs.
-    if (isTableStructureNode(m_downstreamEnd.node()->enclosingBlockFlowElement()) || isTableStructureNode(m_upstreamStart.node()->enclosingBlockFlowElement()))
-        return;
-        
     VisiblePosition startOfParagraphToMove(m_downstreamEnd);
     VisiblePosition mergeDestination(m_upstreamStart);
     
index 4fa234111d07ba8adde3e3d680e635092216a503..ece27023af222a95905ed243705e2ccd363182db 100644 (file)
@@ -34,6 +34,7 @@
 #include "htmlediting.h"
 #include "HTMLElement.h"
 #include "HTMLNames.h"
+#include "InsertLineBreakCommand.h"
 #include "RenderObject.h"
 #include "visible_units.h"
 
@@ -138,6 +139,15 @@ void InsertParagraphSeparatorCommand::doApply()
         affinity = endingSelection().affinity();
     }
     
+    // FIXME: Turn into an InsertLineBreak in other cases where we don't want to do the splitting/cloning that
+    // InsertParagraphSeparator does.
+    Node* block = pos.node()->enclosingBlockFlowElement();
+    if (block->renderer() && block->renderer()->isTableCell()) {
+        EditCommandPtr cmd(new InsertLineBreakCommand(document())); 
+        applyCommandToComposite(cmd);
+        return;
+    }
+    
     // Use the leftmost candidate.
     pos = pos.upstream();
     if (!pos.inRenderedContent())