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

Side by Side Diff: Source/core/editing/InsertLineBreakCommand.cpp

Issue 299353004: Oilpan: move editing objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make test wrapper class finalized Created 6 years, 6 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
« no previous file with comments | « Source/core/editing/InsertLineBreakCommand.h ('k') | Source/core/editing/InsertListCommand.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // For now, we return to avoid a crash. https://bugs.webkit.org/show_bug.cg i?id=40342 74 // For now, we return to avoid a crash. https://bugs.webkit.org/show_bug.cg i?id=40342
75 if (caret.isNull()) 75 if (caret.isNull())
76 return; 76 return;
77 77
78 Position pos(caret.deepEquivalent()); 78 Position pos(caret.deepEquivalent());
79 79
80 pos = positionAvoidingSpecialElementBoundary(pos); 80 pos = positionAvoidingSpecialElementBoundary(pos);
81 81
82 pos = positionOutsideTabSpan(pos); 82 pos = positionOutsideTabSpan(pos);
83 83
84 RefPtr<Node> nodeToInsert; 84 RefPtrWillBeRawPtr<Node> nodeToInsert = nullptr;
85 if (shouldUseBreakElement(pos)) 85 if (shouldUseBreakElement(pos))
86 nodeToInsert = createBreakElement(document()); 86 nodeToInsert = createBreakElement(document());
87 else 87 else
88 nodeToInsert = document().createTextNode("\n"); 88 nodeToInsert = document().createTextNode("\n");
89 89
90 // FIXME: Need to merge text nodes when inserting just after or before text. 90 // FIXME: Need to merge text nodes when inserting just after or before text.
91 91
92 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) { 92 if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) {
93 bool needExtraLineBreak = !isHTMLHRElement(*pos.deprecatedNode()) && !is HTMLTableElement(*pos.deprecatedNode()); 93 bool needExtraLineBreak = !isHTMLHRElement(*pos.deprecatedNode()) && !is HTMLTableElement(*pos.deprecatedNode());
94 94
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 insertNodeAt(nbspNode.get(), positionBeforeTextNode); 134 insertNodeAt(nbspNode.get(), positionBeforeTextNode);
135 endingPosition = firstPositionInNode(nbspNode.get()); 135 endingPosition = firstPositionInNode(nbspNode.get());
136 } 136 }
137 } 137 }
138 138
139 setEndingSelection(VisibleSelection(endingPosition, DOWNSTREAM, endingSe lection().isDirectional())); 139 setEndingSelection(VisibleSelection(endingPosition, DOWNSTREAM, endingSe lection().isDirectional()));
140 } 140 }
141 141
142 // Handle the case where there is a typing style. 142 // Handle the case where there is a typing style.
143 143
144 RefPtr<EditingStyle> typingStyle = document().frame()->selection().typingSty le(); 144 RefPtrWillBeRawPtr<EditingStyle> typingStyle = document().frame()->selection ().typingStyle();
145 145
146 if (typingStyle && !typingStyle->isEmpty()) { 146 if (typingStyle && !typingStyle->isEmpty()) {
147 // Apply the typing style to the inserted line break, so that if the sel ection 147 // Apply the typing style to the inserted line break, so that if the sel ection
148 // leaves and then comes back, new input will have the right style. 148 // leaves and then comes back, new input will have the right style.
149 // FIXME: We shouldn't always apply the typing style to the line break h ere, 149 // FIXME: We shouldn't always apply the typing style to the line break h ere,
150 // see <rdar://problem/5794462>. 150 // see <rdar://problem/5794462>.
151 applyStyle(typingStyle.get(), firstPositionInOrBeforeNode(nodeToInsert.g et()), lastPositionInOrAfterNode(nodeToInsert.get())); 151 applyStyle(typingStyle.get(), firstPositionInOrBeforeNode(nodeToInsert.g et()), lastPositionInOrAfterNode(nodeToInsert.get()));
152 // Even though this applyStyle operates on a Range, it still sets an end ingSelection(). 152 // Even though this applyStyle operates on a Range, it still sets an end ingSelection().
153 // It tries to set a VisibleSelection around the content it operated on. So, that VisibleSelection 153 // It tries to set a VisibleSelection around the content it operated on. So, that VisibleSelection
154 // will either (a) select the line break we inserted, or it will (b) be a caret just 154 // will either (a) select the line break we inserted, or it will (b) be a caret just
155 // before the line break (if the line break is at the end of a block it isn't selectable). 155 // before the line break (if the line break is at the end of a block it isn't selectable).
156 // So, this next call sets the endingSelection() to a caret just after t he line break 156 // So, this next call sets the endingSelection() to a caret just after t he line break
157 // that we inserted, or just before it if it's at the end of a block. 157 // that we inserted, or just before it if it's at the end of a block.
158 setEndingSelection(endingSelection().visibleEnd()); 158 setEndingSelection(endingSelection().visibleEnd());
159 } 159 }
160 160
161 rebalanceWhitespace(); 161 rebalanceWhitespace();
162 } 162 }
163 163
164 } 164 }
OLDNEW
« no previous file with comments | « Source/core/editing/InsertLineBreakCommand.h ('k') | Source/core/editing/InsertListCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698