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

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

Issue 2950053002: Make Position::BeforeNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-21T17:56:36 Created 3 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
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 // If the position is at the beginning of the top quoted content, we don't 128 // If the position is at the beginning of the top quoted content, we don't
129 // need to break the quote. Instead, insert the break before the blockquote, 129 // need to break the quote. Instead, insert the break before the blockquote,
130 // unless the position is as the end of the the quoted content. 130 // unless the position is as the end of the the quoted content.
131 if (IsFirstVisiblePositionInNode(visible_pos, top_blockquote) && 131 if (IsFirstVisiblePositionInNode(visible_pos, top_blockquote) &&
132 !is_last_vis_pos_in_node) { 132 !is_last_vis_pos_in_node) {
133 InsertNodeBefore(break_element, top_blockquote, editing_state); 133 InsertNodeBefore(break_element, top_blockquote, editing_state);
134 if (editing_state->IsAborted()) 134 if (editing_state->IsAborted())
135 return; 135 return;
136 SetEndingSelection(SelectionInDOMTree::Builder() 136 SetEndingSelection(SelectionInDOMTree::Builder()
137 .Collapse(Position::BeforeNode(break_element)) 137 .Collapse(Position::BeforeNode(*break_element))
138 .SetIsDirectional(EndingSelection().IsDirectional()) 138 .SetIsDirectional(EndingSelection().IsDirectional())
139 .Build()); 139 .Build());
140 RebalanceWhitespace(); 140 RebalanceWhitespace();
141 return; 141 return;
142 } 142 }
143 143
144 // Insert a break after the top blockquote. 144 // Insert a break after the top blockquote.
145 InsertNodeAfter(break_element, top_blockquote, editing_state); 145 InsertNodeAfter(break_element, top_blockquote, editing_state);
146 if (editing_state->IsAborted()) 146 if (editing_state->IsAborted())
147 return; 147 return;
148 148
149 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 149 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
150 150
151 // If we're inserting the break at the end of the quoted content, we don't 151 // If we're inserting the break at the end of the quoted content, we don't
152 // need to break the quote. 152 // need to break the quote.
153 if (is_last_vis_pos_in_node) { 153 if (is_last_vis_pos_in_node) {
154 SetEndingSelection(SelectionInDOMTree::Builder() 154 SetEndingSelection(SelectionInDOMTree::Builder()
155 .Collapse(Position::BeforeNode(break_element)) 155 .Collapse(Position::BeforeNode(*break_element))
156 .SetIsDirectional(EndingSelection().IsDirectional()) 156 .SetIsDirectional(EndingSelection().IsDirectional())
157 .Build()); 157 .Build());
158 RebalanceWhitespace(); 158 RebalanceWhitespace();
159 return; 159 return;
160 } 160 }
161 161
162 // Don't move a line break just after the caret. Doing so would create an 162 // Don't move a line break just after the caret. Doing so would create an
163 // extra, empty paragraph in the new blockquote. 163 // extra, empty paragraph in the new blockquote.
164 if (LineBreakExistsAtVisiblePosition(visible_pos)) { 164 if (LineBreakExistsAtVisiblePosition(visible_pos)) {
165 pos = NextPositionOf(pos, PositionMoveType::kGraphemeCluster); 165 pos = NextPositionOf(pos, PositionMoveType::kGraphemeCluster);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 } 276 }
277 277
278 // Make sure the cloned block quote renders. 278 // Make sure the cloned block quote renders.
279 AddBlockPlaceholderIfNeeded(cloned_blockquote, editing_state); 279 AddBlockPlaceholderIfNeeded(cloned_blockquote, editing_state);
280 if (editing_state->IsAborted()) 280 if (editing_state->IsAborted())
281 return; 281 return;
282 282
283 // Put the selection right before the break. 283 // Put the selection right before the break.
284 SetEndingSelection(SelectionInDOMTree::Builder() 284 SetEndingSelection(SelectionInDOMTree::Builder()
285 .Collapse(Position::BeforeNode(break_element)) 285 .Collapse(Position::BeforeNode(*break_element))
286 .SetIsDirectional(EndingSelection().IsDirectional()) 286 .SetIsDirectional(EndingSelection().IsDirectional())
287 .Build()); 287 .Build());
288 RebalanceWhitespace(); 288 RebalanceWhitespace();
289 } 289 }
290 290
291 } // namespace blink 291 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698