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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
index 612ea9eda0c092adddc26a72337b8444e63cb009..a021aebc124291acc483312ee2e748996f7a0613 100644
--- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
@@ -83,19 +83,19 @@ public:
bool hasInterchangeNewlineAtStart() const { return m_hasInterchangeNewlineAtStart; }
bool hasInterchangeNewlineAtEnd() const { return m_hasInterchangeNewlineAtEnd; }
- void removeNode(PassRefPtrWillBeRawPtr<Node>);
- void removeNodePreservingChildren(PassRefPtrWillBeRawPtr<ContainerNode>);
+ void removeNode(RawPtr<Node>);
+ void removeNodePreservingChildren(RawPtr<ContainerNode>);
private:
- PassRefPtrWillBeRawPtr<HTMLElement> insertFragmentForTestRendering(Element* rootEditableElement);
+ RawPtr<HTMLElement> insertFragmentForTestRendering(Element* rootEditableElement);
void removeUnrenderedNodes(ContainerNode*);
void restoreAndRemoveTestRenderingNodesToFragment(Element*);
void removeInterchangeNodes(ContainerNode*);
- void insertNodeBefore(PassRefPtrWillBeRawPtr<Node>, Node* refNode);
+ void insertNodeBefore(RawPtr<Node>, Node* refNode);
- RefPtrWillBeMember<Document> m_document;
- RefPtrWillBeMember<DocumentFragment> m_fragment;
+ Member<Document> m_document;
+ Member<DocumentFragment> m_fragment;
bool m_hasInterchangeNewlineAtStart;
bool m_hasInterchangeNewlineAtEnd;
};
@@ -155,7 +155,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
if (!m_fragment || !m_fragment->hasChildren())
return;
- RefPtrWillBeRawPtr<Element> editableRoot = selection.rootEditableElement();
+ RawPtr<Element> editableRoot = selection.rootEditableElement();
ASSERT(editableRoot);
if (!editableRoot)
return;
@@ -174,7 +174,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
return;
}
- RefPtrWillBeRawPtr<HTMLElement> holder = insertFragmentForTestRendering(editableRoot.get());
+ RawPtr<HTMLElement> holder = insertFragmentForTestRendering(editableRoot.get());
if (!holder) {
removeInterchangeNodes(m_fragment.get());
return;
@@ -188,7 +188,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
restoreAndRemoveTestRenderingNodesToFragment(holder.get());
// Give the root a chance to change the text.
- RefPtrWillBeRawPtr<BeforeTextInsertedEvent> evt = BeforeTextInsertedEvent::create(text);
+ RawPtr<BeforeTextInsertedEvent> evt = BeforeTextInsertedEvent::create(text);
editableRoot->dispatchEvent(evt);
if (text != evt->text() || !editableRoot->layoutObjectIsRichlyEditable()) {
restoreAndRemoveTestRenderingNodesToFragment(holder.get());
@@ -219,19 +219,19 @@ Node* ReplacementFragment::lastChild() const
return m_fragment ? m_fragment->lastChild() : 0;
}
-void ReplacementFragment::removeNodePreservingChildren(PassRefPtrWillBeRawPtr<ContainerNode> node)
+void ReplacementFragment::removeNodePreservingChildren(RawPtr<ContainerNode> node)
{
if (!node)
return;
- while (RefPtrWillBeRawPtr<Node> n = node->firstChild()) {
+ while (RawPtr<Node> n = node->firstChild()) {
removeNode(n);
insertNodeBefore(n.release(), node.get());
}
removeNode(node);
}
-void ReplacementFragment::removeNode(PassRefPtrWillBeRawPtr<Node> node)
+void ReplacementFragment::removeNode(RawPtr<Node> node)
{
if (!node)
return;
@@ -243,7 +243,7 @@ void ReplacementFragment::removeNode(PassRefPtrWillBeRawPtr<Node> node)
parent->removeChild(node.get());
}
-void ReplacementFragment::insertNodeBefore(PassRefPtrWillBeRawPtr<Node> node, Node* refNode)
+void ReplacementFragment::insertNodeBefore(RawPtr<Node> node, Node* refNode)
{
if (!node || !refNode)
return;
@@ -255,10 +255,10 @@ void ReplacementFragment::insertNodeBefore(PassRefPtrWillBeRawPtr<Node> node, No
parent->insertBefore(node, refNode);
}
-PassRefPtrWillBeRawPtr<HTMLElement> ReplacementFragment::insertFragmentForTestRendering(Element* rootEditableElement)
+RawPtr<HTMLElement> ReplacementFragment::insertFragmentForTestRendering(Element* rootEditableElement)
{
ASSERT(m_document);
- RefPtrWillBeRawPtr<HTMLElement> holder = createDefaultParagraphElement(*m_document.get());
+ RawPtr<HTMLElement> holder = createDefaultParagraphElement(*m_document.get());
holder->appendChild(m_fragment);
rootEditableElement->appendChild(holder.get());
@@ -272,7 +272,7 @@ void ReplacementFragment::restoreAndRemoveTestRenderingNodesToFragment(Element*
if (!holder)
return;
- while (RefPtrWillBeRawPtr<Node> node = holder->firstChild()) {
+ while (RawPtr<Node> node = holder->firstChild()) {
holder->removeChild(node.get());
m_fragment->appendChild(node.get());
}
@@ -282,7 +282,7 @@ void ReplacementFragment::restoreAndRemoveTestRenderingNodesToFragment(Element*
void ReplacementFragment::removeUnrenderedNodes(ContainerNode* holder)
{
- WillBeHeapVector<RefPtrWillBeMember<Node>> unrendered;
+ HeapVector<Member<Node>> unrendered;
for (Node& node : NodeTraversal::descendantsOf(*holder)) {
if (!isNodeRendered(node) && !isTableStructureNode(&node))
@@ -325,7 +325,7 @@ void ReplacementFragment::removeInterchangeNodes(ContainerNode* container)
node = container->firstChild();
while (node) {
- RefPtrWillBeRawPtr<Node> next = NodeTraversal::next(*node);
+ RawPtr<Node> next = NodeTraversal::next(*node);
if (isHTMLInterchangeConvertedSpaceSpan(node)) {
HTMLElement& element = toHTMLElement(*node);
next = NodeTraversal::nextSkippingChildren(element);
@@ -371,7 +371,7 @@ inline void ReplaceSelectionCommand::InsertedNodes::didReplaceNode(Node& node, N
m_lastNodeInserted = &newNode;
}
-ReplaceSelectionCommand::ReplaceSelectionCommand(Document& document, PassRefPtrWillBeRawPtr<DocumentFragment> fragment, CommandOptions options, EditAction editAction)
+ReplaceSelectionCommand::ReplaceSelectionCommand(Document& document, RawPtr<DocumentFragment> fragment, CommandOptions options, EditAction editAction)
: CompositeEditCommand(document)
, m_selectReplacement(options & SelectReplacement)
, m_smartReplace(options & SmartReplace)
@@ -484,9 +484,9 @@ bool ReplaceSelectionCommand::shouldMerge(const VisiblePosition& source, const V
// a div inserted into a document with div { display:inline; }.
void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(InsertedNodes& insertedNodes)
{
- RefPtrWillBeRawPtr<Node> pastEndNode = insertedNodes.pastLastLeaf();
- RefPtrWillBeRawPtr<Node> next = nullptr;
- for (RefPtrWillBeRawPtr<Node> node = insertedNodes.firstNodeInserted(); node && node != pastEndNode; node = next) {
+ RawPtr<Node> pastEndNode = insertedNodes.pastLastLeaf();
+ RawPtr<Node> next = nullptr;
+ for (RawPtr<Node> node = insertedNodes.firstNodeInserted(); node && node != pastEndNode; node = next) {
// FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance
next = NodeTraversal::next(*node);
@@ -496,7 +496,7 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
Element* element = toElement(node);
const StylePropertySet* inlineStyle = element->inlineStyle();
- RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = EditingStyle::create(inlineStyle);
+ RawPtr<EditingStyle> newInlineStyle = EditingStyle::create(inlineStyle);
if (inlineStyle) {
if (element->isHTMLElement()) {
Vector<QualifiedName> attributes;
@@ -635,9 +635,9 @@ static bool isProhibitedParagraphChild(const AtomicString& name)
void ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder(const InsertedNodes& insertedNodes)
{
- RefPtrWillBeRawPtr<Node> pastEndNode = insertedNodes.pastLastLeaf();
- RefPtrWillBeRawPtr<Node> next = nullptr;
- for (RefPtrWillBeRawPtr<Node> node = insertedNodes.firstNodeInserted(); node && node != pastEndNode; node = next) {
+ RawPtr<Node> pastEndNode = insertedNodes.pastLastLeaf();
+ RawPtr<Node> next = nullptr;
+ for (RawPtr<Node> node = insertedNodes.firstNodeInserted(); node && node != pastEndNode; node = next) {
next = NodeTraversal::next(*node);
if (!node->isHTMLElement())
@@ -660,10 +660,10 @@ void ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuild
}
}
-void ReplaceSelectionCommand::moveElementOutOfAncestor(PassRefPtrWillBeRawPtr<Element> prpElement, PassRefPtrWillBeRawPtr<Element> prpAncestor)
+void ReplaceSelectionCommand::moveElementOutOfAncestor(RawPtr<Element> prpElement, RawPtr<Element> prpAncestor)
{
- RefPtrWillBeRawPtr<Element> element = prpElement;
- RefPtrWillBeRawPtr<Element> ancestor = prpAncestor;
+ RawPtr<Element> element = prpElement;
+ RawPtr<Element> ancestor = prpAncestor;
if (!ancestor->parentNode()->hasEditableStyle())
return;
@@ -677,7 +677,7 @@ void ReplaceSelectionCommand::moveElementOutOfAncestor(PassRefPtrWillBeRawPtr<El
else
appendNode(element, ancestor->parentNode());
} else {
- RefPtrWillBeRawPtr<Node> nodeToSplitTo = splitTreeToNode(element.get(), ancestor.get(), true);
+ RawPtr<Node> nodeToSplitTo = splitTreeToNode(element.get(), ancestor.get(), true);
removeNode(element);
insertNodeBefore(element, nodeToSplitTo);
}
@@ -757,7 +757,7 @@ static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const
return false;
HTMLSpanElement* wrappingStyleSpan = toHTMLSpanElement(topNode);
- RefPtrWillBeRawPtr<EditingStyle> styleAtInsertionPos = EditingStyle::create(insertionPos.parentAnchoredEquivalent());
+ RawPtr<EditingStyle> styleAtInsertionPos = EditingStyle::create(insertionPos.parentAnchoredEquivalent());
String styleText = styleAtInsertionPos->style()->asText();
// FIXME: This string comparison is a naive way of comparing two styles.
@@ -796,7 +796,7 @@ void ReplaceSelectionCommand::handleStyleSpans(InsertedNodes& insertedNodes)
if (!wrappingStyleSpan)
return;
- RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(wrappingStyleSpan->inlineStyle());
+ RawPtr<EditingStyle> style = EditingStyle::create(wrappingStyleSpan->inlineStyle());
ContainerNode* context = wrappingStyleSpan->parentNode();
// If Mail wraps the fragment with a Paste as Quotation blockquote, or if you're pasting into a quoted region,
@@ -851,7 +851,7 @@ void ReplaceSelectionCommand::mergeEndIfNeeded()
// Merging forward could result in deleting the destination anchor node.
// To avoid this, we add a placeholder node before the start of the paragraph.
if (endOfParagraph(startOfParagraphToMove).deepEquivalent() == destination.deepEquivalent()) {
- RefPtrWillBeRawPtr<HTMLBRElement> placeholder = HTMLBRElement::create(document());
+ RawPtr<HTMLBRElement> placeholder = HTMLBRElement::create(document());
insertNodeBefore(placeholder, startOfParagraphToMove.deepEquivalent().anchorNode());
destination = createVisiblePosition(positionBeforeNode(placeholder.get()));
}
@@ -1031,7 +1031,7 @@ void ReplaceSelectionCommand::doApply()
if (endBR)
originalVisPosBeforeEndBR = previousPositionOf(createVisiblePosition(positionBeforeNode(endBR)));
- RefPtrWillBeRawPtr<Element> enclosingBlockOfInsertionPos = enclosingBlock(insertionPos.anchorNode());
+ RawPtr<Element> enclosingBlockOfInsertionPos = enclosingBlock(insertionPos.anchorNode());
// Adjust insertionPos to prevent nesting.
// If the start was in a Mail blockquote, we will have already handled adjusting insertionPos above.
@@ -1080,12 +1080,12 @@ void ReplaceSelectionCommand::doApply()
insertionPos = firstPositionInNode(insertionPos.computeContainerNode());
}
- if (RefPtrWillBeRawPtr<HTMLElement> elementToSplitTo = elementToSplitToAvoidPastingIntoInlineElementsWithStyle(insertionPos)) {
+ if (RawPtr<HTMLElement> elementToSplitTo = elementToSplitToAvoidPastingIntoInlineElementsWithStyle(insertionPos)) {
if (insertionPos.computeContainerNode() != elementToSplitTo->parentNode()) {
Node* splitStart = insertionPos.computeNodeAfterPosition();
if (!splitStart)
splitStart = insertionPos.computeContainerNode();
- RefPtrWillBeRawPtr<Node> nodeToSplitTo = splitTreeToNode(splitStart, elementToSplitTo->parentNode()).get();
+ RawPtr<Node> nodeToSplitTo = splitTreeToNode(splitStart, elementToSplitTo->parentNode()).get();
insertionPos = positionInParentBeforeNode(*nodeToSplitTo);
}
}
@@ -1105,9 +1105,9 @@ void ReplaceSelectionCommand::doApply()
// 6) Select the replacement if requested, and match style if requested.
InsertedNodes insertedNodes;
- RefPtrWillBeRawPtr<Node> refNode = fragment.firstChild();
+ RawPtr<Node> refNode = fragment.firstChild();
ASSERT(refNode);
- RefPtrWillBeRawPtr<Node> node = refNode->nextSibling();
+ RawPtr<Node> node = refNode->nextSibling();
fragment.removeNode(refNode);
@@ -1127,7 +1127,7 @@ void ReplaceSelectionCommand::doApply()
bool plainTextFragment = isPlainTextMarkup(refNode.get());
while (node) {
- RefPtrWillBeRawPtr<Node> next = node->nextSibling();
+ RawPtr<Node> next = node->nextSibling();
fragment.removeNode(node.get());
insertNodeAfter(node, refNode);
insertedNodes.respondToNodeInsertion(*node);
@@ -1164,7 +1164,7 @@ void ReplaceSelectionCommand::doApply()
insertNodeAt(HTMLBRElement::create(document()).get(), startOfInsertedContent.deepEquivalent());
if (endBR && (plainTextFragment || (shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR) && !(fragment.hasInterchangeNewlineAtEnd() && selectionIsPlainText)))) {
- RefPtrWillBeRawPtr<ContainerNode> parent = endBR->parentNode();
+ RawPtr<ContainerNode> parent = endBR->parentNode();
insertedNodes.willRemoveNode(*endBR);
removeNode(endBR);
if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) {
@@ -1231,7 +1231,7 @@ void ReplaceSelectionCommand::doApply()
setEndingSelection(endOfInsertedContent);
Element* enclosingBlockElement = enclosingBlock(endOfInsertedContent.deepEquivalent().anchorNode());
if (isListItem(enclosingBlockElement)) {
- RefPtrWillBeRawPtr<HTMLLIElement> newListItem = HTMLLIElement::create(document());
+ RawPtr<HTMLLIElement> newListItem = HTMLLIElement::create(document());
insertNodeAfter(newListItem, enclosingBlockElement);
setEndingSelection(createVisiblePosition(firstPositionInNode(newListItem.get())));
} else {
@@ -1325,7 +1325,7 @@ void ReplaceSelectionCommand::addSpacesForSmartReplace()
if (m_endOfInsertedContent.computeContainerNode() == endNode)
m_endOfInsertedContent = Position(endNode, m_endOfInsertedContent.offsetInContainerNode() + 1);
} else {
- RefPtrWillBeRawPtr<Text> node = document().createEditingTextNode(collapseWhiteSpace ? nonBreakingSpaceString() : " ");
+ RawPtr<Text> node = document().createEditingTextNode(collapseWhiteSpace ? nonBreakingSpaceString() : " ");
insertNodeAfter(node, endNode);
updateNodesInserted(node.get());
}
@@ -1349,7 +1349,7 @@ void ReplaceSelectionCommand::addSpacesForSmartReplace()
if (m_endOfInsertedContent.computeContainerNode() == startNode && m_endOfInsertedContent.offsetInContainerNode())
m_endOfInsertedContent = Position(startNode, m_endOfInsertedContent.offsetInContainerNode() + 1);
} else {
- RefPtrWillBeRawPtr<Text> node = document().createEditingTextNode(collapseWhiteSpace ? nonBreakingSpaceString() : " ");
+ RawPtr<Text> node = document().createEditingTextNode(collapseWhiteSpace ? nonBreakingSpaceString() : " ");
// Don't updateNodesInserted. Doing so would set m_endOfInsertedContent to be the node containing the leading space,
// but m_endOfInsertedContent is supposed to mark the end of pasted content.
insertNodeBefore(node, startNode);
@@ -1397,7 +1397,7 @@ void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P
{
bool positionIsOffsetInAnchor = position.isOffsetInAnchor();
bool positionOnlyToBeUpdatedIsOffsetInAnchor = positionOnlyToBeUpdated.isOffsetInAnchor();
- RefPtrWillBeRawPtr<Text> text = nullptr;
+ RawPtr<Text> text = nullptr;
if (positionIsOffsetInAnchor && position.computeContainerNode() && position.computeContainerNode()->isTextNode()) {
text = toText(position.computeContainerNode());
} else {
@@ -1414,7 +1414,7 @@ void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P
return;
if (text->previousSibling() && text->previousSibling()->isTextNode()) {
- RefPtrWillBeRawPtr<Text> previous = toText(text->previousSibling());
+ RawPtr<Text> previous = toText(text->previousSibling());
insertTextIntoNode(text, 0, previous->data());
if (positionIsOffsetInAnchor)
@@ -1434,7 +1434,7 @@ void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P
removeNode(previous);
}
if (text->nextSibling() && text->nextSibling()->isTextNode()) {
- RefPtrWillBeRawPtr<Text> next = toText(text->nextSibling());
+ RawPtr<Text> next = toText(text->nextSibling());
unsigned originalLength = text->length();
insertTextIntoNode(text, originalLength, next->data());
@@ -1457,9 +1457,9 @@ EditAction ReplaceSelectionCommand::editingAction() const
// If the user is inserting a list into an existing list, instead of nesting the list,
// we put the list items into the existing list.
-Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtrWillBeRawPtr<HTMLElement> prpListElement, Element* insertionBlock, const Position& insertPos, InsertedNodes& insertedNodes)
+Node* ReplaceSelectionCommand::insertAsListItems(RawPtr<HTMLElement> prpListElement, Element* insertionBlock, const Position& insertPos, InsertedNodes& insertedNodes)
{
- RefPtrWillBeRawPtr<HTMLElement> listElement = prpListElement;
+ RawPtr<HTMLElement> listElement = prpListElement;
while (listElement->hasOneChild() && isHTMLListElement(listElement->firstChild()))
listElement = toHTMLElement(listElement->firstChild());
@@ -1478,7 +1478,7 @@ Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtrWillBeRawPtr<HTMLElem
splitTreeToNode(insertPos.anchorNode(), lastNode, true);
}
- while (RefPtrWillBeRawPtr<Node> listItem = listElement->firstChild()) {
+ while (RawPtr<Node> listItem = listElement->firstChild()) {
listElement->removeChild(listItem.get(), ASSERT_NO_EXCEPTION);
if (isStart || isMiddle) {
insertNodeBefore(listItem, lastNode);
@@ -1526,7 +1526,7 @@ bool ReplaceSelectionCommand::performTrivialReplace(const ReplacementFragment& f
if (elementToSplitToAvoidPastingIntoInlineElementsWithStyle(endingSelection().start()))
return false;
- RefPtrWillBeRawPtr<Node> nodeAfterInsertionPos = mostForwardCaretPosition(endingSelection().end()).anchorNode();
+ RawPtr<Node> nodeAfterInsertionPos = mostForwardCaretPosition(endingSelection().end()).anchorNode();
Text* textNode = toText(fragment.firstChild());
// Our fragment creation code handles tabs, spaces, and newlines, so we don't have to worry about those here.

Powered by Google App Engine
This is Rietveld 408576698