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

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

Issue 2442673002: Get rid of createVisibleSelection() taking one Position (Closed)
Patch Set: 2016-10-24T17:42:38 Created 4 years, 1 month 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // If the position is at the beginning of the top quoted content, we don't 116 // If the position is at the beginning of the top quoted content, we don't
117 // need to break the quote. Instead, insert the break before the blockquote, 117 // need to break the quote. Instead, insert the break before the blockquote,
118 // unless the position is as the end of the the quoted content. 118 // unless the position is as the end of the the quoted content.
119 if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && 119 if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) &&
120 !isLastVisPosInNode) { 120 !isLastVisPosInNode) {
121 insertNodeBefore(breakElement, topBlockquote, editingState); 121 insertNodeBefore(breakElement, topBlockquote, editingState);
122 if (editingState->isAborted()) 122 if (editingState->isAborted())
123 return; 123 return;
124 document().updateStyleAndLayoutIgnorePendingStylesheets(); 124 document().updateStyleAndLayoutIgnorePendingStylesheets();
125 setEndingSelection(createVisibleSelection( 125 setEndingSelection(createVisibleSelection(
126 Position::beforeNode(breakElement), TextAffinity::Downstream, 126 SelectionInDOMTree::Builder()
127 endingSelection().isDirectional())); 127 .collapse(Position::beforeNode(breakElement))
128 .setIsDirectional(endingSelection().isDirectional())
129 .build()));
128 rebalanceWhitespace(); 130 rebalanceWhitespace();
129 return; 131 return;
130 } 132 }
131 133
132 // Insert a break after the top blockquote. 134 // Insert a break after the top blockquote.
133 insertNodeAfter(breakElement, topBlockquote, editingState); 135 insertNodeAfter(breakElement, topBlockquote, editingState);
134 if (editingState->isAborted()) 136 if (editingState->isAborted())
135 return; 137 return;
136 138
137 document().updateStyleAndLayoutIgnorePendingStylesheets(); 139 document().updateStyleAndLayoutIgnorePendingStylesheets();
138 140
139 // If we're inserting the break at the end of the quoted content, we don't 141 // If we're inserting the break at the end of the quoted content, we don't
140 // need to break the quote. 142 // need to break the quote.
141 if (isLastVisPosInNode) { 143 if (isLastVisPosInNode) {
142 setEndingSelection(createVisibleSelection( 144 setEndingSelection(createVisibleSelection(
143 Position::beforeNode(breakElement), TextAffinity::Downstream, 145 SelectionInDOMTree::Builder()
144 endingSelection().isDirectional())); 146 .collapse(Position::beforeNode(breakElement))
147 .setIsDirectional(endingSelection().isDirectional())
148 .build()));
145 rebalanceWhitespace(); 149 rebalanceWhitespace();
146 return; 150 return;
147 } 151 }
148 152
149 // Don't move a line break just after the caret. Doing so would create an 153 // Don't move a line break just after the caret. Doing so would create an
150 // extra, empty paragraph in the new blockquote. 154 // extra, empty paragraph in the new blockquote.
151 if (lineBreakExistsAtVisiblePosition(visiblePos)) { 155 if (lineBreakExistsAtVisiblePosition(visiblePos)) {
152 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster); 156 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster);
153 } 157 }
154 158
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 267 }
264 268
265 // Make sure the cloned block quote renders. 269 // Make sure the cloned block quote renders.
266 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState); 270 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState);
267 if (editingState->isAborted()) 271 if (editingState->isAborted())
268 return; 272 return;
269 273
270 document().updateStyleAndLayoutIgnorePendingStylesheets(); 274 document().updateStyleAndLayoutIgnorePendingStylesheets();
271 275
272 // Put the selection right before the break. 276 // Put the selection right before the break.
273 setEndingSelection(createVisibleSelection(Position::beforeNode(breakElement), 277 setEndingSelection(createVisibleSelection(
274 TextAffinity::Downstream, 278 SelectionInDOMTree::Builder()
275 endingSelection().isDirectional())); 279 .collapse(Position::beforeNode(breakElement))
280 .setIsDirectional(endingSelection().isDirectional())
281 .build()));
276 rebalanceWhitespace(); 282 rebalanceWhitespace();
277 } 283 }
278 284
279 } // namespace blink 285 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698