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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.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, 8 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return; 80 return;
81 81
82 Position pos(caret.deepEquivalent()); 82 Position pos(caret.deepEquivalent());
83 83
84 pos = positionAvoidingSpecialElementBoundary(pos, editingState); 84 pos = positionAvoidingSpecialElementBoundary(pos, editingState);
85 if (editingState->isAborted()) 85 if (editingState->isAborted())
86 return; 86 return;
87 87
88 pos = positionOutsideTabSpan(pos); 88 pos = positionOutsideTabSpan(pos);
89 89
90 RefPtrWillBeRawPtr<Node> nodeToInsert = nullptr; 90 RawPtr<Node> nodeToInsert = nullptr;
91 if (shouldUseBreakElement(pos)) 91 if (shouldUseBreakElement(pos))
92 nodeToInsert = HTMLBRElement::create(document()); 92 nodeToInsert = HTMLBRElement::create(document());
93 else 93 else
94 nodeToInsert = document().createTextNode("\n"); 94 nodeToInsert = document().createTextNode("\n");
95 95
96 // FIXME: Need to merge text nodes when inserting just after or before text. 96 // FIXME: Need to merge text nodes when inserting just after or before text.
97 97
98 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) { 98 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) {
99 bool needExtraLineBreak = !isHTMLHRElement(*pos.anchorNode()) && !isHTML TableElement(*pos.anchorNode()); 99 bool needExtraLineBreak = !isHTMLHRElement(*pos.anchorNode()) && !isHTML TableElement(*pos.anchorNode());
100 100
101 insertNodeAt(nodeToInsert.get(), pos, editingState); 101 insertNodeAt(nodeToInsert.get(), pos, editingState);
102 if (editingState->isAborted()) 102 if (editingState->isAborted())
103 return; 103 return;
104 104
105 if (needExtraLineBreak) { 105 if (needExtraLineBreak) {
106 RefPtrWillBeRawPtr<Node> extraNode; 106 RawPtr<Node> extraNode;
107 // TODO(tkent): Can we remove HTMLTextFormControlElement dependency? 107 // TODO(tkent): Can we remove HTMLTextFormControlElement dependency?
108 if (HTMLTextFormControlElement* textControl = enclosingTextFormContr ol(nodeToInsert.get())) 108 if (HTMLTextFormControlElement* textControl = enclosingTextFormContr ol(nodeToInsert.get()))
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.get(), nodeToInsert, editingState); 112 insertNodeAfter(extraNode.get(), nodeToInsert, editingState);
113 if (editingState->isAborted()) 113 if (editingState->isAborted())
114 return; 114 return;
115 nodeToInsert = extraNode.release(); 115 nodeToInsert = extraNode.release();
116 } 116 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // use |VisiblePosition::characterAfter()|. 152 // use |VisiblePosition::characterAfter()|.
153 if (!isRenderedCharacter(endingPosition)) { 153 if (!isRenderedCharacter(endingPosition)) {
154 Position positionBeforeTextNode(positionInParentBeforeNode(*textNode )); 154 Position positionBeforeTextNode(positionInParentBeforeNode(*textNode ));
155 // Clear out all whitespace and insert one non-breaking space 155 // Clear out all whitespace and insert one non-breaking space
156 deleteInsignificantTextDownstream(endingPosition); 156 deleteInsignificantTextDownstream(endingPosition);
157 ASSERT(!textNode->layoutObject() || textNode->layoutObject()->style( )->collapseWhiteSpace()); 157 ASSERT(!textNode->layoutObject() || textNode->layoutObject()->style( )->collapseWhiteSpace());
158 // Deleting insignificant whitespace will remove textNode if it cont ains nothing but insignificant whitespace. 158 // Deleting insignificant whitespace will remove textNode if it cont ains nothing but insignificant whitespace.
159 if (textNode->inDocument()) { 159 if (textNode->inDocument()) {
160 insertTextIntoNode(textNode, 0, nonBreakingSpaceString()); 160 insertTextIntoNode(textNode, 0, nonBreakingSpaceString());
161 } else { 161 } else {
162 RefPtrWillBeRawPtr<Text> nbspNode = document().createTextNode(no nBreakingSpaceString()); 162 RawPtr<Text> nbspNode = document().createTextNode(nonBreakingSpa ceString());
163 insertNodeAt(nbspNode.get(), positionBeforeTextNode, editingStat e); 163 insertNodeAt(nbspNode.get(), positionBeforeTextNode, editingStat e);
164 if (editingState->isAborted()) 164 if (editingState->isAborted())
165 return; 165 return;
166 endingPosition = firstPositionInNode(nbspNode.get()); 166 endingPosition = firstPositionInNode(nbspNode.get());
167 } 167 }
168 } 168 }
169 169
170 setEndingSelection(VisibleSelection(endingPosition, TextAffinity::Downst ream, endingSelection().isDirectional())); 170 setEndingSelection(VisibleSelection(endingPosition, TextAffinity::Downst ream, endingSelection().isDirectional()));
171 } 171 }
172 172
173 // Handle the case where there is a typing style. 173 // Handle the case where there is a typing style.
174 174
175 RefPtrWillBeRawPtr<EditingStyle> typingStyle = document().frame()->selection ().typingStyle(); 175 RawPtr<EditingStyle> typingStyle = document().frame()->selection().typingSty le();
176 176
177 if (typingStyle && !typingStyle->isEmpty()) { 177 if (typingStyle && !typingStyle->isEmpty()) {
178 // Apply the typing style to the inserted line break, so that if the sel ection 178 // Apply the typing style to the inserted line break, so that if the sel ection
179 // leaves and then comes back, new input will have the right style. 179 // leaves and then comes back, new input will have the right style.
180 // FIXME: We shouldn't always apply the typing style to the line break h ere, 180 // FIXME: We shouldn't always apply the typing style to the line break h ere,
181 // see <rdar://problem/5794462>. 181 // see <rdar://problem/5794462>.
182 applyStyle(typingStyle.get(), firstPositionInOrBeforeNode(nodeToInsert.g et()), lastPositionInOrAfterNode(nodeToInsert.get()), editingState); 182 applyStyle(typingStyle.get(), firstPositionInOrBeforeNode(nodeToInsert.g et()), lastPositionInOrAfterNode(nodeToInsert.get()), editingState);
183 if (editingState->isAborted()) 183 if (editingState->isAborted())
184 return; 184 return;
185 // Even though this applyStyle operates on a Range, it still sets an end ingSelection(). 185 // Even though this applyStyle operates on a Range, it still sets an end ingSelection().
186 // It tries to set a VisibleSelection around the content it operated on. So, that VisibleSelection 186 // It tries to set a VisibleSelection around the content it operated on. So, that VisibleSelection
187 // will either (a) select the line break we inserted, or it will (b) be a caret just 187 // will either (a) select the line break we inserted, or it will (b) be a caret just
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