| 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 5ec5142351d9917d16c93412fa7ba116eee04229..06fb28d3b8d29f80ecf72ddd278007f874d217e8 100644
|
| --- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
|
| @@ -96,15 +96,15 @@ EditCommandComposition::EditCommandComposition(Document* document, const Visible
|
|
|
| bool EditCommandComposition::belongsTo(const LocalFrame& frame) const
|
| {
|
| - ASSERT(m_document);
|
| + DCHECK(m_document);
|
| return m_document->frame() == &frame;
|
| }
|
|
|
| void EditCommandComposition::unapply()
|
| {
|
| - ASSERT(m_document);
|
| + DCHECK(m_document);
|
| RawPtr<LocalFrame> frame = m_document->frame();
|
| - ASSERT(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
|
| @@ -122,9 +122,9 @@ void EditCommandComposition::unapply()
|
|
|
| void EditCommandComposition::reapply()
|
| {
|
| - ASSERT(m_document);
|
| + DCHECK(m_document);
|
| RawPtr<LocalFrame> frame = m_document->frame();
|
| - ASSERT(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
|
| @@ -174,7 +174,7 @@ CompositeEditCommand::CompositeEditCommand(Document& document)
|
|
|
| CompositeEditCommand::~CompositeEditCommand()
|
| {
|
| - ASSERT(isTopLevelCommand() || !m_composition);
|
| + DCHECK(isTopLevelCommand() || !m_composition);
|
| }
|
|
|
| bool CompositeEditCommand::apply()
|
| @@ -201,7 +201,7 @@ bool CompositeEditCommand::apply()
|
| document().updateLayoutIgnorePendingStylesheets();
|
|
|
| LocalFrame* frame = document().frame();
|
| - ASSERT(frame);
|
| + DCHECK(frame);
|
| EditingState editingState;
|
| {
|
| EventQueueScope eventQueueScope;
|
| @@ -303,7 +303,7 @@ void CompositeEditCommand::insertParagraphSeparator(EditingState* editingState,
|
|
|
| bool CompositeEditCommand::isRemovableBlock(const Node* node)
|
| {
|
| - ASSERT(node);
|
| + DCHECK(node);
|
| if (!isHTMLDivElement(*node))
|
| return false;
|
|
|
| @@ -320,23 +320,23 @@ bool CompositeEditCommand::isRemovableBlock(const Node* node)
|
|
|
| void CompositeEditCommand::insertNodeBefore(RawPtr<Node> insertChild, RawPtr<Node> refChild, EditingState* editingState, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
|
| {
|
| - ASSERT(document().body() != refChild);
|
| + DCHECK_NE(document().body(), refChild);
|
| ABORT_EDITING_COMMAND_IF(!refChild->parentNode()->hasEditableStyle() && refChild->parentNode()->inActiveDocument());
|
| applyCommandToComposite(InsertNodeBeforeCommand::create(insertChild, refChild, shouldAssumeContentIsAlwaysEditable), editingState);
|
| }
|
|
|
| void CompositeEditCommand::insertNodeAfter(RawPtr<Node> insertChild, RawPtr<Node> refChild, EditingState* editingState)
|
| {
|
| - ASSERT(insertChild);
|
| - ASSERT(refChild);
|
| - ASSERT(document().body() != refChild);
|
| + DCHECK(insertChild);
|
| + DCHECK(refChild);
|
| + DCHECK_NE(document().body(), refChild);
|
| ContainerNode* parent = refChild->parentNode();
|
| - ASSERT(parent);
|
| - ASSERT(!parent->isShadowRoot());
|
| + DCHECK(parent);
|
| + DCHECK(!parent->isShadowRoot());
|
| if (parent->lastChild() == refChild) {
|
| appendNode(insertChild, parent, editingState);
|
| } else {
|
| - ASSERT(refChild->nextSibling());
|
| + DCHECK(refChild->nextSibling());
|
| insertNodeBefore(insertChild, refChild->nextSibling(), editingState);
|
| }
|
| }
|
| @@ -420,7 +420,7 @@ void CompositeEditCommand::removeNodePreservingChildren(RawPtr<Node> node, Editi
|
|
|
| void CompositeEditCommand::removeNodeAndPruneAncestors(RawPtr<Node> node, EditingState* editingState, Node* excludeNode)
|
| {
|
| - ASSERT(node.get() != excludeNode);
|
| + DCHECK_NE(node.get(), excludeNode);
|
| RawPtr<ContainerNode> parent = node->parentNode();
|
| removeNode(node, editingState);
|
| if (editingState->isAborted())
|
| @@ -466,7 +466,7 @@ HTMLSpanElement* CompositeEditCommand::replaceElementWithSpanPreservingChildrenA
|
| // Returning a raw pointer here is OK because the command is retained by
|
| // applyCommandToComposite (thus retaining the span), and the span is also
|
| // in the DOM tree, and thus alive whie it has a parent.
|
| - ASSERT(command->spanElement()->inShadowIncludingDocument());
|
| + DCHECK(command->spanElement()->inShadowIncludingDocument());
|
| return command->spanElement();
|
| }
|
|
|
| @@ -492,7 +492,7 @@ void CompositeEditCommand::mergeIdenticalElements(RawPtr<Element> prpFirst, RawP
|
| {
|
| RawPtr<Element> first = prpFirst;
|
| RawPtr<Element> second = prpSecond;
|
| - ASSERT(!first->isDescendantOf(second.get()) && second != first);
|
| + DCHECK(!first->isDescendantOf(second.get()) && second != first);
|
| if (first->nextSibling() != second) {
|
| removeNode(second, editingState);
|
| if (editingState->isAborted())
|
| @@ -573,7 +573,7 @@ void CompositeEditCommand::replaceTextInNodePreservingMarkers(RawPtr<Text> prpNo
|
| replaceTextInNode(node, offset, count, replacementText);
|
| Position startPosition(node.get(), offset);
|
| Position endPosition(node.get(), offset + replacementText.length());
|
| - ASSERT(types.size() == descriptions.size());
|
| + DCHECK_EQ(types.size(), descriptions.size());
|
| for (size_t i = 0; i < types.size(); ++i)
|
| markerController.addMarker(startPosition, endPosition, types[i], descriptions[i]);
|
| }
|
| @@ -597,7 +597,7 @@ Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos)
|
| }
|
|
|
| HTMLSpanElement* tabSpan = tabSpanElement(pos.computeContainerNode());
|
| - ASSERT(tabSpan);
|
| + DCHECK(tabSpan);
|
|
|
| if (pos.offsetInContainerNode() <= caretMinOffset(pos.computeContainerNode()))
|
| return positionInParentBeforeNode(*tabSpan);
|
| @@ -700,7 +700,7 @@ void CompositeEditCommand::rebalanceWhitespaceOnTextSubstring(RawPtr<Text> prpTe
|
| RawPtr<Text> textNode = prpTextNode;
|
|
|
| String text = textNode->data();
|
| - ASSERT(!text.isEmpty());
|
| + DCHECK(!text.isEmpty());
|
|
|
| // Set upstream and downstream to define the extent of the whitespace surrounding text[offset].
|
| int upstream = startOffset;
|
| @@ -854,7 +854,7 @@ void CompositeEditCommand::deleteInsignificantText(RawPtr<Text> textNode, unsign
|
| // Assert that we are not going to delete all of the text in the node.
|
| // If we were, that should have been done above with the call to
|
| // removeNode and return.
|
| - ASSERT(start > 0 || end - start < textNode->length());
|
| + DCHECK(start > 0 || end - start < textNode->length());
|
| deleteTextFromNode(textNode, start, end - start);
|
| }
|
| }
|
| @@ -898,7 +898,7 @@ RawPtr<HTMLBRElement> CompositeEditCommand::appendBlockPlaceholder(RawPtr<Elemen
|
| document().updateLayoutIgnorePendingStylesheets();
|
|
|
| // Should assert isLayoutBlockFlow || isInlineFlow when deletion improves. See 4244964.
|
| - ASSERT(container->layoutObject());
|
| + DCHECK(container->layoutObject());
|
|
|
| RawPtr<HTMLBRElement> placeholder = HTMLBRElement::create(document());
|
| appendNode(placeholder, container, editingState);
|
| @@ -913,7 +913,7 @@ RawPtr<HTMLBRElement> CompositeEditCommand::insertBlockPlaceholder(const Positio
|
| return nullptr;
|
|
|
| // Should assert isLayoutBlockFlow || isInlineFlow when deletion improves. See 4244964.
|
| - ASSERT(pos.anchorNode()->layoutObject());
|
| + DCHECK(pos.anchorNode()->layoutObject());
|
|
|
| RawPtr<HTMLBRElement> placeholder = HTMLBRElement::create(document());
|
| insertNodeAt(placeholder, pos, editingState);
|
| @@ -945,7 +945,7 @@ RawPtr<HTMLBRElement> CompositeEditCommand::addBlockPlaceholderIfNeeded(Element*
|
| // Assumes that the position is at a placeholder and does the removal without much checking.
|
| void CompositeEditCommand::removePlaceholderAt(const Position& p)
|
| {
|
| - ASSERT(lineBreakExistsAtPosition(p));
|
| + DCHECK(lineBreakExistsAtPosition(p));
|
|
|
| // 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())) {
|
| @@ -971,7 +971,7 @@ RawPtr<HTMLElement> CompositeEditCommand::insertNewDefaultParagraphElementAt(con
|
| // it, and return that block. Otherwise return 0.
|
| RawPtr<HTMLElement> CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(const Position& pos, EditingState* editingState)
|
| {
|
| - ASSERT(isEditablePosition(pos, ContentIsEditable, DoNotUpdateStyle));
|
| + DCHECK(isEditablePosition(pos, ContentIsEditable, DoNotUpdateStyle));
|
|
|
| // 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.
|
| @@ -1046,7 +1046,7 @@ void CompositeEditCommand::pushAnchorElementDown(Element* anchorNode, EditingSta
|
| if (!anchorNode)
|
| return;
|
|
|
| - ASSERT(anchorNode->isLink());
|
| + DCHECK(anchorNode->isLink());
|
|
|
| setEndingSelection(VisibleSelection::selectionFromContentsOfNode(anchorNode));
|
| applyStyledElement(anchorNode, editingState);
|
| @@ -1062,9 +1062,9 @@ void CompositeEditCommand::pushAnchorElementDown(Element* anchorNode, EditingSta
|
|
|
| void CompositeEditCommand::cloneParagraphUnderNewElement(const Position& start, const Position& end, Node* passedOuterNode, Element* blockElement, EditingState* editingState)
|
| {
|
| - ASSERT(comparePositions(start, end) <= 0);
|
| - ASSERT(passedOuterNode);
|
| - ASSERT(blockElement);
|
| + DCHECK_LE(comparePositions(start, end), 0);
|
| + DCHECK(passedOuterNode);
|
| + DCHECK(blockElement);
|
|
|
| // First we clone the outerNode
|
| RawPtr<Node> lastNode = nullptr;
|
| @@ -1197,8 +1197,8 @@ void CompositeEditCommand::cleanupAfterDeletion(EditingState* editingState, Visi
|
|
|
| void CompositeEditCommand::moveParagraphWithClones(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, HTMLElement* blockElement, Node* outerNode, EditingState* editingState)
|
| {
|
| - ASSERT(outerNode);
|
| - ASSERT(blockElement);
|
| + DCHECK(outerNode);
|
| + DCHECK(blockElement);
|
|
|
| VisiblePosition beforeParagraph = previousPositionOf(startOfParagraphToMove);
|
| VisiblePosition afterParagraph = nextPositionOf(endOfParagraphToMove);
|
| @@ -1244,8 +1244,8 @@ void CompositeEditCommand::moveParagraphWithClones(const VisiblePosition& startO
|
|
|
| void CompositeEditCommand::moveParagraph(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, const VisiblePosition& destination, EditingState* editingState, bool preserveSelection, bool preserveStyle, Node* constrainingAncestor)
|
| {
|
| - ASSERT(isStartOfParagraph(startOfParagraphToMove));
|
| - ASSERT(isEndOfParagraph(endOfParagraphToMove));
|
| + DCHECK(isStartOfParagraph(startOfParagraphToMove));
|
| + DCHECK(isEndOfParagraph(endOfParagraphToMove));
|
| moveParagraphs(startOfParagraphToMove, endOfParagraphToMove, destination, editingState, preserveSelection, preserveStyle, constrainingAncestor);
|
| }
|
|
|
| @@ -1311,11 +1311,11 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
|
| if (editingState->isAborted())
|
| return;
|
|
|
| - ASSERT(destination.deepEquivalent().inShadowIncludingDocument());
|
| + DCHECK(destination.deepEquivalent().inShadowIncludingDocument());
|
| cleanupAfterDeletion(editingState, destination);
|
| if (editingState->isAborted())
|
| return;
|
| - ASSERT(destination.deepEquivalent().inShadowIncludingDocument());
|
| + DCHECK(destination.deepEquivalent().inShadowIncludingDocument());
|
|
|
| // Add a br if pruning an empty block level element caused a collapse. For example:
|
| // foo^
|
| @@ -1338,7 +1338,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
|
| destinationIndex = TextIterator::rangeLength(firstPositionInNode(document().documentElement()), destination.toParentAnchoredPosition(), true);
|
|
|
| setEndingSelection(VisibleSelection(destination, originalIsDirectional));
|
| - ASSERT(endingSelection().isCaretOrRange());
|
| + DCHECK(endingSelection().isCaretOrRange());
|
| ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MovingParagraph;
|
| if (!preserveStyle)
|
| options |= ReplaceSelectionCommand::MatchStyle;
|
| @@ -1499,14 +1499,14 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph(EditingState*
|
|
|
| Position caretPos(mostForwardCaretPosition(caret.deepEquivalent()));
|
| // A line break is either a br or a preserved newline.
|
| - ASSERT(isHTMLBRElement(caretPos.anchorNode()) || (caretPos.anchorNode()->isTextNode() && caretPos.anchorNode()->layoutObject()->style()->preserveNewline()));
|
| + DCHECK(isHTMLBRElement(caretPos.anchorNode()) || (caretPos.anchorNode()->isTextNode() && caretPos.anchorNode()->layoutObject()->style()->preserveNewline()));
|
|
|
| if (isHTMLBRElement(*caretPos.anchorNode())) {
|
| removeNodeAndPruneAncestors(caretPos.anchorNode(), editingState);
|
| if (editingState->isAborted())
|
| return false;
|
| } else if (caretPos.anchorNode()->isTextNode()) {
|
| - ASSERT(caretPos.computeOffsetInContainerNode() == 0);
|
| + 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
|
| @@ -1589,9 +1589,9 @@ Position CompositeEditCommand::positionAvoidingSpecialElementBoundary(const Posi
|
| // to determine if the split is necessary. Returns the last split node.
|
| RawPtr<Node> CompositeEditCommand::splitTreeToNode(Node* start, Node* end, bool shouldSplitAncestor)
|
| {
|
| - ASSERT(start);
|
| - ASSERT(end);
|
| - ASSERT(start != end);
|
| + DCHECK(start);
|
| + DCHECK(end);
|
| + DCHECK_NE(start, end);
|
|
|
| if (shouldSplitAncestor && end->parentNode())
|
| end = end->parentNode();
|
|
|