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

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

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/PlainTextRange.cpp ('k') | Source/core/editing/SurroundingText.cpp » ('j') | 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 { 332 {
333 if (m_firstNodeInserted == node) 333 if (m_firstNodeInserted == node)
334 m_firstNodeInserted = NodeTraversal::next(node); 334 m_firstNodeInserted = NodeTraversal::next(node);
335 if (m_lastNodeInserted == node) 335 if (m_lastNodeInserted == node)
336 m_lastNodeInserted = node.lastChild() ? node.lastChild() : NodeTraversal ::nextSkippingChildren(node); 336 m_lastNodeInserted = node.lastChild() ? node.lastChild() : NodeTraversal ::nextSkippingChildren(node);
337 } 337 }
338 338
339 inline void ReplaceSelectionCommand::InsertedNodes::willRemoveNode(Node& node) 339 inline void ReplaceSelectionCommand::InsertedNodes::willRemoveNode(Node& node)
340 { 340 {
341 if (m_firstNodeInserted == node && m_lastNodeInserted == node) { 341 if (m_firstNodeInserted == node && m_lastNodeInserted == node) {
342 m_firstNodeInserted = 0; 342 m_firstNodeInserted = nullptr;
343 m_lastNodeInserted = 0; 343 m_lastNodeInserted = nullptr;
344 } else if (m_firstNodeInserted == node) { 344 } else if (m_firstNodeInserted == node) {
345 m_firstNodeInserted = NodeTraversal::nextSkippingChildren(*m_firstNodeIn serted); 345 m_firstNodeInserted = NodeTraversal::nextSkippingChildren(*m_firstNodeIn serted);
346 } else if (m_lastNodeInserted == node) { 346 } else if (m_lastNodeInserted == node) {
347 m_lastNodeInserted = NodeTraversal::previousSkippingChildren(*m_lastNode Inserted); 347 m_lastNodeInserted = NodeTraversal::previousSkippingChildren(*m_lastNode Inserted);
348 } 348 }
349 } 349 }
350 350
351 inline void ReplaceSelectionCommand::InsertedNodes::didReplaceNode(Node& node, N ode& newNode) 351 inline void ReplaceSelectionCommand::InsertedNodes::didReplaceNode(Node& node, N ode& newNode)
352 { 352 {
353 if (m_firstNodeInserted == node) 353 if (m_firstNodeInserted == node)
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 if (!handledStyleSpans) 1108 if (!handledStyleSpans)
1109 handleStyleSpans(insertedNodes); 1109 handleStyleSpans(insertedNodes);
1110 1110
1111 // Mutation events (bug 20161) may have already removed the inserted content 1111 // Mutation events (bug 20161) may have already removed the inserted content
1112 if (!insertedNodes.firstNodeInserted() || !insertedNodes.firstNodeInserted() ->inDocument()) 1112 if (!insertedNodes.firstNodeInserted() || !insertedNodes.firstNodeInserted() ->inDocument())
1113 return; 1113 return;
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 = 0; 1118 insertionBlock = nullptr;
1119 1119
1120 VisiblePosition startOfInsertedContent = firstPositionInOrBeforeNode(inserte dNodes.firstNodeInserted()); 1120 VisiblePosition startOfInsertedContent = firstPositionInOrBeforeNode(inserte dNodes.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 (insertionBlock && insertionPos.deprecatedNode() == insertionBlock->paren tNode() && (unsigned)insertionPos.deprecatedEditingOffset() < insertionBlock->no deIndex() && !isStartOfParagraph(startOfInsertedContent))
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();
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 if (m_selectReplacement) 1347 if (m_selectReplacement)
1348 setEndingSelection(VisibleSelection(start, end, SEL_DEFAULT_AFFINITY, en dingSelection().isDirectional())); 1348 setEndingSelection(VisibleSelection(start, end, SEL_DEFAULT_AFFINITY, en dingSelection().isDirectional()));
1349 else 1349 else
1350 setEndingSelection(VisibleSelection(end, SEL_DEFAULT_AFFINITY, endingSel ection().isDirectional())); 1350 setEndingSelection(VisibleSelection(end, SEL_DEFAULT_AFFINITY, endingSel ection().isDirectional()));
1351 } 1351 }
1352 1352
1353 void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P osition& positionOnlyToBeUpdated) 1353 void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P osition& positionOnlyToBeUpdated)
1354 { 1354 {
1355 bool positionIsOffsetInAnchor = position.anchorType() == Position::PositionI sOffsetInAnchor; 1355 bool positionIsOffsetInAnchor = position.anchorType() == Position::PositionI sOffsetInAnchor;
1356 bool positionOnlyToBeUpdatedIsOffsetInAnchor = positionOnlyToBeUpdated.ancho rType() == Position::PositionIsOffsetInAnchor; 1356 bool positionOnlyToBeUpdatedIsOffsetInAnchor = positionOnlyToBeUpdated.ancho rType() == Position::PositionIsOffsetInAnchor;
1357 RefPtr<Text> text = 0; 1357 RefPtr<Text> text = nullptr;
1358 if (positionIsOffsetInAnchor && position.containerNode() && position.contain erNode()->isTextNode()) 1358 if (positionIsOffsetInAnchor && position.containerNode() && position.contain erNode()->isTextNode())
1359 text = toText(position.containerNode()); 1359 text = toText(position.containerNode());
1360 else { 1360 else {
1361 Node* before = position.computeNodeBeforePosition(); 1361 Node* before = position.computeNodeBeforePosition();
1362 if (before && before->isTextNode()) 1362 if (before && before->isTextNode())
1363 text = toText(before); 1363 text = toText(before);
1364 else { 1364 else {
1365 Node* after = position.computeNodeAfterPosition(); 1365 Node* after = position.computeNodeAfterPosition();
1366 if (after && after->isTextNode()) 1366 if (after && after->isTextNode())
1367 text = toText(after); 1367 text = toText(after);
(...skipping 125 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
« no previous file with comments | « Source/core/editing/PlainTextRange.cpp ('k') | Source/core/editing/SurroundingText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698