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

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

Issue 1878473002: ASSERT -> DCHECK in core/editing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Output info for some DCHECKs, add TODOs. 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 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005 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 // Delete the current selection. 80 // Delete the current selection.
81 if (endingSelection().isRange()) { 81 if (endingSelection().isRange()) {
82 deleteSelection(editingState, false, false); 82 deleteSelection(editingState, false, false);
83 if (editingState->isAborted()) 83 if (editingState->isAborted())
84 return; 84 return;
85 } 85 }
86 86
87 // This is a scenario that should never happen, but we want to 87 // This is a scenario that should never happen, but we want to
88 // make sure we don't dereference a null pointer below. 88 // make sure we don't dereference a null pointer below.
89 89
90 ASSERT(!endingSelection().isNone()); 90 DCHECK(!endingSelection().isNone());
91 91
92 if (endingSelection().isNone()) 92 if (endingSelection().isNone())
93 return; 93 return;
94 94
95 VisiblePosition visiblePos = endingSelection().visibleStart(); 95 VisiblePosition visiblePos = endingSelection().visibleStart();
96 96
97 // pos is a position equivalent to the caret. We use downstream() so that p os will 97 // pos is a position equivalent to the caret. We use downstream() so that p os will
98 // be in the first node that we need to move (there are a few exceptions to this, see below). 98 // be in the first node that we need to move (there are a few exceptions to this, see below).
99 Position pos = mostForwardCaretPosition(endingSelection().start()); 99 Position pos = mostForwardCaretPosition(endingSelection().start());
100 100
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster); 136 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster);
137 } 137 }
138 138
139 // Adjust the position so we don't split at the beginning of a quote. 139 // Adjust the position so we don't split at the beginning of a quote.
140 while (isFirstVisiblePositionInNode(createVisiblePosition(pos), toHTMLQuoteE lement(enclosingNodeOfType(pos, isMailHTMLBlockquoteElement)))) { 140 while (isFirstVisiblePositionInNode(createVisiblePosition(pos), toHTMLQuoteE lement(enclosingNodeOfType(pos, isMailHTMLBlockquoteElement)))) {
141 pos = previousPositionOf(pos, PositionMoveType::GraphemeCluster); 141 pos = previousPositionOf(pos, PositionMoveType::GraphemeCluster);
142 } 142 }
143 143
144 // startNode is the first node that we need to move to the new blockquote. 144 // startNode is the first node that we need to move to the new blockquote.
145 Node* startNode = pos.anchorNode(); 145 Node* startNode = pos.anchorNode();
146 ASSERT(startNode); 146 DCHECK(startNode);
147 147
148 // Split at pos if in the middle of a text node. 148 // Split at pos if in the middle of a text node.
149 if (startNode->isTextNode()) { 149 if (startNode->isTextNode()) {
150 Text* textNode = toText(startNode); 150 Text* textNode = toText(startNode);
151 int textOffset = pos.computeOffsetInContainerNode(); 151 int textOffset = pos.computeOffsetInContainerNode();
152 if ((unsigned)textOffset >= textNode->length()) { 152 if ((unsigned)textOffset >= textNode->length()) {
153 startNode = NodeTraversal::next(*startNode); 153 startNode = NodeTraversal::next(*startNode);
154 ASSERT(startNode); 154 DCHECK(startNode);
155 } else if (textOffset > 0) { 155 } else if (textOffset > 0) {
156 splitTextNode(textNode, textOffset); 156 splitTextNode(textNode, textOffset);
157 } 157 }
158 } else if (pos.computeEditingOffset() > 0) { 158 } else if (pos.computeEditingOffset() > 0) {
159 Node* childAtOffset = NodeTraversal::childAt(*startNode, pos.computeEdit ingOffset()); 159 Node* childAtOffset = NodeTraversal::childAt(*startNode, pos.computeEdit ingOffset());
160 startNode = childAtOffset ? childAtOffset : NodeTraversal::next(*startNo de); 160 startNode = childAtOffset ? childAtOffset : NodeTraversal::next(*startNo de);
161 ASSERT(startNode); 161 DCHECK(startNode);
162 } 162 }
163 163
164 // If there's nothing inside topBlockquote to move, we're finished. 164 // If there's nothing inside topBlockquote to move, we're finished.
165 if (!startNode->isDescendantOf(topBlockquote)) { 165 if (!startNode->isDescendantOf(topBlockquote)) {
166 setEndingSelection(VisibleSelection(createVisiblePosition(firstPositionI nOrBeforeNode(startNode)), endingSelection().isDirectional())); 166 setEndingSelection(VisibleSelection(createVisiblePosition(firstPositionI nOrBeforeNode(startNode)), endingSelection().isDirectional()));
167 return; 167 return;
168 } 168 }
169 169
170 // Build up list of ancestors in between the start node and the top blockquo te. 170 // Build up list of ancestors in between the start node and the top blockquo te.
171 HeapVector<Member<Element>> ancestors; 171 HeapVector<Member<Element>> ancestors;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState); 234 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState);
235 if (editingState->isAborted()) 235 if (editingState->isAborted())
236 return; 236 return;
237 237
238 // Put the selection right before the break. 238 // Put the selection right before the break.
239 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement), TextAf finity::Downstream, endingSelection().isDirectional())); 239 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement), TextAf finity::Downstream, endingSelection().isDirectional()));
240 rebalanceWhitespace(); 240 rebalanceWhitespace();
241 } 241 }
242 242
243 } // namespace blink 243 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698