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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 selection.modify(SelectionController::EXTEND, SelectionControlle
r::BACKWARD, granularity); | 410 selection.modify(SelectionController::EXTEND, SelectionControlle
r::BACKWARD, granularity); |
411 // If the caret is just after a table, select the table and don't de
lete anything. | 411 // If the caret is just after a table, select the table and don't de
lete anything. |
412 } else if (Node* table = isFirstPositionAfterTable(visibleStart)) { | 412 } else if (Node* table = isFirstPositionAfterTable(visibleStart)) { |
413 setEndingSelection(Selection(Position(table, 0), endingSelection
().start(), DOWNSTREAM)); | 413 setEndingSelection(Selection(Position(table, 0), endingSelection
().start(), DOWNSTREAM)); |
414 typingAddedToOpenCommand(); | 414 typingAddedToOpenCommand(); |
415 return; | 415 return; |
416 } | 416 } |
417 | 417 |
418 selectionToDelete = selection.selection(); | 418 selectionToDelete = selection.selection(); |
419 | 419 |
420 if (granularity == CharacterGranularity && selectionToDelete.end().o
ffset() - selectionToDelete.start().offset() > 1) { | 420 if (granularity == CharacterGranularity && selectionToDelete.end().n
ode() == selectionToDelete.start().node() && selectionToDelete.end().offset() -
selectionToDelete.start().offset() > 1) { |
421 // When we delete a ligature consisting of multiple Unicode char
acters with a backspace key, | 421 // If there are multiple Unicode code points to be deleted, adju
st the range to match platform conventions. |
422 // we should not delete the ligature but delete only its last ch
araceter. To check we are deleting | 422 selectionToDelete.setWithoutValidation(selectionToDelete.end(),
selectionToDelete.end().previous(BackwardDeletion)); |
423 // a ligature, we retrieve the previous position of the caret an
d count the number of | |
424 // characters to be deleted. | |
425 // To prevent from calculating the previous position every time
when pressing a backspace key, | |
426 // we retrieve the previous position only when the given selecti
on consists of two or more characters. | |
427 if (selectionToDelete.end().offset() - selectionToDelete.end().p
revious(UsingComposedCharacters).offset() > 1) | |
428 selectionToDelete.setWithoutValidation(selectionToDelete.end
(), selectionToDelete.end().previous(NotUsingComposedCharacters)); | |
429 } | 423 } |
430 | 424 |
431 if (!startingSelection().isRange() || selectionToDelete.base() != st
artingSelection().start()) | 425 if (!startingSelection().isRange() || selectionToDelete.base() != st
artingSelection().start()) |
432 selectionAfterUndo = selectionToDelete; | 426 selectionAfterUndo = selectionToDelete; |
433 else | 427 else |
434 // It's a little tricky to compute what the starting selection w
ould have been in the original document. | 428 // It's a little tricky to compute what the starting selection w
ould have been in the original document. |
435 // We can't let the Selection class's validation kick in or it'l
l adjust for us based on | 429 // We can't let the Selection class's validation kick in or it'l
l adjust for us based on |
436 // the current state of the document and we'll get the wrong res
ult. | 430 // the current state of the document and we'll get the wrong res
ult. |
437 selectionAfterUndo.setWithoutValidation(startingSelection().end(
), selectionToDelete.extent()); | 431 selectionAfterUndo.setWithoutValidation(startingSelection().end(
), selectionToDelete.extent()); |
438 break; | 432 break; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 return false; | 548 return false; |
555 } | 549 } |
556 | 550 |
557 bool TypingCommand::isTypingCommand() const | 551 bool TypingCommand::isTypingCommand() const |
558 { | 552 { |
559 return true; | 553 return true; |
560 } | 554 } |
561 | 555 |
562 } // namespace WebCore | 556 } // namespace WebCore |
563 | 557 |
OLD | NEW |