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

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

Issue 2341053002: Mark the createVisiblePosition overloads as deprecated (Closed)
Patch Set: minor revision Created 4 years, 3 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) 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 VisiblePosition endAfterSelection = endOfParagraph(nextPositionOf(endOfLastP aragraph)); 136 VisiblePosition endAfterSelection = endOfParagraph(nextPositionOf(endOfLastP aragraph));
137 m_endOfLastParagraph = endOfLastParagraph.deepEquivalent(); 137 m_endOfLastParagraph = endOfLastParagraph.deepEquivalent();
138 138
139 bool atEnd = false; 139 bool atEnd = false;
140 Position end; 140 Position end;
141 while (endOfCurrentParagraph.deepEquivalent() != endAfterSelection.deepEquiv alent() && !atEnd) { 141 while (endOfCurrentParagraph.deepEquivalent() != endAfterSelection.deepEquiv alent() && !atEnd) {
142 if (endOfCurrentParagraph.deepEquivalent() == m_endOfLastParagraph) 142 if (endOfCurrentParagraph.deepEquivalent() == m_endOfLastParagraph)
143 atEnd = true; 143 atEnd = true;
144 144
145 rangeForParagraphSplittingTextNodesIfNeeded(endOfCurrentParagraph, start , end); 145 rangeForParagraphSplittingTextNodesIfNeeded(endOfCurrentParagraph, start , end);
146 endOfCurrentParagraph = createVisiblePosition(end); 146 endOfCurrentParagraph = createVisiblePositionDeprecated(end);
147 147
148 Node* enclosingCell = enclosingNodeOfType(start, &isTableCell); 148 Node* enclosingCell = enclosingNodeOfType(start, &isTableCell);
149 VisiblePosition endOfNextParagraph = endOfNextParagrahSplittingTextNodes IfNeeded(endOfCurrentParagraph, start, end); 149 VisiblePosition endOfNextParagraph = endOfNextParagrahSplittingTextNodes IfNeeded(endOfCurrentParagraph, start, end);
150 150
151 formatRange(start, end, m_endOfLastParagraph, blockquoteForNextIndent, e ditingState); 151 formatRange(start, end, m_endOfLastParagraph, blockquoteForNextIndent, e ditingState);
152 if (editingState->isAborted()) 152 if (editingState->isAborted())
153 return; 153 return;
154 154
155 // Don't put the next paragraph in the blockquote we just created for th is paragraph unless 155 // Don't put the next paragraph in the blockquote we just created for th is paragraph unless
156 // the next paragraph is in the same cell. 156 // the next paragraph is in the same cell.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 bool isStartAndEndOnSameNode = false; 202 bool isStartAndEndOnSameNode = false;
203 if (const ComputedStyle* startStyle = computedStyleOfEnclosingTextNode(start )) { 203 if (const ComputedStyle* startStyle = computedStyleOfEnclosingTextNode(start )) {
204 isStartAndEndOnSameNode = computedStyleOfEnclosingTextNode(end) && start .computeContainerNode() == end.computeContainerNode(); 204 isStartAndEndOnSameNode = computedStyleOfEnclosingTextNode(end) && start .computeContainerNode() == end.computeContainerNode();
205 bool isStartAndEndOfLastParagraphOnSameNode = computedStyleOfEnclosingTe xtNode(m_endOfLastParagraph) && start.computeContainerNode() == m_endOfLastParag raph.computeContainerNode(); 205 bool isStartAndEndOfLastParagraphOnSameNode = computedStyleOfEnclosingTe xtNode(m_endOfLastParagraph) && start.computeContainerNode() == m_endOfLastParag raph.computeContainerNode();
206 206
207 // Avoid obtanining the start of next paragraph for start 207 // Avoid obtanining the start of next paragraph for start
208 // TODO(yosin) We should use |PositionMoveType::CodePoint| for 208 // TODO(yosin) We should use |PositionMoveType::CodePoint| for
209 // |previousPositionOf()|. 209 // |previousPositionOf()|.
210 if (startStyle->preserveNewline() && isNewLineAtPosition(start) && !isNe wLineAtPosition(previousPositionOf(start, PositionMoveType::CodeUnit)) && start. offsetInContainerNode() > 0) 210 if (startStyle->preserveNewline() && isNewLineAtPosition(start) && !isNe wLineAtPosition(previousPositionOf(start, PositionMoveType::CodeUnit)) && start. offsetInContainerNode() > 0)
211 start = startOfParagraph(createVisiblePosition(previousPositionOf(en d, PositionMoveType::CodeUnit))).deepEquivalent(); 211 start = startOfParagraph(createVisiblePositionDeprecated(previousPos itionOf(end, PositionMoveType::CodeUnit))).deepEquivalent();
212 212
213 // If start is in the middle of a text node, split. 213 // If start is in the middle of a text node, split.
214 if (!startStyle->collapseWhiteSpace() && start.offsetInContainerNode() > 0) { 214 if (!startStyle->collapseWhiteSpace() && start.offsetInContainerNode() > 0) {
215 int startOffset = start.offsetInContainerNode(); 215 int startOffset = start.offsetInContainerNode();
216 Text* startText = toText(start.computeContainerNode()); 216 Text* startText = toText(start.computeContainerNode());
217 splitTextNode(startText, startOffset); 217 splitTextNode(startText, startOffset);
218 start = Position::firstPositionInNode(startText); 218 start = Position::firstPositionInNode(startText);
219 if (isStartAndEndOnSameNode) { 219 if (isStartAndEndOnSameNode) {
220 DCHECK_GE(end.offsetInContainerNode(), startOffset); 220 DCHECK_GE(end.offsetInContainerNode(), startOffset);
221 end = Position(startText, end.offsetInContainerNode() - startOff set); 221 end = Position(startText, end.offsetInContainerNode() - startOff set);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 if (m_endOfLastParagraph.offsetInContainerNode() < position.offsetInCont ainerNode()) { 288 if (m_endOfLastParagraph.offsetInContainerNode() < position.offsetInCont ainerNode()) {
289 // We can only fix endOfLastParagraph if the previous node was still text and hasn't been modified by script. 289 // We can only fix endOfLastParagraph if the previous node was still text and hasn't been modified by script.
290 if (text->previousSibling()->isTextNode() 290 if (text->previousSibling()->isTextNode()
291 && static_cast<unsigned>(m_endOfLastParagraph.offsetInContainerN ode()) <= toText(text->previousSibling())->length()) 291 && static_cast<unsigned>(m_endOfLastParagraph.offsetInContainerN ode()) <= toText(text->previousSibling())->length())
292 m_endOfLastParagraph = Position(toText(text->previousSibling()), m_endOfLastParagraph.offsetInContainerNode()); 292 m_endOfLastParagraph = Position(toText(text->previousSibling()), m_endOfLastParagraph.offsetInContainerNode());
293 } else { 293 } else {
294 m_endOfLastParagraph = Position(text, m_endOfLastParagraph.offsetInC ontainerNode() - 1); 294 m_endOfLastParagraph = Position(text, m_endOfLastParagraph.offsetInC ontainerNode() - 1);
295 } 295 }
296 } 296 }
297 297
298 return createVisiblePosition(Position(text, position.offsetInContainerNode() - 1)); 298 return createVisiblePositionDeprecated(Position(text, position.offsetInConta inerNode() - 1));
299 } 299 }
300 300
301 HTMLElement* ApplyBlockElementCommand::createBlockElement() const 301 HTMLElement* ApplyBlockElementCommand::createBlockElement() const
302 { 302 {
303 HTMLElement* element = createHTMLElement(document(), m_tagName); 303 HTMLElement* element = createHTMLElement(document(), m_tagName);
304 if (m_inlineStyle.length()) 304 if (m_inlineStyle.length())
305 element->setAttribute(styleAttr, m_inlineStyle); 305 element->setAttribute(styleAttr, m_inlineStyle);
306 return element; 306 return element;
307 } 307 }
308 308
309 DEFINE_TRACE(ApplyBlockElementCommand) 309 DEFINE_TRACE(ApplyBlockElementCommand)
310 { 310 {
311 visitor->trace(m_endOfLastParagraph); 311 visitor->trace(m_endOfLastParagraph);
312 CompositeEditCommand::trace(visitor); 312 CompositeEditCommand::trace(visitor);
313 } 313 }
314 314
315 } // namespace blink 315 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698