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

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

Issue 183893018: Check VisualPosition.isNull() after DOM mutation in ReplaceSelectionCommand (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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, 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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 1114
1115 // Scripts specified in javascript protocol may remove |insertionBlock| 1115 // Scripts specified in javascript protocol may remove |insertionBlock|
1116 // during insertion, e.g. <iframe src="javascript:..."> 1116 // during insertion, e.g. <iframe src="javascript:...">
1117 if (insertionBlock && !insertionBlock->inDocument()) 1117 if (insertionBlock && !insertionBlock->inDocument())
1118 insertionBlock = nullptr; 1118 insertionBlock = nullptr;
1119 1119
1120 VisiblePosition startOfInsertedContent(firstPositionInOrBeforeNode(insertedN odes.firstNodeInserted())); 1120 VisiblePosition startOfInsertedContent(firstPositionInOrBeforeNode(insertedN odes.firstNodeInserted()));
1121 1121
1122 // We inserted before the insertionBlock to prevent nesting, and the content before the insertionBlock wasn't in its own block and 1122 // We inserted before the insertionBlock to prevent nesting, and the content before the insertionBlock wasn't in its own block and
1123 // didn't have a br after it, so the inserted content ended up in the same p aragraph. 1123 // didn't have a br after it, so the inserted content ended up in the same p aragraph.
1124 if (insertionBlock && insertionPos.deprecatedNode() == insertionBlock->paren tNode() && (unsigned)insertionPos.deprecatedEditingOffset() < insertionBlock->no deIndex() && !isStartOfParagraph(startOfInsertedContent)) 1124 if (!startOfInsertedContent.isNull() && insertionBlock && insertionPos.depre catedNode() == insertionBlock->parentNode() && (unsigned)insertionPos.deprecated EditingOffset() < insertionBlock->nodeIndex() && !isStartOfParagraph(startOfInse rtedContent))
1125 insertNodeAt(createBreakElement(document()).get(), startOfInsertedConten t.deepEquivalent()); 1125 insertNodeAt(createBreakElement(document()).get(), startOfInsertedConten t.deepEquivalent());
1126 1126
1127 if (endBR && (plainTextFragment || (shouldRemoveEndBR(endBR, originalVisPosB eforeEndBR) && !(fragment.hasInterchangeNewlineAtEnd() && selectionIsPlainText)) )) { 1127 if (endBR && (plainTextFragment || (shouldRemoveEndBR(endBR, originalVisPosB eforeEndBR) && !(fragment.hasInterchangeNewlineAtEnd() && selectionIsPlainText)) )) {
1128 RefPtr<Node> parent = endBR->parentNode(); 1128 RefPtr<Node> parent = endBR->parentNode();
1129 insertedNodes.willRemoveNode(*endBR); 1129 insertedNodes.willRemoveNode(*endBR);
1130 removeNode(endBR); 1130 removeNode(endBR);
1131 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) { 1131 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) {
1132 insertedNodes.willRemoveNode(*nodeToRemove); 1132 insertedNodes.willRemoveNode(*nodeToRemove);
1133 removeNode(nodeToRemove); 1133 removeNode(nodeToRemove);
1134 } 1134 }
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); 1493 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get());
1494 1494
1495 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); 1495 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d);
1496 1496
1497 setEndingSelection(selectionAfterReplace); 1497 setEndingSelection(selectionAfterReplace);
1498 1498
1499 return true; 1499 return true;
1500 } 1500 }
1501 1501
1502 } // namespace WebCore 1502 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698