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

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

Issue 2373483003: Ensure valid VisiblePosition input for absoluteCaretBoundsOf (Closed)
Patch Set: Ensure valid VP for absoluteCaretBoundsOf Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('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 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 // m_downstreamEnd's block has been emptied out by deletion. There is no co ntent inside of it to 651 // m_downstreamEnd's block has been emptied out by deletion. There is no co ntent inside of it to
652 // move, so just remove it. 652 // move, so just remove it.
653 Element* endBlock = enclosingBlock(m_downstreamEnd.anchorNode()); 653 Element* endBlock = enclosingBlock(m_downstreamEnd.anchorNode());
654 if (!endBlock || !endBlock->contains(startOfParagraphToMove.deepEquivalent() .anchorNode()) || !startOfParagraphToMove.deepEquivalent().anchorNode()) { 654 if (!endBlock || !endBlock->contains(startOfParagraphToMove.deepEquivalent() .anchorNode()) || !startOfParagraphToMove.deepEquivalent().anchorNode()) {
655 removeNode(enclosingBlock(m_downstreamEnd.anchorNode()), editingState); 655 removeNode(enclosingBlock(m_downstreamEnd.anchorNode()), editingState);
656 return; 656 return;
657 } 657 }
658 658
659 // We need to merge into m_upstreamStart's block, but it's been emptied out and collapsed by deletion. 659 // We need to merge into m_upstreamStart's block, but it's been emptied out and collapsed by deletion.
660 if (!mergeDestination.deepEquivalent().anchorNode() || (!mergeDestination.de epEquivalent().anchorNode()->isDescendantOf(enclosingBlock(m_upstreamStart.compu teContainerNode())) && (!mergeDestination.deepEquivalent().anchorNode()->hasChil dren() || !m_upstreamStart.computeContainerNode()->hasChildren())) || (m_startsA tEmptyLine && mergeDestination.deepEquivalent() != startOfParagraphToMove.deepEq uivalent())) { 660 if (!mergeDestination.deepEquivalent().anchorNode() || (!mergeDestination.de epEquivalent().anchorNode()->isDescendantOf(enclosingBlock(m_upstreamStart.compu teContainerNode())) && (!mergeDestination.deepEquivalent().anchorNode()->hasChil dren() || !m_upstreamStart.computeContainerNode()->hasChildren())) || (m_startsA tEmptyLine && mergeDestination.deepEquivalent() != startOfParagraphToMove.deepEq uivalent())) {
661 PositionWithAffinity storedStartOfParagraphToMove = startOfParagraphToMo ve.toPositionWithAffinity();
661 insertNodeAt(HTMLBRElement::create(document()), m_upstreamStart, editing State); 662 insertNodeAt(HTMLBRElement::create(document()), m_upstreamStart, editing State);
662 if (editingState->isAborted()) 663 if (editingState->isAborted())
663 return; 664 return;
664 mergeDestination = createVisiblePositionDeprecated(m_upstreamStart); 665 mergeDestination = createVisiblePositionDeprecated(m_upstreamStart);
666 startOfParagraphToMove = createVisiblePosition(storedStartOfParagraphToM ove);
yosin_UTC9 2016/09/28 01:24:06 Rational of converting VP: |startOfParagraphToMove
665 } 667 }
666 668
667 if (mergeDestination.deepEquivalent() == startOfParagraphToMove.deepEquivale nt()) 669 if (mergeDestination.deepEquivalent() == startOfParagraphToMove.deepEquivale nt())
668 return; 670 return;
669 671
670 VisiblePosition endOfParagraphToMove = endOfParagraphDeprecated(startOfParag raphToMove, CanSkipOverEditingBoundary); 672 VisiblePosition endOfParagraphToMove = endOfParagraphDeprecated(startOfParag raphToMove, CanSkipOverEditingBoundary);
671 673
672 if (mergeDestination.deepEquivalent() == endOfParagraphToMove.deepEquivalent ()) 674 if (mergeDestination.deepEquivalent() == endOfParagraphToMove.deepEquivalent ())
673 return; 675 return;
674 676
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 visitor->trace(m_deleteIntoBlockquoteStyle); 965 visitor->trace(m_deleteIntoBlockquoteStyle);
964 visitor->trace(m_startRoot); 966 visitor->trace(m_startRoot);
965 visitor->trace(m_endRoot); 967 visitor->trace(m_endRoot);
966 visitor->trace(m_startTableRow); 968 visitor->trace(m_startTableRow);
967 visitor->trace(m_endTableRow); 969 visitor->trace(m_endTableRow);
968 visitor->trace(m_temporaryPlaceholder); 970 visitor->trace(m_temporaryPlaceholder);
969 CompositeEditCommand::trace(visitor); 971 CompositeEditCommand::trace(visitor);
970 } 972 }
971 973
972 } // namespace blink 974 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698