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

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

Issue 2405223002: Ensure valid input for CompositeEditCommand::moveParagraph[s] (Closed)
Patch Set: Remove the dirty hacks 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 | third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
index db204e2e52d03eb4aa4c0c79708a9c1b269b41f3..870c5e892b1d1dd6dc56600d3dd9d7f2ece59f8c 100644
--- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -1482,7 +1482,6 @@ void CompositeEditCommand::moveParagraphWithClones(
}
}
-// TODO(xiaochengh): Ensure valid VisiblePositions are passed to this function.
void CompositeEditCommand::moveParagraph(
const VisiblePosition& startOfParagraphToMove,
const VisiblePosition& endOfParagraphToMove,
@@ -1491,18 +1490,14 @@ void CompositeEditCommand::moveParagraph(
ShouldPreserveSelection shouldPreserveSelection,
ShouldPreserveStyle shouldPreserveStyle,
Node* constrainingAncestor) {
- DCHECK(isStartOfParagraphDeprecated(startOfParagraphToMove))
- << startOfParagraphToMove;
- DCHECK(isEndOfParagraphDeprecated(endOfParagraphToMove))
- << endOfParagraphToMove;
+ DCHECK(!document().needsLayoutTreeUpdate());
+ DCHECK(isStartOfParagraph(startOfParagraphToMove)) << startOfParagraphToMove;
+ DCHECK(isEndOfParagraph(endOfParagraphToMove)) << endOfParagraphToMove;
moveParagraphs(startOfParagraphToMove, endOfParagraphToMove, destination,
editingState, shouldPreserveSelection, shouldPreserveStyle,
constrainingAncestor);
}
-// TODO(xiaochengh): Ensure valid VisiblePositions are passed to this function,
-// and do proper recalculation after mutations so that they are still valid when
-// being used.
void CompositeEditCommand::moveParagraphs(
const VisiblePosition& startOfParagraphToMove,
const VisiblePosition& endOfParagraphToMove,
@@ -1511,12 +1506,11 @@ void CompositeEditCommand::moveParagraphs(
ShouldPreserveSelection shouldPreserveSelection,
ShouldPreserveStyle shouldPreserveStyle,
Node* constrainingAncestor) {
+ DCHECK(!document().needsLayoutTreeUpdate());
if (startOfParagraphToMove.deepEquivalent() == destination.deepEquivalent() ||
startOfParagraphToMove.isNull())
return;
- document().updateStyleAndLayoutIgnorePendingStylesheets();
-
int startIndex = -1;
int endIndex = -1;
int destinationIndex = -1;
@@ -1552,11 +1546,10 @@ void CompositeEditCommand::moveParagraphs(
}
RelocatablePosition beforeParagraphPosition(
- previousPositionOfDeprecated(startOfParagraphToMove,
- CannotCrossEditingBoundary)
+ previousPositionOf(startOfParagraphToMove, CannotCrossEditingBoundary)
.deepEquivalent());
RelocatablePosition afterParagraphPosition(
- nextPositionOfDeprecated(endOfParagraphToMove, CannotCrossEditingBoundary)
+ nextPositionOf(endOfParagraphToMove, CannotCrossEditingBoundary)
.deepEquivalent());
// We upstream() the end and downstream() the start so that we don't include
@@ -1651,8 +1644,8 @@ void CompositeEditCommand::moveParagraphs(
Position::firstPositionInNode(document().documentElement()),
destination.toParentAnchoredPosition(), true);
- VisibleSelection destinationSelection =
- createVisibleSelectionDeprecated(destination, originalIsDirectional);
+ VisibleSelection destinationSelection = createVisibleSelection(
+ destination.toPositionWithAffinity(), originalIsDirectional);
if (endingSelection().isNone()) {
// We abort executing command since |destination| becomes invisible.
editingState->abort();
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698