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

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

Issue 2451613003: Get rid of createVisibleSelection() taking two Position (Closed)
Patch Set: 2016-10-26T11:29:45 Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 if (tableElementJustAfter(visibleStart)) 605 if (tableElementJustAfter(visibleStart))
606 return; 606 return;
607 // Extend the selection backward into the last cell, then deletion will 607 // Extend the selection backward into the last cell, then deletion will
608 // handle the move. 608 // handle the move.
609 selectionModifier.modify(FrameSelection::AlterationExtend, 609 selectionModifier.modify(FrameSelection::AlterationExtend,
610 DirectionBackward, granularity); 610 DirectionBackward, granularity);
611 // If the caret is just after a table, select the table and don't delete 611 // If the caret is just after a table, select the table and don't delete
612 // anything. 612 // anything.
613 } else if (Element* table = tableElementJustBefore(visibleStart)) { 613 } else if (Element* table = tableElementJustBefore(visibleStart)) {
614 setEndingSelection(createVisibleSelection( 614 setEndingSelection(createVisibleSelection(
615 Position::beforeNode(table), endingSelection().start(), 615 SelectionInDOMTree::Builder()
616 TextAffinity::Downstream, endingSelection().isDirectional())); 616 .setBaseAndExtentDeprecated(Position::beforeNode(table),
Xiaocheng 2016/10/26 05:49:18 We can use |setBaseAndExtent| since Position::befo
yosin_UTC9 2016/10/26 07:43:07 Done.
617 endingSelection().start())
618 .setIsDirectional(endingSelection().isDirectional())
619 .build()));
617 typingAddedToOpenCommand(DeleteKey); 620 typingAddedToOpenCommand(DeleteKey);
618 return; 621 return;
619 } 622 }
620 623
621 selectionToDelete = selectionModifier.selection(); 624 selectionToDelete = selectionModifier.selection();
622 625
623 if (granularity == CharacterGranularity && 626 if (granularity == CharacterGranularity &&
624 selectionToDelete.end().computeContainerNode() == 627 selectionToDelete.end().computeContainerNode() ==
625 selectionToDelete.start().computeContainerNode() && 628 selectionToDelete.start().computeContainerNode() &&
626 selectionToDelete.end().computeOffsetInContainerNode() - 629 selectionToDelete.end().computeOffsetInContainerNode() -
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 if (visibleEnd.deepEquivalent() == 726 if (visibleEnd.deepEquivalent() ==
724 endOfParagraph(visibleEnd).deepEquivalent()) 727 endOfParagraph(visibleEnd).deepEquivalent())
725 downstreamEnd = mostForwardCaretPosition( 728 downstreamEnd = mostForwardCaretPosition(
726 nextPositionOf(visibleEnd, CannotCrossEditingBoundary) 729 nextPositionOf(visibleEnd, CannotCrossEditingBoundary)
727 .deepEquivalent()); 730 .deepEquivalent());
728 // When deleting tables: Select the table first, then perform the deletion 731 // When deleting tables: Select the table first, then perform the deletion
729 if (isDisplayInsideTable(downstreamEnd.computeContainerNode()) && 732 if (isDisplayInsideTable(downstreamEnd.computeContainerNode()) &&
730 downstreamEnd.computeOffsetInContainerNode() <= 733 downstreamEnd.computeOffsetInContainerNode() <=
731 caretMinOffset(downstreamEnd.computeContainerNode())) { 734 caretMinOffset(downstreamEnd.computeContainerNode())) {
732 setEndingSelection(createVisibleSelection( 735 setEndingSelection(createVisibleSelection(
733 endingSelection().end(), 736 SelectionInDOMTree::Builder()
734 Position::afterNode(downstreamEnd.computeContainerNode()), 737 .setBaseAndExtentDeprecated(
735 TextAffinity::Downstream, endingSelection().isDirectional())); 738 endingSelection().end(),
739 Position::afterNode(downstreamEnd.computeContainerNode()))
740 .setIsDirectional(endingSelection().isDirectional())
741 .build()));
736 typingAddedToOpenCommand(ForwardDeleteKey); 742 typingAddedToOpenCommand(ForwardDeleteKey);
737 return; 743 return;
738 } 744 }
739 745
740 // deleting to end of paragraph when at end of paragraph needs to merge 746 // deleting to end of paragraph when at end of paragraph needs to merge
741 // the next paragraph (if any) 747 // the next paragraph (if any)
742 if (granularity == ParagraphBoundary && 748 if (granularity == ParagraphBoundary &&
743 selectionModifier.selection().isCaret() && 749 selectionModifier.selection().isCaret() &&
744 isEndOfParagraph(selectionModifier.selection().visibleEnd())) 750 isEndOfParagraph(selectionModifier.selection().visibleEnd()))
745 selectionModifier.modify(FrameSelection::AlterationExtend, 751 selectionModifier.modify(FrameSelection::AlterationExtend,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 } 833 }
828 NOTREACHED(); 834 NOTREACHED();
829 m_preservesTypingStyle = false; 835 m_preservesTypingStyle = false;
830 } 836 }
831 837
832 bool TypingCommand::isTypingCommand() const { 838 bool TypingCommand::isTypingCommand() const {
833 return true; 839 return true;
834 } 840 }
835 841
836 } // namespace blink 842 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698