OLD | NEW |
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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 return; | 457 return; |
458 | 458 |
459 // If the caret is at the start of a paragraph after a table, move conte
nt into the last table cell. | 459 // If the caret is at the start of a paragraph after a table, move conte
nt into the last table cell. |
460 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(visibl
eStart.previous(CannotCrossEditingBoundary))) { | 460 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(visibl
eStart.previous(CannotCrossEditingBoundary))) { |
461 // Unless the caret is just before a table. We don't want to move a
table into the last table cell. | 461 // Unless the caret is just before a table. We don't want to move a
table into the last table cell. |
462 if (isLastPositionBeforeTable(visibleStart)) | 462 if (isLastPositionBeforeTable(visibleStart)) |
463 return; | 463 return; |
464 // Extend the selection backward into the last cell, then deletion w
ill handle the move. | 464 // Extend the selection backward into the last cell, then deletion w
ill handle the move. |
465 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar
d, granularity); | 465 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar
d, granularity); |
466 // If the caret is just after a table, select the table and don't delete
anything. | 466 // If the caret is just after a table, select the table and don't delete
anything. |
467 } else if (Node* table = isFirstPositionAfterTable(visibleStart)) { | 467 } else if (Element* table = isFirstPositionAfterTable(visibleStart)) { |
468 setEndingSelection(VisibleSelection(positionBeforeNode(table), endin
gSelection().start(), DOWNSTREAM, endingSelection().isDirectional())); | 468 setEndingSelection(VisibleSelection(positionBeforeNode(table), endin
gSelection().start(), DOWNSTREAM, endingSelection().isDirectional())); |
469 typingAddedToOpenCommand(DeleteKey); | 469 typingAddedToOpenCommand(DeleteKey); |
470 return; | 470 return; |
471 } | 471 } |
472 | 472 |
473 selectionToDelete = selection->selection(); | 473 selectionToDelete = selection->selection(); |
474 | 474 |
475 if (granularity == CharacterGranularity && selectionToDelete.end().conta
inerNode() == selectionToDelete.start().containerNode() | 475 if (granularity == CharacterGranularity && selectionToDelete.end().conta
inerNode() == selectionToDelete.start().containerNode() |
476 && selectionToDelete.end().computeOffsetInContainerNode() - selectio
nToDelete.start().computeOffsetInContainerNode() > 1) { | 476 && selectionToDelete.end().computeOffsetInContainerNode() - selectio
nToDelete.start().computeOffsetInContainerNode() > 1) { |
477 // If there are multiple Unicode code points to be deleted, adjust t
he range to match platform conventions. | 477 // If there are multiple Unicode code points to be deleted, adjust t
he range to match platform conventions. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 selection->modify(FrameSelection::AlterationExtend, DirectionForward
, CharacterGranularity); | 540 selection->modify(FrameSelection::AlterationExtend, DirectionForward
, CharacterGranularity); |
541 | 541 |
542 Position downstreamEnd = endingSelection().end().downstream(); | 542 Position downstreamEnd = endingSelection().end().downstream(); |
543 VisiblePosition visibleEnd = endingSelection().visibleEnd(); | 543 VisiblePosition visibleEnd = endingSelection().visibleEnd(); |
544 Node* enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEquivalent
(), &isTableCell); | 544 Node* enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEquivalent
(), &isTableCell); |
545 if (enclosingTableCell && visibleEnd == VisiblePosition(lastPositionInNo
de(enclosingTableCell))) | 545 if (enclosingTableCell && visibleEnd == VisiblePosition(lastPositionInNo
de(enclosingTableCell))) |
546 return; | 546 return; |
547 if (visibleEnd == endOfParagraph(visibleEnd)) | 547 if (visibleEnd == endOfParagraph(visibleEnd)) |
548 downstreamEnd = visibleEnd.next(CannotCrossEditingBoundary).deepEqui
valent().downstream(); | 548 downstreamEnd = visibleEnd.next(CannotCrossEditingBoundary).deepEqui
valent().downstream(); |
549 // When deleting tables: Select the table first, then perform the deleti
on | 549 // When deleting tables: Select the table first, then perform the deleti
on |
550 if (isRenderedTable(downstreamEnd.containerNode()) && downstreamEnd.comp
uteOffsetInContainerNode() <= caretMinOffset(downstreamEnd.containerNode())) { | 550 if (isRenderedTableElement(downstreamEnd.containerNode()) && downstreamE
nd.computeOffsetInContainerNode() <= caretMinOffset(downstreamEnd.containerNode(
))) { |
551 setEndingSelection(VisibleSelection(endingSelection().end(), positio
nAfterNode(downstreamEnd.containerNode()), DOWNSTREAM, endingSelection().isDirec
tional())); | 551 setEndingSelection(VisibleSelection(endingSelection().end(), positio
nAfterNode(downstreamEnd.containerNode()), DOWNSTREAM, endingSelection().isDirec
tional())); |
552 typingAddedToOpenCommand(ForwardDeleteKey); | 552 typingAddedToOpenCommand(ForwardDeleteKey); |
553 return; | 553 return; |
554 } | 554 } |
555 | 555 |
556 // deleting to end of paragraph when at end of paragraph needs to merge
the next paragraph (if any) | 556 // deleting to end of paragraph when at end of paragraph needs to merge
the next paragraph (if any) |
557 if (granularity == ParagraphBoundary && selection->selection().isCaret()
&& isEndOfParagraph(selection->selection().visibleEnd())) | 557 if (granularity == ParagraphBoundary && selection->selection().isCaret()
&& isEndOfParagraph(selection->selection().visibleEnd())) |
558 selection->modify(FrameSelection::AlterationExtend, DirectionForward
, CharacterGranularity); | 558 selection->modify(FrameSelection::AlterationExtend, DirectionForward
, CharacterGranularity); |
559 | 559 |
560 selectionToDelete = selection->selection(); | 560 selectionToDelete = selection->selection(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 ASSERT_NOT_REACHED(); | 625 ASSERT_NOT_REACHED(); |
626 m_preservesTypingStyle = false; | 626 m_preservesTypingStyle = false; |
627 } | 627 } |
628 | 628 |
629 bool TypingCommand::isTypingCommand() const | 629 bool TypingCommand::isTypingCommand() const |
630 { | 630 { |
631 return true; | 631 return true; |
632 } | 632 } |
633 | 633 |
634 } // namespace blink | 634 } // namespace blink |
OLD | NEW |