Index: Source/WebCore/editing/ReplaceSelectionCommand.cpp |
=================================================================== |
--- Source/WebCore/editing/ReplaceSelectionCommand.cpp (revision 118026) |
+++ Source/WebCore/editing/ReplaceSelectionCommand.cpp (working copy) |
@@ -1299,7 +1299,7 @@ |
if (nodeToSplitToAvoidPastingIntoInlineNodesWithStyle(endingSelection().start())) |
return false; |
- Node* nodeAfterInsertionPos = endingSelection().end().downstream().anchorNode(); |
+ RefPtr<Node> nodeAfterInsertionPos = endingSelection().end().downstream().anchorNode(); |
Text* textNode = toText(fragment.firstChild()); |
// Our fragment creation code handles tabs, spaces, and newlines, so we don't have to worry about those here. |
@@ -1308,8 +1308,9 @@ |
if (end.isNull()) |
return false; |
- if (nodeAfterInsertionPos && nodeAfterInsertionPos->hasTagName(brTag) && shouldRemoveEndBR(nodeAfterInsertionPos, positionBeforeNode(nodeAfterInsertionPos))) |
- removeNodeAndPruneAncestors(nodeAfterInsertionPos); |
+ if (nodeAfterInsertionPos && nodeAfterInsertionPos->parentNode() && nodeAfterInsertionPos->hasTagName(brTag) |
+ && shouldRemoveEndBR(nodeAfterInsertionPos.get(), positionBeforeNode(nodeAfterInsertionPos.get()))) |
+ removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); |
VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, end); |