WebCore:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Oct 2007 00:40:48 +0000 (00:40 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Oct 2007 00:40:48 +0000 (00:40 +0000)
        Reviewed by Harrison.

        <rdar://problem/5483370> GoogleDocs: Deleting cell text in a table row also removes any empty rows beneath the row being edited
        <rdar://problem/5482524> GoogleDocs: A hang occurs when applying list to selected table

        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows):
        * editing/InsertListCommand.cpp:
        (WebCore::InsertListCommand::modifyRange):
        (WebCore::InsertListCommand::doApply):

LayoutTests:

        Reviewed by Harrison.

        <rdar://problem/5483370> GoogleDocs: Deleting cell text in a table row also removes any empty rows beneath the row being edited
        <rdar://problem/5482524> GoogleDocs: A hang occurs when applying list to selected table

        * editing/deleting/5483370.html: Added.
        * editing/pasteboard/5483567.html-disabled: Removed.
        * editing/execCommand/5482524.html: Added.
        * platform/mac/editing/deleting/5483370-expected.checksum: Added.
        * platform/mac/editing/deleting/5483370-expected.png: Added.
        * platform/mac/editing/deleting/5483370-expected.txt: Added.
        * platform/mac/editing/execCommand/5482524-expected.checksum: Added.
        * platform/mac/editing/execCommand/5482524-expected.png: Added.
        * platform/mac/editing/execCommand/5482524-expected.txt: Added.

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/deleting/5483370.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/5483567.html-disabled [deleted file]
LayoutTests/platform/mac/editing/deleting/5483370-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/deleting/5483370-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/deleting/5483370-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5482524-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5482524-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5482524-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/InsertListCommand.cpp

index 1a558748c1807c7f811febf0cb1f1f42579cba5a..802babecb62aa390db68985f03fbe49fede7c813 100644 (file)
@@ -1,3 +1,20 @@
+2007-10-12  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Harrison.
+        
+        <rdar://problem/5483370> GoogleDocs: Deleting cell text in a table row also removes any empty rows beneath the row being edited
+        <rdar://problem/5482524> GoogleDocs: A hang occurs when applying list to selected table
+
+        * editing/deleting/5483370.html: Added.
+        * editing/pasteboard/5483567.html-disabled: Removed.
+        * editing/execCommand/5482524.html: Added.
+        * platform/mac/editing/deleting/5483370-expected.checksum: Added.
+        * platform/mac/editing/deleting/5483370-expected.png: Added.
+        * platform/mac/editing/deleting/5483370-expected.txt: Added.
+        * platform/mac/editing/execCommand/5482524-expected.checksum: Added.
+        * platform/mac/editing/execCommand/5482524-expected.png: Added.
+        * platform/mac/editing/execCommand/5482524-expected.txt: Added.
+
 2007-10-12  Darin Adler  <darin@apple.com>
 
         Reviewed by Oliver Hunt.
diff --git a/LayoutTests/editing/deleting/5483370.html b/LayoutTests/editing/deleting/5483370.html
new file mode 100644 (file)
index 0000000..8a83905
--- /dev/null
@@ -0,0 +1,9 @@
+<p>This tests for a problem where empty table rows after the selection being deleted would be removed incorrectly.  Only the last letter in 'foo' should be removed during this delete.</p>
+<div contenteditable="true"><table border="1"><tr><td id="td">foo</td><td></td></tr><tr><td></td><td></td></tr></table</div>
+
+<script>
+td = document.getElementById("td");
+sel = window.getSelection();
+sel.setPosition(td, 1);
+document.execCommand("Delete");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/5483567.html-disabled b/LayoutTests/editing/pasteboard/5483567.html-disabled
deleted file mode 100644 (file)
index 09fa00e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<div id="div" contenteditable="true">xx</div>
-
-<script>
-text = document.getElementById("div").firstChild;
-window.getSelection().setPosition(text, 1);
-document.execCommand("InsertHTML", false, " <div>foo</div> ");
-</script>
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/deleting/5483370-expected.checksum b/LayoutTests/platform/mac/editing/deleting/5483370-expected.checksum
new file mode 100644 (file)
index 0000000..5d0b19f
--- /dev/null
@@ -0,0 +1 @@
+04a7c9c29cfc6c243a2997183b14115b
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/deleting/5483370-expected.png b/LayoutTests/platform/mac/editing/deleting/5483370-expected.png
new file mode 100644 (file)
index 0000000..9838d4c
Binary files /dev/null and b/LayoutTests/platform/mac/editing/deleting/5483370-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/deleting/5483370-expected.txt b/LayoutTests/platform/mac/editing/deleting/5483370-expected.txt
new file mode 100644 (file)
index 0000000..82239d8
--- /dev/null
@@ -0,0 +1,22 @@
+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 761x36
+          text run at (0,0) width 706: "This tests for a problem where empty table rows after the selection being deleted would be removed incorrectly. "
+          text run at (706,0) width 55: "Only the"
+          text run at (0,18) width 343: "last letter in 'foo' should be removed during this delete."
+      RenderBlock {DIV} at (0,52) size 784x34
+        RenderTable {TABLE} at (0,0) size 29x34 [border: (1px outset #808080)]
+          RenderTableSection {TBODY} at (1,1) size 27x32
+            RenderTableRow {TR} at (0,2) size 27x22
+              RenderTableCell {TD} at (2,2) size 17x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 13x18
+                  text run at (2,2) width 13: "fo"
+              RenderTableCell {TD} at (21,11) size 4x4 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+            RenderTableRow {TR} at (0,26) size 27x4
+              RenderTableCell {TD} at (2,26) size 17x4 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+              RenderTableCell {TD} at (21,26) size 4x4 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+caret: position 2 of child 0 {#text} 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/platform/mac/editing/execCommand/5482524-expected.checksum b/LayoutTests/platform/mac/editing/execCommand/5482524-expected.checksum
new file mode 100644 (file)
index 0000000..1784fb5
--- /dev/null
@@ -0,0 +1 @@
+29d2d581d963f9dfa27ad6aef8571dd2
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/execCommand/5482524-expected.png b/LayoutTests/platform/mac/editing/execCommand/5482524-expected.png
new file mode 100644 (file)
index 0000000..b3c06f2
Binary files /dev/null and b/LayoutTests/platform/mac/editing/execCommand/5482524-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/execCommand/5482524-expected.txt b/LayoutTests/platform/mac/editing/execCommand/5482524-expected.txt
new file mode 100644 (file)
index 0000000..2fbda47
--- /dev/null
@@ -0,0 +1,42 @@
+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 766x36
+          text run at (0,0) width 625: "This tests for a hang when creating a list out of a selection that starts inside a table and ends after it. "
+          text run at (625,0) width 141: "You should see empty"
+          text run at (0,18) width 346: "list items in each table cell and 'foo' in the first list item."
+      RenderBlock {DIV} at (0,52) size 784x84
+        RenderTable {TABLE} at (0,0) size 117x84 [border: (1px outset #808080)]
+          RenderTableSection {TBODY} at (1,1) size 115x82
+            RenderTableRow {TR} at (0,2) size 115x38
+              RenderTableCell {TD} at (2,2) size 65x38 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+                RenderBlock {UL} at (2,2) size 61x18
+                  RenderListItem {LI} at (40,0) size 21x18
+                    RenderListMarker at (-17,0) size 7x18: bullet
+                    RenderText {#text} at (0,0) size 21x18
+                      text run at (0,0) width 21: "foo"
+                RenderBlock (anonymous) at (2,36) size 61x0
+              RenderTableCell {TD} at (69,2) size 44x38 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+                RenderBlock {UL} at (2,2) size 40x18
+                  RenderListItem {LI} at (40,0) size 0x18
+                    RenderListMarker at (-17,0) size 7x18: bullet
+                    RenderBR {BR} at (0,0) size 0x18
+                RenderBlock (anonymous) at (2,36) size 40x0
+            RenderTableRow {TR} at (0,42) size 115x38
+              RenderTableCell {TD} at (2,42) size 65x38 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+                RenderBlock {UL} at (2,2) size 61x18
+                  RenderListItem {LI} at (40,0) size 21x18
+                    RenderListMarker at (-17,0) size 7x18: bullet
+                    RenderBR {BR} at (0,0) size 0x18
+                RenderBlock (anonymous) at (2,36) size 61x0
+              RenderTableCell {TD} at (69,42) size 44x38 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+                RenderBlock {UL} at (2,2) size 40x18
+                  RenderListItem {LI} at (40,0) size 0x18
+                    RenderListMarker at (-17,0) size 7x18: bullet
+                    RenderBR {BR} at (0,0) size 0x18
+                RenderBlock (anonymous) at (2,36) size 40x0
+selection start: position 0 of child 0 {#text} of child 0 {LI} of child 0 {UL} 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
+selection end:   position 0 of child 0 {LI} of child 0 {UL} of child 1 {TD} of child 1 {TR} of child 0 {TBODY} of child 0 {TABLE} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
index 961b65bdc632daf461f2b9ce535c15396a1d1fa6..657e71f11eb5756298862bc83a4000e6f139d094 100644 (file)
@@ -1,3 +1,16 @@
+2007-10-12  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Harrison.
+        
+        <rdar://problem/5483370> GoogleDocs: Deleting cell text in a table row also removes any empty rows beneath the row being edited
+        <rdar://problem/5482524> GoogleDocs: A hang occurs when applying list to selected table
+        
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows):
+        * editing/InsertListCommand.cpp:
+        (WebCore::InsertListCommand::modifyRange):
+        (WebCore::InsertListCommand::doApply):
+
 2007-10-12  Darin Adler  <darin@apple.com>
 
         - fix another float/int conversion
index c2e1c708b8cdf08fb06af861b075663a9f49d7d0..10bc6824f6960b97692959ff75120f529e680f3a 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index faf8562e3802bdce875c9071ece46142e7e59a73..188f6bf8cbf9f3a7e954546ebfd2e2d5d8b7c6b6 100644 (file)
@@ -571,7 +571,8 @@ void DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows()
         }
     }
     
-    if (m_startTableRow && m_startTableRow->inDocument()) {
+    // Remove empty rows after the start row.
+    if (m_startTableRow && m_startTableRow->inDocument() && m_startTableRow != m_endTableRow) {
         // Do not remove the row that contained the start of the selection,
         // since it now contains the selection.
         Node* row = m_startTableRow->nextSibling();
index 093b637fa1fd12e8f583ac94b1eeccad1d7de809..03fd6349ab29380f7451b3f4e8aa957f7b8a7422 100644 (file)
@@ -68,10 +68,12 @@ bool InsertListCommand::modifyRange()
     // If the end of the selection to modify is just after a table, and
     // if the start of the selection is inside that table, the last paragraph
     // that we'll want modify is the last one inside the table, not the table itself.
-    // Adjust startOfLastParagraph here to avoid infinite recursion.
+    // Adjust startOfLastParagraph and visibleEnd here to avoid infinite recursion.
     if (Node* table = isFirstPositionAfterTable(visibleEnd))
-        if (visibleStart.deepEquivalent().node()->isDescendantOf(table))
-            startOfLastParagraph = startOfParagraph(visibleEnd.previous(true));
+        if (visibleStart.deepEquivalent().node()->isDescendantOf(table)) {
+            visibleEnd = visibleEnd.previous(true);
+            startOfLastParagraph = startOfParagraph(visibleEnd);
+        }
         
     if (startOfParagraph(visibleStart) == startOfLastParagraph)
         return false;
@@ -191,9 +193,12 @@ void InsertListCommand::doApply()
         Node* previousList = outermostEnclosingList(previousPosition.deepEquivalent().node());
         Node* nextList = outermostEnclosingList(nextPosition.deepEquivalent().node());
         Node* startNode = start.deepEquivalent().node();
-        if (previousList && (!previousList->hasTagName(listTag) || startNode->isDescendantOf(previousList)))
+        Node* previousCell = enclosingTableCell(previousPosition.deepEquivalent());
+        Node* nextCell = enclosingTableCell(nextPosition.deepEquivalent());
+        Node* currentCell = enclosingTableCell(start.deepEquivalent());
+        if (previousList && (!previousList->hasTagName(listTag) || startNode->isDescendantOf(previousList) || previousCell != currentCell))
             previousList = 0;
-        if (nextList && (!nextList->hasTagName(listTag) || startNode->isDescendantOf(nextList)))
+        if (nextList && (!nextList->hasTagName(listTag) || startNode->isDescendantOf(nextList) || nextCell != currentCell))
             nextList = 0;
         // Place list item into adjoining lists.
         if (previousList)