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

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

Issue 1307803003: Introduce nextPositionOf() for VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-28T18:13:02 Created 5 years, 3 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
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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar d, CharacterGranularity); 438 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar d, CharacterGranularity);
439 439
440 VisiblePosition visibleStart(endingSelection().visibleStart()); 440 VisiblePosition visibleStart(endingSelection().visibleStart());
441 if (previousPositionOf(visibleStart, CannotCrossEditingBoundary).isNull( )) { 441 if (previousPositionOf(visibleStart, CannotCrossEditingBoundary).isNull( )) {
442 // When the caret is at the start of the editable area in an empty l ist item, break out of the list item. 442 // When the caret is at the start of the editable area in an empty l ist item, break out of the list item.
443 if (breakOutOfEmptyListItem()) { 443 if (breakOutOfEmptyListItem()) {
444 typingAddedToOpenCommand(DeleteKey); 444 typingAddedToOpenCommand(DeleteKey);
445 return; 445 return;
446 } 446 }
447 // When there are no visible positions in the editing root, delete i ts entire contents. 447 // When there are no visible positions in the editing root, delete i ts entire contents.
448 if (visibleStart.next(CannotCrossEditingBoundary).isNull() && makeEd itableRootEmpty()) { 448 if (nextPositionOf(visibleStart, CannotCrossEditingBoundary).isNull( ) && makeEditableRootEmpty()) {
449 typingAddedToOpenCommand(DeleteKey); 449 typingAddedToOpenCommand(DeleteKey);
450 return; 450 return;
451 } 451 }
452 } 452 }
453 453
454 // If we have a caret selection at the beginning of a cell, we have noth ing to do. 454 // If we have a caret selection at the beginning of a cell, we have noth ing to do.
455 Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivale nt(), &isTableCell); 455 Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivale nt(), &isTableCell);
456 if (enclosingTableCell && visibleStart.deepEquivalent() == VisiblePositi on(firstPositionInNode(enclosingTableCell)).deepEquivalent()) 456 if (enclosingTableCell && visibleStart.deepEquivalent() == VisiblePositi on(firstPositionInNode(enclosingTableCell)).deepEquivalent())
457 return; 457 return;
458 458
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 selection->modify(FrameSelection::AlterationExtend, DirectionForward, gr anularity); 539 selection->modify(FrameSelection::AlterationExtend, DirectionForward, gr anularity);
540 if (killRing && selection->isCaret() && granularity != CharacterGranular ity) 540 if (killRing && selection->isCaret() && granularity != CharacterGranular ity)
541 selection->modify(FrameSelection::AlterationExtend, DirectionForward , CharacterGranularity); 541 selection->modify(FrameSelection::AlterationExtend, DirectionForward , CharacterGranularity);
542 542
543 Position downstreamEnd = mostForwardCaretPosition(endingSelection().end( )); 543 Position downstreamEnd = mostForwardCaretPosition(endingSelection().end( ));
544 VisiblePosition visibleEnd = endingSelection().visibleEnd(); 544 VisiblePosition visibleEnd = endingSelection().visibleEnd();
545 Node* enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEquivalent (), &isTableCell); 545 Node* enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEquivalent (), &isTableCell);
546 if (enclosingTableCell && visibleEnd.deepEquivalent() == VisiblePosition (lastPositionInNode(enclosingTableCell)).deepEquivalent()) 546 if (enclosingTableCell && visibleEnd.deepEquivalent() == VisiblePosition (lastPositionInNode(enclosingTableCell)).deepEquivalent())
547 return; 547 return;
548 if (visibleEnd.deepEquivalent() == endOfParagraph(visibleEnd).deepEquiva lent()) 548 if (visibleEnd.deepEquivalent() == endOfParagraph(visibleEnd).deepEquiva lent())
549 downstreamEnd = mostForwardCaretPosition(visibleEnd.next(CannotCross EditingBoundary).deepEquivalent()); 549 downstreamEnd = mostForwardCaretPosition(nextPositionOf(visibleEnd, CannotCrossEditingBoundary).deepEquivalent());
550 // When deleting tables: Select the table first, then perform the deleti on 550 // When deleting tables: Select the table first, then perform the deleti on
551 if (isRenderedTableElement(downstreamEnd.computeContainerNode()) && down streamEnd.computeOffsetInContainerNode() <= caretMinOffset(downstreamEnd.compute ContainerNode())) { 551 if (isRenderedTableElement(downstreamEnd.computeContainerNode()) && down streamEnd.computeOffsetInContainerNode() <= caretMinOffset(downstreamEnd.compute ContainerNode())) {
552 setEndingSelection(VisibleSelection(endingSelection().end(), positio nAfterNode(downstreamEnd.computeContainerNode()), TextAffinity::Downstream, endi ngSelection().isDirectional())); 552 setEndingSelection(VisibleSelection(endingSelection().end(), positio nAfterNode(downstreamEnd.computeContainerNode()), TextAffinity::Downstream, endi ngSelection().isDirectional()));
553 typingAddedToOpenCommand(ForwardDeleteKey); 553 typingAddedToOpenCommand(ForwardDeleteKey);
554 return; 554 return;
555 } 555 }
556 556
557 // deleting to end of paragraph when at end of paragraph needs to merge the next paragraph (if any) 557 // deleting to end of paragraph when at end of paragraph needs to merge the next paragraph (if any)
558 if (granularity == ParagraphBoundary && selection->selection().isCaret() && isEndOfParagraph(selection->selection().visibleEnd())) 558 if (granularity == ParagraphBoundary && selection->selection().isCaret() && isEndOfParagraph(selection->selection().visibleEnd()))
559 selection->modify(FrameSelection::AlterationExtend, DirectionForward , CharacterGranularity); 559 selection->modify(FrameSelection::AlterationExtend, DirectionForward , CharacterGranularity);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 ASSERT_NOT_REACHED(); 626 ASSERT_NOT_REACHED();
627 m_preservesTypingStyle = false; 627 m_preservesTypingStyle = false;
628 } 628 }
629 629
630 bool TypingCommand::isTypingCommand() const 630 bool TypingCommand::isTypingCommand() const
631 { 631 {
632 return true; 632 return true;
633 } 633 }
634 634
635 } // namespace blink 635 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/commands/ReplaceSelectionCommand.cpp ('k') | Source/core/editing/serializers/StyledMarkupSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698