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

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

Issue 16001010: Make replacing selection in heading/paragraph with heading/paragraph to work (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-06-11T17:06 Created 7 years, 6 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 | « LayoutTests/editing/inserting/replace-in-paragraph-001-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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 moveNodeOutOfAncestor(node, headerElement); 631 moveNodeOutOfAncestor(node, headerElement);
632 } 632 }
633 } 633 }
634 } 634 }
635 635
636 void ReplaceSelectionCommand::moveNodeOutOfAncestor(PassRefPtr<Node> prpNode, Pa ssRefPtr<Node> prpAncestor) 636 void ReplaceSelectionCommand::moveNodeOutOfAncestor(PassRefPtr<Node> prpNode, Pa ssRefPtr<Node> prpAncestor)
637 { 637 {
638 RefPtr<Node> node = prpNode; 638 RefPtr<Node> node = prpNode;
639 RefPtr<Node> ancestor = prpAncestor; 639 RefPtr<Node> ancestor = prpAncestor;
640 640
641 if (!ancestor->parentNode()->rendererIsEditable())
642 return;
643
641 VisiblePosition positionAtEndOfNode = lastPositionInOrAfterNode(node.get()); 644 VisiblePosition positionAtEndOfNode = lastPositionInOrAfterNode(node.get());
642 VisiblePosition lastPositionInParagraph = lastPositionInNode(ancestor.get()) ; 645 VisiblePosition lastPositionInParagraph = lastPositionInNode(ancestor.get()) ;
643 if (positionAtEndOfNode == lastPositionInParagraph) { 646 if (positionAtEndOfNode == lastPositionInParagraph) {
644 removeNode(node); 647 removeNode(node);
645 if (ancestor->nextSibling()) 648 if (ancestor->nextSibling())
646 insertNodeBefore(node, ancestor->nextSibling()); 649 insertNodeBefore(node, ancestor->nextSibling());
647 else 650 else
648 appendNode(node, ancestor->parentNode()); 651 appendNode(node, ancestor->parentNode());
649 } else { 652 } else {
650 RefPtr<Node> nodeToSplitTo = splitTreeToNode(node.get(), ancestor.get(), true); 653 RefPtr<Node> nodeToSplitTo = splitTreeToNode(node.get(), ancestor.get(), true);
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); 1487 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get());
1485 1488
1486 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); 1489 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d);
1487 1490
1488 setEndingSelection(selectionAfterReplace); 1491 setEndingSelection(selectionAfterReplace);
1489 1492
1490 return true; 1493 return true;
1491 } 1494 }
1492 1495
1493 } // namespace WebCore 1496 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/inserting/replace-in-paragraph-001-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698