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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp

Issue 1997563002: Get rid of a redundant function alias positionBeforeNode() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-05-19T22:35:34 rebase Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (HTMLTextFormControlElement* textControl = enclosingTextFormContr ol(nodeToInsert)) 108 if (HTMLTextFormControlElement* textControl = enclosingTextFormContr ol(nodeToInsert))
109 extraNode = textControl->createPlaceholderBreakElement(); 109 extraNode = textControl->createPlaceholderBreakElement();
110 else 110 else
111 extraNode = nodeToInsert->cloneNode(false); 111 extraNode = nodeToInsert->cloneNode(false);
112 insertNodeAfter(extraNode, nodeToInsert, editingState); 112 insertNodeAfter(extraNode, nodeToInsert, editingState);
113 if (editingState->isAborted()) 113 if (editingState->isAborted())
114 return; 114 return;
115 nodeToInsert = extraNode; 115 nodeToInsert = extraNode;
116 } 116 }
117 117
118 VisiblePosition endingPosition = createVisiblePosition(positionBeforeNod e(nodeToInsert)); 118 VisiblePosition endingPosition = createVisiblePosition(Position::beforeN ode(nodeToInsert));
119 setEndingSelection(VisibleSelection(endingPosition, endingSelection().is Directional())); 119 setEndingSelection(VisibleSelection(endingPosition, endingSelection().is Directional()));
120 } else if (pos.computeEditingOffset() <= caretMinOffset(pos.anchorNode())) { 120 } else if (pos.computeEditingOffset() <= caretMinOffset(pos.anchorNode())) {
121 insertNodeAt(nodeToInsert, pos, editingState); 121 insertNodeAt(nodeToInsert, pos, editingState);
122 if (editingState->isAborted()) 122 if (editingState->isAborted())
123 return; 123 return;
124 124
125 // Insert an extra br or '\n' if the just inserted one collapsed. 125 // Insert an extra br or '\n' if the just inserted one collapsed.
126 if (!isStartOfParagraph(createVisiblePosition(positionBeforeNode(nodeToI nsert)))) { 126 if (!isStartOfParagraph(createVisiblePosition(Position::beforeNode(nodeT oInsert)))) {
127 insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert, editi ngState); 127 insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert, editi ngState);
128 if (editingState->isAborted()) 128 if (editingState->isAborted())
129 return; 129 return;
130 } 130 }
131 131
132 setEndingSelection(VisibleSelection(Position::inParentAfterNode(*nodeToI nsert), TextAffinity::Downstream, endingSelection().isDirectional())); 132 setEndingSelection(VisibleSelection(Position::inParentAfterNode(*nodeToI nsert), TextAffinity::Downstream, endingSelection().isDirectional()));
133 // If we're inserting after all of the rendered text in a text node, or into a non-text node, 133 // If we're inserting after all of the rendered text in a text node, or into a non-text node,
134 // a simple insertion is sufficient. 134 // a simple insertion is sufficient.
135 } else if (!pos.anchorNode()->isTextNode() || pos.computeOffsetInContainerNo de() >= caretMaxOffset(pos.anchorNode())) { 135 } else if (!pos.anchorNode()->isTextNode() || pos.computeOffsetInContainerNo de() >= caretMaxOffset(pos.anchorNode())) {
136 insertNodeAt(nodeToInsert, pos, editingState); 136 insertNodeAt(nodeToInsert, pos, editingState);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // before the line break (if the line break is at the end of a block it isn't selectable). 188 // before the line break (if the line break is at the end of a block it isn't selectable).
189 // So, this next call sets the endingSelection() to a caret just after t he line break 189 // So, this next call sets the endingSelection() to a caret just after t he line break
190 // that we inserted, or just before it if it's at the end of a block. 190 // that we inserted, or just before it if it's at the end of a block.
191 setEndingSelection(endingSelection().visibleEnd()); 191 setEndingSelection(endingSelection().visibleEnd());
192 } 192 }
193 193
194 rebalanceWhitespace(); 194 rebalanceWhitespace();
195 } 195 }
196 196
197 } // namespace blink 197 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698