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

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

Issue 2322853004: Convert an assertion to if-condition in ReplaceSelectionCommand::doApply() (Closed)
Patch Set: 2016-09-12T14:19:36 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
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/editing/pasteboard/paste-text-009-expected.txt ('k') | no next file » | 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) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2010, 2011 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 // NOTE: This would be an incorrect usage of downstream() if downstream() we re changed to mean the last position after 1138 // NOTE: This would be an incorrect usage of downstream() if downstream() we re changed to mean the last position after
1139 // p that maps to the same visible position as p (since in the case where a br is at the end of a block and collapsed 1139 // p that maps to the same visible position as p (since in the case where a br is at the end of a block and collapsed
1140 // away, there are positions after the br which map to the same visible posi tion as [br, 0]). 1140 // away, there are positions after the br which map to the same visible posi tion as [br, 0]).
1141 HTMLBRElement* endBR = isHTMLBRElement(*mostForwardCaretPosition(insertionPo s).anchorNode()) ? toHTMLBRElement(mostForwardCaretPosition(insertionPos).anchor Node()) : 0; 1141 HTMLBRElement* endBR = isHTMLBRElement(*mostForwardCaretPosition(insertionPo s).anchorNode()) ? toHTMLBRElement(mostForwardCaretPosition(insertionPos).anchor Node()) : 0;
1142 VisiblePosition originalVisPosBeforeEndBR; 1142 VisiblePosition originalVisPosBeforeEndBR;
1143 if (endBR) 1143 if (endBR)
1144 originalVisPosBeforeEndBR = previousPositionOf(VisiblePosition::beforeNo de(endBR)); 1144 originalVisPosBeforeEndBR = previousPositionOf(VisiblePosition::beforeNo de(endBR));
1145 1145
1146 Element* enclosingBlockOfInsertionPos = enclosingBlock(insertionPos.anchorNo de()); 1146 Element* enclosingBlockOfInsertionPos = enclosingBlock(insertionPos.anchorNo de());
1147 1147
1148 // Adjust insertionPos to prevent nesting. 1148 // Adjust |enclosingBlockOfInsertionPos| to prevent nesting.
Xiaocheng 2016/09/12 07:19:49 nit: The body of this |if| is still adjusting |ins
yosin_UTC9 2016/09/12 07:36:01 I just change variable name |insertPos| to |enclos
1149 // If the start was in a Mail blockquote, we will have already handled adjus ting insertionPos above. 1149 // If the start was in a Mail blockquote, we will have already handled
1150 if (m_preventNesting && enclosingBlockOfInsertionPos && !isTableCell(enclosi ngBlockOfInsertionPos) && !startIsInsideMailBlockquote) { 1150 // adjusting |enclosingBlockOfInsertionPos| above.
1151 DCHECK_NE(enclosingBlockOfInsertionPos, currentRoot); 1151 if (m_preventNesting && enclosingBlockOfInsertionPos && enclosingBlockOfInse rtionPos != currentRoot && !isTableCell(enclosingBlockOfInsertionPos) && !startI sInsideMailBlockquote) {
1152 VisiblePosition visibleInsertionPos = createVisiblePosition(insertionPos ); 1152 VisiblePosition visibleInsertionPos = createVisiblePosition(insertionPos );
1153 if (isEndOfBlock(visibleInsertionPos) && !(isStartOfBlock(visibleInserti onPos) && fragment.hasInterchangeNewlineAtEnd())) 1153 if (isEndOfBlock(visibleInsertionPos) && !(isStartOfBlock(visibleInserti onPos) && fragment.hasInterchangeNewlineAtEnd()))
1154 insertionPos = Position::inParentAfterNode(*enclosingBlockOfInsertio nPos); 1154 insertionPos = Position::inParentAfterNode(*enclosingBlockOfInsertio nPos);
1155 else if (isStartOfBlock(visibleInsertionPos)) 1155 else if (isStartOfBlock(visibleInsertionPos))
1156 insertionPos = Position::inParentBeforeNode(*enclosingBlockOfInserti onPos); 1156 insertionPos = Position::inParentBeforeNode(*enclosingBlockOfInserti onPos);
1157 } 1157 }
1158 1158
1159 // Paste at start or end of link goes outside of link. 1159 // Paste at start or end of link goes outside of link.
1160 insertionPos = positionAvoidingSpecialElementBoundary(insertionPos, editingS tate); 1160 insertionPos = positionAvoidingSpecialElementBoundary(insertionPos, editingS tate);
1161 if (editingState->isAborted()) 1161 if (editingState->isAborted())
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 visitor->trace(m_startOfInsertedContent); 1758 visitor->trace(m_startOfInsertedContent);
1759 visitor->trace(m_endOfInsertedContent); 1759 visitor->trace(m_endOfInsertedContent);
1760 visitor->trace(m_insertionStyle); 1760 visitor->trace(m_insertionStyle);
1761 visitor->trace(m_documentFragment); 1761 visitor->trace(m_documentFragment);
1762 visitor->trace(m_startOfInsertedRange); 1762 visitor->trace(m_startOfInsertedRange);
1763 visitor->trace(m_endOfInsertedRange); 1763 visitor->trace(m_endOfInsertedRange);
1764 CompositeEditCommand::trace(visitor); 1764 CompositeEditCommand::trace(visitor);
1765 } 1765 }
1766 1766
1767 } // namespace blink 1767 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/editing/pasteboard/paste-text-009-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698