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

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

Issue 1307803003: Introduce nextPositionOf() for VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-28T18:13:02 Created 5 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 insertNodeAt(blockquote, start); 116 insertNodeAt(blockquote, start);
117 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(docum ent()); 117 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(docum ent());
118 appendNode(placeholder, blockquote); 118 appendNode(placeholder, blockquote);
119 setEndingSelection(VisibleSelection(positionBeforeNode(placeholder.get() ), TextAffinity::Downstream, endingSelection().isDirectional())); 119 setEndingSelection(VisibleSelection(positionBeforeNode(placeholder.get() ), TextAffinity::Downstream, endingSelection().isDirectional()));
120 return; 120 return;
121 } 121 }
122 122
123 RefPtrWillBeRawPtr<HTMLElement> blockquoteForNextIndent = nullptr; 123 RefPtrWillBeRawPtr<HTMLElement> blockquoteForNextIndent = nullptr;
124 VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection); 124 VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection);
125 VisiblePosition endOfLastParagraph = endOfParagraph(endOfSelection); 125 VisiblePosition endOfLastParagraph = endOfParagraph(endOfSelection);
126 VisiblePosition endAfterSelection = endOfParagraph(endOfLastParagraph.next() ); 126 VisiblePosition endAfterSelection = endOfParagraph(nextPositionOf(endOfLastP aragraph));
127 m_endOfLastParagraph = endOfLastParagraph.deepEquivalent(); 127 m_endOfLastParagraph = endOfLastParagraph.deepEquivalent();
128 128
129 bool atEnd = false; 129 bool atEnd = false;
130 Position end; 130 Position end;
131 while (endOfCurrentParagraph.deepEquivalent() != endAfterSelection.deepEquiv alent() && !atEnd) { 131 while (endOfCurrentParagraph.deepEquivalent() != endAfterSelection.deepEquiv alent() && !atEnd) {
132 if (endOfCurrentParagraph.deepEquivalent() == m_endOfLastParagraph) 132 if (endOfCurrentParagraph.deepEquivalent() == m_endOfLastParagraph)
133 atEnd = true; 133 atEnd = true;
134 134
135 rangeForParagraphSplittingTextNodesIfNeeded(endOfCurrentParagraph, start , end); 135 rangeForParagraphSplittingTextNodesIfNeeded(endOfCurrentParagraph, start , end);
136 endOfCurrentParagraph = VisiblePosition(end); 136 endOfCurrentParagraph = VisiblePosition(end);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 else 242 else
243 m_endOfLastParagraph = Position(endContainer, m_endOfLastPar agraph.offsetInContainerNode() - end.offsetInContainerNode()); 243 m_endOfLastParagraph = Position(endContainer, m_endOfLastPar agraph.offsetInContainerNode() - end.offsetInContainerNode());
244 } 244 }
245 end = lastPositionInNode(endContainer->previousSibling()); 245 end = lastPositionInNode(endContainer->previousSibling());
246 } 246 }
247 } 247 }
248 } 248 }
249 249
250 VisiblePosition ApplyBlockElementCommand::endOfNextParagrahSplittingTextNodesIfN eeded(VisiblePosition& endOfCurrentParagraph, Position& start, Position& end) 250 VisiblePosition ApplyBlockElementCommand::endOfNextParagrahSplittingTextNodesIfN eeded(VisiblePosition& endOfCurrentParagraph, Position& start, Position& end)
251 { 251 {
252 VisiblePosition endOfNextParagraph = endOfParagraph(endOfCurrentParagraph.ne xt()); 252 VisiblePosition endOfNextParagraph = endOfParagraph(nextPositionOf(endOfCurr entParagraph));
253 Position position = endOfNextParagraph.deepEquivalent(); 253 Position position = endOfNextParagraph.deepEquivalent();
254 const ComputedStyle* style = computedStyleOfEnclosingTextNode(position); 254 const ComputedStyle* style = computedStyleOfEnclosingTextNode(position);
255 if (!style) 255 if (!style)
256 return endOfNextParagraph; 256 return endOfNextParagraph;
257 257
258 RefPtrWillBeRawPtr<Text> text = toText(position.computeContainerNode()); 258 RefPtrWillBeRawPtr<Text> text = toText(position.computeContainerNode());
259 if (!style->preserveNewline() || !position.offsetInContainerNode() || !isNew LineAtPosition(firstPositionInNode(text.get()))) 259 if (!style->preserveNewline() || !position.offsetInContainerNode() || !isNew LineAtPosition(firstPositionInNode(text.get())))
260 return endOfNextParagraph; 260 return endOfNextParagraph;
261 261
262 // \n at the beginning of the text node immediately following the current pa ragraph is trimmed by moveParagraphWithClones. 262 // \n at the beginning of the text node immediately following the current pa ragraph is trimmed by moveParagraphWithClones.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return element.release(); 294 return element.release();
295 } 295 }
296 296
297 DEFINE_TRACE(ApplyBlockElementCommand) 297 DEFINE_TRACE(ApplyBlockElementCommand)
298 { 298 {
299 visitor->trace(m_endOfLastParagraph); 299 visitor->trace(m_endOfLastParagraph);
300 CompositeEditCommand::trace(visitor); 300 CompositeEditCommand::trace(visitor);
301 } 301 }
302 302
303 } 303 }
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleUnits.cpp ('k') | Source/core/editing/commands/ApplyStyleCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698