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

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

Issue 2397963002: Reflow comments in //third_party/WebKit/Source/core/editing/commands (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
Index: third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp
index bec26b9d2e209f76ee0e37c6be482d3a6d74abdc..d3d6cc7799199cc289fa1e818ebb631d87ce82f3 100644
--- a/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp
@@ -77,16 +77,16 @@ void InsertTextCommand::setEndingSelectionWithoutValidation(
const Position& startPosition,
const Position& endPosition) {
// We could have inserted a part of composed character sequence,
- // so we are basically treating ending selection as a range to avoid validation.
- // <http://bugs.webkit.org/show_bug.cgi?id=15781>
+ // so we are basically treating ending selection as a range to avoid
+ // validation. <http://bugs.webkit.org/show_bug.cgi?id=15781>
VisibleSelection forcedEndingSelection;
forcedEndingSelection.setWithoutValidation(startPosition, endPosition);
forcedEndingSelection.setIsDirectional(endingSelection().isDirectional());
setEndingSelection(forcedEndingSelection);
}
-// This avoids the expense of a full fledged delete operation, and avoids a layout that typically results
-// from text removal.
+// This avoids the expense of a full fledged delete operation, and avoids a
+// layout that typically results from text removal.
bool InsertTextCommand::performTrivialReplace(const String& text,
bool selectInsertedText) {
if (!endingSelection().isRange())
@@ -153,9 +153,11 @@ void InsertTextCommand::doApply(EditingState* editingState) {
deleteSelection(editingState, false, true, false, false);
if (editingState->isAborted())
return;
- // deleteSelection eventually makes a new endingSelection out of a Position. If that Position doesn't have
- // a layoutObject (e.g. it is on a <frameset> in the DOM), the VisibleSelection cannot be canonicalized to
- // anything other than NoSelection. The rest of this function requires a real endingSelection, so bail out.
+ // deleteSelection eventually makes a new endingSelection out of a Position.
+ // If that Position doesn't have a layoutObject (e.g. it is on a <frameset>
+ // in the DOM), the VisibleSelection cannot be canonicalized to anything
+ // other than NoSelection. The rest of this function requires a real
+ // endingSelection, so bail out.
if (endingSelection().isNone())
return;
if (endOfSelectionWasAtStartOfBlock) {
@@ -171,26 +173,31 @@ void InsertTextCommand::doApply(EditingState* editingState) {
Position startPosition(endingSelection().start());
Position placeholder;
- // We want to remove preserved newlines and brs that will collapse (and thus become unnecessary) when content
- // is inserted just before them.
- // FIXME: We shouldn't really have to do this, but removing placeholders is a workaround for 9661.
- // If the caret is just before a placeholder, downstream will normalize the caret to it.
+ // We want to remove preserved newlines and brs that will collapse (and thus
+ // become unnecessary) when content is inserted just before them.
+ // FIXME: We shouldn't really have to do this, but removing placeholders is a
+ // workaround for 9661.
+ // If the caret is just before a placeholder, downstream will normalize the
+ // caret to it.
Position downstream(mostForwardCaretPosition(startPosition));
if (lineBreakExistsAtPosition(downstream)) {
// FIXME: This doesn't handle placeholders at the end of anonymous blocks.
VisiblePosition caret = createVisiblePositionDeprecated(startPosition);
if (isEndOfBlock(caret) && isStartOfParagraphDeprecated(caret))
placeholder = downstream;
- // Don't remove the placeholder yet, otherwise the block we're inserting into would collapse before
- // we get a chance to insert into it. We check for a placeholder now, though, because doing so requires
- // the creation of a VisiblePosition, and if we did that post-insertion it would force a layout.
+ // Don't remove the placeholder yet, otherwise the block we're inserting
+ // into would collapse before we get a chance to insert into it. We check
+ // for a placeholder now, though, because doing so requires the creation of
+ // a VisiblePosition, and if we did that post-insertion it would force a
+ // layout.
}
// Insert the character at the leftmost candidate.
startPosition = mostBackwardCaretPosition(startPosition);
- // It is possible for the node that contains startPosition to contain only unrendered whitespace,
- // and so deleteInsignificantText could remove it. Save the position before the node in case that happens.
+ // It is possible for the node that contains startPosition to contain only
+ // unrendered whitespace, and so deleteInsignificantText could remove it.
+ // Save the position before the node in case that happens.
DCHECK(startPosition.computeContainerNode()) << startPosition;
Position positionBeforeStartNode(
Position::inParentBeforeNode(*startPosition.computeContainerNode()));
@@ -233,9 +240,11 @@ void InsertTextCommand::doApply(EditingState* editingState) {
endPosition = Position(textNode, offset + m_text.length());
if (m_rebalanceType == RebalanceLeadingAndTrailingWhitespaces) {
- // The insertion may require adjusting adjacent whitespace, if it is present.
+ // The insertion may require adjusting adjacent whitespace, if it is
+ // present.
rebalanceWhitespaceAt(endPosition);
- // Rebalancing on both sides isn't necessary if we've inserted only spaces.
+ // Rebalancing on both sides isn't necessary if we've inserted only
+ // spaces.
if (!shouldRebalanceLeadingWhitespaceFor(m_text))
rebalanceWhitespaceAt(startPosition);
} else {

Powered by Google App Engine
This is Rietveld 408576698