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

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

Issue 2412443002: Recalculate |visiblePos| for InsertParagraphSeparatorCommand::doApply() after mutations (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | 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/InsertParagraphSeparatorCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp
index c1497d83200b2a6ab41cb9b3c4f099966a86c287..0afb7544e81428624bf1378cfe1aa7e6dfe5b905 100644
--- a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp
@@ -253,10 +253,6 @@ void InsertParagraphSeparatorCommand::doApply(EditingState* editingState) {
blockToInsert = startBlock->cloneElementWithoutChildren();
}
- // TODO(xiaochengh): Recalculate visiblePos properly after mutations, so that
- // visiblePos is always valid when used. Straightforward recanonicalization
- // by deepEquivalent() leads to failure of
- // editing/inserting/insert_paragraph_separator.html.
VisiblePosition visiblePos =
createVisiblePosition(insertionPosition, affinity);
bool isFirstInBlock = isStartOfBlock(visiblePos);
@@ -418,6 +414,7 @@ void InsertParagraphSeparatorCommand::doApply(EditingState* editingState) {
document().updateStyleAndLayoutIgnorePendingStylesheets();
insertionPosition = Position::inParentAfterNode(*br);
+ visiblePos = createVisiblePosition(insertionPosition);
// If the insertion point is a break element, there is nothing else
// we need to do.
if (visiblePos.deepEquivalent().anchorNode()->layoutObject()->isBR()) {
@@ -482,7 +479,6 @@ void InsertParagraphSeparatorCommand::doApply(EditingState* editingState) {
positionAfterSplit = Position::firstPositionInNode(textNode);
insertionPosition = Position(textNode->previousSibling(), textOffset);
- visiblePos = createVisiblePosition(insertionPosition);
}
}
@@ -506,12 +502,13 @@ void InsertParagraphSeparatorCommand::doApply(EditingState* editingState) {
return;
document().updateStyleAndLayoutIgnorePendingStylesheets();
+ visiblePos = createVisiblePosition(insertionPosition);
// If the paragraph separator was inserted at the end of a paragraph, an empty
// line must be created. All of the nodes, starting at visiblePos, are about
// to be added to the new paragraph element. If the first node to be inserted
// won't be one that will hold an empty line open, add a br.
- if (isEndOfParagraphDeprecated(visiblePos) &&
+ if (isEndOfParagraph(visiblePos) &&
!lineBreakExistsAtVisiblePosition(visiblePos)) {
appendNode(HTMLBRElement::create(document()), blockToInsert, editingState);
if (editingState->isAborted())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698