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
+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.
--- /dev/null
+<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
--- /dev/null
+ef98ce1d9b897938ce26a5acdd684a66
\ No newline at end of file
--- /dev/null
+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
+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.
// 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;
} 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));