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

Unified Diff: Source/core/editing/ReplaceSelectionCommand.cpp

Issue 64103002: Make "InsertHTML" and "Indent" commands to handle DOM tree modification during processing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-11-08T13:02:58 Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/CompositeEditCommand.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/ReplaceSelectionCommand.cpp
diff --git a/Source/core/editing/ReplaceSelectionCommand.cpp b/Source/core/editing/ReplaceSelectionCommand.cpp
index 3dcd36b7ecd71fdcb15db53f867c9264f6afedd1..57bc4417769adea40ab5b8dd39d7df2bde2c2cad 100644
--- a/Source/core/editing/ReplaceSelectionCommand.cpp
+++ b/Source/core/editing/ReplaceSelectionCommand.cpp
@@ -990,17 +990,17 @@ void ReplaceSelectionCommand::doApply()
if (endBR)
originalVisPosBeforeEndBR = VisiblePosition(positionBeforeNode(endBR), DOWNSTREAM).previous();
- startBlock = enclosingBlock(insertionPos.deprecatedNode());
+ RefPtr<Node> insertionBlock = enclosingBlock(insertionPos.deprecatedNode());
// Adjust insertionPos to prevent nesting.
// If the start was in a Mail blockquote, we will have already handled adjusting insertionPos above.
- if (m_preventNesting && startBlock && !isTableCell(startBlock) && !startIsInsideMailBlockquote) {
- ASSERT(startBlock != currentRoot);
+ if (m_preventNesting && insertionBlock && !isTableCell(insertionBlock.get()) && !startIsInsideMailBlockquote) {
+ ASSERT(insertionBlock != currentRoot);
VisiblePosition visibleInsertionPos(insertionPos);
if (isEndOfBlock(visibleInsertionPos) && !(isStartOfBlock(visibleInsertionPos) && fragment.hasInterchangeNewlineAtEnd()))
- insertionPos = positionInParentAfterNode(startBlock);
+ insertionPos = positionInParentAfterNode(insertionBlock.get());
else if (isStartOfBlock(visibleInsertionPos))
- insertionPos = positionInParentBeforeNode(startBlock);
+ insertionPos = positionInParentBeforeNode(insertionBlock.get());
}
// Paste at start or end of link goes outside of link.
@@ -1110,11 +1110,16 @@ void ReplaceSelectionCommand::doApply()
if (!insertedNodes.firstNodeInserted() || !insertedNodes.firstNodeInserted()->inDocument())
return;
+ // Scripts specified in javascript protocol may remove |insertionBlock|
+ // during insertion, e.g. <iframe src="javascript:...">
+ if (insertionBlock && !insertionBlock->inDocument())
+ insertionBlock = 0;
+
VisiblePosition startOfInsertedContent = firstPositionInOrBeforeNode(insertedNodes.firstNodeInserted());
- // We inserted before the startBlock to prevent nesting, and the content before the startBlock wasn't in its own block and
+ // We inserted before the insertionBlock to prevent nesting, and the content before the insertionBlock wasn't in its own block and
// didn't have a br after it, so the inserted content ended up in the same paragraph.
- if (startBlock && insertionPos.deprecatedNode() == startBlock->parentNode() && (unsigned)insertionPos.deprecatedEditingOffset() < startBlock->nodeIndex() && !isStartOfParagraph(startOfInsertedContent))
+ if (insertionBlock && insertionPos.deprecatedNode() == insertionBlock->parentNode() && (unsigned)insertionPos.deprecatedEditingOffset() < insertionBlock->nodeIndex() && !isStartOfParagraph(startOfInsertedContent))
insertNodeAt(createBreakElement(document()).get(), startOfInsertedContent.deepEquivalent());
if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR))) {
« no previous file with comments | « Source/core/editing/CompositeEditCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698