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

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

Issue 2372903003: Ensure valid VisiblePosition input for inSameBlock (Closed)
Patch Set: 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/VisibleUnits.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/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 9a281d416d5701d41c0d8cf21cab4e82ea5dba56..a023267e5199eb3e6e6982346e18e34ad0045261 100644
--- a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp
@@ -201,7 +201,6 @@ void InsertParagraphSeparatorCommand::doApply(EditingState* editingState)
// move to another place.
listChild = toHTMLElement(enclosingAnchorElement(originalInsertionPosition));
}
- VisiblePosition visiblePos = createVisiblePositionDeprecated(insertionPosition, affinity);
calculateStyleBeforeInsertion(insertionPosition);
//---------------------------------------------------------------------
@@ -212,11 +211,8 @@ void InsertParagraphSeparatorCommand::doApply(EditingState* editingState)
//---------------------------------------------------------------------
// Prepare for more general cases.
- bool isFirstInBlock = isStartOfBlock(visiblePos);
- bool isLastInBlock = isEndOfBlock(visiblePos);
- bool nestNewBlock = false;
-
// Create block to be inserted.
+ bool nestNewBlock = false;
Element* blockToInsert = nullptr;
if (isRootEditableElement(*startBlock)) {
blockToInsert = createDefaultParagraphElement(document());
@@ -227,6 +223,10 @@ void InsertParagraphSeparatorCommand::doApply(EditingState* editingState)
blockToInsert = startBlock->cloneElementWithoutChildren();
}
+ VisiblePosition visiblePos = createVisiblePositionDeprecated(insertionPosition, affinity);
+ bool isFirstInBlock = isStartOfBlock(visiblePos);
+ bool isLastInBlock = isEndOfBlock(visiblePos);
+
//---------------------------------------------------------------------
// Handle case when position is in the last visible position in its block,
// including when the block is empty.
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698