WebCore:
authorharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Sep 2007 16:55:42 +0000 (16:55 +0000)
committerharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Sep 2007 16:55:42 +0000 (16:55 +0000)
        Reviewed by Maciej and John.

        <rdar://problem/5452675> CrashTracer: [USER] 10 crashes in Mail at com.apple.WebCore: WebCore::Node::nodeIndex const + 6

        * editing/InsertParagraphSeparatorCommand.cpp:
        (WebCore::InsertParagraphSeparatorCommand::doApply):
        Adjust pos to pos.downstream() after the refNode is calculated, but before the insertion. Doing it earlier
        undid the logic of positionAvoidingSpecialElementBoundary(). The downstream is still needed just to set the
        ending selection.

LayoutTests:

        Reviewed by Maciej and John.

        Testcase for:
        <rdar://problem/5452675> CrashTracer: [USER] 10 crashes in Mail at com.apple.WebCore: WebCore::Node::nodeIndex const + 6

        * editing/inserting/insert-paragraph-05.html: Added.
        * platform/mac/editing/inserting/insert-paragraph-05-expected.checksum: Added.
        * platform/mac/editing/inserting/insert-paragraph-05-expected.png: Added.
        * platform/mac/editing/inserting/insert-paragraph-05-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/inserting/insert-paragraph-05.html [new file with mode: 0644]
LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/InsertParagraphSeparatorCommand.cpp

index 9a211a396741c26ce092c174a03d61c0e24c7360..67ac136672d94d6bb6e4b2f79a69203fd8c6050a 100644 (file)
@@ -1,3 +1,15 @@
+2007-09-04  David Harrison  <harrison@apple.com>
+
+        Reviewed by Maciej and John.
+
+        Testcase for:
+        <rdar://problem/5452675> CrashTracer: [USER] 10 crashes in Mail at com.apple.WebCore: WebCore::Node::nodeIndex const + 6
+
+        * editing/inserting/insert-paragraph-05.html: Added.
+        * platform/mac/editing/inserting/insert-paragraph-05-expected.checksum: Added.
+        * platform/mac/editing/inserting/insert-paragraph-05-expected.png: Added.
+        * platform/mac/editing/inserting/insert-paragraph-05-expected.txt: Added.
+
 2007-09-04  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Maciej.
diff --git a/LayoutTests/editing/inserting/insert-paragraph-05.html b/LayoutTests/editing/inserting/insert-paragraph-05.html
new file mode 100644 (file)
index 0000000..c814a5c
--- /dev/null
@@ -0,0 +1,13 @@
+<script>
+if (window.layoutTestController)
+     layoutTestController.dumpEditingCallbacks();
+</script>
+<p>This tests inserting a paragraph separator before a special element at the start of an editable root.</p>
+<p>Visually, it should leave a blank line before the link, and the caret selection at the start of the link.</p>
+<p>Structurally, the empty paragraph element should go before the anchor element, rather than inside of it. See Radar #5452675.</p>
+<div contenteditable="true"><a id="anchor" href="http://www.apple.com">applesite</a></div>
+<script>
+var sel = window.getSelection();
+sel.setPosition(document.getElementById("anchor"), 0);
+document.execCommand("InsertParagraph");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.checksum b/LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.checksum
new file mode 100644 (file)
index 0000000..4ed9208
--- /dev/null
@@ -0,0 +1 @@
+ef98ce1d9b897938ce26a5acdd684a66
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.png b/LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.png
new file mode 100644 (file)
index 0000000..a76417f
Binary files /dev/null and b/LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.txt b/LayoutTests/platform/mac/editing/inserting/insert-paragraph-05-expected.txt
new file mode 100644 (file)
index 0000000..513bed3
--- /dev/null
@@ -0,0 +1,27 @@
+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: 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 601x18
+          text run at (0,0) width 601: "This tests inserting a paragraph separator before a special element at the start of an editable root."
+      RenderBlock {P} at (0,34) size 784x18
+        RenderText {#text} at (0,0) size 611x18
+          text run at (0,0) width 611: "Visually, it should leave a blank line before the link, and the caret selection at the start of the link."
+      RenderBlock {P} at (0,68) size 784x36
+        RenderText {#text} at (0,0) size 714x36
+          text run at (0,0) width 714: "Structurally, the empty paragraph element should go before the anchor element, rather than inside of it. See Radar"
+          text run at (0,18) width 68: "#5452675."
+      RenderBlock {DIV} at (0,120) size 784x36
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderBR {BR} at (0,0) size 0x18
+        RenderBlock (anonymous) at (0,18) size 784x18
+          RenderInline {A} at (0,0) size 55x18 [color=#0000EE]
+            RenderText {#text} at (0,0) size 55x18
+              text run at (0,0) width 55: "applesite"
+caret: position 0 of child 0 {#text} of child 1 {A} of child 6 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index cb6440d4216daa22eebcf7e62e967b4c8308e591..ebe440d2722cf3b0b0d63db0bc727cade5834ce0 100644 (file)
@@ -1,3 +1,15 @@
+2007-09-04  David Harrison  <harrison@apple.com>
+
+        Reviewed by Maciej and John.
+
+        <rdar://problem/5452675> CrashTracer: [USER] 10 crashes in Mail at com.apple.WebCore: WebCore::Node::nodeIndex const + 6
+
+        * editing/InsertParagraphSeparatorCommand.cpp:
+        (WebCore::InsertParagraphSeparatorCommand::doApply):
+        Adjust pos to pos.downstream() after the refNode is calculated, but before the insertion. Doing it earlier
+        undid the logic of positionAvoidingSpecialElementBoundary(). The downstream is still needed just to set the
+        ending selection.
+
 2007-09-04  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Maciej.
index d2e1643171f85f44833eae69fea2c8634caa82d5..bea04e796d768acac5afd905fab4aaf9afe10cd2 100644 (file)
@@ -168,7 +168,6 @@ void InsertParagraphSeparatorCommand::doApply()
     // Handle case when position is in the first visible position in its block, and
     // similar case where previous position is in another, presumeably nested, block.
     if (isFirstInBlock || !inSameBlock(visiblePos, visiblePos.previous())) {
-        pos = pos.downstream();
         Node *refNode;
         if (isFirstInBlock && !nestNewBlock)
             refNode = startBlock;
@@ -178,6 +177,9 @@ void InsertParagraphSeparatorCommand::doApply()
         } else
             refNode = pos.node();
 
+        // find ending selection position easily before inserting the paragraph
+        pos = pos.downstream();
+        
         insertNodeBefore(blockToInsert.get(), refNode);
         appendBlockPlaceholder(blockToInsert.get());
         setEndingSelection(Selection(Position(blockToInsert.get(), 0), DOWNSTREAM));