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

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

Issue 1245843003: [CodeHealth] Use Position::anchorNode instead of deprecatedNode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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/dom/Position.cpp ('k') | Source/core/editing/ApplyStyleCommand.cpp » ('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) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Don't put the next paragraph in the blockquote we just created for th is paragraph unless 143 // Don't put the next paragraph in the blockquote we just created for th is paragraph unless
144 // the next paragraph is in the same cell. 144 // the next paragraph is in the same cell.
145 if (enclosingCell && enclosingCell != enclosingNodeOfType(endOfNextParag raph.deepEquivalent(), &isTableCell)) 145 if (enclosingCell && enclosingCell != enclosingNodeOfType(endOfNextParag raph.deepEquivalent(), &isTableCell))
146 blockquoteForNextIndent = nullptr; 146 blockquoteForNextIndent = nullptr;
147 147
148 // indentIntoBlockquote could move more than one paragraph if the paragr aph 148 // indentIntoBlockquote could move more than one paragraph if the paragr aph
149 // is in a list item or a table. As a result, endAfterSelection could re fer to a position 149 // is in a list item or a table. As a result, endAfterSelection could re fer to a position
150 // no longer in the document. 150 // no longer in the document.
151 if (endAfterSelection.isNotNull() && !endAfterSelection.deepEquivalent() .inDocument()) 151 if (endAfterSelection.isNotNull() && !endAfterSelection.deepEquivalent() .inDocument())
152 break; 152 break;
153 // Sanity check: Make sure our moveParagraph calls didn't remove endOfNe xtParagraph.deepEquivalent().deprecatedNode() 153 // Sanity check: Make sure our moveParagraph calls didn't remove endOfNe xtParagraph.deepEquivalent().anchorNode()
154 // If somehow, e.g. mutation event handler, we did, return to prevent cr ashes. 154 // If somehow, e.g. mutation event handler, we did, return to prevent cr ashes.
155 if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent ().inDocument()) 155 if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent ().inDocument())
156 return; 156 return;
157 endOfCurrentParagraph = endOfNextParagraph; 157 endOfCurrentParagraph = endOfNextParagraph;
158 } 158 }
159 } 159 }
160 160
161 static bool isNewLineAtPosition(const Position& position) 161 static bool isNewLineAtPosition(const Position& position)
162 { 162 {
163 Node* textNode = position.containerNode(); 163 Node* textNode = position.containerNode();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if (isStartAndEndOfLastParagraphOnSameNode) { 209 if (isStartAndEndOfLastParagraphOnSameNode) {
210 ASSERT(m_endOfLastParagraph.offsetInContainerNode() >= startOffs et); 210 ASSERT(m_endOfLastParagraph.offsetInContainerNode() >= startOffs et);
211 m_endOfLastParagraph = Position(startText, m_endOfLastParagraph. offsetInContainerNode() - startOffset); 211 m_endOfLastParagraph = Position(startText, m_endOfLastParagraph. offsetInContainerNode() - startOffset);
212 } 212 }
213 } 213 }
214 } 214 }
215 215
216 document().updateLayoutTreeIfNeeded(); 216 document().updateLayoutTreeIfNeeded();
217 217
218 if (const ComputedStyle* endStyle = computedStyleOfEnclosingTextNode(end)) { 218 if (const ComputedStyle* endStyle = computedStyleOfEnclosingTextNode(end)) {
219 bool isEndAndEndOfLastParagraphOnSameNode = computedStyleOfEnclosingText Node(m_endOfLastParagraph) && end.deprecatedNode() == m_endOfLastParagraph.depre catedNode(); 219 bool isEndAndEndOfLastParagraphOnSameNode = computedStyleOfEnclosingText Node(m_endOfLastParagraph) && end.anchorNode() == m_endOfLastParagraph.anchorNod e();
220 // Include \n at the end of line if we're at an empty paragraph 220 // Include \n at the end of line if we're at an empty paragraph
221 if (endStyle->preserveNewline() && start == end && end.offsetInContainer Node() < end.containerNode()->maxCharacterOffset()) { 221 if (endStyle->preserveNewline() && start == end && end.offsetInContainer Node() < end.containerNode()->maxCharacterOffset()) {
222 int endOffset = end.offsetInContainerNode(); 222 int endOffset = end.offsetInContainerNode();
223 if (!isNewLineAtPosition(end.previous()) && isNewLineAtPosition(end) ) 223 if (!isNewLineAtPosition(end.previous()) && isNewLineAtPosition(end) )
224 end = Position(end.containerText(), endOffset + 1); 224 end = Position(end.containerText(), endOffset + 1);
225 if (isEndAndEndOfLastParagraphOnSameNode && end.offsetInContainerNod e() >= m_endOfLastParagraph.offsetInContainerNode()) 225 if (isEndAndEndOfLastParagraphOnSameNode && end.offsetInContainerNod e() >= m_endOfLastParagraph.offsetInContainerNode())
226 m_endOfLastParagraph = end; 226 m_endOfLastParagraph = end;
227 } 227 }
228 228
229 // If end is in the middle of a text node, split. 229 // If end is in the middle of a text node, split.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return element.release(); 289 return element.release();
290 } 290 }
291 291
292 DEFINE_TRACE(ApplyBlockElementCommand) 292 DEFINE_TRACE(ApplyBlockElementCommand)
293 { 293 {
294 visitor->trace(m_endOfLastParagraph); 294 visitor->trace(m_endOfLastParagraph);
295 CompositeEditCommand::trace(visitor); 295 CompositeEditCommand::trace(visitor);
296 } 296 }
297 297
298 } 298 }
OLDNEW
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | Source/core/editing/ApplyStyleCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698