WebCore:
authorddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 05:35:21 +0000 (05:35 +0000)
committerddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 05:35:21 +0000 (05:35 +0000)
        Reviewed by Justin.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9505
          moveParagraphContentsToNewBlockIfNecessary creates a new block outside the current position

        * editing/CompositeEditCommand.cpp:
        Added sanity checking to prevent modifying nodes outside of
        where we should be
        (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):

LayoutTests:

        Reviewed by Justin.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9505
         moveParagraphContentsToNewBlockIfNecessary creates a new block outside the current position

        * editing/pasteboard/paste-table-002.html: Added.
        * editing/pasteboard/paste-table-002-expected.checksum: Added.
        * editing/pasteboard/paste-table-002-expected.png: Added.
        * editing/pasteboard/paste-table-002-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/paste-table-002-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-table-002-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-table-002-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-table-002.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/CompositeEditCommand.cpp

index 6b6c274084277903e4025d622fa9af2bd0f9b9b0..6b7c05d200b13758b77a0e281e41e9ea80cd48a1 100644 (file)
@@ -1,3 +1,15 @@
+2006-06-29  Graham Dennis  <Graham.Dennis@gmail.com>
+
+        Reviewed by Justin.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9505
+         moveParagraphContentsToNewBlockIfNecessary creates a new block outside the current position
+
+        * editing/pasteboard/paste-table-002.html: Added.
+        * editing/pasteboard/paste-table-002-expected.checksum: Added.
+        * editing/pasteboard/paste-table-002-expected.png: Added.
+        * editing/pasteboard/paste-table-002-expected.txt: Added.
+
 2006-06-29  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/editing/pasteboard/paste-table-002-expected.checksum b/LayoutTests/editing/pasteboard/paste-table-002-expected.checksum
new file mode 100644 (file)
index 0000000..821e7e6
--- /dev/null
@@ -0,0 +1 @@
+92b222216c0ad7cb02568b948edd8d0b
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/paste-table-002-expected.png b/LayoutTests/editing/pasteboard/paste-table-002-expected.png
new file mode 100644 (file)
index 0000000..2f420eb
Binary files /dev/null and b/LayoutTests/editing/pasteboard/paste-table-002-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/paste-table-002-expected.txt b/LayoutTests/editing/pasteboard/paste-table-002-expected.txt
new file mode 100644 (file)
index 0000000..38c174e
--- /dev/null
@@ -0,0 +1,49 @@
+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:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > DIV > BODY > HTML > #document to 6 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 5 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > DIV > 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 784x576
+      RenderBlock (anonymous) at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 770x36
+          text run at (0,0) width 770: "Problem: copy/pasting some HTML including tables can give rise to a <div> element as the first child of the table element."
+          text run at (0,18) width 93: "This is invalid."
+      RenderBlock {DIV} at (0,36) size 784x84
+        RenderBlock {DIV} at (0,0) size 784x84 [border: (2px solid #FF0000)]
+          RenderBlock {DIV} at (2,2) size 780x80
+            RenderBlock (anonymous) at (0,0) size 780x28
+              RenderText {#text} at (0,0) size 65x28
+                text run at (0,0) width 65: "abcdef"
+            RenderBlock {DIV} at (0,28) size 780x52
+              RenderTable {TABLE} at (0,0) size 51x24
+                RenderTableSection {TBODY} at (0,0) size 51x24
+                  RenderTableRow {TR} at (0,2) size 51x20
+                    RenderTableCell {TD} at (2,2) size 23x20 [r=0 c=0 rs=1 cs=1]
+                      RenderText {#text} at (1,1) size 21x18
+                        text run at (1,1) width 21: "foo"
+                    RenderTableCell {TD} at (27,2) size 22x20 [r=0 c=1 rs=1 cs=1]
+                      RenderText {#text} at (1,1) size 20x18
+                        text run at (1,1) width 20: "bar"
+              RenderBlock (anonymous) at (0,24) size 780x28
+                RenderText {#text} at (365,0) size 50x28
+                  text run at (365,0) width 50: "ghijk"
+            RenderBlock (anonymous) at (0,80) size 780x0
+      RenderBlock {OL} at (0,136) size 784x54
+        RenderListItem {LI} at (40,0) size 744x54
+          RenderListMarker at (-20,0) size 16x18
+          RenderText {#text} at (0,0) size 731x54
+            text run at (0,0) width 731: "<div id=\"test\" class=\"editing\"> <div>abcdef<div style=\"text-align: center;\"><table style=\"border-spacing: 2px 2px;"
+            text run at (0,18) width 729: "\"><tbody style=\"border-spacing: 2px 2px; \"><tr style=\"border-spacing: 2px 2px; \"><td style=\"border-spacing: 2px"
+            text run at (0,36) width 712: "2px; \">foo</td><td style=\"border-spacing: 2px 2px; \">bar</td></tr></tbody></table>ghijk</div> </div> </div>"
+caret: position 5 of child 1 {#text} of child 1 {DIV} of child 1 {DIV} of child 1 {DIV} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/paste-table-002.html b/LayoutTests/editing/pasteboard/paste-table-002.html
new file mode 100644 (file)
index 0000000..0ab865a
--- /dev/null
@@ -0,0 +1,63 @@
+<html> 
+<head>
+
+<style>
+.editing { 
+    border: 2px solid red; 
+    font-size: 24px; 
+}
+.explanation { 
+    border: 2px solid blue; 
+    padding: 12px; 
+    font-size: 24px; 
+    margin-bottom: 24px;
+}
+.scenario { margin-bottom: 16px;}
+.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
+.expected-results:first-line { font-weight: bold }
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+function log(message) {
+    var console = document.getElementById("console");
+    var li = document.createElement("li");
+    var text = document.createTextNode(message);
+    li.appendChild(text);
+    console.appendChild(li);
+}
+
+function editingTest() {
+    execSelectAllCommand();
+    copyCommand();
+    execDeleteCommand();
+    pasteCommand();
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body>
+Problem: copy/pasting some HTML including tables can give rise to a &lt;div&gt; element as the first child of the table element. This is invalid.
+<div contenteditable id="root">
+<div id="test" class="editing">
+<div>
+abcdef
+<div style="text-align: center" >
+<table><tr><td>foo</td><td>bar</td></tr></table>
+ghijk
+</div>
+</div>
+</div>
+</div>
+
+<ol id="console" />
+
+<script>
+runEditingTest();
+log(root.innerHTML);
+</script>
+
+</body>
+</html>
index 0d885b487507b7dd83d3a3e11412fbc88802d396..8aa51d31857eb00d54e444c78325180551cf37b5 100644 (file)
@@ -1,3 +1,15 @@
+2006-06-29  Graham Dennis  <Graham.Dennis@gmail.com>
+
+        Reviewed by Justin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9505
+          moveParagraphContentsToNewBlockIfNecessary creates a new block outside the current position
+
+        * editing/CompositeEditCommand.cpp:
+        Added sanity checking to prevent modifying nodes outside of 
+        where we should be
+        (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
+
 2006-06-29  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Levi.
@@ -27,7 +39,6 @@
         * icon/SiteIcon.cpp:
         (SiteIcon::getImage):
 
-
 2006-06-29  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Darin.
         (WebCore::SQLStatement::getColumnBlobAsVector):
         (WebCore::SQLStatement::getColumnBlob):
 
->>>>>>> .r15079
 2006-06-27  Ada Chan <adachan@apple.com>
 
         Reviewed by sfalken.
         (WebCore::xmlDocPtrFromNode):
         Pass DocLoader to xmlDocPtrForString
         
->>>>>>> .r15049
 2006-06-21  David Hyatt  <hyatt@apple.com>
 
         Back out -webkit-overlay and just rename it back to overlay.
index ebe0e25bfa3d5fb65c7f09e09d1ecb9afeaf561d..d741bfec5167d6812565658ba219414cbe20a066 100644 (file)
@@ -552,7 +552,12 @@ void CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(const Posi
     
     Position paragraphStart = visibleParagraphStart.deepEquivalent().upstream();
     Position end = visibleEnd.deepEquivalent().upstream();
-    
+
+    // Perform some sanity checks. If there are no VisiblePositions in
+    // the same block as pos then paragraphStart will be outside the paragraph
+    if (Range::compareBoundaryPoints(pos, paragraphStart) < 0)
+        return;
+
     // Perform some checks to see if we need to perform work in this function.
     if (paragraphStart.node()->isBlockFlow()) {
         if (end.node()->isBlockFlow()) {