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

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, 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 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // For now, we return to avoid a crash. https://bugs.webkit.org/show_bug.cg i?id=40342 75 // For now, we return to avoid a crash. https://bugs.webkit.org/show_bug.cg i?id=40342
76 if (caret.isNull()) 76 if (caret.isNull())
77 return; 77 return;
78 78
79 Position pos(caret.deepEquivalent()); 79 Position pos(caret.deepEquivalent());
80 80
81 pos = positionAvoidingSpecialElementBoundary(pos); 81 pos = positionAvoidingSpecialElementBoundary(pos);
82 82
83 pos = positionOutsideTabSpan(pos); 83 pos = positionOutsideTabSpan(pos);
84 84
85 RefPtrWillBeRawPtr<Node> nodeToInsert = nullptr; 85 RawPtr<Node> nodeToInsert = nullptr;
86 if (shouldUseBreakElement(pos)) 86 if (shouldUseBreakElement(pos))
87 nodeToInsert = HTMLBRElement::create(document()); 87 nodeToInsert = HTMLBRElement::create(document());
88 else 88 else
89 nodeToInsert = document().createTextNode("\n"); 89 nodeToInsert = document().createTextNode("\n");
90 90
91 // FIXME: Need to merge text nodes when inserting just after or before text. 91 // FIXME: Need to merge text nodes when inserting just after or before text.
92 92
93 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) { 93 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) {
94 bool needExtraLineBreak = !isHTMLHRElement(*pos.anchorNode()) && !isHTML TableElement(*pos.anchorNode()); 94 bool needExtraLineBreak = !isHTMLHRElement(*pos.anchorNode()) && !isHTML TableElement(*pos.anchorNode());
95 95
(...skipping 30 matching lines...) Expand all
126 // use |VisiblePosition::characterAfter()|. 126 // use |VisiblePosition::characterAfter()|.
127 if (!isRenderedCharacter(endingPosition)) { 127 if (!isRenderedCharacter(endingPosition)) {
128 Position positionBeforeTextNode(positionInParentBeforeNode(*textNode )); 128 Position positionBeforeTextNode(positionInParentBeforeNode(*textNode ));
129 // Clear out all whitespace and insert one non-breaking space 129 // Clear out all whitespace and insert one non-breaking space
130 deleteInsignificantTextDownstream(endingPosition); 130 deleteInsignificantTextDownstream(endingPosition);
131 ASSERT(!textNode->layoutObject() || textNode->layoutObject()->style( )->collapseWhiteSpace()); 131 ASSERT(!textNode->layoutObject() || textNode->layoutObject()->style( )->collapseWhiteSpace());
132 // Deleting insignificant whitespace will remove textNode if it cont ains nothing but insignificant whitespace. 132 // Deleting insignificant whitespace will remove textNode if it cont ains nothing but insignificant whitespace.
133 if (textNode->inDocument()) { 133 if (textNode->inDocument()) {
134 insertTextIntoNode(textNode, 0, nonBreakingSpaceString()); 134 insertTextIntoNode(textNode, 0, nonBreakingSpaceString());
135 } else { 135 } else {
136 RefPtrWillBeRawPtr<Text> nbspNode = document().createTextNode(no nBreakingSpaceString()); 136 RawPtr<Text> nbspNode = document().createTextNode(nonBreakingSpa ceString());
137 insertNodeAt(nbspNode.get(), positionBeforeTextNode); 137 insertNodeAt(nbspNode.get(), positionBeforeTextNode);
138 endingPosition = firstPositionInNode(nbspNode.get()); 138 endingPosition = firstPositionInNode(nbspNode.get());
139 } 139 }
140 } 140 }
141 141
142 setEndingSelection(VisibleSelection(endingPosition, TextAffinity::Downst ream, endingSelection().isDirectional())); 142 setEndingSelection(VisibleSelection(endingPosition, TextAffinity::Downst ream, endingSelection().isDirectional()));
143 } 143 }
144 144
145 // Handle the case where there is a typing style. 145 // Handle the case where there is a typing style.
146 146
147 RefPtrWillBeRawPtr<EditingStyle> typingStyle = document().frame()->selection ().typingStyle(); 147 RawPtr<EditingStyle> typingStyle = document().frame()->selection().typingSty le();
148 148
149 if (typingStyle && !typingStyle->isEmpty()) { 149 if (typingStyle && !typingStyle->isEmpty()) {
150 // Apply the typing style to the inserted line break, so that if the sel ection 150 // Apply the typing style to the inserted line break, so that if the sel ection
151 // leaves and then comes back, new input will have the right style. 151 // leaves and then comes back, new input will have the right style.
152 // FIXME: We shouldn't always apply the typing style to the line break h ere, 152 // FIXME: We shouldn't always apply the typing style to the line break h ere,
153 // see <rdar://problem/5794462>. 153 // see <rdar://problem/5794462>.
154 applyStyle(typingStyle.get(), firstPositionInOrBeforeNode(nodeToInsert.g et()), lastPositionInOrAfterNode(nodeToInsert.get())); 154 applyStyle(typingStyle.get(), firstPositionInOrBeforeNode(nodeToInsert.g et()), lastPositionInOrAfterNode(nodeToInsert.get()));
155 // Even though this applyStyle operates on a Range, it still sets an end ingSelection(). 155 // Even though this applyStyle operates on a Range, it still sets an end ingSelection().
156 // It tries to set a VisibleSelection around the content it operated on. So, that VisibleSelection 156 // It tries to set a VisibleSelection around the content it operated on. So, that VisibleSelection
157 // will either (a) select the line break we inserted, or it will (b) be a caret just 157 // will either (a) select the line break we inserted, or it will (b) be a caret just
158 // before the line break (if the line break is at the end of a block it isn't selectable). 158 // before the line break (if the line break is at the end of a block it isn't selectable).
159 // So, this next call sets the endingSelection() to a caret just after t he line break 159 // So, this next call sets the endingSelection() to a caret just after t he line break
160 // that we inserted, or just before it if it's at the end of a block. 160 // that we inserted, or just before it if it's at the end of a block.
161 setEndingSelection(endingSelection().visibleEnd()); 161 setEndingSelection(endingSelection().visibleEnd());
162 } 162 }
163 163
164 rebalanceWhitespace(); 164 rebalanceWhitespace();
165 } 165 }
166 166
167 } // namespace blink 167 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698