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

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

Issue 2534783002: Apply RelocatablePosition in DeleteSelectionCommand::mergeParagraphs (Closed)
Patch Set: Tue Nov 29 21:12:11 JST 2016 Created 4 years 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 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 // content inside of it to move, so just remove it. 811 // content inside of it to move, so just remove it.
812 Element* endBlock = enclosingBlock(m_downstreamEnd.anchorNode()); 812 Element* endBlock = enclosingBlock(m_downstreamEnd.anchorNode());
813 if (!endBlock || 813 if (!endBlock ||
814 !endBlock->contains( 814 !endBlock->contains(
815 startOfParagraphToMove.deepEquivalent().anchorNode()) || 815 startOfParagraphToMove.deepEquivalent().anchorNode()) ||
816 !startOfParagraphToMove.deepEquivalent().anchorNode()) { 816 !startOfParagraphToMove.deepEquivalent().anchorNode()) {
817 removeNode(enclosingBlock(m_downstreamEnd.anchorNode()), editingState); 817 removeNode(enclosingBlock(m_downstreamEnd.anchorNode()), editingState);
818 return; 818 return;
819 } 819 }
820 820
821 RelocatablePosition relocatableStart(startOfParagraphToMove.deepEquivalent());
822
821 // We need to merge into m_upstreamStart's block, but it's been emptied out 823 // We need to merge into m_upstreamStart's block, but it's been emptied out
822 // and collapsed by deletion. 824 // and collapsed by deletion.
823 if (!mergeDestination.deepEquivalent().anchorNode() || 825 if (!mergeDestination.deepEquivalent().anchorNode() ||
824 (!mergeDestination.deepEquivalent().anchorNode()->isDescendantOf( 826 (!mergeDestination.deepEquivalent().anchorNode()->isDescendantOf(
825 enclosingBlock(m_upstreamStart.computeContainerNode())) && 827 enclosingBlock(m_upstreamStart.computeContainerNode())) &&
826 (!mergeDestination.deepEquivalent().anchorNode()->hasChildren() || 828 (!mergeDestination.deepEquivalent().anchorNode()->hasChildren() ||
827 !m_upstreamStart.computeContainerNode()->hasChildren())) || 829 !m_upstreamStart.computeContainerNode()->hasChildren())) ||
828 (m_startsAtEmptyLine && 830 (m_startsAtEmptyLine &&
829 mergeDestination.deepEquivalent() != 831 mergeDestination.deepEquivalent() !=
830 startOfParagraphToMove.deepEquivalent())) { 832 startOfParagraphToMove.deepEquivalent())) {
831 PositionWithAffinity storedStartOfParagraphToMove =
832 startOfParagraphToMove.toPositionWithAffinity();
833 insertNodeAt(HTMLBRElement::create(document()), m_upstreamStart, 833 insertNodeAt(HTMLBRElement::create(document()), m_upstreamStart,
834 editingState); 834 editingState);
835 if (editingState->isAborted()) 835 if (editingState->isAborted())
836 return; 836 return;
837 document().updateStyleAndLayoutIgnorePendingStylesheets(); 837 document().updateStyleAndLayoutIgnorePendingStylesheets();
838 mergeDestination = createVisiblePosition(m_upstreamStart); 838 mergeDestination = createVisiblePosition(m_upstreamStart);
839 startOfParagraphToMove = 839 startOfParagraphToMove = createVisiblePosition(relocatableStart.position());
840 createVisiblePosition(storedStartOfParagraphToMove);
841 } 840 }
842 841
843 if (mergeDestination.deepEquivalent() == 842 if (mergeDestination.deepEquivalent() ==
844 startOfParagraphToMove.deepEquivalent()) 843 startOfParagraphToMove.deepEquivalent())
845 return; 844 return;
846 845
847 VisiblePosition endOfParagraphToMove = 846 VisiblePosition endOfParagraphToMove =
848 endOfParagraph(startOfParagraphToMove, CanSkipOverEditingBoundary); 847 endOfParagraph(startOfParagraphToMove, CanSkipOverEditingBoundary);
849 848
850 if (mergeDestination.deepEquivalent() == 849 if (mergeDestination.deepEquivalent() ==
(...skipping 28 matching lines...) Expand all
879 absoluteCaretBoundsOf(mergeDestination).x()) { 878 absoluteCaretBoundsOf(mergeDestination).x()) {
880 if (isHTMLBRElement( 879 if (isHTMLBRElement(
881 *mostForwardCaretPosition(mergeDestination.deepEquivalent()) 880 *mostForwardCaretPosition(mergeDestination.deepEquivalent())
882 .anchorNode())) { 881 .anchorNode())) {
883 removeNodeAndPruneAncestors( 882 removeNodeAndPruneAncestors(
884 mostForwardCaretPosition(mergeDestination.deepEquivalent()) 883 mostForwardCaretPosition(mergeDestination.deepEquivalent())
885 .anchorNode(), 884 .anchorNode(),
886 editingState); 885 editingState);
887 if (editingState->isAborted()) 886 if (editingState->isAborted())
888 return; 887 return;
889 m_endingPosition = startOfParagraphToMove.deepEquivalent(); 888 m_endingPosition = relocatableStart.position();
890 return; 889 return;
891 } 890 }
892 } 891 }
893 892
894 // Block images, tables and horizontal rules cannot be made inline with 893 // Block images, tables and horizontal rules cannot be made inline with
895 // content at mergeDestination. If there is any 894 // content at mergeDestination. If there is any
896 // (!isStartOfParagraph(mergeDestination)), don't merge, just move 895 // (!isStartOfParagraph(mergeDestination)), don't merge, just move
897 // the caret to just before the selection we deleted. See 896 // the caret to just before the selection we deleted. See
898 // https://bugs.webkit.org/show_bug.cgi?id=25439 897 // https://bugs.webkit.org/show_bug.cgi?id=25439
899 if (isRenderedAsNonInlineTableImageOrHR( 898 if (isRenderedAsNonInlineTableImageOrHR(
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 visitor->trace(m_deleteIntoBlockquoteStyle); 1226 visitor->trace(m_deleteIntoBlockquoteStyle);
1228 visitor->trace(m_startRoot); 1227 visitor->trace(m_startRoot);
1229 visitor->trace(m_endRoot); 1228 visitor->trace(m_endRoot);
1230 visitor->trace(m_startTableRow); 1229 visitor->trace(m_startTableRow);
1231 visitor->trace(m_endTableRow); 1230 visitor->trace(m_endTableRow);
1232 visitor->trace(m_temporaryPlaceholder); 1231 visitor->trace(m_temporaryPlaceholder);
1233 CompositeEditCommand::trace(visitor); 1232 CompositeEditCommand::trace(visitor);
1234 } 1233 }
1235 1234
1236 } // namespace blink 1235 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698