| 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 447 } |
| 448 // When there are no visible positions in the editing root, delete i
ts entire contents. | 448 // When there are no visible positions in the editing root, delete i
ts entire contents. |
| 449 if (endingSelection().visibleStart().next(CannotCrossEditingBoundary
).isNull() && makeEditableRootEmpty()) { | 449 if (endingSelection().visibleStart().next(CannotCrossEditingBoundary
).isNull() && makeEditableRootEmpty()) { |
| 450 typingAddedToOpenCommand(DeleteKey); | 450 typingAddedToOpenCommand(DeleteKey); |
| 451 return; | 451 return; |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 | 454 |
| 455 VisiblePosition visibleStart(endingSelection().visibleStart()); | 455 VisiblePosition visibleStart(endingSelection().visibleStart()); |
| 456 // If we have a caret selection at the beginning of a cell, we have noth
ing to do. | 456 // If we have a caret selection at the beginning of a cell, we have noth
ing to do. |
| 457 Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivale
nt(), &isTableCell); | 457 Handle<Node> enclosingTableCell = enclosingNodeOfType(visibleStart.deepE
quivalent(), &isTableCell); |
| 458 if (enclosingTableCell && visibleStart == firstPositionInNode(adoptRawRe
sult(enclosingTableCell))) | 458 if (enclosingTableCell && visibleStart == firstPositionInNode(enclosingT
ableCell)) |
| 459 return; | 459 return; |
| 460 | 460 |
| 461 // If the caret is at the start of a paragraph after a table, move conte
nt into the last table cell. | 461 // If the caret is at the start of a paragraph after a table, move conte
nt into the last table cell. |
| 462 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(visibl
eStart.previous(CannotCrossEditingBoundary))) { | 462 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(visibl
eStart.previous(CannotCrossEditingBoundary))) { |
| 463 // Unless the caret is just before a table. We don't want to move a
table into the last table cell. | 463 // Unless the caret is just before a table. We don't want to move a
table into the last table cell. |
| 464 if (isLastPositionBeforeTable(visibleStart)) | 464 if (isLastPositionBeforeTable(visibleStart)) |
| 465 return; | 465 return; |
| 466 // Extend the selection backward into the last cell, then deletion w
ill handle the move. | 466 // Extend the selection backward into the last cell, then deletion w
ill handle the move. |
| 467 selection.modify(FrameSelection::AlterationExtend, DirectionBackward
, granularity); | 467 selection.modify(FrameSelection::AlterationExtend, DirectionBackward
, granularity); |
| 468 // If the caret is just after a table, select the table and don't delete
anything. | 468 // If the caret is just after a table, select the table and don't delete
anything. |
| 469 } else if (Node* table = isFirstPositionAfterTable(visibleStart)) { | 469 } else if (Handle<Node> table = isFirstPositionAfterTable(visibleStart))
{ |
| 470 setEndingSelection(VisibleSelection(positionBeforeNode(adoptRawResul
t(table)), endingSelection().start(), DOWNSTREAM, endingSelection().isDirectiona
l())); | 470 setEndingSelection(VisibleSelection(positionBeforeNode(table), endin
gSelection().start(), DOWNSTREAM, endingSelection().isDirectional())); |
| 471 typingAddedToOpenCommand(DeleteKey); | 471 typingAddedToOpenCommand(DeleteKey); |
| 472 return; | 472 return; |
| 473 } | 473 } |
| 474 | 474 |
| 475 selectionToDelete = selection.selection(); | 475 selectionToDelete = selection.selection(); |
| 476 | 476 |
| 477 if (granularity == CharacterGranularity && selectionToDelete.end().conta
inerNode() == selectionToDelete.start().containerNode() | 477 if (granularity == CharacterGranularity && selectionToDelete.end().conta
inerNode() == selectionToDelete.start().containerNode() |
| 478 && selectionToDelete.end().computeOffsetInContainerNode() - selectio
nToDelete.start().computeOffsetInContainerNode() > 1) { | 478 && selectionToDelete.end().computeOffsetInContainerNode() - selectio
nToDelete.start().computeOffsetInContainerNode() > 1) { |
| 479 // If there are multiple Unicode code points to be deleted, adjust t
he range to match platform conventions. | 479 // If there are multiple Unicode code points to be deleted, adjust t
he range to match platform conventions. |
| 480 selectionToDelete.setWithoutValidation(selectionToDelete.end(), sele
ctionToDelete.end().previous(BackwardDeletion)); | 480 selectionToDelete.setWithoutValidation(selectionToDelete.end(), sele
ctionToDelete.end().previous(BackwardDeletion)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 // Do nothing in the case that the caret is at the start of a | 536 // Do nothing in the case that the caret is at the start of a |
| 537 // root editable element or at the start of a document. | 537 // root editable element or at the start of a document. |
| 538 FrameSelection selection; | 538 FrameSelection selection; |
| 539 selection.setSelection(endingSelection()); | 539 selection.setSelection(endingSelection()); |
| 540 selection.modify(FrameSelection::AlterationExtend, DirectionForward, gra
nularity); | 540 selection.modify(FrameSelection::AlterationExtend, DirectionForward, gra
nularity); |
| 541 if (killRing && selection.isCaret() && granularity != CharacterGranulari
ty) | 541 if (killRing && selection.isCaret() && granularity != CharacterGranulari
ty) |
| 542 selection.modify(FrameSelection::AlterationExtend, DirectionForward,
CharacterGranularity); | 542 selection.modify(FrameSelection::AlterationExtend, DirectionForward,
CharacterGranularity); |
| 543 | 543 |
| 544 Position downstreamEnd = endingSelection().end().downstream(); | 544 Position downstreamEnd = endingSelection().end().downstream(); |
| 545 VisiblePosition visibleEnd = endingSelection().visibleEnd(); | 545 VisiblePosition visibleEnd = endingSelection().visibleEnd(); |
| 546 Node* enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEquivalent
(), &isTableCell); | 546 Handle<Node> enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEqu
ivalent(), &isTableCell); |
| 547 if (enclosingTableCell && visibleEnd == lastPositionInNode(adoptRawResul
t(enclosingTableCell))) | 547 if (enclosingTableCell && visibleEnd == lastPositionInNode(enclosingTabl
eCell)) |
| 548 return; | 548 return; |
| 549 if (visibleEnd == endOfParagraph(visibleEnd)) | 549 if (visibleEnd == endOfParagraph(visibleEnd)) |
| 550 downstreamEnd = visibleEnd.next(CannotCrossEditingBoundary).deepEqui
valent().downstream(); | 550 downstreamEnd = visibleEnd.next(CannotCrossEditingBoundary).deepEqui
valent().downstream(); |
| 551 // When deleting tables: Select the table first, then perform the deleti
on | 551 // When deleting tables: Select the table first, then perform the deleti
on |
| 552 if (downstreamEnd.containerNode() && downstreamEnd.containerNode()->rend
erer() && downstreamEnd.containerNode()->renderer()->isTable() | 552 if (downstreamEnd.containerNode() && downstreamEnd.containerNode()->rend
erer() && downstreamEnd.containerNode()->renderer()->isTable() |
| 553 && downstreamEnd.computeOffsetInContainerNode() <= caretMinOffset(do
wnstreamEnd.containerNode().handle().raw())) { | 553 && downstreamEnd.computeOffsetInContainerNode() <= caretMinOffset(do
wnstreamEnd.containerNode())) { |
| 554 setEndingSelection(VisibleSelection(endingSelection().end(), positio
nAfterNode(downstreamEnd.containerNode()), DOWNSTREAM, endingSelection().isDirec
tional())); | 554 setEndingSelection(VisibleSelection(endingSelection().end(), positio
nAfterNode(downstreamEnd.containerNode()), DOWNSTREAM, endingSelection().isDirec
tional())); |
| 555 typingAddedToOpenCommand(ForwardDeleteKey); | 555 typingAddedToOpenCommand(ForwardDeleteKey); |
| 556 return; | 556 return; |
| 557 } | 557 } |
| 558 | 558 |
| 559 // deleting to end of paragraph when at end of paragraph needs to merge
the next paragraph (if any) | 559 // deleting to end of paragraph when at end of paragraph needs to merge
the next paragraph (if any) |
| 560 if (granularity == ParagraphBoundary && selection.selection().isCaret()
&& isEndOfParagraph(selection.selection().visibleEnd())) | 560 if (granularity == ParagraphBoundary && selection.selection().isCaret()
&& isEndOfParagraph(selection.selection().visibleEnd())) |
| 561 selection.modify(FrameSelection::AlterationExtend, DirectionForward,
CharacterGranularity); | 561 selection.modify(FrameSelection::AlterationExtend, DirectionForward,
CharacterGranularity); |
| 562 | 562 |
| 563 selectionToDelete = selection.selection(); | 563 selectionToDelete = selection.selection(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 ASSERT_NOT_REACHED(); | 627 ASSERT_NOT_REACHED(); |
| 628 m_preservesTypingStyle = false; | 628 m_preservesTypingStyle = false; |
| 629 } | 629 } |
| 630 | 630 |
| 631 bool TypingCommand::isTypingCommand() const | 631 bool TypingCommand::isTypingCommand() const |
| 632 { | 632 { |
| 633 return true; | 633 return true; |
| 634 } | 634 } |
| 635 | 635 |
| 636 } // namespace WebCore | 636 } // namespace WebCore |
| OLD | NEW |