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

Unified Diff: Source/core/editing/ReplaceSelectionCommand.cpp

Issue 182383012: Have positionInParentBeforeNode() / positionInParentAfterNode() take a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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
« no previous file with comments | « Source/core/editing/InsertTextCommand.cpp ('k') | Source/core/editing/VisibleSelection.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/ReplaceSelectionCommand.cpp
diff --git a/Source/core/editing/ReplaceSelectionCommand.cpp b/Source/core/editing/ReplaceSelectionCommand.cpp
index c58cc8f05c8c01952bbe8510a21345158e42f966..d28e85d733ddef3d312083add35f940782f82c10 100644
--- a/Source/core/editing/ReplaceSelectionCommand.cpp
+++ b/Source/core/editing/ReplaceSelectionCommand.cpp
@@ -122,7 +122,7 @@ static Position positionAvoidingPrecedingNodes(Position pos)
break;
if (pos.containerNode()->nonShadowBoundaryParentNode())
- nextPosition = positionInParentAfterNode(pos.containerNode());
+ nextPosition = positionInParentAfterNode(*pos.containerNode());
if (nextPosition == pos
|| enclosingBlock(nextPosition.containerNode()) != enclosingBlockNode
@@ -620,12 +620,12 @@ void ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuild
continue;
if (isProhibitedParagraphChild(toHTMLElement(node)->localName())) {
- if (HTMLElement* paragraphElement = toHTMLElement(enclosingNodeWithTag(positionInParentBeforeNode(node.get()), pTag)))
+ if (HTMLElement* paragraphElement = toHTMLElement(enclosingNodeWithTag(positionInParentBeforeNode(*node), pTag)))
moveNodeOutOfAncestor(node, paragraphElement);
}
if (isHeaderElement(node.get())) {
- if (HTMLElement* headerElement = toHTMLElement(highestEnclosingNodeOfType(positionInParentBeforeNode(node.get()), isHeaderElement)))
+ if (HTMLElement* headerElement = toHTMLElement(highestEnclosingNodeOfType(positionInParentBeforeNode(*node), isHeaderElement)))
moveNodeOutOfAncestor(node, headerElement);
}
}
@@ -973,7 +973,7 @@ void ReplaceSelectionCommand::doApply()
Node* br = endingSelection().start().deprecatedNode();
ASSERT(br->hasTagName(brTag));
// Insert content between the two blockquotes, but remove the br (since it was just a placeholder).
- insertionPos = positionInParentBeforeNode(br);
+ insertionPos = positionInParentBeforeNode(*br);
removeNode(br);
}
@@ -1000,9 +1000,9 @@ void ReplaceSelectionCommand::doApply()
ASSERT(insertionBlock != currentRoot);
VisiblePosition visibleInsertionPos(insertionPos);
if (isEndOfBlock(visibleInsertionPos) && !(isStartOfBlock(visibleInsertionPos) && fragment.hasInterchangeNewlineAtEnd()))
- insertionPos = positionInParentAfterNode(insertionBlock.get());
+ insertionPos = positionInParentAfterNode(*insertionBlock);
else if (isStartOfBlock(visibleInsertionPos))
- insertionPos = positionInParentBeforeNode(insertionBlock.get());
+ insertionPos = positionInParentBeforeNode(*insertionBlock);
}
// Paste at start or end of link goes outside of link.
@@ -1047,7 +1047,7 @@ void ReplaceSelectionCommand::doApply()
if (!splitStart)
splitStart = insertionPos.containerNode();
nodeToSplitTo = splitTreeToNode(splitStart, nodeToSplitTo->parentNode()).get();
- insertionPos = positionInParentBeforeNode(nodeToSplitTo.get());
+ insertionPos = positionInParentBeforeNode(*nodeToSplitTo);
}
}
}
@@ -1377,15 +1377,16 @@ void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P
if (positionIsOffsetInAnchor)
position.moveToOffset(previous->length() + position.offsetInContainerNode());
else
- updatePositionForNodeRemoval(position, previous.get());
+ updatePositionForNodeRemoval(position, *previous);
if (positionOnlyToBeUpdatedIsOffsetInAnchor) {
if (positionOnlyToBeUpdated.containerNode() == text)
positionOnlyToBeUpdated.moveToOffset(previous->length() + positionOnlyToBeUpdated.offsetInContainerNode());
else if (positionOnlyToBeUpdated.containerNode() == previous)
positionOnlyToBeUpdated.moveToPosition(text, positionOnlyToBeUpdated.offsetInContainerNode());
- } else
- updatePositionForNodeRemoval(positionOnlyToBeUpdated, previous.get());
+ } else {
+ updatePositionForNodeRemoval(positionOnlyToBeUpdated, *previous);
+ }
removeNode(previous);
}
@@ -1395,12 +1396,12 @@ void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P
insertTextIntoNode(text, originalLength, next->data());
if (!positionIsOffsetInAnchor)
- updatePositionForNodeRemoval(position, next.get());
+ updatePositionForNodeRemoval(position, *next);
if (positionOnlyToBeUpdatedIsOffsetInAnchor && positionOnlyToBeUpdated.containerNode() == next)
positionOnlyToBeUpdated.moveToPosition(text, originalLength + positionOnlyToBeUpdated.offsetInContainerNode());
else
- updatePositionForNodeRemoval(positionOnlyToBeUpdated, next.get());
+ updatePositionForNodeRemoval(positionOnlyToBeUpdated, *next);
removeNode(next);
}
« no previous file with comments | « Source/core/editing/InsertTextCommand.cpp ('k') | Source/core/editing/VisibleSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698