Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp

Issue 2368903002: Ensure valid VisiblePosition input for character{Before,After} (Closed)
Patch Set: Add DCHECK for the correctness of postponing Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
index f21d21a182bb057c7149e13211f738823bdbaf0f..5d3139d59d7c5f5736ce08cf69cedf60c8e4da36 100644
--- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
@@ -1469,9 +1469,7 @@ static bool isCharacterSmartReplaceExemptConsideringNonBreakingSpace(UChar32 cha
void ReplaceSelectionCommand::addSpacesForSmartReplace(EditingState* editingState)
{
- VisiblePosition startOfInsertedContent = positionAtStartOfInsertedContent();
VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent();
-
Position endUpstream = mostBackwardCaretPosition(endOfInsertedContent.deepEquivalent());
Node* endNode = endUpstream.computeNodeBeforePosition();
int endOffset = endNode && endNode->isTextNode() ? toText(endNode)->length() : 0;
@@ -1492,12 +1490,16 @@ void ReplaceSelectionCommand::addSpacesForSmartReplace(EditingState* editingStat
insertNodeAfter(node, endNode, editingState);
if (editingState->isAborted())
return;
+ // Make sure that |updateNodesInserted| does not change
+ // |m_startOfInsertedContent|.
+ DCHECK(m_startOfInsertedContent.isNotNull());
updateNodesInserted(node);
}
}
document().updateStyleAndLayout();
+ VisiblePosition startOfInsertedContent = positionAtStartOfInsertedContent();
Position startDownstream = mostForwardCaretPosition(startOfInsertedContent.deepEquivalent());
Node* startNode = startDownstream.computeNodeAfterPosition();
unsigned startOffset = 0;
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698