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

Unified Diff: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.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/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 a71e3fec593d8be4dfac56b78d3ea32c56a51f1f..cccd76bdb4c065c70d8a1c58622a1df747e35f1e 100644
--- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -110,9 +110,11 @@ void EditCommandComposition::unapply() {
LocalFrame* frame = m_document->frame();
DCHECK(frame);
- // Changes to the document may have been made since the last editing operation that require a layout, as in <rdar://problem/5658603>.
- // Low level operations, like RemoveNodeCommand, don't require a layout because the high level operations that use them perform one
- // if one is necessary (like for the creation of VisiblePositions).
+ // Changes to the document may have been made since the last editing operation
+ // that require a layout, as in <rdar://problem/5658603>. Low level
+ // operations, like RemoveNodeCommand, don't require a layout because the high
+ // level operations that use them perform one if one is necessary (like for
+ // the creation of VisiblePositions).
m_document->updateStyleAndLayoutIgnorePendingStylesheets();
{
@@ -129,9 +131,11 @@ void EditCommandComposition::reapply() {
LocalFrame* frame = m_document->frame();
DCHECK(frame);
- // Changes to the document may have been made since the last editing operation that require a layout, as in <rdar://problem/5658603>.
- // Low level operations, like RemoveNodeCommand, don't require a layout because the high level operations that use them perform one
- // if one is necessary (like for the creation of VisiblePositions).
+ // Changes to the document may have been made since the last editing operation
+ // that require a layout, as in <rdar://problem/5658603>. Low level
+ // operations, like RemoveNodeCommand, don't require a layout because the high
+ // level operations that use them perform one if one is necessary (like for
+ // the creation of VisiblePositions).
m_document->updateStyleAndLayoutIgnorePendingStylesheets();
{
@@ -212,9 +216,11 @@ bool CompositeEditCommand::apply() {
}
ensureComposition();
- // Changes to the document may have been made since the last editing operation that require a layout, as in <rdar://problem/5658603>.
- // Low level operations, like RemoveNodeCommand, don't require a layout because the high level operations that use them perform one
- // if one is necessary (like for the creation of VisiblePositions).
+ // Changes to the document may have been made since the last editing operation
+ // that require a layout, as in <rdar://problem/5658603>. Low level
+ // operations, like RemoveNodeCommand, don't require a layout because the high
+ // level operations that use them perform one if one is necessary (like for
+ // the creation of VisiblePositions).
document().updateStyleAndLayoutIgnorePendingStylesheets();
LocalFrame* frame = document().frame();
@@ -225,8 +231,8 @@ bool CompositeEditCommand::apply() {
doApply(&editingState);
}
- // Only need to call appliedEditing for top-level commands,
- // and TypingCommands do it on their own (see TypingCommand::typingAddedToOpenCommand).
+ // Only need to call appliedEditing for top-level commands, and TypingCommands
+ // do it on their own (see TypingCommand::typingAddedToOpenCommand).
if (!isTypingCommand())
frame->editor().appliedEditing(this);
setShouldRetainAutocorrectionIndicator(false);
@@ -266,7 +272,8 @@ bool CompositeEditCommand::isReplaceSelectionCommand() const {
void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool) {}
//
-// sugary-sweet convenience functions to help create and apply edit commands in composite commands
+// sugary-sweet convenience functions to help create and apply edit commands in
+// composite commands
//
void CompositeEditCommand::applyCommandToComposite(EditCommand* command,
EditingState* editingState) {
@@ -414,7 +421,8 @@ void CompositeEditCommand::insertNodeAt(Node* insertChild,
} else if (refChild->isTextNode() && caretMaxOffset(refChild) > offset) {
splitTextNode(toText(refChild), offset);
- // Mutation events (bug 22634) from the text node insertion may have removed the refChild
+ // Mutation events (bug 22634) from the text node insertion may have removed
+ // the refChild
if (!refChild->isConnected())
return;
insertNodeBefore(insertChild, refChild, editingState);
@@ -806,13 +814,15 @@ bool CompositeEditCommand::canRebalance(const Position& position) const {
return true;
}
-// FIXME: Doesn't go into text nodes that contribute adjacent text (siblings, cousins, etc).
+// FIXME: Doesn't go into text nodes that contribute adjacent text (siblings,
+// cousins, etc).
void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position) {
Node* node = position.computeContainerNode();
if (!canRebalance(position))
return;
- // If the rebalance is for the single offset, and neither text[offset] nor text[offset - 1] are some form of whitespace, do nothing.
+ // If the rebalance is for the single offset, and neither text[offset] nor
+ // text[offset - 1] are some form of whitespace, do nothing.
int offset = position.computeOffsetInContainerNode();
String text = toText(node)->data();
if (!isWhitespace(text[offset])) {
@@ -832,7 +842,8 @@ void CompositeEditCommand::rebalanceWhitespaceOnTextSubstring(Text* textNode,
String text = textNode->data();
DCHECK(!text.isEmpty());
- // Set upstream and downstream to define the extent of the whitespace surrounding text[offset].
+ // Set upstream and downstream to define the extent of the whitespace
+ // surrounding text[offset].
int upstream = startOffset;
while (upstream > 0 && isWhitespace(text[upstream - 1]))
upstream--;
@@ -1056,7 +1067,8 @@ HTMLBRElement* CompositeEditCommand::appendBlockPlaceholder(
document().updateStyleAndLayoutIgnorePendingStylesheets();
- // Should assert isLayoutBlockFlow || isInlineFlow when deletion improves. See 4244964.
+ // Should assert isLayoutBlockFlow || isInlineFlow when deletion improves. See
+ // 4244964.
DCHECK(container->layoutObject()) << container;
HTMLBRElement* placeholder = HTMLBRElement::create(document());
@@ -1072,7 +1084,8 @@ HTMLBRElement* CompositeEditCommand::insertBlockPlaceholder(
if (pos.isNull())
return nullptr;
- // Should assert isLayoutBlockFlow || isInlineFlow when deletion improves. See 4244964.
+ // Should assert isLayoutBlockFlow || isInlineFlow when deletion improves. See
+ // 4244964.
DCHECK(pos.anchorNode()->layoutObject()) << pos;
HTMLBRElement* placeholder = HTMLBRElement::create(document());
@@ -1104,11 +1117,13 @@ HTMLBRElement* CompositeEditCommand::addBlockPlaceholderIfNeeded(
return nullptr;
}
-// Assumes that the position is at a placeholder and does the removal without much checking.
+// Assumes that the position is at a placeholder and does the removal without
+// much checking.
void CompositeEditCommand::removePlaceholderAt(const Position& p) {
DCHECK(lineBreakExistsAtPosition(p)) << p;
- // We are certain that the position is at a line break, but it may be a br or a preserved newline.
+ // We are certain that the position is at a line break, but it may be a br or
+ // a preserved newline.
if (isHTMLBRElement(*p.anchorNode())) {
// Removing a BR element won't dispatch synchronous events.
removeNode(p.anchorNode(), ASSERT_NO_EDITING_ABORT);
@@ -1129,15 +1144,16 @@ HTMLElement* CompositeEditCommand::insertNewDefaultParagraphElementAt(
return paragraphElement;
}
-// If the paragraph is not entirely within it's own block, create one and move the paragraph into
-// it, and return that block. Otherwise return 0.
+// If the paragraph is not entirely within it's own block, create one and move
+// the paragraph into it, and return that block. Otherwise return 0.
HTMLElement* CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(
const Position& pos,
EditingState* editingState) {
DCHECK(isEditablePosition(pos)) << pos;
- // It's strange that this function is responsible for verifying that pos has not been invalidated
- // by an earlier call to this function. The caller, applyBlockStyle, should do this.
+ // It's strange that this function is responsible for verifying that pos has
+ // not been invalidated by an earlier call to this function. The caller,
+ // applyBlockStyle, should do this.
VisiblePosition visiblePos =
createVisiblePositionDeprecated(pos, VP_DEFAULT_AFFINITY);
VisiblePosition visibleParagraphStart =
@@ -1157,19 +1173,21 @@ HTMLElement* CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(
// Perform some checks to see if we need to perform work in this function.
if (isEnclosingBlock(upstreamStart.anchorNode())) {
- // If the block is the root editable element, always move content to a new block,
- // since it is illegal to modify attributes on the root editable element for editing.
+ // If the block is the root editable element, always move content to a new
+ // block, since it is illegal to modify attributes on the root editable
+ // element for editing.
if (upstreamStart.anchorNode() == rootEditableElementOf(upstreamStart)) {
- // If the block is the root editable element and it contains no visible content, create a new
- // block but don't try and move content into it, since there's nothing for moveParagraphs to move.
+ // If the block is the root editable element and it contains no visible
+ // content, create a new block but don't try and move content into it,
+ // since there's nothing for moveParagraphs to move.
if (!hasRenderedNonAnonymousDescendantsWithHeight(
upstreamStart.anchorNode()->layoutObject()))
return insertNewDefaultParagraphElementAt(upstreamStart, editingState);
} else if (isEnclosingBlock(upstreamEnd.anchorNode())) {
if (!upstreamEnd.anchorNode()->isDescendantOf(
upstreamStart.anchorNode())) {
- // If the paragraph end is a descendant of paragraph start, then we need to run
- // the rest of this function. If not, we can bail here.
+ // If the paragraph end is a descendant of paragraph start, then we need
+ // to run the rest of this function. If not, we can bail here.
return nullptr;
}
} else if (enclosingBlock(upstreamEnd.anchorNode()) !=
@@ -1304,9 +1322,9 @@ void CompositeEditCommand::cloneParagraphUnderNewElement(
for (Node* node =
NodeTraversal::nextSkippingChildren(*startNode, outerNode);
node; node = NodeTraversal::nextSkippingChildren(*node, outerNode)) {
- // Move lastNode up in the tree as much as node was moved up in the
- // tree by NodeTraversal::nextSkippingChildren, so that the relative depth between
- // node and the original start node is maintained in the clone.
+ // Move lastNode up in the tree as much as node was moved up in the tree
+ // by NodeTraversal::nextSkippingChildren, so that the relative depth
+ // between node and the original start node is maintained in the clone.
while (startNode && lastNode &&
startNode->parentNode() != node->parentNode()) {
startNode = startNode->parentNode();
@@ -1378,11 +1396,12 @@ void CompositeEditCommand::cleanupAfterDeletion(EditingState* editingState,
}
}
-// This is a version of moveParagraph that preserves style by keeping the original markup
-// It is currently used only by IndentOutdentCommand but it is meant to be used in the
-// future by several other commands such as InsertList and the align commands.
-// The blockElement parameter is the element to move the paragraph to,
-// outerNode is the top element of the paragraph hierarchy.
+// This is a version of moveParagraph that preserves style by keeping the
+// original markup. It is currently used only by IndentOutdentCommand but it is
+// meant to be used in the future by several other commands such as InsertList
+// and the align commands.
+// The blockElement parameter is the element to move the paragraph to, outerNode
+// is the top element of the paragraph hierarchy.
void CompositeEditCommand::moveParagraphWithClones(
const VisiblePosition& startOfParagraphToMove,
@@ -1396,8 +1415,9 @@ void CompositeEditCommand::moveParagraphWithClones(
VisiblePosition beforeParagraph = previousPositionOf(startOfParagraphToMove);
VisiblePosition afterParagraph = nextPositionOf(endOfParagraphToMove);
- // We upstream() the end and downstream() the start so that we don't include collapsed whitespace in the move.
- // When we paste a fragment, spaces after the end and before the start are treated as though they were rendered.
+ // We upstream() the end and downstream() the start so that we don't include
+ // collapsed whitespace in the move. When we paste a fragment, spaces after
+ // the end and before the start are treated as though they were rendered.
Position start =
mostForwardCaretPosition(startOfParagraphToMove.deepEquivalent());
Position end =
@@ -1424,13 +1444,15 @@ void CompositeEditCommand::moveParagraphWithClones(
if (editingState->isAborted())
return;
- // Add a br if pruning an empty block level element caused a collapse. For example:
+ // Add a br if pruning an empty block level element caused a collapse. For
+ // example:
// foo^
// <div>bar</div>
// baz
- // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That would
- // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br.
- // Must recononicalize these two VisiblePositions after the pruning above.
+ // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That
+ // would cause 'baz' to collapse onto the line with 'foobar' unless we insert
+ // a br. Must recononicalize these two VisiblePositions after the pruning
+ // above.
// TODO(yosin): We should abort when |beforeParagraph| is a orphan when
// we have a sample.
beforeParagraph =
@@ -1447,7 +1469,8 @@ void CompositeEditCommand::moveParagraphWithClones(
((!isEndOfParagraphDeprecated(beforeParagraph) &&
!isStartOfParagraphDeprecated(beforeParagraph)) ||
beforeParagraph.deepEquivalent() == afterParagraph.deepEquivalent())) {
- // FIXME: Trim text between beforeParagraph and afterParagraph if they aren't equal.
+ // FIXME: Trim text between beforeParagraph and afterParagraph if they
+ // aren't equal.
insertNodeAt(HTMLBRElement::create(document()),
beforeParagraph.deepEquivalent(), editingState);
}
@@ -1527,15 +1550,17 @@ void CompositeEditCommand::moveParagraphs(
nextPositionOfDeprecated(endOfParagraphToMove, CannotCrossEditingBoundary)
.deepEquivalent());
- // We upstream() the end and downstream() the start so that we don't include collapsed whitespace in the move.
- // When we paste a fragment, spaces after the end and before the start are treated as though they were rendered.
+ // We upstream() the end and downstream() the start so that we don't include
+ // collapsed whitespace in the move. When we paste a fragment, spaces after
+ // the end and before the start are treated as though they were rendered.
Position start =
mostForwardCaretPosition(startOfParagraphToMove.deepEquivalent());
Position end =
mostBackwardCaretPosition(endOfParagraphToMove.deepEquivalent());
- // FIXME: This is an inefficient way to preserve style on nodes in the paragraph to move. It
- // shouldn't matter though, since moved paragraphs will usually be quite small.
+ // FIXME: This is an inefficient way to preserve style on nodes in the
+ // paragraph to move. It shouldn't matter though, since moved paragraphs will
+ // usually be quite small.
DocumentFragment* fragment =
startOfParagraphToMove.deepEquivalent() !=
endOfParagraphToMove.deepEquivalent()
@@ -1549,9 +1574,10 @@ void CompositeEditCommand::moveParagraphs(
"")
: nullptr;
- // A non-empty paragraph's style is moved when we copy and move it. We don't move
- // anything if we're given an empty paragraph, but an empty paragraph can have style
- // too, <div><b><br></b></div> for example. Save it so that we can preserve it later.
+ // A non-empty paragraph's style is moved when we copy and move it. We don't
+ // move anything if we're given an empty paragraph, but an empty paragraph can
+ // have style too, <div><b><br></b></div> for example. Save it so that we can
+ // preserve it later.
EditingStyle* styleInEmptyParagraph = nullptr;
if (startOfParagraphToMove.deepEquivalent() ==
endOfParagraphToMove.deepEquivalent() &&
@@ -1563,7 +1589,8 @@ void CompositeEditCommand::moveParagraphs(
styleInEmptyParagraph->removeBlockProperties();
}
- // FIXME (5098931): We should add a new insert action "WebViewInsertActionMoved" and call shouldInsertFragment here.
+ // FIXME (5098931): We should add a new insert action
+ // "WebViewInsertActionMoved" and call shouldInsertFragment here.
setEndingSelection(createVisibleSelectionDeprecated(start, end));
document()
@@ -1580,13 +1607,15 @@ void CompositeEditCommand::moveParagraphs(
return;
DCHECK(destination.deepEquivalent().isConnected()) << destination;
- // Add a br if pruning an empty block level element caused a collapse. For example:
+ // Add a br if pruning an empty block level element caused a collapse. For
+ // example:
// foo^
// <div>bar</div>
// baz
- // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That would
- // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br.
- // Must recononicalize these two VisiblePositions after the pruning above.
+ // Imagine moving 'bar' to ^. 'bar' will be deleted and its div pruned. That
+ // would cause 'baz' to collapse onto the line with 'foobar' unless we insert
+ // a br. Must recononicalize these two VisiblePositions after the pruning
+ // above.
VisiblePosition beforeParagraph =
createVisiblePositionDeprecated(beforeParagraphPosition.position());
VisiblePosition afterParagraph =
@@ -1594,7 +1623,8 @@ void CompositeEditCommand::moveParagraphs(
if (beforeParagraph.isNotNull() &&
(!isEndOfParagraphDeprecated(beforeParagraph) ||
beforeParagraph.deepEquivalent() == afterParagraph.deepEquivalent())) {
- // FIXME: Trim text between beforeParagraph and afterParagraph if they aren't equal.
+ // FIXME: Trim text between beforeParagraph and afterParagraph if they
+ // aren't equal.
insertNodeAt(HTMLBRElement::create(document()),
beforeParagraph.deepEquivalent(), editingState);
if (editingState->isAborted())
@@ -1631,7 +1661,8 @@ void CompositeEditCommand::moveParagraphs(
->spellChecker()
.markMisspellingsAndBadGrammarForMovingParagraphs(endingSelection());
- // If the selection is in an empty paragraph, restore styles from the old empty paragraph to the new empty paragraph.
+ // If the selection is in an empty paragraph, restore styles from the old
+ // empty paragraph to the new empty paragraph.
bool selectionIsEmptyParagraph =
endingSelection().isCaret() &&
isStartOfParagraphDeprecated(
@@ -1681,7 +1712,8 @@ bool CompositeEditCommand::breakOutOfEmptyListItem(EditingState* editingState) {
style->mergeTypingStyle(&document());
ContainerNode* listNode = emptyListItem->parentNode();
- // FIXME: Can't we do something better when the immediate parent wasn't a list node?
+ // FIXME: Can't we do something better when the immediate parent wasn't a list
+ // node?
if (!listNode ||
(!isHTMLUListElement(*listNode) && !isHTMLOListElement(*listNode)) ||
!hasEditableStyle(*listNode) ||
@@ -1694,17 +1726,27 @@ bool CompositeEditCommand::breakOutOfEmptyListItem(EditingState* editingState) {
*blockEnclosingList)) { // listNode is inside another list item
if (visiblePositionAfterNode(*blockEnclosingList).deepEquivalent() ==
visiblePositionAfterNode(*listNode).deepEquivalent()) {
- // If listNode appears at the end of the outer list item, then move listNode outside of this list item
- // e.g. <ul><li>hello <ul><li><br></li></ul> </li></ul> should become <ul><li>hello</li> <ul><li><br></li></ul> </ul> after this section
- // If listNode does NOT appear at the end, then we should consider it as a regular paragraph.
- // e.g. <ul><li> <ul><li><br></li></ul> hello</li></ul> should become <ul><li> <div><br></div> hello</li></ul> at the end
+ // If listNode appears at the end of the outer list item, then move
+ // listNode outside of this list item, e.g.
+ // <ul><li>hello <ul><li><br></li></ul> </li></ul>
+ // should become
+ // <ul><li>hello</li> <ul><li><br></li></ul> </ul>
+ // after this section.
+ //
+ // If listNode does NOT appear at the end, then we should consider it as
+ // a regular paragraph, e.g.
+ // <ul><li> <ul><li><br></li></ul> hello</li></ul>
+ // should become
+ // <ul><li> <div><br></div> hello</li></ul>
+ // at the end
splitElement(toElement(blockEnclosingList), listNode);
removeNodePreservingChildren(listNode->parentNode(), editingState);
if (editingState->isAborted())
return false;
newBlock = HTMLLIElement::create(document());
}
- // If listNode does NOT appear at the end of the outer list item, then behave as if in a regular paragraph.
+ // If listNode does NOT appear at the end of the outer list item, then
+ // behave as if in a regular paragraph.
} else if (isHTMLOListElement(*blockEnclosingList) ||
isHTMLUListElement(*blockEnclosingList)) {
newBlock = HTMLLIElement::create(document());
@@ -1721,12 +1763,14 @@ bool CompositeEditCommand::breakOutOfEmptyListItem(EditingState* editingState) {
? ElementTraversal::nextSibling(*emptyListItem)
: emptyListItem->nextSibling();
if (isListItem(nextListNode) || isHTMLListElement(nextListNode)) {
- // If emptyListItem follows another list item or nested list, split the list node.
+ // If emptyListItem follows another list item or nested list, split the list
+ // node.
if (isListItem(previousListNode) || isHTMLListElement(previousListNode))
splitElement(toElement(listNode), emptyListItem);
- // If emptyListItem is followed by other list item or nested list, then insert newBlock before the list node.
- // Because we have splitted the element, emptyListItem is the first element in the list node.
+ // If emptyListItem is followed by other list item or nested list, then
+ // insert newBlock before the list node. Because we have splitted the
+ // element, emptyListItem is the first element in the list node.
// i.e. insert newBlock before ul or ol whose first element is emptyListItem
insertNodeBefore(newBlock, listNode, editingState);
if (editingState->isAborted())
@@ -1735,8 +1779,9 @@ bool CompositeEditCommand::breakOutOfEmptyListItem(EditingState* editingState) {
if (editingState->isAborted())
return false;
} else {
- // When emptyListItem does not follow any list item or nested list, insert newBlock after the enclosing list node.
- // Remove the enclosing node if emptyListItem is the only child; otherwise just remove emptyListItem.
+ // When emptyListItem does not follow any list item or nested list, insert
+ // newBlock after the enclosing list node. Remove the enclosing node if
+ // emptyListItem is the only child; otherwise just remove emptyListItem.
insertNodeAfter(newBlock, listNode, editingState);
if (editingState->isAborted())
return false;
@@ -1766,8 +1811,9 @@ bool CompositeEditCommand::breakOutOfEmptyListItem(EditingState* editingState) {
return true;
}
-// If the caret is in an empty quoted paragraph, and either there is nothing before that
-// paragraph, or what is before is unquoted, and the user presses delete, unquote that paragraph.
+// If the caret is in an empty quoted paragraph, and either there is nothing
+// before that paragraph, or what is before is unquoted, and the user presses
+// delete, unquote that paragraph.
bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph(
EditingState* editingState) {
if (!endingSelection().isCaret())
@@ -1786,20 +1832,22 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph(
VisiblePosition previous =
previousPositionOf(caret, CannotCrossEditingBoundary);
- // Only move forward if there's nothing before the caret, or if there's unquoted content before it.
+ // Only move forward if there's nothing before the caret, or if there's
+ // unquoted content before it.
if (enclosingNodeOfType(previous.deepEquivalent(),
&isMailHTMLBlockquoteElement))
return false;
HTMLBRElement* br = HTMLBRElement::create(document());
- // We want to replace this quoted paragraph with an unquoted one, so insert a br
- // to hold the caret before the highest blockquote.
+ // We want to replace this quoted paragraph with an unquoted one, so insert a
+ // br to hold the caret before the highest blockquote.
insertNodeBefore(br, highestBlockquote, editingState);
if (editingState->isAborted())
return false;
VisiblePosition atBR = VisiblePosition::beforeNode(br);
- // If the br we inserted collapsed, for example foo<br><blockquote>...</blockquote>, insert
- // a second one.
+ // If the br we inserted collapsed, for example:
+ // foo<br><blockquote>...</blockquote>
+ // insert a second one.
if (!isStartOfParagraphDeprecated(atBR)) {
insertNodeBefore(HTMLBRElement::create(document()), br, editingState);
if (editingState->isAborted())
@@ -1827,8 +1875,9 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph(
DCHECK_EQ(caretPos.computeOffsetInContainerNode(), 0);
Text* textNode = toText(caretPos.anchorNode());
ContainerNode* parentNode = textNode->parentNode();
- // The preserved newline must be the first thing in the node, since otherwise the previous
- // paragraph would be quoted, and we verified that it wasn't above.
+ // The preserved newline must be the first thing in the node, since
+ // otherwise the previous paragraph would be quoted, and we verified that it
+ // wasn't above.
deleteTextFromNode(textNode, 0, 1);
prune(parentNode, editingState);
if (editingState->isAborted())
@@ -1838,10 +1887,10 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph(
return true;
}
-// Operations use this function to avoid inserting content into an anchor when at the start or the end of
-// that anchor, as in NSTextView.
-// FIXME: This is only an approximation of NSTextViews insertion behavior, which varies depending on how
-// the caret was made.
+// Operations use this function to avoid inserting content into an anchor when
+// at the start or the end of that anchor, as in NSTextView.
+// FIXME: This is only an approximation of NSTextViews insertion behavior, which
+// varies depending on how the caret was made.
Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(
const Position& original,
EditingState* editingState) {
@@ -1855,14 +1904,15 @@ Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(
if (!enclosingAnchor)
return result;
- // Don't avoid block level anchors, because that would insert content into the wrong paragraph.
+ // Don't avoid block level anchors, because that would insert content into the
+ // wrong paragraph.
if (enclosingAnchor && !isEnclosingBlock(enclosingAnchor)) {
VisiblePosition firstInAnchor =
VisiblePosition::firstPositionInNode(enclosingAnchor);
VisiblePosition lastInAnchor =
VisiblePosition::lastPositionInNode(enclosingAnchor);
- // If visually just after the anchor, insert *inside* the anchor unless it's the last
- // VisiblePosition in the document, to match NSTextView.
+ // If visually just after the anchor, insert *inside* the anchor unless it's
+ // the last VisiblePosition in the document, to match NSTextView.
if (visiblePos.deepEquivalent() == lastInAnchor.deepEquivalent()) {
// Make sure anchors are pushed down before avoiding them so that we don't
// also avoid structural elements like lists and blocks (5142012).
@@ -1875,8 +1925,9 @@ Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(
if (!enclosingAnchor)
return original;
}
- // Don't insert outside an anchor if doing so would skip over a line break. It would
- // probably be safe to move the line break so that we could still avoid the anchor here.
+ // Don't insert outside an anchor if doing so would skip over a line
+ // break. It would probably be safe to move the line break so that we
+ // could still avoid the anchor here.
Position downstream(
mostForwardCaretPosition(visiblePos.deepEquivalent()));
if (lineBreakExistsAtVisiblePosition(visiblePos) &&
@@ -1885,8 +1936,8 @@ Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(
result = Position::inParentAfterNode(*enclosingAnchor);
}
- // If visually just before an anchor, insert *outside* the anchor unless it's the first
- // VisiblePosition in a paragraph, to match NSTextView.
+ // If visually just before an anchor, insert *outside* the anchor unless
+ // it's the first VisiblePosition in a paragraph, to match NSTextView.
if (visiblePos.deepEquivalent() == firstInAnchor.deepEquivalent()) {
// Make sure anchors are pushed down before avoiding them so that we don't
// also avoid structural elements like lists and blocks (5142012).
@@ -1910,8 +1961,9 @@ Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(
return result;
}
-// Splits the tree parent by parent until we reach the specified ancestor. We use VisiblePositions
-// to determine if the split is necessary. Returns the last split node.
+// Splits the tree parent by parent until we reach the specified ancestor. We
+// use VisiblePositions to determine if the split is necessary. Returns the last
+// split node.
Node* CompositeEditCommand::splitTreeToNode(Node* start,
Node* end,
bool shouldSplitAncestor) {

Powered by Google App Engine
This is Rietveld 408576698