Index: Source/core/editing/InsertParagraphSeparatorCommand.cpp |
diff --git a/Source/core/editing/InsertParagraphSeparatorCommand.cpp b/Source/core/editing/InsertParagraphSeparatorCommand.cpp |
index cbfb99ffe943974088824d9f53bf77d5a566950b..3eca03506ca01381ae088077d269544c3a21db1a 100644 |
--- a/Source/core/editing/InsertParagraphSeparatorCommand.cpp |
+++ b/Source/core/editing/InsertParagraphSeparatorCommand.cpp |
@@ -316,6 +316,15 @@ void InsertParagraphSeparatorCommand::doApply() |
// before we walk the DOM tree. |
insertionPosition = positionOutsideTabSpan(VisiblePosition(insertionPosition).deepEquivalent()); |
+ // If the returned position lies either at the end or at the start of an element that is ignored by editing |
+ // we should move to its upstream or downstream position. |
+ if (editingIgnoresContent(insertionPosition.deprecatedNode())) { |
+ if (insertionPosition.atLastEditingPositionForNode()) |
+ insertionPosition = insertionPosition.downstream(); |
+ else if (insertionPosition.atFirstEditingPositionForNode()) |
+ insertionPosition = insertionPosition.upstream(); |
+ } |
+ |
// Make sure we do not cause a rendered space to become unrendered. |
// FIXME: We need the affinity for pos, but pos.downstream() does not give it |
Position leadingWhitespace = insertionPosition.leadingWhitespacePosition(VP_DEFAULT_AFFINITY); |