LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2006 01:01:13 +0000 (01:01 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2006 01:01:13 +0000 (01:01 +0000)
        Reviewed by john

        <rdar://problem/4854869>
        Inserting a new line in a contenteditable=true SPAN whose parent is a DIV asserts

        * editing/deleting/delete-mixed-editable-content-001-expected.txt:
        * editing/inserting/editable-inline-element-expected.checksum: Added.
        * editing/inserting/editable-inline-element-expected.txt: Added.
        * editing/inserting/editable-inline-element-expected.png: Added.
        * editing/inserting/editable-inline-element.html: Added.

WebCore:

        Reviewed by john

        <rdar://problem/4854869>
        Inserting a new line in a contenteditable=true SPAN whose parent is a DIV asserts

        * editing/htmlediting.cpp:
        (WebCore::enclosingBlock): Use enclosingNodeWithType to prevent escape
        from editable content.
        * editing/markup.cpp:
        (WebCore::createMarkup): A null commonAncestorBlock will happen
        if commonAncestor is inside an inline editable root that doesn't
        contain any blocks.  Removed an early return for this case: the
        code below the early return can and must handle it.

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

LayoutTests/ChangeLog
LayoutTests/editing/deleting/delete-mixed-editable-content-001-expected.txt
LayoutTests/editing/inserting/editable-inline-element-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/editable-inline-element-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/editable-inline-element-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/editable-inline-element.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/htmlediting.cpp
WebCore/editing/markup.cpp
WebCore/editing/visible_units.cpp

index ab1878f3bc04605f786a14fc6b9864922329579b..b1da667ddc5c6e541b3a1bf03b397969991d8049 100644 (file)
@@ -1,3 +1,16 @@
+2006-12-06  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+        
+        <rdar://problem/4854869>
+        Inserting a new line in a contenteditable=true SPAN whose parent is a DIV asserts
+
+        * editing/deleting/delete-mixed-editable-content-001-expected.txt:
+        * editing/inserting/editable-inline-element-expected.checksum: Added.
+        * editing/inserting/editable-inline-element-expected.txt: Added.
+        * editing/inserting/editable-inline-element-expected.png: Added.
+        * editing/inserting/editable-inline-element.html: Added.
+
 2006-12-06  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
index b975da823e33a4b4f667fadafbd422dd1762a3ca..f9be92c5c769166db6a0e3d067ae63404a1bfe44 100644 (file)
@@ -1,7 +1,7 @@
 EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of SPAN > SPAN > DIV > BODY > HTML > #document to 1 of SPAN > SPAN > DIV > BODY > HTML > #document
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of SPAN > SPAN > DIV > BODY > HTML > #document to 0 of SPAN > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > SPAN > DIV > BODY > HTML > #document to 5 of #text > SPAN > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > SPAN > SPAN > DIV > BODY > HTML > #document to 0 of #text > SPAN > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > SPAN > DIV > BODY > HTML > #document to 5 of #text > SPAN > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > SPAN > SPAN > DIV > BODY > HTML > #document to 5 of #text > SPAN > SPAN > DIV > BODY > HTML > #document
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
diff --git a/LayoutTests/editing/inserting/editable-inline-element-expected.checksum b/LayoutTests/editing/inserting/editable-inline-element-expected.checksum
new file mode 100644 (file)
index 0000000..8f08e1d
--- /dev/null
@@ -0,0 +1 @@
+343a501a0a187e3c15ed65ca51d95c32
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/editable-inline-element-expected.png b/LayoutTests/editing/inserting/editable-inline-element-expected.png
new file mode 100644 (file)
index 0000000..32e07bc
Binary files /dev/null and b/LayoutTests/editing/inserting/editable-inline-element-expected.png differ
diff --git a/LayoutTests/editing/inserting/editable-inline-element-expected.txt b/LayoutTests/editing/inserting/editable-inline-element-expected.txt
new file mode 100644 (file)
index 0000000..845245c
--- /dev/null
@@ -0,0 +1,14 @@
+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 371x18
+          text run at (0,0) width 371: "This tests InsertParagraph inside an editable inline element."
+      RenderBlock {DIV} at (0,34) size 784x38 [border: (1px solid #FF0000)]
+        RenderInline {SPAN} at (0,0) size 21x36
+          RenderBR {BR} at (1,1) size 0x18
+          RenderText {#text} at (1,19) size 21x18
+            text run at (1,19) width 21: "foo"
+caret: position 0 of child 1 {#text} of child 0 {SPAN} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/editable-inline-element.html b/LayoutTests/editing/inserting/editable-inline-element.html
new file mode 100644 (file)
index 0000000..1a50aba
--- /dev/null
@@ -0,0 +1,10 @@
+<p>This tests InsertParagraph inside an editable inline element.</p>
+<div style="border: 1px solid red;"><span id="span" contenteditable="true">foo</span></div>
+
+<script>
+var sel = window.getSelection();
+var span = document.getElementById("span");
+
+sel.setPosition(span, 0);
+document.execCommand("InsertParagraph");
+</script>
\ No newline at end of file
index c9010b3019ae6ed552b87c39e79761b7a1c739f0..7f4fcecc37232ce82abd2eff74daed03f4d233fd 100644 (file)
@@ -1,3 +1,19 @@
+2006-12-06  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+        
+        <rdar://problem/4854869>
+        Inserting a new line in a contenteditable=true SPAN whose parent is a DIV asserts
+
+        * editing/htmlediting.cpp:
+        (WebCore::enclosingBlock): Use enclosingNodeWithType to prevent escape
+        from editable content.
+        * editing/markup.cpp:
+        (WebCore::createMarkup): A null commonAncestorBlock will happen
+        if commonAncestor is inside an inline editable root that doesn't
+        contain any blocks.  Removed an early return for this case: the 
+        code below the early return can and must handle it.
+
 2006-12-06  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Mark Rowe.
index c112a9c390ea3ae9b47b819c1ae49cb4404f9cc7..16568206561ef775ba27041fd353570b99fd3d79 100644 (file)
@@ -288,14 +288,7 @@ Node* enclosingBlock(Node* node)
     if (isBlock(node))
         return node;
         
-    while (1) {
-        node = node->parentNode();
-        if (!node)
-            break;
-        if (isBlock(node))
-            return node;
-    }
-    return 0;
+    return enclosingNodeOfType(node, &isBlock);
 }
 
 Position rangeCompliantEquivalent(const Position& pos)
index b2ad84b8a1b96f46f98c195f76feca32e1135256..b9909eacdb2bc01a0dcc5a39ed834b520c2223b6 100644 (file)
@@ -365,7 +365,7 @@ DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotat
     Node *commonAncestorBlock = 0;
     if (commonAncestor) {
         commonAncestorBlock = enclosingBlock(commonAncestor);
-        if (commonAncestorBlock->hasTagName(tbodyTag)) {
+        if (commonAncestorBlock && commonAncestorBlock->hasTagName(tbodyTag)) {
             Node* table = commonAncestorBlock->parentNode();
             while (table && !table->hasTagName(tableTag))
                 table = table->parentNode();
@@ -374,11 +374,6 @@ DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotat
         }
     }
 
-    if (!commonAncestorBlock) {
-        doc->frame()->editor()->deleteButtonController()->enable();
-        return "";
-    }
-
     DeprecatedStringList markups;
     Node *pastEnd = range->pastEndNode();
     Node *lastClosed = 0;
index 15440fd2b02aac00844ff90e21e6c71996626ac8..a37c9f9e53a2e2e965399654a2e514d9fb22450b 100644 (file)
@@ -318,7 +318,7 @@ VisiblePosition startOfLine(const VisiblePosition &c)
     return VisiblePosition(startNode, startOffset, DOWNSTREAM);
 }
 
-VisiblePosition endOfLine(const VisiblePosition &c)
+VisiblePosition endOfLine(const VisiblePositionc)
 {
     RootInlineBox *rootBox = rootBoxForLine(c);
     if (!rootBox)