Drop remaining uses of PassRefPtr from CompositeEditCommand
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 May 2017 05:09:56 +0000 (05:09 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 May 2017 05:09:56 +0000 (05:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171645

Reviewed by Darin Adler.

Drop remaining uses of PassRefPtr from CompositeEditCommand.

* editing/ApplyBlockElementCommand.cpp:
(WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded):
(WebCore::ApplyBlockElementCommand::endOfNextParagraphSplittingTextNodesIfNeeded):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
(WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans):
(WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi):
(WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock):
(WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
(WebCore::ApplyStyleCommand::removeInlineStyleFromElement):
(WebCore::ApplyStyleCommand::replaceWithSpanOrRemoveIfWithoutAttributes):
(WebCore::ApplyStyleCommand::removeImplicitlyStyledElement):
(WebCore::ApplyStyleCommand::removeCSSStyle):
(WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
(WebCore::ApplyStyleCommand::splitTextAtStart):
(WebCore::ApplyStyleCommand::splitTextAtEnd):
(WebCore::ApplyStyleCommand::splitTextElementAtStart):
(WebCore::ApplyStyleCommand::splitTextElementAtEnd):
(WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
(WebCore::ApplyStyleCommand::addBlockStyle):
(WebCore::ApplyStyleCommand::addInlineStyleIfNeeded):
(WebCore::ApplyStyleCommand::applyInlineStyleChange):
(WebCore::ApplyStyleCommand::joinChildTextNodes):
* editing/BreakBlockquoteCommand.cpp:
(WebCore::BreakBlockquoteCommand::doApply):
* editing/CompositeEditCommand.cpp:
(WebCore::applyCommand):
(WebCore::CompositeEditCommand::insertNodeAt):
(WebCore::CompositeEditCommand::removeChildrenInRange):
(WebCore::CompositeEditCommand::removeNode):
(WebCore::CompositeEditCommand::removeNodePreservingChildren):
(WebCore::CompositeEditCommand::removeNodeAndPruneAncestors):
(WebCore::CompositeEditCommand::moveRemainingSiblingsToNewParent):
(WebCore::CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAttributes):
(WebCore::CompositeEditCommand::prune):
(WebCore::CompositeEditCommand::splitTextNode):
(WebCore::CompositeEditCommand::splitElement):
(WebCore::CompositeEditCommand::mergeIdenticalElements):
(WebCore::CompositeEditCommand::splitTextNodeContainingElement):
(WebCore::CompositeEditCommand::positionOutsideTabSpan):
(WebCore::CompositeEditCommand::removeNodeAttribute):
(WebCore::CompositeEditCommand::setNodeAttribute):
(WebCore::CompositeEditCommand::deleteInsignificantText):
(WebCore::CompositeEditCommand::removePlaceholderAt):
(WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
(WebCore::CompositeEditCommand::pushAnchorElementDown):
(WebCore::CompositeEditCommand::cleanupAfterDeletion):
(WebCore::CompositeEditCommand::moveParagraphs):
* editing/CompositeEditCommand.h:
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):
(WebCore::DeleteSelectionCommand::removeNodeUpdatingStates):
(WebCore::DeleteSelectionCommand::removeNode):
(WebCore::DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss):
(WebCore::DeleteSelectionCommand::handleGeneralDelete):
(WebCore::DeleteSelectionCommand::mergeParagraphs):
(WebCore::DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows):
(WebCore::DeleteSelectionCommand::removeRedundantBlocks):
* editing/DeleteSelectionCommand.h:
* editing/Editor.cpp:
(WebCore::ClearTextCommand::CreateAndApply):
(WebCore::Editor::replaceSelectionWithFragment):
(WebCore::Editor::handleAcceptedCandidate):
* editing/EditorCommand.cpp:
(WebCore::executeFormatBlock):
* editing/IndentOutdentCommand.cpp:
(WebCore::IndentOutdentCommand::outdentParagraph):
* editing/InsertLineBreakCommand.cpp:
(WebCore::InsertLineBreakCommand::doApply):
* editing/InsertListCommand.cpp:
(WebCore::InsertListCommand::fixOrphanedListChild):
(WebCore::InsertListCommand::doApplyForSingleParagraph):
(WebCore::InsertListCommand::unlistifyParagraph):
* editing/InsertParagraphSeparatorCommand.cpp:
(WebCore::InsertParagraphSeparatorCommand::doApply):
* editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::insertTab):
* editing/ModifySelectionListLevel.cpp:
(WebCore::ModifySelectionListLevelCommand::insertSiblingNodeRangeBefore):
(WebCore::ModifySelectionListLevelCommand::insertSiblingNodeRangeAfter):
(WebCore::ModifySelectionListLevelCommand::appendSiblingNodeRange):
(WebCore::DecreaseSelectionListLevelCommand::doApply):
* editing/RemoveNodePreservingChildrenCommand.cpp:
(WebCore::RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand):
(WebCore::RemoveNodePreservingChildrenCommand::doApply):
* editing/RemoveNodePreservingChildrenCommand.h:
(WebCore::RemoveNodePreservingChildrenCommand::create):
* editing/ReplaceNodeWithSpanCommand.cpp:
(WebCore::ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand):
(WebCore::ReplaceNodeWithSpanCommand::doApply):
(WebCore::ReplaceNodeWithSpanCommand::doUnapply):
(WebCore::ReplaceNodeWithSpanCommand::getNodesInCommand):
* editing/ReplaceNodeWithSpanCommand.h:
(WebCore::ReplaceNodeWithSpanCommand::create):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplacementFragment::removeNodePreservingChildren):
(WebCore::ReplacementFragment::removeInterchangeNodes):
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
(WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
(WebCore::ReplaceSelectionCommand::moveNodeOutOfAncestor):
(WebCore::ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds):
(WebCore::handleStyleSpansBeforeInsertion):
(WebCore::ReplaceSelectionCommand::handleStyleSpans):
(WebCore::ReplaceSelectionCommand::doApply):
(WebCore::ReplaceSelectionCommand::mergeTextNodesAroundPosition):
(WebCore::ReplaceSelectionCommand::insertAsListItems):
(WebCore::ReplaceSelectionCommand::performTrivialReplace):
* editing/SetNodeAttributeCommand.cpp:
(WebCore::SetNodeAttributeCommand::SetNodeAttributeCommand):
(WebCore::SetNodeAttributeCommand::getNodesInCommand):
* editing/SetNodeAttributeCommand.h:
(WebCore::SetNodeAttributeCommand::create):
* editing/SimplifyMarkupCommand.cpp:
(WebCore::SimplifyMarkupCommand::doApply):
(WebCore::SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove):
* editing/SimplifyMarkupCommand.h:
* editing/SplitElementCommand.cpp:
(WebCore::SplitElementCommand::SplitElementCommand):
(WebCore::SplitElementCommand::executeApply):
(WebCore::SplitElementCommand::getNodesInCommand):
* editing/SplitElementCommand.h:
(WebCore::SplitElementCommand::create):
* editing/SplitTextNodeCommand.cpp:
(WebCore::SplitTextNodeCommand::SplitTextNodeCommand):
(WebCore::SplitTextNodeCommand::doApply):
(WebCore::SplitTextNodeCommand::doUnapply):
(WebCore::SplitTextNodeCommand::doReapply):
(WebCore::SplitTextNodeCommand::insertText1AndTrimText2):
* editing/SplitTextNodeCommand.h:
(WebCore::SplitTextNodeCommand::create):
* editing/SplitTextNodeContainingElementCommand.cpp:
(WebCore::SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand):
(WebCore::SplitTextNodeContainingElementCommand::doApply):
* editing/SplitTextNodeContainingElementCommand.h:
(WebCore::SplitTextNodeContainingElementCommand::create):
* editing/TextInsertionBaseCommand.cpp:
(WebCore::TextInsertionBaseCommand::applyTextInsertionCommand):
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::makeEditableRootEmpty):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216233 268f45cc-cd09-0410-ab3c-d52691b4dbfc

37 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/AlternativeTextController.cpp
Source/WebCore/editing/ApplyBlockElementCommand.cpp
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/editing/BreakBlockquoteCommand.cpp
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/CompositeEditCommand.h
Source/WebCore/editing/DeleteSelectionCommand.cpp
Source/WebCore/editing/DeleteSelectionCommand.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/EditorCommand.cpp
Source/WebCore/editing/IndentOutdentCommand.cpp
Source/WebCore/editing/InsertLineBreakCommand.cpp
Source/WebCore/editing/InsertListCommand.cpp
Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp
Source/WebCore/editing/InsertTextCommand.cpp
Source/WebCore/editing/ModifySelectionListLevel.cpp
Source/WebCore/editing/RemoveNodePreservingChildrenCommand.cpp
Source/WebCore/editing/RemoveNodePreservingChildrenCommand.h
Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
Source/WebCore/editing/ReplaceNodeWithSpanCommand.h
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/SetNodeAttributeCommand.cpp
Source/WebCore/editing/SetNodeAttributeCommand.h
Source/WebCore/editing/SimplifyMarkupCommand.cpp
Source/WebCore/editing/SimplifyMarkupCommand.h
Source/WebCore/editing/SplitElementCommand.cpp
Source/WebCore/editing/SplitElementCommand.h
Source/WebCore/editing/SplitTextNodeCommand.cpp
Source/WebCore/editing/SplitTextNodeCommand.h
Source/WebCore/editing/SplitTextNodeContainingElementCommand.cpp
Source/WebCore/editing/SplitTextNodeContainingElementCommand.h
Source/WebCore/editing/TextInsertionBaseCommand.cpp
Source/WebCore/editing/TypingCommand.cpp
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/DragController.cpp

index 7b6f56b..0bca65c 100644 (file)
@@ -1,3 +1,154 @@
+2017-05-04  Chris Dumez  <cdumez@apple.com>
+
+        Drop remaining uses of PassRefPtr from CompositeEditCommand
+        https://bugs.webkit.org/show_bug.cgi?id=171645
+
+        Reviewed by Darin Adler.
+
+        Drop remaining uses of PassRefPtr from CompositeEditCommand.
+
+        * editing/ApplyBlockElementCommand.cpp:
+        (WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded):
+        (WebCore::ApplyBlockElementCommand::endOfNextParagraphSplittingTextNodesIfNeeded):
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
+        (WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans):
+        (WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi):
+        (WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock):
+        (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
+        (WebCore::ApplyStyleCommand::removeInlineStyleFromElement):
+        (WebCore::ApplyStyleCommand::replaceWithSpanOrRemoveIfWithoutAttributes):
+        (WebCore::ApplyStyleCommand::removeImplicitlyStyledElement):
+        (WebCore::ApplyStyleCommand::removeCSSStyle):
+        (WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
+        (WebCore::ApplyStyleCommand::splitTextAtStart):
+        (WebCore::ApplyStyleCommand::splitTextAtEnd):
+        (WebCore::ApplyStyleCommand::splitTextElementAtStart):
+        (WebCore::ApplyStyleCommand::splitTextElementAtEnd):
+        (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
+        (WebCore::ApplyStyleCommand::addBlockStyle):
+        (WebCore::ApplyStyleCommand::addInlineStyleIfNeeded):
+        (WebCore::ApplyStyleCommand::applyInlineStyleChange):
+        (WebCore::ApplyStyleCommand::joinChildTextNodes):
+        * editing/BreakBlockquoteCommand.cpp:
+        (WebCore::BreakBlockquoteCommand::doApply):
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::applyCommand):
+        (WebCore::CompositeEditCommand::insertNodeAt):
+        (WebCore::CompositeEditCommand::removeChildrenInRange):
+        (WebCore::CompositeEditCommand::removeNode):
+        (WebCore::CompositeEditCommand::removeNodePreservingChildren):
+        (WebCore::CompositeEditCommand::removeNodeAndPruneAncestors):
+        (WebCore::CompositeEditCommand::moveRemainingSiblingsToNewParent):
+        (WebCore::CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAttributes):
+        (WebCore::CompositeEditCommand::prune):
+        (WebCore::CompositeEditCommand::splitTextNode):
+        (WebCore::CompositeEditCommand::splitElement):
+        (WebCore::CompositeEditCommand::mergeIdenticalElements):
+        (WebCore::CompositeEditCommand::splitTextNodeContainingElement):
+        (WebCore::CompositeEditCommand::positionOutsideTabSpan):
+        (WebCore::CompositeEditCommand::removeNodeAttribute):
+        (WebCore::CompositeEditCommand::setNodeAttribute):
+        (WebCore::CompositeEditCommand::deleteInsignificantText):
+        (WebCore::CompositeEditCommand::removePlaceholderAt):
+        (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
+        (WebCore::CompositeEditCommand::pushAnchorElementDown):
+        (WebCore::CompositeEditCommand::cleanupAfterDeletion):
+        (WebCore::CompositeEditCommand::moveParagraphs):
+        * editing/CompositeEditCommand.h:
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):
+        (WebCore::DeleteSelectionCommand::removeNodeUpdatingStates):
+        (WebCore::DeleteSelectionCommand::removeNode):
+        (WebCore::DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss):
+        (WebCore::DeleteSelectionCommand::handleGeneralDelete):
+        (WebCore::DeleteSelectionCommand::mergeParagraphs):
+        (WebCore::DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows):
+        (WebCore::DeleteSelectionCommand::removeRedundantBlocks):
+        * editing/DeleteSelectionCommand.h:
+        * editing/Editor.cpp:
+        (WebCore::ClearTextCommand::CreateAndApply):
+        (WebCore::Editor::replaceSelectionWithFragment):
+        (WebCore::Editor::handleAcceptedCandidate):
+        * editing/EditorCommand.cpp:
+        (WebCore::executeFormatBlock):
+        * editing/IndentOutdentCommand.cpp:
+        (WebCore::IndentOutdentCommand::outdentParagraph):
+        * editing/InsertLineBreakCommand.cpp:
+        (WebCore::InsertLineBreakCommand::doApply):
+        * editing/InsertListCommand.cpp:
+        (WebCore::InsertListCommand::fixOrphanedListChild):
+        (WebCore::InsertListCommand::doApplyForSingleParagraph):
+        (WebCore::InsertListCommand::unlistifyParagraph):
+        * editing/InsertParagraphSeparatorCommand.cpp:
+        (WebCore::InsertParagraphSeparatorCommand::doApply):
+        * editing/InsertTextCommand.cpp:
+        (WebCore::InsertTextCommand::insertTab):
+        * editing/ModifySelectionListLevel.cpp:
+        (WebCore::ModifySelectionListLevelCommand::insertSiblingNodeRangeBefore):
+        (WebCore::ModifySelectionListLevelCommand::insertSiblingNodeRangeAfter):
+        (WebCore::ModifySelectionListLevelCommand::appendSiblingNodeRange):
+        (WebCore::DecreaseSelectionListLevelCommand::doApply):
+        * editing/RemoveNodePreservingChildrenCommand.cpp:
+        (WebCore::RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand):
+        (WebCore::RemoveNodePreservingChildrenCommand::doApply):
+        * editing/RemoveNodePreservingChildrenCommand.h:
+        (WebCore::RemoveNodePreservingChildrenCommand::create):
+        * editing/ReplaceNodeWithSpanCommand.cpp:
+        (WebCore::ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand):
+        (WebCore::ReplaceNodeWithSpanCommand::doApply):
+        (WebCore::ReplaceNodeWithSpanCommand::doUnapply):
+        (WebCore::ReplaceNodeWithSpanCommand::getNodesInCommand):
+        * editing/ReplaceNodeWithSpanCommand.h:
+        (WebCore::ReplaceNodeWithSpanCommand::create):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplacementFragment::removeNodePreservingChildren):
+        (WebCore::ReplacementFragment::removeInterchangeNodes):
+        (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+        (WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
+        (WebCore::ReplaceSelectionCommand::moveNodeOutOfAncestor):
+        (WebCore::ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds):
+        (WebCore::handleStyleSpansBeforeInsertion):
+        (WebCore::ReplaceSelectionCommand::handleStyleSpans):
+        (WebCore::ReplaceSelectionCommand::doApply):
+        (WebCore::ReplaceSelectionCommand::mergeTextNodesAroundPosition):
+        (WebCore::ReplaceSelectionCommand::insertAsListItems):
+        (WebCore::ReplaceSelectionCommand::performTrivialReplace):
+        * editing/SetNodeAttributeCommand.cpp:
+        (WebCore::SetNodeAttributeCommand::SetNodeAttributeCommand):
+        (WebCore::SetNodeAttributeCommand::getNodesInCommand):
+        * editing/SetNodeAttributeCommand.h:
+        (WebCore::SetNodeAttributeCommand::create):
+        * editing/SimplifyMarkupCommand.cpp:
+        (WebCore::SimplifyMarkupCommand::doApply):
+        (WebCore::SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove):
+        * editing/SimplifyMarkupCommand.h:
+        * editing/SplitElementCommand.cpp:
+        (WebCore::SplitElementCommand::SplitElementCommand):
+        (WebCore::SplitElementCommand::executeApply):
+        (WebCore::SplitElementCommand::getNodesInCommand):
+        * editing/SplitElementCommand.h:
+        (WebCore::SplitElementCommand::create):
+        * editing/SplitTextNodeCommand.cpp:
+        (WebCore::SplitTextNodeCommand::SplitTextNodeCommand):
+        (WebCore::SplitTextNodeCommand::doApply):
+        (WebCore::SplitTextNodeCommand::doUnapply):
+        (WebCore::SplitTextNodeCommand::doReapply):
+        (WebCore::SplitTextNodeCommand::insertText1AndTrimText2):
+        * editing/SplitTextNodeCommand.h:
+        (WebCore::SplitTextNodeCommand::create):
+        * editing/SplitTextNodeContainingElementCommand.cpp:
+        (WebCore::SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand):
+        (WebCore::SplitTextNodeContainingElementCommand::doApply):
+        * editing/SplitTextNodeContainingElementCommand.h:
+        (WebCore::SplitTextNodeContainingElementCommand::create):
+        * editing/TextInsertionBaseCommand.cpp:
+        (WebCore::TextInsertionBaseCommand::applyTextInsertionCommand):
+        * editing/TypingCommand.cpp:
+        (WebCore::TypingCommand::makeEditableRootEmpty):
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::contextMenuItemSelected):
+
 2017-05-04  Daniel Bates  <dabates@apple.com>
 
         Fix misspelled word "interrupt" as pointed out by Darin Adler
index e2d7fbf..034f3cf 100644 (file)
@@ -267,7 +267,7 @@ void AlternativeTextController::applyAlternativeTextToRange(const Range& range,
 
     ContainerNode& rootNode = paragraphRangeContainingCorrection.get()->startContainer().treeScope().rootNode();
     int paragraphStartIndex = TextIterator::rangeLength(Range::create(rootNode.document(), &rootNode, 0, &paragraphRangeContainingCorrection->startContainer(), paragraphRangeContainingCorrection->startOffset()).ptr());
-    applyCommand(SpellingCorrectionCommand::create(rangeWithAlternative, alternative));
+    SpellingCorrectionCommand::create(rangeWithAlternative, alternative)->apply();
     // Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526
     paragraphRangeContainingCorrection = TextIterator::rangeFromLocationAndLength(&rootNode, paragraphStartIndex, correctionStartOffsetInParagraph + alternative.length());
     if (!paragraphRangeContainingCorrection)
index e54d293..89cd294 100644 (file)
@@ -212,7 +212,8 @@ void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const
         if (!startStyle->collapseWhiteSpace() && start.offsetInContainerNode() > 0) {
             int startOffset = start.offsetInContainerNode();
             Text* startText = start.containerText();
-            splitTextNode(startText, startOffset);
+            ASSERT(startText);
+            splitTextNode(*startText, startOffset);
             start = firstPositionInNode(startText);
             if (isStartAndEndOnSameNode) {
                 ASSERT(end.offsetInContainerNode() >= startOffset);
@@ -239,7 +240,7 @@ void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const
         // If end is in the middle of a text node and the text node is editable, split.
         if (endStyle->userModify() != READ_ONLY && !endStyle->collapseWhiteSpace() && end.offsetInContainerNode() && end.offsetInContainerNode() < end.containerNode()->maxCharacterOffset()) {
             RefPtr<Text> endContainer = end.containerText();
-            splitTextNode(endContainer, end.offsetInContainerNode());
+            splitTextNode(*endContainer, end.offsetInContainerNode());
             if (isStartAndEndOnSameNode)
                 start = firstPositionInOrBeforeNode(endContainer->previousSibling());
             if (isEndAndEndOfLastParagraphOnSameNode) {
@@ -268,7 +269,7 @@ VisiblePosition ApplyBlockElementCommand::endOfNextParagraphSplittingTextNodesIf
     // \n at the beginning of the text node immediately following the current paragraph is trimmed by moveParagraphWithClones.
     // If endOfNextParagraph was pointing at this same text node, endOfNextParagraph will be shifted by one paragraph.
     // Avoid this by splitting "\n"
-    splitTextNode(text, 1);
+    splitTextNode(*text, 1);
 
     if (text == start.containerNode() && is<Text>(text->previousSibling())) {
         ASSERT(start.offsetInContainerNode() < position.offsetInContainerNode());
index 5beb6aa..6037402 100644 (file)
@@ -384,7 +384,7 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(EditingStyle* style)
     }
 
     // These spans were added by us. If empty after font size changes, they can be removed.
-    Vector<RefPtr<HTMLElement>> unstyledSpans;
+    Vector<Ref<HTMLElement>> unstyledSpans;
     
     Node* lastStyledNode = nullptr;
     for (Node* node = startNode; node != beyondEnd; node = NodeTraversal::next(*node)) {
@@ -417,17 +417,17 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(EditingStyle* style)
         }
         if (currentFontSize != desiredFontSize) {
             inlineStyle->setProperty(CSSPropertyFontSize, CSSValuePool::singleton().createValue(desiredFontSize, CSSPrimitiveValue::CSS_PX), false);
-            setNodeAttribute(element.get(), styleAttr, inlineStyle->asText());
+            setNodeAttribute(*element, styleAttr, inlineStyle->asText());
         }
         if (inlineStyle->isEmpty()) {
             removeNodeAttribute(*element, styleAttr);
             if (isSpanWithoutAttributesOrUnstyledStyleSpan(*element))
-                unstyledSpans.append(WTFMove(element));
+                unstyledSpans.append(element.releaseNonNull());
         }
     }
 
     for (auto& unstyledSpan : unstyledSpans)
-        removeNodePreservingChildren(unstyledSpan.get());
+        removeNodePreservingChildren(unstyledSpan);
 }
 
 static ContainerNode* dummySpanAncestorForNode(const Node* node)
@@ -455,7 +455,7 @@ void ApplyStyleCommand::cleanupUnstyledAppleStyleSpans(ContainerNode* dummySpanA
     }
 
     for (auto& element : toRemove)
-        removeNodePreservingChildren(element);
+        removeNodePreservingChildren(*element);
 }
 
 HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool before, WritingDirection allowedDirection)
@@ -501,7 +501,7 @@ HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool b
     while (currentNode) {
         RefPtr<Element> parent = downcast<Element>(currentNode->parentNode());
         if (before ? currentNode->previousSibling() : currentNode->nextSibling())
-            splitElement(parent, before ? currentNode : currentNode->nextSibling());
+            splitElement(*parent, before ? *currentNode : *currentNode->nextSibling());
         if (parent == highestAncestorWithUnicodeBidi)
             break;
         currentNode = parent;
@@ -538,9 +538,9 @@ void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsp
             RefPtr<MutableStyleProperties> inlineStyle = copyStyleOrCreateEmpty(element.inlineStyle());
             inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
             inlineStyle->removeProperty(CSSPropertyDirection);
-            setNodeAttribute(&element, styleAttr, inlineStyle->asText());
+            setNodeAttribute(element, styleAttr, inlineStyle->asText());
             if (isSpanWithoutAttributesOrUnstyledStyleSpan(element))
-                removeNodePreservingChildren(&element);
+                removeNodePreservingChildren(element);
         }
     }
 }
@@ -792,7 +792,7 @@ void ApplyStyleCommand::applyInlineStyleToNodeRange(EditingStyle& style, Node& s
             RefPtr<MutableStyleProperties> inlineStyle = copyStyleOrCreateEmpty(element.inlineStyle());
             if (MutableStyleProperties* otherStyle = style.style())
                 inlineStyle->mergeAndOverrideOnConflict(*otherStyle);
-            setNodeAttribute(&element, styleAttr, inlineStyle->asText());
+            setNodeAttribute(element, styleAttr, inlineStyle->asText());
             next = NodeTraversal::nextSkippingChildren(*node);
             continue;
         }
@@ -838,7 +838,7 @@ void ApplyStyleCommand::applyInlineStyleToNodeRange(EditingStyle& style, Node& s
 
     for (auto& run : runs) {
         if (run.dummyElement)
-            removeNode(run.dummyElement);
+            removeNode(*run.dummyElement);
         if (run.startAndEndAreStillInDocument())
             applyInlineStyleChange(run.start.releaseNonNull(), run.end.releaseNonNull(), run.change, AddStyledElement);
     }
@@ -904,7 +904,7 @@ bool ApplyStyleCommand::removeInlineStyleFromElement(EditingStyle& style, HTMLEl
             return true;
         if (extractedStyle)
             extractedStyle->mergeInlineStyleOfElement(&element, EditingStyle::OverrideValues);
-        removeNodePreservingChildren(&element);
+        removeNodePreservingChildren(element);
         return true;
     }
 
@@ -926,9 +926,9 @@ bool ApplyStyleCommand::removeInlineStyleFromElement(EditingStyle& style, HTMLEl
 void ApplyStyleCommand::replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement& element)
 {
     if (hasNoAttributeOrOnlyStyleAttribute(element, StyleAttributeShouldBeEmpty))
-        removeNodePreservingChildren(&element);
+        removeNodePreservingChildren(element);
     else {
-        HTMLElement* newSpanElement = replaceElementWithSpanPreservingChildrenAndAttributes(&element);
+        HTMLElement* newSpanElement = replaceElementWithSpanPreservingChildrenAndAttributes(element);
         ASSERT_UNUSED(newSpanElement, newSpanElement && newSpanElement->isConnected());
     }
 }
@@ -957,7 +957,7 @@ bool ApplyStyleCommand::removeImplicitlyStyledElement(EditingStyle& style, HTMLE
         removeNodeAttribute(element, attribute);
 
     if (isEmptyFontTag(&element) || isSpanWithoutAttributesOrUnstyledStyleSpan(element))
-        removeNodePreservingChildren(&element);
+        removeNodePreservingChildren(element);
 
     return true;
 }
@@ -974,10 +974,10 @@ bool ApplyStyleCommand::removeCSSStyle(EditingStyle& style, HTMLElement& element
     if (newInlineStyle->isEmpty())
         removeNodeAttribute(element, styleAttr);
     else
-        setNodeAttribute(&element, styleAttr, newInlineStyle->asText());
+        setNodeAttribute(element, styleAttr, newInlineStyle->asText());
 
     if (isSpanWithoutAttributesOrUnstyledStyleSpan(element))
-        removeNodePreservingChildren(&element);
+        removeNodePreservingChildren(element);
 
     return true;
 }
@@ -1018,7 +1018,7 @@ void ApplyStyleCommand::applyInlineStyleToPushDown(Node& node, EditingStyle* sty
     // Since addInlineStyleIfNeeded can't add styles to block-flow render objects, add style attribute instead.
     // FIXME: applyInlineStyleToRange should be used here instead.
     if ((node.renderer()->isRenderBlockFlow() || node.hasChildNodes()) && is<HTMLElement>(node)) {
-        setNodeAttribute(&downcast<HTMLElement>(node), styleAttr, newInlineStyle->style()->asText());
+        setNodeAttribute(downcast<HTMLElement>(node), styleAttr, newInlineStyle->style()->asText());
         return;
     }
 
@@ -1198,7 +1198,7 @@ void ApplyStyleCommand::splitTextAtStart(const Position& start, const Position&
         newEnd = end;
 
     RefPtr<Text> text = start.containerText();
-    splitTextNode(text, start.offsetInContainerNode());
+    splitTextNode(*text, start.offsetInContainerNode());
     updateStartEnd(firstPositionInNode(text.get()), newEnd);
 }
 
@@ -1208,7 +1208,7 @@ void ApplyStyleCommand::splitTextAtEnd(const Position& start, const Position& en
 
     bool shouldUpdateStart = start.anchorType() == Position::PositionIsOffsetInAnchor && start.containerNode() == end.containerNode();
     Text& text = downcast<Text>(*end.deprecatedNode());
-    splitTextNode(&text, end.offsetInContainerNode());
+    splitTextNode(text, end.offsetInContainerNode());
 
     Node* prevNode = text.previousSibling();
     if (!is<Text>(prevNode))
@@ -1228,7 +1228,7 @@ void ApplyStyleCommand::splitTextElementAtStart(const Position& start, const Pos
     else
         newEnd = end;
 
-    splitTextNodeContainingElement(start.containerText(), start.offsetInContainerNode());
+    splitTextNodeContainingElement(*start.containerText(), start.offsetInContainerNode());
     updateStartEnd(positionBeforeNode(start.containerNode()), newEnd);
 }
 
@@ -1237,7 +1237,7 @@ void ApplyStyleCommand::splitTextElementAtEnd(const Position& start, const Posit
     ASSERT(is<Text>(end.containerNode()));
 
     bool shouldUpdateStart = start.containerNode() == end.containerNode();
-    splitTextNodeContainingElement(end.containerText(), end.offsetInContainerNode());
+    splitTextNodeContainingElement(*end.containerText(), end.offsetInContainerNode());
 
     Node* parentElement = end.containerNode()->parentNode();
     if (!parentElement || !parentElement->previousSibling())
@@ -1343,7 +1343,7 @@ void ApplyStyleCommand::surroundNodeRangeWithElement(Node& startNode, Node& endN
     while (node) {
         RefPtr<Node> next = node->nextSibling();
         if (isEditableNode(*node)) {
-            removeNode(node);
+            removeNode(*node);
             appendNode(*node, element.copyRef());
         }
         if (node == &endNode)
@@ -1383,7 +1383,7 @@ void ApplyStyleCommand::addBlockStyle(const StyleChange& styleChange, HTMLElemen
             cssText.append(' ');
         cssText.append(decl->asText());
     }
-    setNodeAttribute(&block, styleAttr, cssText.toString());
+    setNodeAttribute(block, styleAttr, cssText.toString());
 }
 
 void ApplyStyleCommand::addInlineStyleIfNeeded(EditingStyle* style, Node& start, Node& end, EAddStyledElement addStyledElement)
@@ -1396,7 +1396,7 @@ void ApplyStyleCommand::addInlineStyleIfNeeded(EditingStyle* style, Node& start,
     StyleChange styleChange(style, positionToComputeInlineStyleChange(start, dummyElement));
 
     if (dummyElement)
-        removeNode(dummyElement);
+        removeNode(*dummyElement);
 
     applyInlineStyleChange(start, end, styleChange, addStyledElement);
 }
@@ -1442,11 +1442,11 @@ void ApplyStyleCommand::applyInlineStyleChange(Node& passedStart, Node& passedEn
     if (styleChange.applyFontColor() || styleChange.applyFontFace() || styleChange.applyFontSize()) {
         if (fontContainer) {
             if (styleChange.applyFontColor())
-                setNodeAttribute(fontContainer, colorAttr, styleChange.fontColor());
+                setNodeAttribute(*fontContainer, colorAttr, styleChange.fontColor());
             if (styleChange.applyFontFace())
-                setNodeAttribute(fontContainer, faceAttr, styleChange.fontFace());
+                setNodeAttribute(*fontContainer, faceAttr, styleChange.fontFace());
             if (styleChange.applyFontSize())
-                setNodeAttribute(fontContainer, sizeAttr, styleChange.fontSize());
+                setNodeAttribute(*fontContainer, sizeAttr, styleChange.fontSize());
         } else {
             auto fontElement = createFontElement(document());
             if (styleChange.applyFontColor())
@@ -1464,9 +1464,9 @@ void ApplyStyleCommand::applyInlineStyleChange(Node& passedStart, Node& passedEn
             if (auto existingStyle = styleContainer->inlineStyle()) {
                 auto inlineStyle = EditingStyle::create(existingStyle);
                 inlineStyle->overrideWithStyle(styleToMerge);
-                setNodeAttribute(styleContainer, styleAttr, inlineStyle->style()->asText());
+                setNodeAttribute(*styleContainer, styleAttr, inlineStyle->style()->asText());
             } else
-                setNodeAttribute(styleContainer, styleAttr, styleToMerge->asText());
+                setNodeAttribute(*styleContainer, styleAttr, styleToMerge->asText());
         } else {
             auto styleElement = createStyleSpanElement(document());
             styleElement->setAttribute(styleAttr, styleToMerge->asText());
@@ -1528,7 +1528,7 @@ void ApplyStyleCommand::joinChildTextNodes(Node* node, const Position& start, co
             newEnd = Position(childText.ptr(), childText->length() + end.offsetInContainerNode());
         String textToMove = nextText.data();
         insertTextIntoNode(childText, childText->length(), textToMove);
-        removeNode(next);
+        removeNode(*next);
         // don't move child node pointer. it may want to merge with more text nodes.
     }
 
index 982cc99..5821b08 100644 (file)
@@ -112,7 +112,7 @@ void BreakBlockquoteCommand::doApply()
             startNode = NodeTraversal::next(*startNode);
             ASSERT(startNode);
         } else if (pos.deprecatedEditingOffset() > 0)
-            splitTextNode(&textNode, pos.deprecatedEditingOffset());
+            splitTextNode(textNode, pos.deprecatedEditingOffset());
     } else if (pos.deprecatedEditingOffset() > 0) {
         Node* childAtOffset = startNode->traverseToChildAt(pos.deprecatedEditingOffset());
         startNode = childAtOffset ? childAtOffset : NodeTraversal::next(*startNode);
@@ -149,14 +149,14 @@ void BreakBlockquoteCommand::doApply()
             while (listChildNode && !listChildNode->hasTagName(liTag))
                 listChildNode = listChildNode->nextSibling();
             if (listChildNode && is<RenderListItem>(listChildNode->renderer()))
-                setNodeAttribute(clonedChild.ptr(), startAttr, AtomicString::number(downcast<RenderListItem>(*listChildNode->renderer()).value()));
+                setNodeAttribute(clonedChild, startAttr, AtomicString::number(downcast<RenderListItem>(*listChildNode->renderer()).value()));
         }
             
         appendNode(clonedChild.copyRef(), clonedAncestor.releaseNonNull());
         clonedAncestor = WTFMove(clonedChild);
     }
 
-    moveRemainingSiblingsToNewParent(startNode, 0, clonedAncestor);
+    moveRemainingSiblingsToNewParent(startNode, 0, *clonedAncestor);
 
     if (!ancestors.isEmpty()) {
         // Split the tree up the ancestor chain until the topBlockquote
@@ -168,12 +168,12 @@ void BreakBlockquoteCommand::doApply()
         for (ancestor = ancestors.first(), clonedParent = clonedAncestor->parentElement();
              ancestor && ancestor != topBlockquote;
              ancestor = ancestor->parentElement(), clonedParent = clonedParent->parentElement())
-            moveRemainingSiblingsToNewParent(ancestor->nextSibling(), 0, clonedParent);
+            moveRemainingSiblingsToNewParent(ancestor->nextSibling(), 0, *clonedParent);
 
         // If the startNode's original parent is now empty, remove it
         Node* originalParent = ancestors.first().get();
         if (!originalParent->hasChildNodes())
-            removeNode(originalParent);
+            removeNode(*originalParent);
     }
     
     // Make sure the cloned block quote renders.
index 8aabb32..780ca6f 100644 (file)
@@ -302,11 +302,6 @@ void EditCommandComposition::getNodesInCommand(HashSet<Node*>& nodes)
 }
 #endif
 
-void applyCommand(PassRefPtr<CompositeEditCommand> command)
-{
-    command->apply();
-}
-
 CompositeEditCommand::CompositeEditCommand(Document& document, EditAction editingAction)
     : EditCommand(document, editingAction)
 {
@@ -565,7 +560,7 @@ void CompositeEditCommand::insertNodeAt(Ref<Node>&& insertChild, const Position&
     } else if (caretMinOffset(*refChild) >= offset)
         insertNodeBefore(WTFMove(insertChild), *refChild);
     else if (is<Text>(*refChild) && caretMaxOffset(*refChild) > offset) {
-        splitTextNode(downcast<Text>(refChild), offset);
+        splitTextNode(downcast<Text>(*refChild), offset);
 
         // Mutation events (bug 22634) from the text node insertion may have removed the refChild
         if (!refChild->isConnected())
@@ -583,45 +578,45 @@ void CompositeEditCommand::appendNode(Ref<Node>&& node, Ref<ContainerNode>&& par
 
 void CompositeEditCommand::removeChildrenInRange(Node& node, unsigned from, unsigned to)
 {
-    Vector<RefPtr<Node>> children;
+    Vector<Ref<Node>> children;
     Node* child = node.traverseToChildAt(from);
     for (unsigned i = from; child && i < to; i++, child = child->nextSibling())
-        children.append(child);
+        children.append(*child);
 
     for (auto& child : children)
-        removeNode(WTFMove(child));
+        removeNode(child);
 }
 
-void CompositeEditCommand::removeNode(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
+void CompositeEditCommand::removeNode(Node& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
 {
-    if (!node || !node->nonShadowBoundaryParentNode())
+    if (!node.nonShadowBoundaryParentNode())
         return;
-    applyCommandToComposite(RemoveNodeCommand::create(*node, shouldAssumeContentIsAlwaysEditable, editingAction()));
+    applyCommandToComposite(RemoveNodeCommand::create(node, shouldAssumeContentIsAlwaysEditable, editingAction()));
 }
 
-void CompositeEditCommand::removeNodePreservingChildren(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
+void CompositeEditCommand::removeNodePreservingChildren(Node& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
 {
     applyCommandToComposite(RemoveNodePreservingChildrenCommand::create(node, shouldAssumeContentIsAlwaysEditable, editingAction()));
 }
 
-void CompositeEditCommand::removeNodeAndPruneAncestors(PassRefPtr<Node> node)
+void CompositeEditCommand::removeNodeAndPruneAncestors(Node& node)
 {
-    RefPtr<ContainerNode> parent = node->parentNode();
+    RefPtr<ContainerNode> parent = node.parentNode();
     removeNode(node);
-    prune(WTFMove(parent));
+    prune(parent.get());
 }
 
-void CompositeEditCommand::moveRemainingSiblingsToNewParent(Node* node, Node* pastLastNodeToMove, PassRefPtr<Element> prpNewParent)
+void CompositeEditCommand::moveRemainingSiblingsToNewParent(Node* node, Node* pastLastNodeToMove, Element& newParent)
 {
     NodeVector nodesToRemove;
-    RefPtr<Element> newParent = prpNewParent;
+    Ref<Element> protectedNewParent = newParent;
 
     for (; node && node != pastLastNodeToMove; node = node->nextSibling())
         nodesToRemove.append(*node);
 
     for (auto& nodeToRemove : nodesToRemove) {
-        removeNode(nodeToRemove.ptr());
-        appendNode(WTFMove(nodeToRemove), *newParent);
+        removeNode(nodeToRemove);
+        appendNode(WTFMove(nodeToRemove), newParent);
     }
 }
 
@@ -633,12 +628,12 @@ void CompositeEditCommand::updatePositionForNodeRemovalPreservingChildren(Positi
         position.moveToOffset(offset);    
 }
 
-HTMLElement* CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAttributes(PassRefPtr<HTMLElement> node)
+HTMLElement* CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAttributes(HTMLElement& element)
 {
     // It would also be possible to implement all of ReplaceNodeWithSpanCommand
     // as a series of existing smaller edit commands.  Someone who wanted to
     // reduce the number of edit commands could do so here.
-    auto command = ReplaceNodeWithSpanCommand::create(node);
+    auto command = ReplaceNodeWithSpanCommand::create(element);
     auto* commandPtr = command.ptr();
     applyCommandToComposite(WTFMove(command));
     // Returning a raw pointer here is OK because the command is retained by
@@ -648,18 +643,18 @@ HTMLElement* CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAt
     return commandPtr->spanElement();
 }
 
-void CompositeEditCommand::prune(PassRefPtr<Node> node)
+void CompositeEditCommand::prune(Node* node)
 {
-    if (RefPtr<Node> highestNodeToRemove = highestNodeToRemoveInPruning(node.get()))
-        removeNode(WTFMove(highestNodeToRemove));
+    if (auto* highestNodeToRemove = highestNodeToRemoveInPruning(node))
+        removeNode(*highestNodeToRemove);
 }
 
-void CompositeEditCommand::splitTextNode(PassRefPtr<Text> node, unsigned offset)
+void CompositeEditCommand::splitTextNode(Text& node, unsigned offset)
 {
     applyCommandToComposite(SplitTextNodeCommand::create(node, offset));
 }
 
-void CompositeEditCommand::splitElement(PassRefPtr<Element> element, PassRefPtr<Node> atChild)
+void CompositeEditCommand::splitElement(Element& element, Node& atChild)
 {
     applyCommandToComposite(SplitElementCommand::create(element, atChild));
 }
@@ -670,7 +665,7 @@ void CompositeEditCommand::mergeIdenticalElements(Element& first, Element& secon
     Ref<Element> protectedSecond = second;
     ASSERT(!first.isDescendantOf(&second) && &second != &first);
     if (first.nextSibling() != &second) {
-        removeNode(&second);
+        removeNode(second);
         insertNodeAfter(second, first);
     }
     applyCommandToComposite(MergeIdenticalElementsCommand::create(first, second));
@@ -681,7 +676,7 @@ void CompositeEditCommand::wrapContentsInDummySpan(Element& element)
     applyCommandToComposite(WrapContentsInDummySpanCommand::create(element));
 }
 
-void CompositeEditCommand::splitTextNodeContainingElement(PassRefPtr<Text> text, unsigned offset)
+void CompositeEditCommand::splitTextNodeContainingElement(Text& text, unsigned offset)
 {
     applyCommandToComposite(SplitTextNodeContainingElementCommand::create(text, offset));
 }
@@ -808,7 +803,7 @@ Position CompositeEditCommand::positionOutsideTabSpan(const Position& position)
     if (position.offsetInContainerNode() >= caretMaxOffset(*position.containerNode()))
         return positionInParentAfterNode(tabSpan);
 
-    splitTextNodeContainingElement(&downcast<Text>(*position.containerNode()), position.offsetInContainerNode());
+    splitTextNodeContainingElement(downcast<Text>(*position.containerNode()), position.offsetInContainerNode());
     return positionInParentBeforeNode(tabSpan);
 }
 
@@ -842,10 +837,10 @@ void CompositeEditCommand::deleteSelection(const VisibleSelection &selection, bo
 
 void CompositeEditCommand::removeNodeAttribute(Element& element, const QualifiedName& attribute)
 {
-    setNodeAttribute(&element, attribute, nullAtom);
+    setNodeAttribute(element, attribute, nullAtom);
 }
 
-void CompositeEditCommand::setNodeAttribute(PassRefPtr<Element> element, const QualifiedName& attribute, const AtomicString& value)
+void CompositeEditCommand::setNodeAttribute(Element& element, const QualifiedName& attribute, const AtomicString& value)
 {
     applyCommandToComposite(SetNodeAttributeCommand::create(element, attribute, value));
 }
@@ -998,7 +993,7 @@ void CompositeEditCommand::deleteInsignificantText(Text& textNode, unsigned star
 
     if (!box) {
         // whole text node is empty
-        removeNode(&textNode);
+        removeNode(textNode);
         return;    
     }
     
@@ -1134,7 +1129,7 @@ void CompositeEditCommand::removePlaceholderAt(const Position& p)
     
     // We are certain that the position is at a line break, but it may be a br or a preserved newline.
     if (is<HTMLBRElement>(*p.anchorNode())) {
-        removeNode(p.anchorNode());
+        removeNode(*p.anchorNode());
         return;
     }
     
@@ -1210,7 +1205,7 @@ RefPtr<Node> CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(co
     moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition(firstPositionInNode(newBlock.ptr())));
 
     if (newBlock->lastChild() && newBlock->lastChild()->hasTagName(brTag) && !endWasBr)
-        removeNode(newBlock->lastChild());
+        removeNode(*newBlock->lastChild());
 
     return WTFMove(newBlock);
 }
@@ -1223,7 +1218,7 @@ void CompositeEditCommand::pushAnchorElementDown(Element& anchorElement)
     applyStyledElement(anchorElement);
     // Clones of anchorElement have been pushed down, now remove it.
     if (anchorElement.isConnected())
-        removeNodePreservingChildren(&anchorElement);
+        removeNodePreservingChildren(anchorElement);
 }
 
 // Clone the paragraph between start and end under blockElement,
@@ -1308,7 +1303,7 @@ void CompositeEditCommand::cleanupAfterDeletion(VisiblePosition destination)
         ASSERT(node);
         // Normally deletion will leave a br as a placeholder.
         if (is<HTMLBRElement>(*node))
-            removeNodeAndPruneAncestors(node);
+            removeNodeAndPruneAncestors(*node);
         // If the selection to move was empty and in an empty block that 
         // doesn't require a placeholder to prop itself open (like a bordered
         // div or an li), remove it during the move (the list removal code
@@ -1320,14 +1315,14 @@ void CompositeEditCommand::cleanupAfterDeletion(VisiblePosition destination)
                 prune(node);
                 return;
             }
-            removeNodeAndPruneAncestors(node);
+            removeNodeAndPruneAncestors(*node);
         }
         else if (lineBreakExistsAtPosition(position)) {
             // There is a preserved '\n' at caretAfterDelete.
             // We can safely assume this is a text node.
             Text& textNode = downcast<Text>(*node);
             if (textNode.length() == 1)
-                removeNodeAndPruneAncestors(node);
+                removeNodeAndPruneAncestors(textNode);
             else
                 deleteTextFromNode(textNode, position.deprecatedEditingOffset(), 1);
         }
@@ -1555,8 +1550,8 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
                 // 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(downcast<HTMLLIElement>(blockEnclosingList), listNode);
-                removeNodePreservingChildren(listNode->parentNode());
+                splitElement(downcast<HTMLLIElement>(*blockEnclosingList), *listNode);
+                removeNodePreservingChildren(*listNode->parentNode());
                 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.
@@ -1571,18 +1566,18 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
     if (isListItem(nextListNode.get()) || isListHTMLElement(nextListNode.get())) {
         // If emptyListItem follows another list item or nested list, split the list node.
         if (isListItem(previousListNode.get()) || isListHTMLElement(previousListNode.get()))
-            splitElement(downcast<Element>(listNode), emptyListItem);
+            splitElement(downcast<Element>(*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.
         // i.e. insert newBlock before ul or ol whose first element is emptyListItem
         insertNodeBefore(*newBlock, *listNode);
-        removeNode(emptyListItem);
+        removeNode(*emptyListItem);
     } 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.
         insertNodeAfter(*newBlock, *listNode);
-        removeNode(isListItem(previousListNode.get()) || isListHTMLElement(previousListNode.get()) ? emptyListItem : listNode);
+        removeNode(isListItem(previousListNode.get()) || isListHTMLElement(previousListNode.get()) ? *emptyListItem : *listNode);
     }
 
     appendBlockPlaceholder(*newBlock);
@@ -1636,7 +1631,7 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph()
     ASSERT(caretPos.deprecatedNode()->hasTagName(brTag) || (caretPos.deprecatedNode()->isTextNode() && caretPos.deprecatedNode()->renderer()->style().preserveNewline()));
     
     if (caretPos.deprecatedNode()->hasTagName(brTag))
-        removeNodeAndPruneAncestors(caretPos.deprecatedNode());
+        removeNodeAndPruneAncestors(*caretPos.deprecatedNode());
     else if (is<Text>(*caretPos.deprecatedNode())) {
         ASSERT(caretPos.deprecatedEditingOffset() == 0);
         Text& textNode = downcast<Text>(*caretPos.deprecatedNode());
@@ -1731,7 +1726,7 @@ RefPtr<Node> CompositeEditCommand::splitTreeToNode(Node* start, Node* end, bool
         VisiblePosition positionInParent = firstPositionInNode(node->parentNode());
         VisiblePosition positionInNode = firstPositionInOrBeforeNode(node.get());
         if (positionInParent != positionInNode)
-            splitElement(downcast<Element>(node->parentNode()), node);
+            splitElement(downcast<Element>(*node->parentNode()), *node);
     }
 
     return node;
index abe1c8b..688a23b 100644 (file)
@@ -161,21 +161,21 @@ protected:
     bool shouldRebalanceLeadingWhitespaceFor(const String&) const;
     void removeNodeAttribute(Element&, const QualifiedName& attribute);
     void removeChildrenInRange(Node&, unsigned from, unsigned to);
-    virtual void removeNode(PassRefPtr<Node>, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable);
-    HTMLElement* replaceElementWithSpanPreservingChildrenAndAttributes(PassRefPtr<HTMLElement>);
-    void removeNodePreservingChildren(PassRefPtr<Node>, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable);
-    void removeNodeAndPruneAncestors(PassRefPtr<Node>);
-    void moveRemainingSiblingsToNewParent(Node*, Node* pastLastNodeToMove, PassRefPtr<Element> prpNewParent);
+    virtual void removeNode(Node&, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable);
+    HTMLElement* replaceElementWithSpanPreservingChildrenAndAttributes(HTMLElement&);
+    void removeNodePreservingChildren(Node&, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable);
+    void removeNodeAndPruneAncestors(Node&);
+    void moveRemainingSiblingsToNewParent(Node*, Node* pastLastNodeToMove, Element& newParent);
     void updatePositionForNodeRemovalPreservingChildren(Position&, Node&);
-    void prune(PassRefPtr<Node>);
+    void prune(Node*);
     void replaceTextInNode(Text&, unsigned offset, unsigned count, const String& replacementText);
     Position replaceSelectedTextInNode(const String&);
     void replaceTextInNodePreservingMarkers(Text&, unsigned offset, unsigned count, const String& replacementText);
     Position positionOutsideTabSpan(const Position&);
-    void setNodeAttribute(PassRefPtr<Element>, const QualifiedName& attribute, const AtomicString& value);
-    void splitElement(PassRefPtr<Element>, PassRefPtr<Node> atChild);
-    void splitTextNode(PassRefPtr<Text>, unsigned offset);
-    void splitTextNodeContainingElement(PassRefPtr<Text>, unsigned offset);
+    void setNodeAttribute(Element&, const QualifiedName& attribute, const AtomicString& value);
+    void splitElement(Element&, Node& atChild);
+    void splitTextNode(Text&, unsigned offset);
+    void splitTextNodeContainingElement(Text&, unsigned offset);
     void wrapContentsInDummySpan(Element&);
 
     void deleteInsignificantText(Text&, unsigned start, unsigned end);
@@ -214,8 +214,6 @@ private:
 
     RefPtr<EditCommandComposition> m_composition;
 };
-    
-void applyCommand(PassRefPtr<CompositeEditCommand>);
 
 inline CompositeEditCommand* toCompositeEditCommand(EditCommand* command)
 {
index c5cee71..a705be1 100644 (file)
@@ -320,7 +320,7 @@ bool DeleteSelectionCommand::handleSpecialCaseBRDelete()
     bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && ((nodeAfterDownstreamStart == nodeAfterUpstreamEnd) || (nodeAfterUpstreamEnd && nodeAfterUpstreamEnd->hasTagName(brTag) && nodeAfterUpstreamStart->nextSibling() == nodeAfterUpstreamEnd));
 
     if (isBROnLineByItself) {
-        removeNode(nodeAfterDownstreamStart);
+        removeNode(*nodeAfterDownstreamStart);
         return true;
     }
 
@@ -368,7 +368,7 @@ void DeleteSelectionCommand::removeNodeUpdatingStates(Node& node, ShouldAssumeCo
     updatePositionForNodeRemoval(m_leadingWhitespace, node);
     updatePositionForNodeRemoval(m_trailingWhitespace, node);
     
-    CompositeEditCommand::removeNode(&node, shouldAssumeContentIsAlwaysEditable);
+    CompositeEditCommand::removeNode(node, shouldAssumeContentIsAlwaysEditable);
 }
     
 static inline bool shouldRemoveContentOnly(const Node& node)
@@ -376,24 +376,22 @@ static inline bool shouldRemoveContentOnly(const Node& node)
     return isTableStructureNode(&node) || node.isRootEditableElement();
 }
 
-void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
+void DeleteSelectionCommand::removeNode(Node& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
 {
-    if (!node)
-        return;
-        
-    if (m_startRoot != m_endRoot && !(node->isDescendantOf(m_startRoot.get()) && node->isDescendantOf(m_endRoot.get()))) {
+    Ref<Node> protectedNode = node;
+    if (m_startRoot != m_endRoot && !(node.isDescendantOf(m_startRoot.get()) && node.isDescendantOf(m_endRoot.get()))) {
         // If a node is not in both the start and end editable roots, remove it only if its inside an editable region.
-        if (!node->parentNode()->hasEditableStyle()) {
+        if (!node.parentNode()->hasEditableStyle()) {
             // Don't remove non-editable atomic nodes.
-            if (!node->firstChild())
+            if (!node.firstChild())
                 return;
             // Search this non-editable region for editable regions to empty.
-            RefPtr<Node> child = node->firstChild();
+            RefPtr<Node> child = node.firstChild();
             while (child) {
                 RefPtr<Node> nextChild = child->nextSibling();
-                removeNode(child.get(), shouldAssumeContentIsAlwaysEditable);
+                removeNode(*child, shouldAssumeContentIsAlwaysEditable);
                 // Bail if nextChild is no longer node's child.
-                if (nextChild && nextChild->parentNode() != node)
+                if (nextChild && nextChild->parentNode() != &node)
                     return;
                 child = nextChild;
             }
@@ -403,22 +401,22 @@ void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node, ShouldAssumeConte
         }
     }
     
-    if (shouldRemoveContentOnly(*node)) {
+    if (shouldRemoveContentOnly(node)) {
         // Do not remove an element of table structure; remove its contents.
         // Likewise for the root editable element.
-        auto* child = NodeTraversal::next(*node, node.get());
+        auto* child = NodeTraversal::next(node, &node);
         while (child) {
             if (shouldRemoveContentOnly(*child)) {
-                child = NodeTraversal::next(*child, node.get());
+                child = NodeTraversal::next(*child, &node);
                 continue;
             }
             auto* remove = child;
-            child = NodeTraversal::nextSkippingChildren(*child, node.get());
+            child = NodeTraversal::nextSkippingChildren(*child, &node);
             removeNodeUpdatingStates(*remove, shouldAssumeContentIsAlwaysEditable);
         }
         
-        ASSERT(is<Element>(*node));
-        auto& element = downcast<Element>(*node);
+        ASSERT(is<Element>(node));
+        auto& element = downcast<Element>(node);
         document().updateLayoutIgnorePendingStylesheets();
         // Check if we need to insert a placeholder for descendant table cells.
         auto* descendant = ElementTraversal::next(element, &element);
@@ -430,7 +428,7 @@ void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node, ShouldAssumeConte
         insertBlockPlaceholderForTableCellIfNeeded(element);
         return;
     }
-    removeNodeUpdatingStates(*node, shouldAssumeContentIsAlwaysEditable);
+    removeNodeUpdatingStates(node, shouldAssumeContentIsAlwaysEditable);
 }
 
 static void updatePositionForTextRemoval(Node* node, int offset, int count, Position& position)
@@ -465,7 +463,7 @@ void DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPr
             nextNode = NodeTraversal::nextSkippingChildren(*node);
             RefPtr<ContainerNode> rootEditableElement = node->rootEditableElement();
             if (rootEditableElement) {
-                removeNode(node);
+                removeNode(*node);
                 appendNode(*node, *rootEditableElement);
             }
         }
@@ -521,7 +519,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
 
         // The selection to delete is all in one node.
         if (!startNode->renderer() || (!startOffset && m_downstreamEnd.atLastEditingPositionForNode()))
-            removeNode(startNode);
+            removeNode(*startNode);
     }
     else {
         bool startNodeWasDescendantOfEndNode = m_upstreamStart.deprecatedNode()->isDescendantOf(m_downstreamEnd.deprecatedNode());
@@ -552,12 +550,12 @@ void DeleteSelectionCommand::handleGeneralDelete()
                 // if we just removed a node from the end container, update end position so the
                 // check above will work
                 updatePositionForNodeRemoval(m_downstreamEnd, *node);
-                removeNode(node.get());
+                removeNode(*node);
                 node = nextNode.get();
             } else {
                 Node* n = node->lastDescendant();
                 if (m_downstreamEnd.deprecatedNode() == n && m_downstreamEnd.deprecatedEditingOffset() >= caretMaxOffset(*n)) {
-                    removeNode(node.get());
+                    removeNode(*node);
                     node = nullptr;
                 } else
                     node = NodeTraversal::next(*node);
@@ -567,7 +565,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
         if (m_downstreamEnd.deprecatedNode() != startNode && !m_upstreamStart.deprecatedNode()->isDescendantOf(m_downstreamEnd.deprecatedNode()) && m_downstreamEnd.anchorNode()->isConnected() && m_downstreamEnd.deprecatedEditingOffset() >= caretMinOffset(*m_downstreamEnd.deprecatedNode())) {
             if (m_downstreamEnd.atLastEditingPositionForNode() && !canHaveChildrenForEditing(*m_downstreamEnd.deprecatedNode())) {
                 // The node itself is fully selected, not just its contents.  Delete it.
-                removeNode(m_downstreamEnd.deprecatedNode());
+                removeNode(*m_downstreamEnd.deprecatedNode());
             } else {
                 if (is<Text>(*m_downstreamEnd.deprecatedNode())) {
                     // in a text node that needs to be trimmed
@@ -621,7 +619,7 @@ void DeleteSelectionCommand::mergeParagraphs()
     if (!m_mergeBlocksAfterDelete) {
         if (m_pruneStartBlockIfNecessary) {
             // We aren't going to merge into the start block, so remove it if it's empty.
-            prune(m_startBlock);
+            prune(m_startBlock.get());
             // Removing the start block during a deletion is usually an indication that we need
             // a placeholder, but not in this case.
             m_needPlaceholder = false;
@@ -650,8 +648,11 @@ void DeleteSelectionCommand::mergeParagraphs()
     // m_downstreamEnd's block has been emptied out by deletion.  There is no content inside of it to
     // move, so just remove it.
     Element* endBlock = enclosingBlock(m_downstreamEnd.deprecatedNode());
-    if (!endBlock || !endBlock->contains(startOfParagraphToMove.deepEquivalent().deprecatedNode()) || !startOfParagraphToMove.deepEquivalent().deprecatedNode()) {
-        removeNode(enclosingBlock(m_downstreamEnd.deprecatedNode()));
+    if (!endBlock)
+        return;
+
+    if (!endBlock->contains(startOfParagraphToMove.deepEquivalent().deprecatedNode()) || !startOfParagraphToMove.deepEquivalent().deprecatedNode()) {
+        removeNode(*endBlock);
         return;
     }
     
@@ -673,7 +674,7 @@ void DeleteSelectionCommand::mergeParagraphs()
     // FIXME: Consider RTL.
     if (!m_startsAtEmptyLine && isStartOfParagraph(mergeDestination) && startOfParagraphToMove.absoluteCaretBounds().x() > mergeDestination.absoluteCaretBounds().x()) {
         if (mergeDestination.deepEquivalent().downstream().deprecatedNode()->hasTagName(brTag)) {
-            removeNodeAndPruneAncestors(mergeDestination.deepEquivalent().downstream().deprecatedNode());
+            removeNodeAndPruneAncestors(*mergeDestination.deepEquivalent().downstream().deprecatedNode());
             m_endingPosition = startOfParagraphToMove.deepEquivalent();
             return;
         }
@@ -711,7 +712,7 @@ void DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows()
             if (isTableRowEmpty(row))
                 // Use a raw removeNode, instead of DeleteSelectionCommand's, because
                 // that won't remove rows, it only empties them in preparation for this function.
-                CompositeEditCommand::removeNode(row);
+                CompositeEditCommand::removeNode(*row);
             row = previousRow.get();
         }
     }
@@ -722,7 +723,7 @@ void DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows()
         while (row && row != m_endTableRow) {
             RefPtr<Node> nextRow = row->nextSibling();
             if (isTableRowEmpty(row))
-                CompositeEditCommand::removeNode(row);
+                CompositeEditCommand::removeNode(*row);
             row = nextRow.get();
         }
     }
@@ -734,7 +735,7 @@ void DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows()
                 // FIXME: We probably shouldn't remove m_endTableRow unless it's fully selected, even if it is empty.
                 // We'll need to start adjusting the selection endpoints during deletion to know whether or not m_endTableRow
                 // was fully selected here.
-                CompositeEditCommand::removeNode(m_endTableRow.get());
+                CompositeEditCommand::removeNode(*m_endTableRow);
             }
         }
     }
@@ -811,7 +812,7 @@ void DeleteSelectionCommand::removeRedundantBlocks()
             if (node == m_endingPosition.anchorNode())
                 updatePositionForNodeRemovalPreservingChildren(m_endingPosition, *node);
             
-            CompositeEditCommand::removeNodePreservingChildren(node);
+            CompositeEditCommand::removeNodePreservingChildren(*node);
             node = m_endingPosition.anchorNode();
         } else
             node = node->parentNode();
index 6d8a7c2..296ad9e 100644 (file)
@@ -66,7 +66,7 @@ private:
     void calculateTypingStyleAfterDelete();
     void clearTransientState();
     void makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss();
-    void removeNode(PassRefPtr<Node>, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable) override;
+    void removeNode(Node&, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable) override;
     void deleteTextFromNode(Text&, unsigned, unsigned) override;
     void removeRedundantBlocks();
 
index c3dd48c..e34b411 100644 (file)
@@ -176,7 +176,7 @@ void ClearTextCommand::CreateAndApply(const RefPtr<Frame> frame)
     frame->selection().selectAll();
     auto clearCommand = adoptRef(*new ClearTextCommand(*frame->document()));
     clearCommand->setStartingSelection(oldSelection);
-    applyCommand(WTFMove(clearCommand));
+    clearCommand->apply();
 }
 
 using namespace HTMLNames;
@@ -414,7 +414,7 @@ void Editor::deleteSelectionWithSmartDelete(bool smartDelete, EditAction editing
     if (m_frame.selection().isNone())
         return;
 
-    applyCommand(DeleteSelectionCommand::create(document(), smartDelete, true, false, false, true, editingAction));
+    DeleteSelectionCommand::create(document(), smartDelete, true, false, false, true, editingAction)->apply();
 }
 
 void Editor::clearText()
@@ -506,7 +506,7 @@ void Editor::replaceSelectionWithFragment(DocumentFragment& fragment, bool selec
         options |= ReplaceSelectionCommand::IgnoreMailBlockquote;
 
     auto command = ReplaceSelectionCommand::create(document(), &fragment, options, editingAction);
-    applyCommand(command.ptr());
+    command->apply();
     revealSelectionAfterEditingOperation();
 
     selection = m_frame.selection().selection();
@@ -729,7 +729,7 @@ void Editor::decreaseSelectionListLevel()
 
 void Editor::removeFormattingAndStyle()
 {
-    applyCommand(RemoveFormatCommand::create(document()));
+    RemoveFormatCommand::create(document())->apply();
 }
 
 void Editor::clearLastEditCommand() 
@@ -808,7 +808,7 @@ void Editor::applyStyle(RefPtr<EditingStyle>&& style, EditAction editingAction)
         computeAndSetTypingStyle(*style, editingAction);
         break;
     case VisibleSelection::RangeSelection:
-        applyCommand(ApplyStyleCommand::create(document(), style.get(), editingAction));
+        ApplyStyleCommand::create(document(), style.get(), editingAction)->apply();
         break;
     default:
         break;
@@ -839,7 +839,7 @@ void Editor::applyParagraphStyle(StyleProperties* style, EditAction editingActio
     if (element && !dispatchBeforeInputEvent(*element, inputTypeName, inputEventData))
         return;
 
-    applyCommand(ApplyStyleCommand::create(document(), EditingStyle::create(style).ptr(), editingAction, ApplyStyleCommand::ForceBlockProperties));
+    ApplyStyleCommand::create(document(), EditingStyle::create(style).ptr(), editingAction, ApplyStyleCommand::ForceBlockProperties)->apply();
     client()->didApplyStyle();
     if (element)
         dispatchInputEvent(*element, inputTypeName, inputEventData);
@@ -901,12 +901,12 @@ String Editor::selectionStartCSSPropertyValue(CSSPropertyID propertyID)
 
 void Editor::indent()
 {
-    applyCommand(IndentOutdentCommand::create(document(), IndentOutdentCommand::Indent));
+    IndentOutdentCommand::create(document(), IndentOutdentCommand::Indent)->apply();
 }
 
 void Editor::outdent()
 {
-    applyCommand(IndentOutdentCommand::create(document(), IndentOutdentCommand::Outdent));
+    IndentOutdentCommand::create(document(), IndentOutdentCommand::Outdent)->apply();
 }
 
 static void notifyTextFromControls(Element* startRoot, Element* endRoot)
@@ -1331,7 +1331,7 @@ void Editor::simplifyMarkup(Node* startNode, Node* endNode)
             return;
     }
     
-    applyCommand(SimplifyMarkupCommand::create(document(), startNode, endNode ? NodeTraversal::next(*endNode) : nullptr));
+    SimplifyMarkupCommand::create(document(), startNode, endNode ? NodeTraversal::next(*endNode) : nullptr)->apply();
 }
 
 void Editor::copyURL(const URL& url, const String& title)
@@ -2446,7 +2446,7 @@ static void correctSpellcheckingPreservingTextCheckingParagraph(TextCheckingPara
     size_t paragraphLength;
     TextIterator::getLocationAndLengthFromRange(&scope, &paragraph.paragraphRange(), paragraphLocation, paragraphLength);
 
-    applyCommand(SpellingCorrectionCommand::create(rangeToReplace, replacement));
+    SpellingCorrectionCommand::create(rangeToReplace, replacement)->apply();
 
     // TextCheckingParagraph may be orphaned after SpellingCorrectionCommand mutated DOM.
     // See <rdar://10305315>, http://webkit.org/b/89526.
@@ -2575,7 +2575,7 @@ void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect
                 selectionChanged = true;
                 restoreSelectionAfterChange = false;
                 if (canEditRichly())
-                    applyCommand(CreateLinkCommand::create(document(), replacement));
+                    CreateLinkCommand::create(document(), replacement)->apply();
             } else if (canEdit() && shouldInsertText(replacement, rangeToReplace.ptr(), EditorInsertAction::Typed)) {
                 correctSpellcheckingPreservingTextCheckingParagraph(paragraph, rangeToReplace, replacement, resultLocation, resultLength);
 
@@ -3038,7 +3038,7 @@ void Editor::computeAndSetTypingStyle(EditingStyle& style, EditAction editingAct
     // Handle block styles, substracting these from the typing style.
     RefPtr<EditingStyle> blockStyle = typingStyle->extractAndRemoveBlockProperties();
     if (!blockStyle->isEmpty())
-        applyCommand(ApplyStyleCommand::create(document(), blockStyle.get(), editingAction));
+        ApplyStyleCommand::create(document(), blockStyle.get(), editingAction)->apply();
 
     // Set the remaining style as the typing style.
     m_frame.selection().setTypingStyle(WTFMove(typingStyle));
@@ -3619,10 +3619,8 @@ void Editor::handleAcceptedCandidate(TextCheckingResult acceptedCandidate)
     m_isHandlingAcceptedCandidate = true;
 
     if (auto range = rangeForTextCheckingResult(acceptedCandidate)) {
-        if (shouldInsertText(acceptedCandidate.replacement, range.get(), EditorInsertAction::Typed)) {
-            Ref<ReplaceRangeWithTextCommand> replaceCommand = ReplaceRangeWithTextCommand::create(range.get(), acceptedCandidate.replacement);
-            applyCommand(replaceCommand.ptr());
-        }
+        if (shouldInsertText(acceptedCandidate.replacement, range.get(), EditorInsertAction::Typed))
+            ReplaceRangeWithTextCommand::create(range.get(), acceptedCandidate.replacement)->apply();
     } else
         insertText(acceptedCandidate.replacement, nullptr);
 
index 74283b6..7b2dc6e 100644 (file)
@@ -158,7 +158,7 @@ static bool executeApplyParagraphStyle(Frame& frame, EditorCommandSource source,
 static bool executeInsertFragment(Frame& frame, PassRefPtr<DocumentFragment> fragment)
 {
     ASSERT(frame.document());
-    applyCommand(ReplaceSelectionCommand::create(*frame.document(), fragment, ReplaceSelectionCommand::PreventNesting, EditActionInsert));
+    ReplaceSelectionCommand::create(*frame.document(), fragment, ReplaceSelectionCommand::PreventNesting, EditActionInsert)->apply();
     return true;
 }
 
@@ -251,7 +251,7 @@ static bool executeCreateLink(Frame& frame, Event*, EditorCommandSource, const S
     if (value.isEmpty())
         return false;
     ASSERT(frame.document());
-    applyCommand(CreateLinkCommand::create(*frame.document(), value));
+    CreateLinkCommand::create(*frame.document(), value)->apply();
     return true;
 }
 
@@ -415,7 +415,7 @@ static bool executeFormatBlock(Frame& frame, Event*, EditorCommandSource, const
 
     ASSERT(frame.document());
     auto command = FormatBlockCommand::create(*frame.document(), qualifiedTagName.releaseReturnValue());
-    applyCommand(command.copyRef());
+    command->apply();
     return command->didApply();
 }
 
@@ -446,7 +446,7 @@ static bool executeIgnoreSpelling(Frame& frame, Event*, EditorCommandSource, con
 static bool executeIndent(Frame& frame, Event*, EditorCommandSource, const String&)
 {
     ASSERT(frame.document());
-    applyCommand(IndentOutdentCommand::create(*frame.document(), IndentOutdentCommand::Indent));
+    IndentOutdentCommand::create(*frame.document(), IndentOutdentCommand::Indent)->apply();
     return true;
 }
 
@@ -508,7 +508,7 @@ static bool executeInsertNewlineInQuotedContent(Frame& frame, Event*, EditorComm
 static bool executeInsertOrderedList(Frame& frame, Event*, EditorCommandSource, const String&)
 {
     ASSERT(frame.document());
-    applyCommand(InsertListCommand::create(*frame.document(), InsertListCommand::OrderedList));
+    InsertListCommand::create(*frame.document(), InsertListCommand::OrderedList)->apply();
     return true;
 }
 
@@ -532,7 +532,7 @@ static bool executeInsertText(Frame& frame, Event*, EditorCommandSource, const S
 static bool executeInsertUnorderedList(Frame& frame, Event*, EditorCommandSource, const String&)
 {
     ASSERT(frame.document());
-    applyCommand(InsertListCommand::create(*frame.document(), InsertListCommand::UnorderedList));
+    InsertListCommand::create(*frame.document(), InsertListCommand::UnorderedList)->apply();
     return true;
 }
 
@@ -869,7 +869,7 @@ static bool executeMoveToRightEndOfLineAndModifySelection(Frame& frame, Event*,
 static bool executeOutdent(Frame& frame, Event*, EditorCommandSource, const String&)
 {
     ASSERT(frame.document());
-    applyCommand(IndentOutdentCommand::create(*frame.document(), IndentOutdentCommand::Outdent));
+    IndentOutdentCommand::create(*frame.document(), IndentOutdentCommand::Outdent)->apply();
     return true;
 }
 
@@ -1110,7 +1110,7 @@ static bool executeUndo(Frame& frame, Event*, EditorCommandSource, const String&
 static bool executeUnlink(Frame& frame, Event*, EditorCommandSource, const String&)
 {
     ASSERT(frame.document());
-    applyCommand(UnlinkCommand::create(*frame.document()));
+    UnlinkCommand::create(*frame.document())->apply();
     return true;
 }
 
index 15637f8..7f8da17 100644 (file)
@@ -152,7 +152,7 @@ void IndentOutdentCommand::outdentParagraph()
         visibleEndOfParagraph == endOfEnclosingBlock) {
         // The blockquote doesn't contain anything outside the paragraph, so it can be totally removed.
         Node* splitPoint = enclosingNode->nextSibling();
-        removeNodePreservingChildren(enclosingNode);
+        removeNodePreservingChildren(*enclosingNode);
         // outdentRegion() assumes it is operating on the first paragraph of an enclosing blockquote, but if there are multiply nested blockquotes and we've
         // just removed one, then this assumption isn't true. By splitting the next containing blockquote after this node, we keep this assumption true
         if (splitPoint) {
@@ -160,7 +160,7 @@ void IndentOutdentCommand::outdentParagraph()
                 if (splitPointParent->hasTagName(blockquoteTag)
                     && !splitPoint->hasTagName(blockquoteTag)
                     && splitPointParent->parentNode()->hasEditableStyle()) // We can't outdent if there is no place to go!
-                    splitElement(downcast<Element>(splitPointParent), splitPoint);
+                    splitElement(downcast<Element>(*splitPointParent), *splitPoint);
             }
         }
 
@@ -183,7 +183,7 @@ void IndentOutdentCommand::outdentParagraph()
     else {
         // We split the blockquote at where we start outdenting.
         auto* highestInlineNode = highestEnclosingNodeOfType(visibleStartOfParagraph.deepEquivalent(), isInline, CannotCrossEditingBoundary, enclosingBlockFlow);
-        splitElement(enclosingNode, highestInlineNode ? highestInlineNode : visibleStartOfParagraph.deepEquivalent().deprecatedNode());
+        splitElement(*enclosingNode, highestInlineNode ? *highestInlineNode : *visibleStartOfParagraph.deepEquivalent().deprecatedNode());
     }
     auto placeholder = HTMLBRElement::create(document());
     auto* placeholderPtr = placeholder.ptr();
index e482ffe..176d8f0 100644 (file)
@@ -115,7 +115,7 @@ void InsertLineBreakCommand::doApply()
     } else if (is<Text>(*position.deprecatedNode())) {
         // Split a text node
         Text& textNode = downcast<Text>(*position.deprecatedNode());
-        splitTextNode(&textNode, position.deprecatedEditingOffset());
+        splitTextNode(textNode, position.deprecatedEditingOffset());
         insertNodeBefore(*nodeToInsert, textNode);
         Position endingPosition = firstPositionInNode(&textNode);
         
index e40cb18..b627676 100644 (file)
@@ -58,7 +58,7 @@ HTMLElement* InsertListCommand::fixOrphanedListChild(Node& node)
 {
     auto listElement = HTMLUListElement::create(document());
     insertNodeBefore(listElement.copyRef(), node);
-    removeNode(&node);
+    removeNode(node);
     appendNode(node, listElement.copyRef());
     m_listElement = listElement.copyRef();
     return listElement.ptr();
@@ -238,7 +238,7 @@ void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HT
             // See the bug 33668 and editing/execCommand/insert-list-orphaned-item-with-nested-lists.html.
             // FIXME: This might be a bug in moveParagraphWithClones or deleteSelection.
             if (listNode && listNode->isConnected())
-                removeNode(listNode);
+                removeNode(*listNode);
 
             newList = mergeWithNeighboringLists(newList);
 
@@ -300,7 +300,7 @@ void InsertListCommand::unlistifyParagraph(const VisiblePosition& originalStart,
         // FIXME: We appear to split at nextListChild as opposed to listChildNode so that when we remove
         // listChildNode below in moveParagraphs, previousListChild will be removed along with it if it is 
         // unrendered. But we ought to remove nextListChild too, if it is unrendered.
-        splitElement(listNode, splitTreeToNode(nextListChild, listNode));
+        splitElement(*listNode, *splitTreeToNode(nextListChild, listNode));
         insertNodeBefore(nodeToInsert.releaseNonNull(), *listNode);
     } else if (nextListChild || listChildNode->parentNode() != listNode) {
         // Just because listChildNode has no previousListChild doesn't mean there isn't any content
@@ -308,7 +308,7 @@ void InsertListCommand::unlistifyParagraph(const VisiblePosition& originalStart,
         // between it and listNode. So, we split up to listNode before inserting the placeholder
         // where we're about to move listChildNode to.
         if (listChildNode->parentNode() != listNode)
-            splitElement(listNode, splitTreeToNode(listChildNode, listNode).get());
+            splitElement(*listNode, *splitTreeToNode(listChildNode, listNode).get());
         insertNodeBefore(nodeToInsert.releaseNonNull(), *listNode);
     } else
         insertNodeAfter(nodeToInsert.releaseNonNull(), *listNode);
index e631d4b..85de12c 100644 (file)
@@ -342,11 +342,11 @@ void InsertParagraphSeparatorCommand::doApply()
     // Split at pos if in the middle of a text node.
     Position positionAfterSplit;
     if (insertionPosition.anchorType() == Position::PositionIsOffsetInAnchor && is<Text>(*insertionPosition.containerNode())) {
-        RefPtr<Text> textNode = downcast<Text>(insertionPosition.containerNode());
+        Ref<Text> textNode = downcast<Text>(*insertionPosition.containerNode());
         bool atEnd = static_cast<unsigned>(insertionPosition.offsetInContainerNode()) >= textNode->length();
         if (insertionPosition.deprecatedEditingOffset() > 0 && !atEnd) {
             splitTextNode(textNode, insertionPosition.offsetInContainerNode());
-            positionAfterSplit = firstPositionInNode(textNode.get());
+            positionAfterSplit = firstPositionInNode(textNode.ptr());
             if (!textNode->previousSibling())
                 return; // Bail out if mutation events detachd the split text node.
             insertionPosition.moveToPosition(textNode->previousSibling(), insertionPosition.offsetInContainerNode());
@@ -391,7 +391,7 @@ void InsertParagraphSeparatorCommand::doApply()
             }
         }
 
-        moveRemainingSiblingsToNewParent(n, blockToInsert.get(), blockToInsert);
+        moveRemainingSiblingsToNewParent(n, blockToInsert.get(), *blockToInsert);
     }            
 
     // Handle whitespace that occurs after the split
index 8c091e7..1755ef0 100644 (file)
@@ -267,7 +267,7 @@ Position InsertTextCommand::insertTab(const Position& pos)
             // second node in the split, so we need to
             // insert the span before it.
             if (offset > 0)
-                splitTextNode(textNode.ptr(), offset);
+                splitTextNode(textNode, offset);
             insertNodeBefore(WTFMove(spanNode), textNode);
         }
     }
index 2392945..9e5d015 100644 (file)
@@ -94,7 +94,7 @@ void ModifySelectionListLevelCommand::insertSiblingNodeRangeBefore(Node* startNo
     Node* node = startNode;
     while (1) {
         Node* next = node->nextSibling();
-        removeNode(node);
+        removeNode(*node);
         insertNodeBefore(*node, *refNode);
 
         if (node == endNode)
@@ -109,7 +109,7 @@ void ModifySelectionListLevelCommand::insertSiblingNodeRangeAfter(Node* startNod
     Node* node = startNode;
     while (1) {
         Node* next = node->nextSibling();
-        removeNode(node);
+        removeNode(*node);
         insertNodeAfter(*node, *refNode);
 
         if (node == endNode)
@@ -125,7 +125,7 @@ void ModifySelectionListLevelCommand::appendSiblingNodeRange(Node* startNode, No
     Node* node = startNode;
     while (1) {
         Node* next = node->nextSibling();
-        removeNode(node);
+        removeNode(*node);
         appendNode(*node, *newParent);
 
         if (node == endNode)
@@ -267,14 +267,14 @@ void DecreaseSelectionListLevelCommand::doApply()
         // at start of sublist, move the child(ren) to before the sublist
         insertSiblingNodeRangeBefore(startListChild, endListChild, listNode);
         // if that was the whole sublist we moved, remove the sublist node
-        if (!nextItem)
-            removeNode(listNode);
+        if (!nextItem && listNode)
+            removeNode(*listNode);
     } else if (!nextItem) {
         // at end of list, move the child(ren) to after the sublist
         insertSiblingNodeRangeAfter(startListChild, endListChild, listNode);    
     } else if (listNode) {
         // in the middle of list, split the list and move the children to the divide
-        splitElement(listNode, startListChild);
+        splitElement(*listNode, *startListChild);
         insertSiblingNodeRangeBefore(startListChild, endListChild, listNode);
     }
 }
@@ -290,7 +290,7 @@ void DecreaseSelectionListLevelCommand::decreaseSelectionListLevel(Document* doc
 {
     ASSERT(document);
     ASSERT(document->frame());
-    applyCommand(create(*document));
+    create(*document)->apply();
 }
 
 }
index b616443..34b9ef7 100644 (file)
 
 namespace WebCore {
 
-RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable, EditAction editingAction)
+RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand(Ref<Node>&& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable, EditAction editingAction)
     : CompositeEditCommand(node->document(), editingAction)
-    , m_node(node)
+    , m_node(WTFMove(node))
     , m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable)
 {
-    ASSERT(m_node);
 }
 
 void RemoveNodePreservingChildrenCommand::doApply()
@@ -48,8 +47,8 @@ void RemoveNodePreservingChildrenCommand::doApply()
     size_t size = children.size();
     for (size_t i = 0; i < size; ++i) {
         auto child = WTFMove(children[i]);
-        removeNode(child.ptr(), m_shouldAssumeContentIsAlwaysEditable);
-        insertNodeBefore(WTFMove(child), *m_node, m_shouldAssumeContentIsAlwaysEditable);
+        removeNode(child, m_shouldAssumeContentIsAlwaysEditable);
+        insertNodeBefore(WTFMove(child), m_node, m_shouldAssumeContentIsAlwaysEditable);
     }
     removeNode(m_node, m_shouldAssumeContentIsAlwaysEditable);
 }
index 07ea088..dd85cc9 100644 (file)
@@ -31,17 +31,17 @@ namespace WebCore {
 
 class RemoveNodePreservingChildrenCommand : public CompositeEditCommand {
 public:
-    static Ref<RemoveNodePreservingChildrenCommand> create(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable, EditAction editingAction)
+    static Ref<RemoveNodePreservingChildrenCommand> create(Ref<Node>&& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable, EditAction editingAction)
     {
-        return adoptRef(*new RemoveNodePreservingChildrenCommand(node, shouldAssumeContentIsAlwaysEditable, editingAction));
+        return adoptRef(*new RemoveNodePreservingChildrenCommand(WTFMove(node), shouldAssumeContentIsAlwaysEditable, editingAction));
     }
 
 private:
-    explicit RemoveNodePreservingChildrenCommand(PassRefPtr<Node>, ShouldAssumeContentIsAlwaysEditable, EditAction);
+    explicit RemoveNodePreservingChildrenCommand(Ref<Node>&&, ShouldAssumeContentIsAlwaysEditable, EditAction);
 
     void doApply() override;
 
-    RefPtr<Node> m_node;
+    Ref<Node> m_node;
     ShouldAssumeContentIsAlwaysEditable m_shouldAssumeContentIsAlwaysEditable;
 };
 
index b3292ce..720f2cd 100644 (file)
 
 namespace WebCore {
 
-ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand(PassRefPtr<HTMLElement> element)
+ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand(Ref<HTMLElement>&& element)
     : SimpleEditCommand(element->document())
-    , m_elementToReplace(element)
+    , m_elementToReplace(WTFMove(element))
 {
-    ASSERT(m_elementToReplace);
 }
 
 static void swapInNodePreservingAttributesAndChildren(HTMLElement& newNode, HTMLElement& nodeToReplace)
@@ -65,20 +64,20 @@ void ReplaceNodeWithSpanCommand::doApply()
         return;
     if (!m_spanElement)
         m_spanElement = HTMLSpanElement::create(m_elementToReplace->document());
-    swapInNodePreservingAttributesAndChildren(*m_spanElement, *m_elementToReplace);
+    swapInNodePreservingAttributesAndChildren(*m_spanElement, m_elementToReplace);
 }
 
 void ReplaceNodeWithSpanCommand::doUnapply()
 {
     if (!m_spanElement->isConnected())
         return;
-    swapInNodePreservingAttributesAndChildren(*m_elementToReplace, *m_spanElement);
+    swapInNodePreservingAttributesAndChildren(m_elementToReplace, *m_spanElement);
 }
 
 #ifndef NDEBUG
 void ReplaceNodeWithSpanCommand::getNodesInCommand(HashSet<Node*>& nodes)
 {
-    addNodeAndDescendants(m_elementToReplace.get(), nodes);
+    addNodeAndDescendants(m_elementToReplace.ptr(), nodes);
     addNodeAndDescendants(m_spanElement.get(), nodes);
 }
 #endif
index b564c66..e5d30fc 100644 (file)
@@ -39,15 +39,15 @@ class HTMLElement;
 // More accurately, this is ReplaceElementWithSpanPreservingChildrenAndAttributesCommand
 class ReplaceNodeWithSpanCommand : public SimpleEditCommand {
 public:
-    static Ref<ReplaceNodeWithSpanCommand> create(PassRefPtr<HTMLElement> element)
+    static Ref<ReplaceNodeWithSpanCommand> create(Ref<HTMLElement>&& element)
     {
-        return adoptRef(*new ReplaceNodeWithSpanCommand(element));
+        return adoptRef(*new ReplaceNodeWithSpanCommand(WTFMove(element)));
     }
 
     HTMLElement* spanElement() { return m_spanElement.get(); }
 
 private:
-    explicit ReplaceNodeWithSpanCommand(PassRefPtr<HTMLElement>);
+    explicit ReplaceNodeWithSpanCommand(Ref<HTMLElement>&&);
 
     void doApply() override;
     void doUnapply() override;
@@ -56,7 +56,7 @@ private:
     void getNodesInCommand(HashSet<Node*>&) override;
 #endif
 
-    RefPtr<HTMLElement> m_elementToReplace;
+    Ref<HTMLElement> m_elementToReplace;
     RefPtr<HTMLElement> m_spanElement;
 };
 
index 4094f58..e50c4eb 100644 (file)
@@ -90,7 +90,7 @@ public:
     bool hasInterchangeNewlineAtEnd() const { return m_hasInterchangeNewlineAtEnd; }
     
     void removeNode(PassRefPtr<Node>);
-    void removeNodePreservingChildren(PassRefPtr<Node>);
+    void removeNodePreservingChildren(Node&);
 
 private:
     Ref<HTMLElement> insertFragmentForTestRendering(Node* rootEditableNode);
@@ -224,16 +224,14 @@ Node *ReplacementFragment::lastChild() const
     return m_fragment ? m_fragment->lastChild() : 0; 
 }
 
-void ReplacementFragment::removeNodePreservingChildren(PassRefPtr<Node> node)
+void ReplacementFragment::removeNodePreservingChildren(Node& node)
 {
-    if (!node)
-        return;
-
-    while (RefPtr<Node> n = node->firstChild()) {
+    Ref<Node> protectedNode = node;
+    while (RefPtr<Node> n = node.firstChild()) {
         removeNode(n);
-        insertNodeBefore(WTFMove(n), node.get());
+        insertNodeBefore(WTFMove(n), &node);
     }
-    removeNode(WTFMove(node));
+    removeNode(&node);
 }
 
 void ReplacementFragment::removeNode(PassRefPtr<Node> node)
@@ -332,7 +330,7 @@ void ReplacementFragment::removeInterchangeNodes(Node* container)
         RefPtr<Node> next = NodeTraversal::next(*node);
         if (isInterchangeConvertedSpaceSpan(node)) {
             next = NodeTraversal::nextSkippingChildren(*node);
-            removeNodePreservingChildren(node);
+            removeNodePreservingChildren(*node);
         }
         node = next.get();
     }
@@ -503,7 +501,7 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
 
                 if (newInlineStyle->conflictsWithImplicitStyleOfElement(&htmlElement)) {
                     // e.g. <b style="font-weight: normal;"> is converted to <span style="font-weight: normal;">
-                    node = replaceElementWithSpanPreservingChildrenAndAttributes(&htmlElement);
+                    node = replaceElementWithSpanPreservingChildrenAndAttributes(htmlElement);
                     element = downcast<StyledElement>(node.get());
                     insertedNodes.didReplaceNode(&htmlElement, node.get());
                 } else if (newInlineStyle->extractConflictingImplicitStyleOfAttributes(&htmlElement, EditingStyle::PreserveWritingDirection, 0, attributes,
@@ -528,19 +526,19 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
         if (!inlineStyle || newInlineStyle->isEmpty()) {
             if (isStyleSpanOrSpanWithOnlyStyleAttribute(*element) || isEmptyFontTag(element, AllowNonEmptyStyleAttribute)) {
                 insertedNodes.willRemoveNodePreservingChildren(element);
-                removeNodePreservingChildren(element);
+                removeNodePreservingChildren(*element);
                 continue;
             }
             removeNodeAttribute(*element, styleAttr);
         } else if (newInlineStyle->style()->propertyCount() != inlineStyle->propertyCount())
-            setNodeAttribute(element, styleAttr, newInlineStyle->style()->asText());
+            setNodeAttribute(*element, styleAttr, newInlineStyle->style()->asText());
 
         // FIXME: Tolerate differences in id, class, and style attributes.
         if (element->parentNode() && isNonTableCellHTMLBlockElement(element) && areIdenticalElements(*element, *element->parentNode())
             && VisiblePosition(firstPositionInNode(element->parentNode())) == VisiblePosition(firstPositionInNode(element))
             && VisiblePosition(lastPositionInNode(element->parentNode())) == VisiblePosition(lastPositionInNode(element))) {
             insertedNodes.willRemoveNodePreservingChildren(element);
-            removeNodePreservingChildren(element);
+            removeNodePreservingChildren(*element);
             continue;
         }
 
@@ -552,7 +550,7 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
         if (isLegacyAppleStyleSpan(element)) {
             if (!element->firstChild()) {
                 insertedNodes.willRemoveNodePreservingChildren(element);
-                removeNodePreservingChildren(element);
+                removeNodePreservingChildren(*element);
                 continue;
             }
             // There are other styles that style rules can give to style spans,
@@ -652,7 +650,7 @@ void ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuild
                 if (headerElement->parentNode() && headerElement->parentNode()->isContentRichlyEditable())
                     moveNodeOutOfAncestor(node, headerElement, insertedNodes);
                 else {
-                    HTMLElement* newSpanElement = replaceElementWithSpanPreservingChildrenAndAttributes(downcast<HTMLElement>(node.get()));
+                    HTMLElement* newSpanElement = replaceElementWithSpanPreservingChildrenAndAttributes(downcast<HTMLElement>(*node));
                     insertedNodes.didReplaceNode(node.get(), newSpanElement);
                 }
             }
@@ -668,19 +666,19 @@ void ReplaceSelectionCommand::moveNodeOutOfAncestor(PassRefPtr<Node> prpNode, Pa
     VisiblePosition positionAtEndOfNode = lastPositionInOrAfterNode(node.get());
     VisiblePosition lastPositionInParagraph = lastPositionInNode(ancestor.get());
     if (positionAtEndOfNode == lastPositionInParagraph) {
-        removeNode(node);
+        removeNode(*node);
         if (ancestor->nextSibling())
             insertNodeBefore(node.releaseNonNull(), *ancestor->nextSibling());
         else
             appendNode(node.releaseNonNull(), *ancestor->parentNode());
     } else {
         RefPtr<Node> nodeToSplitTo = splitTreeToNode(node.get(), ancestor.get(), true);
-        removeNode(node);
+        removeNode(*node);
         insertNodeBefore(node.releaseNonNull(), *nodeToSplitTo);
     }
     if (!ancestor->firstChild()) {
         insertedNodes.willRemoveNode(ancestor.get());
-        removeNode(WTFMove(ancestor));
+        removeNode(*ancestor);
     }
 }
 
@@ -698,7 +696,7 @@ void ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds(InsertedNodes& ins
         && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted), selectTag)
         && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted), scriptTag)) {
         insertedNodes.willRemoveNode(lastLeafInserted);
-        removeNode(lastLeafInserted);
+        removeNode(*lastLeafInserted);
     }
 
     // We don't have to make sure that firstNodeInserted isn't inside a select or script element
@@ -706,7 +704,7 @@ void ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds(InsertedNodes& ins
     Node* firstNodeInserted = insertedNodes.firstNodeInserted();
     if (is<Text>(firstNodeInserted) && !hasRenderedText(downcast<Text>(*firstNodeInserted))) {
         insertedNodes.willRemoveNode(firstNodeInserted);
-        removeNode(firstNodeInserted);
+        removeNode(*firstNodeInserted);
     }
 }
 
@@ -769,7 +767,7 @@ static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const
     if (styleText != downcast<Element>(*wrappingStyleSpan).getAttribute(styleAttr))
         return false;
 
-    fragment.removeNodePreservingChildren(wrappingStyleSpan);
+    fragment.removeNodePreservingChildren(*wrappingStyleSpan);
     return true;
 }
 
@@ -820,9 +818,9 @@ void ReplaceSelectionCommand::handleStyleSpans(InsertedNodes& insertedNodes)
 
     if (style->isEmpty() || !wrappingStyleSpan->firstChild()) {
         insertedNodes.willRemoveNodePreservingChildren(wrappingStyleSpan);
-        removeNodePreservingChildren(wrappingStyleSpan);
+        removeNodePreservingChildren(*wrappingStyleSpan);
     } else
-        setNodeAttribute(wrappingStyleSpan, styleAttr, style->style()->asText());
+        setNodeAttribute(*wrappingStyleSpan, styleAttr, style->style()->asText());
 }
 
 void ReplaceSelectionCommand::mergeEndIfNeeded()
@@ -1018,7 +1016,7 @@ void ReplaceSelectionCommand::doApply()
         ASSERT(br->hasTagName(brTag)); 
         // Insert content between the two blockquotes, but remove the br (since it was just a placeholder). 
         insertionPos = positionInParentBeforeNode(br);
-        removeNode(br);
+        removeNode(*br);
     }
     
     // Inserting content could cause whitespace to collapse, e.g. inserting <div>foo</div> into hello^ world.
@@ -1078,7 +1076,7 @@ void ReplaceSelectionCommand::doApply()
     // since insertAsListItems already does the right thing.
     if (!m_matchStyle && !enclosingList(insertionPos.containerNode())) {
         if (insertionPos.containerNode()->isTextNode() && insertionPos.offsetInContainerNode() && !insertionPos.atLastEditingPositionForNode()) {
-            splitTextNode(insertionPos.containerText(), insertionPos.offsetInContainerNode());
+            splitTextNode(*insertionPos.containerText(), insertionPos.offsetInContainerNode());
             insertionPos = firstPositionInNode(insertionPos.containerNode());
         }
 
@@ -1162,10 +1160,10 @@ void ReplaceSelectionCommand::doApply()
     if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR.get(), originalVisPosBeforeEndBR))) {
         RefPtr<Node> parent = endBR->parentNode();
         insertedNodes.willRemoveNode(endBR.get());
-        removeNode(endBR);
+        removeNode(*endBR);
         if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) {
             insertedNodes.willRemoveNode(nodeToRemove);
-            removeNode(nodeToRemove);
+            removeNode(*nodeToRemove);
         }
     }
     
@@ -1443,7 +1441,7 @@ void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P
         } else
             updatePositionForNodeRemoval(positionOnlyToBeUpdated, previous.get());
 
-        removeNode(previous.ptr());
+        removeNode(previous);
     }
     if (is<Text>(text->nextSibling())) {
         Ref<Text> next(downcast<Text>(*text->nextSibling()));
@@ -1458,7 +1456,7 @@ void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P
         else
             updatePositionForNodeRemoval(positionOnlyToBeUpdated, next.get());
 
-        removeNode(next.ptr());
+        removeNode(next);
     }
 }
 
@@ -1481,7 +1479,7 @@ Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtr<HTMLElement> prpList
     if (isMiddle) {
         int textNodeOffset = insertPos.offsetInContainerNode();
         if (is<Text>(*insertPos.deprecatedNode()) && textNodeOffset > 0)
-            splitTextNode(downcast<Text>(insertPos.deprecatedNode()), textNodeOffset);
+            splitTextNode(downcast<Text>(*insertPos.deprecatedNode()), textNodeOffset);
         splitTreeToNode(insertPos.deprecatedNode(), lastNode, true);
     }
 
@@ -1551,7 +1549,7 @@ bool ReplaceSelectionCommand::performTrivialReplace(const ReplacementFragment& f
 
     if (nodeAfterInsertionPos && nodeAfterInsertionPos->parentNode() && nodeAfterInsertionPos->hasTagName(brTag)
         && shouldRemoveEndBR(nodeAfterInsertionPos.get(), positionBeforeNode(nodeAfterInsertionPos.get())))
-        removeNodeAndPruneAncestors(nodeAfterInsertionPos.get());
+        removeNodeAndPruneAncestors(*nodeAfterInsertionPos);
 
     VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, end);
 
index 1950f0f..f838e54 100644 (file)
 
 namespace WebCore {
 
-SetNodeAttributeCommand::SetNodeAttributeCommand(PassRefPtr<Element> element, const QualifiedName& attribute, const AtomicString& value)
+SetNodeAttributeCommand::SetNodeAttributeCommand(Ref<Element>&& element, const QualifiedName& attribute, const AtomicString& value)
     : SimpleEditCommand(element->document())
-    , m_element(element)
+    , m_element(WTFMove(element))
     , m_attribute(attribute)
     , m_value(value)
 {
-    ASSERT(m_element);
 }
 
 void SetNodeAttributeCommand::doApply()
@@ -56,7 +55,7 @@ void SetNodeAttributeCommand::doUnapply()
 #ifndef NDEBUG
 void SetNodeAttributeCommand::getNodesInCommand(HashSet<Node*>& nodes)
 {
-    addNodeAndDescendants(m_element.get(), nodes);
+    addNodeAndDescendants(m_element.ptr(), nodes);
 }
 #endif
 
index f3ae409..88449de 100644 (file)
@@ -32,13 +32,13 @@ namespace WebCore {
 
 class SetNodeAttributeCommand : public SimpleEditCommand {
 public:
-    static Ref<SetNodeAttributeCommand> create(PassRefPtr<Element> element, const QualifiedName& attribute, const AtomicString& value)
+    static Ref<SetNodeAttributeCommand> create(Ref<Element>&& element, const QualifiedName& attribute, const AtomicString& value)
     {
-        return adoptRef(*new SetNodeAttributeCommand(element, attribute, value));
+        return adoptRef(*new SetNodeAttributeCommand(WTFMove(element), attribute, value));
     }
 
 private:
-    SetNodeAttributeCommand(PassRefPtr<Element>, const QualifiedName& attribute, const AtomicString& value);
+    SetNodeAttributeCommand(Ref<Element>&&, const QualifiedName& attribute, const AtomicString& value);
 
     void doApply() override;
     void doUnapply() override;
@@ -47,7 +47,7 @@ private:
     void getNodesInCommand(HashSet<Node*>&) override;
 #endif
 
-    RefPtr<Element> m_element;
+    Ref<Element> m_element;
     QualifiedName m_attribute;
     AtomicString m_value;
     AtomicString m_oldValue;
index 33e8d83..d6676e3 100644 (file)
@@ -44,7 +44,7 @@ SimplifyMarkupCommand::SimplifyMarkupCommand(Document& document, Node* firstNode
 void SimplifyMarkupCommand::doApply()
 {
     Node* rootNode = m_firstNode->parentNode();
-    Vector<RefPtr<Node>> nodesToRemove;
+    Vector<Ref<Node>> nodesToRemove;
     
     document().updateLayoutIgnorePendingStylesheets();
 
@@ -64,7 +64,7 @@ void SimplifyMarkupCommand::doApply()
         Node* topNodeWithStartingStyle = nullptr;
         while (currentNode != rootNode) {
             if (currentNode->parentNode() != rootNode && isRemovableBlock(currentNode))
-                nodesToRemove.append(currentNode);
+                nodesToRemove.append(*currentNode);
             
             currentNode = currentNode->parentNode();
             if (!currentNode)
@@ -85,8 +85,8 @@ void SimplifyMarkupCommand::doApply()
             
         }
         if (topNodeWithStartingStyle) {
-            for (Node* node = startingNode; node != topNodeWithStartingStyle; node = node->parentNode())
-                nodesToRemove.append(node);
+            for (Node* node = startingNode; node && node != topNodeWithStartingStyle; node = node->parentNode())
+                nodesToRemove.append(*node);
         }
     }
 
@@ -101,17 +101,17 @@ void SimplifyMarkupCommand::doApply()
     }
 }
 
-int SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove(Vector<RefPtr<Node>>& nodesToRemove, size_t startNodeIndex)
+int SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove(Vector<Ref<Node>>& nodesToRemove, size_t startNodeIndex)
 {
     size_t pastLastNodeToRemove = startNodeIndex + 1;
     for (; pastLastNodeToRemove < nodesToRemove.size(); ++pastLastNodeToRemove) {
-        if (nodesToRemove[pastLastNodeToRemove - 1]->parentNode() != nodesToRemove[pastLastNodeToRemove])
+        if (nodesToRemove[pastLastNodeToRemove - 1]->parentNode() != nodesToRemove[pastLastNodeToRemove].ptr())
             break;
         if (nodesToRemove[pastLastNodeToRemove]->firstChild() != nodesToRemove[pastLastNodeToRemove]->lastChild())
             break;
     }
 
-    Node* highestAncestorToRemove = nodesToRemove[pastLastNodeToRemove - 1].get();
+    Node* highestAncestorToRemove = nodesToRemove[pastLastNodeToRemove - 1].ptr();
     RefPtr<ContainerNode> parent = highestAncestorToRemove->parentNode();
     if (!parent) // Parent has already been removed.
         return -1;
@@ -120,8 +120,8 @@ int SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove(Vector<RefPtr<Node>>
         return 0;
 
     removeNode(nodesToRemove[startNodeIndex], AssumeContentIsAlwaysEditable);
-    insertNodeBefore(*nodesToRemove[startNodeIndex], *highestAncestorToRemove, AssumeContentIsAlwaysEditable);
-    removeNode(highestAncestorToRemove, AssumeContentIsAlwaysEditable);
+    insertNodeBefore(nodesToRemove[startNodeIndex].copyRef(), *highestAncestorToRemove, AssumeContentIsAlwaysEditable);
+    removeNode(*highestAncestorToRemove, AssumeContentIsAlwaysEditable);
 
     return pastLastNodeToRemove - startNodeIndex - 1;
 }
index 2d8257a..7a0882e 100644 (file)
@@ -40,7 +40,7 @@ private:
     SimplifyMarkupCommand(Document&, Node* firstNode, Node* nodeAfterLast);
 
     void doApply() override;
-    int pruneSubsequentAncestorsToRemove(Vector<RefPtr<Node>>& nodesToRemove, size_t startNodeIndex);
+    int pruneSubsequentAncestorsToRemove(Vector<Ref<Node>>& nodesToRemove, size_t startNodeIndex);
 
     RefPtr<Node> m_firstNode;
     RefPtr<Node> m_nodeAfterLast;
index 2d4e854..ba32ab5 100644 (file)
 
 namespace WebCore {
 
-SplitElementCommand::SplitElementCommand(PassRefPtr<Element> element, PassRefPtr<Node> atChild)
+SplitElementCommand::SplitElementCommand(Ref<Element>&& element, Ref<Node>&& atChild)
     : SimpleEditCommand(element->document())
-    , m_element2(element)
-    , m_atChild(atChild)
+    , m_element2(WTFMove(element))
+    , m_atChild(WTFMove(atChild))
 {
-    ASSERT(m_element2);
-    ASSERT(m_atChild);
-    ASSERT(m_atChild->parentNode() == m_element2);
+    ASSERT(m_atChild->parentNode() == m_element2.ptr());
 }
 
 void SplitElementCommand::executeApply()
 {
-    if (m_atChild->parentNode() != m_element2)
+    if (m_atChild->parentNode() != m_element2.ptr())
         return;
     
     Vector<Ref<Node>> children;
-    for (Node* node = m_element2->firstChild(); node != m_atChild; node = node->nextSibling())
+    for (Node* node = m_element2->firstChild(); node != m_atChild.ptr(); node = node->nextSibling())
         children.append(*node);
 
     auto* parent = m_element2->parentNode();
     if (!parent || !parent->hasEditableStyle())
         return;
-    if (parent->insertBefore(*m_element1, m_element2.get()).hasException())
+    if (parent->insertBefore(*m_element1, m_element2.ptr()).hasException())
         return;
 
     // Delete id attribute from the second element because the same id cannot be used for more than one element
@@ -105,8 +103,8 @@ void SplitElementCommand::doReapply()
 void SplitElementCommand::getNodesInCommand(HashSet<Node*>& nodes)
 {
     addNodeAndDescendants(m_element1.get(), nodes);
-    addNodeAndDescendants(m_element2.get(), nodes);
-    addNodeAndDescendants(m_atChild.get(), nodes);
+    addNodeAndDescendants(m_element2.ptr(), nodes);
+    addNodeAndDescendants(m_atChild.ptr(), nodes);
 }
 #endif
     
index ca1d0b2..9831651 100644 (file)
@@ -31,13 +31,13 @@ namespace WebCore {
 
 class SplitElementCommand : public SimpleEditCommand {
 public:
-    static Ref<SplitElementCommand> create(PassRefPtr<Element> element, PassRefPtr<Node> splitPointChild)
+    static Ref<SplitElementCommand> create(Ref<Element>&& element, Ref<Node>&& splitPointChild)
     {
-        return adoptRef(*new SplitElementCommand(element, splitPointChild));
+        return adoptRef(*new SplitElementCommand(WTFMove(element), WTFMove(splitPointChild)));
     }
 
 private:
-    SplitElementCommand(PassRefPtr<Element>, PassRefPtr<Node> splitPointChild);
+    SplitElementCommand(Ref<Element>&&, Ref<Node>&& splitPointChild);
 
     void doApply() override;
     void doUnapply() override;
@@ -49,8 +49,8 @@ private:
 #endif
 
     RefPtr<Element> m_element1;
-    RefPtr<Element> m_element2;
-    RefPtr<Node> m_atChild;
+    Ref<Element> m_element2;
+    Ref<Node> m_atChild;
 };
 
 } // namespace WebCore
index b0a4b21..9ad090f 100644 (file)
 
 namespace WebCore {
 
-SplitTextNodeCommand::SplitTextNodeCommand(PassRefPtr<Text> text, int offset)
+SplitTextNodeCommand::SplitTextNodeCommand(Ref<Text>&& text, int offset)
     : SimpleEditCommand(text->document())
-    , m_text2(text)
+    , m_text2(WTFMove(text))
     , m_offset(offset)
 {
     // NOTE: Various callers rely on the fact that the original node becomes
     // the second node (i.e. the new node is inserted before the existing one).
     // That is not a fundamental dependency (i.e. it could be re-coded), but
     // rather is based on how this code happens to work.
-    ASSERT(m_text2);
     ASSERT(m_text2->length() > 0);
     ASSERT(m_offset > 0);
     ASSERT(m_offset < m_text2->length());
@@ -63,7 +62,7 @@ void SplitTextNodeCommand::doApply()
 
     m_text1 = Text::create(document(), WTFMove(prefixText));
     ASSERT(m_text1);
-    document().markers().copyMarkers(m_text2.get(), 0, m_offset, m_text1.get(), 0);
+    document().markers().copyMarkers(m_text2.ptr(), 0, m_offset, m_text1.get(), 0);
 
     insertText1AndTrimText2();
 }
@@ -79,13 +78,13 @@ void SplitTextNodeCommand::doUnapply()
 
     m_text2->insertData(0, prefixText);
 
-    document().markers().copyMarkers(m_text1.get(), 0, prefixText.length(), m_text2.get(), 0);
+    document().markers().copyMarkers(m_text1.get(), 0, prefixText.length(), m_text2.ptr(), 0);
     m_text1->remove();
 }
 
 void SplitTextNodeCommand::doReapply()
 {
-    if (!m_text1 || !m_text2)
+    if (!m_text1)
         return;
 
     ContainerNode* parent = m_text2->parentNode();
@@ -97,7 +96,7 @@ void SplitTextNodeCommand::doReapply()
 
 void SplitTextNodeCommand::insertText1AndTrimText2()
 {
-    if (m_text2->parentNode()->insertBefore(*m_text1, m_text2.get()).hasException())
+    if (m_text2->parentNode()->insertBefore(*m_text1, m_text2.ptr()).hasException())
         return;
     m_text2->deleteData(0, m_offset);
 }
@@ -107,7 +106,7 @@ void SplitTextNodeCommand::insertText1AndTrimText2()
 void SplitTextNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
 {
     addNodeAndDescendants(m_text1.get(), nodes);
-    addNodeAndDescendants(m_text2.get(), nodes);
+    addNodeAndDescendants(m_text2.ptr(), nodes);
 }
 
 #endif
index 567479e..b9919d6 100644 (file)
@@ -33,13 +33,13 @@ class Text;
 
 class SplitTextNodeCommand : public SimpleEditCommand {
 public:
-    static Ref<SplitTextNodeCommand> create(PassRefPtr<Text> node, int offset)
+    static Ref<SplitTextNodeCommand> create(Ref<Text>&& node, int offset)
     {
-        return adoptRef(*new SplitTextNodeCommand(node, offset));
+        return adoptRef(*new SplitTextNodeCommand(WTFMove(node), offset));
     }
 
 private:
-    SplitTextNodeCommand(PassRefPtr<Text>, int offset);
+    SplitTextNodeCommand(Ref<Text>&&, int offset);
 
     void doApply() override;
     void doUnapply() override;
@@ -51,7 +51,7 @@ private:
 #endif
 
     RefPtr<Text> m_text1;
-    RefPtr<Text> m_text2;
+    Ref<Text> m_text2;
     unsigned m_offset;
 };
 
index ce88874..0181e44 100644 (file)
 
 namespace WebCore {
 
-SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand(PassRefPtr<Text> text, int offset)
+SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand(Ref<Text>&& text, int offset)
     : CompositeEditCommand(text->document())
-    , m_text(text)
+    , m_text(WTFMove(text))
     , m_offset(offset)
 {
-    ASSERT(m_text);
     ASSERT(m_text->length() > 0);
 }
 
 void SplitTextNodeContainingElementCommand::doApply()
 {
-    ASSERT(m_text);
     ASSERT(m_offset > 0);
 
-    splitTextNode(m_text.get(), m_offset);
+    splitTextNode(m_text, m_offset);
 
     Element* parent = m_text->parentElement();
     if (!parent || !parent->parentElement() || !parent->parentElement()->hasEditableStyle())
@@ -62,7 +60,7 @@ void SplitTextNodeContainingElementCommand::doApply()
         parent = downcast<Element>(firstChild);
     }
 
-    splitElement(parent, m_text);
+    splitElement(*parent, m_text);
 }
 
 }
index 5e69e12..cdef6ec 100644 (file)
@@ -31,17 +31,17 @@ namespace WebCore {
 
 class SplitTextNodeContainingElementCommand : public CompositeEditCommand {
 public:
-    static Ref<SplitTextNodeContainingElementCommand> create(PassRefPtr<Text> node, int offset)
+    static Ref<SplitTextNodeContainingElementCommand> create(Ref<Text>&& node, int offset)
     {
-        return adoptRef(*new SplitTextNodeContainingElementCommand(node, offset));
+        return adoptRef(*new SplitTextNodeContainingElementCommand(WTFMove(node), offset));
     }
 
 private:
-    SplitTextNodeContainingElementCommand(PassRefPtr<Text>, int offset);
+    SplitTextNodeContainingElementCommand(Ref<Text>&&, int offset);
 
     void doApply() override;
 
-    RefPtr<Text> m_text;
+    Ref<Text> m_text;
     int m_offset;
 };
 
index cf9c262..19c6e3b 100644 (file)
@@ -47,7 +47,7 @@ void TextInsertionBaseCommand::applyTextInsertionCommand(Frame* frame, TextInser
         command.setStartingSelection(selectionForInsertion);
         command.setEndingSelection(selectionForInsertion);
     }
-    applyCommand(&command);
+    command.apply();
     if (changeSelection) {
         command.setEndingSelection(endingSelection);
         frame->selection().setSelection(endingSelection);
index 1d0a32d..7c014e5 100644 (file)
@@ -279,7 +279,7 @@ void TypingCommand::insertLineBreak(Document& document, Options options)
         return;
     }
 
-    applyCommand(TypingCommand::create(document, InsertLineBreak, emptyString(), options));
+    TypingCommand::create(document, InsertLineBreak, emptyString(), options)->apply();
 }
 
 void TypingCommand::insertParagraphSeparatorInQuotedContent(Document& document)
@@ -291,7 +291,7 @@ void TypingCommand::insertParagraphSeparatorInQuotedContent(Document& document)
         return;
     }
 
-    applyCommand(TypingCommand::create(document, InsertParagraphSeparatorInQuotedContent));
+    TypingCommand::create(document, InsertParagraphSeparatorInQuotedContent)->apply();
 }
 
 void TypingCommand::insertParagraphSeparator(Document& document, Options options)
@@ -304,7 +304,7 @@ void TypingCommand::insertParagraphSeparator(Document& document, Options options
         return;
     }
 
-    applyCommand(TypingCommand::create(document, InsertParagraphSeparator, emptyString(), options));
+    TypingCommand::create(document, InsertParagraphSeparator, emptyString(), options)->apply();
 }
 
 RefPtr<TypingCommand> TypingCommand::lastTypingCommandIfStillOpenForTyping(Frame& frame)
@@ -632,7 +632,7 @@ bool TypingCommand::makeEditableRootEmpty()
     }
 
     while (Node* child = root->firstChild())
-        removeNode(child);
+        removeNode(*child);
 
     addBlockPlaceholderIfNeeded(root);
     setEndingSelection(VisibleSelection(firstPositionInNode(root), DOWNSTREAM, endingSelection().isDirectional()));
index 2c5d622..903a728 100644 (file)
@@ -414,7 +414,7 @@ void Editor::insertDictationPhrases(Vector<Vector<String>>&& dictationPhrases, R
     if (dictationPhrases.isEmpty())
         return;
 
-    applyCommand(DictationCommandIOS::create(document(), WTFMove(dictationPhrases), WTFMove(metadata)));
+    DictationCommandIOS::create(document(), WTFMove(dictationPhrases), WTFMove(metadata))->apply();
 }
 
 void Editor::setDictationPhrasesAsChildOfElement(const Vector<Vector<String>>& dictationPhrases, RetainPtr<id> metadata, Element& element)
index cb078cd..68b12eb 100644 (file)
@@ -373,8 +373,8 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuAction action, co
 
             Document* document = frame->document();
             ASSERT(document);
-            RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(*document, createFragmentFromMarkup(*document, title, emptyString()), replaceOptions);
-            applyCommand(command);
+            auto command = ReplaceSelectionCommand::create(*document, createFragmentFromMarkup(*document, title, emptyString()), replaceOptions);
+            command->apply();
             frame->selection().revealSelection(SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded);
         }
         break;
index 5dc9bd4..dca5d76 100644 (file)
@@ -581,7 +581,7 @@ bool DragController::concludeEditDrag(const DragData& dragData)
             // but only to smart insert if the selection granularity is word granularity.
             bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled();
             bool smartInsert = smartDelete && innerFrame->selection().granularity() == WordGranularity && dragData.canSmartReplace();
-            applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base(), smartInsert, smartDelete));
+            MoveSelectionCommand::create(fragment, dragCaret.base(), smartInsert, smartDelete)->apply();
         } else {
             if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point)) {
                 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting;
@@ -589,7 +589,7 @@ bool DragController::concludeEditDrag(const DragData& dragData)
                     options |= ReplaceSelectionCommand::SmartReplace;
                 if (chosePlainText)
                     options |= ReplaceSelectionCommand::MatchStyle;
-                applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, WTFMove(fragment), options, EditActionInsertFromDrop));
+                ReplaceSelectionCommand::create(*m_documentUnderMouse, WTFMove(fragment), options, EditActionInsertFromDrop)->apply();
             }
         }
     } else {
@@ -600,7 +600,7 @@ bool DragController::concludeEditDrag(const DragData& dragData)
 
         m_client.willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
         if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point))
-            applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, createFragmentFromText(*range, text),  ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting, EditActionInsertFromDrop));
+            ReplaceSelectionCommand::create(*m_documentUnderMouse, createFragmentFromText(*range, text),  ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting, EditActionInsertFromDrop)->apply();
     }
 
     if (rootEditableElement) {